ROOT  6.06/09
Reference Guide
RooEfficiency.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 //////////////////////////////////////////////////////////////////////////////
18 //
19 // BEGIN_HTML
20 // RooEfficiency is a PDF helper class to fit efficiencies parameterized
21 // by a supplied function F.
22 //
23 // Given a dataset with a category C that determines if a given
24 // event is accepted or rejected for the efficiency to be measured,
25 // this class evaluates as F if C is 'accept' and as (1-F) if
26 // C is 'reject'. Values of F below 0 and above 1 are clipped.
27 // F may have an arbitrary number of dependents and parameters
28 // END_HTML
29 //
30 
31 #include "RooFit.h"
32 
33 #include "RooEfficiency.h"
34 #include "RooEfficiency.h"
35 #include "RooStreamParser.h"
36 #include "RooArgList.h"
37 
38 #include "TError.h"
39 
40 using namespace std;
41 
43  ;
44 
45 
46 ////////////////////////////////////////////////////////////////////////////////
47 /// Construct an N+1 dimensional efficiency p.d.f from an N-dimensional efficiency
48 /// function and a category cat with two states (0,1) that indicate if a given
49 /// event should be counted as rejected or accepted respectively
50 
51 RooEfficiency::RooEfficiency(const char *name, const char *title, const RooAbsReal& effFunc, const RooAbsCategory& cat, const char* sigCatName) :
52  RooAbsPdf(name,title),
53  _cat("cat","Signal/Background category",this,(RooAbsCategory&)cat),
54  _effFunc("effFunc","Efficiency modeling function",this,(RooAbsReal&)effFunc),
55  _sigCatName(sigCatName)
56 {
57 }
58 
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Copy constructor
63 
64 RooEfficiency::RooEfficiency(const RooEfficiency& other, const char* name) :
65  RooAbsPdf(other, name),
66  _cat("cat",this,other._cat),
67  _effFunc("effFunc",this,other._effFunc),
68  _sigCatName(other._sigCatName)
69 {
70 }
71 
72 
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Destructor
76 
78 {
79 }
80 
81 
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Calculate the raw value of this p.d.f which is the effFunc
85 /// value if cat==1 and it is (1-effFunc) if cat==0
86 
88 {
89  Double_t effFuncVal = _effFunc ;
90 
91  // Truncate efficiency function in range 0.0-1.0
92  if (_effFunc>1) {
93  effFuncVal = 1.0 ;
94  } else if (_effFunc<0) {
95  effFuncVal = 0.0 ;
96  }
97 
98  if (_cat.label() == _sigCatName) {
99  // Accept case
100  return effFuncVal ;
101  } else {
102  // Reject case
103  return 1 - effFuncVal ;
104  }
105 }
106 
107 
108 
109 ////////////////////////////////////////////////////////////////////////////////
110 
111 Int_t RooEfficiency::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
112 {
113  if (matchArgs(allVars,analVars,_cat)) return 1 ;
114  return 0 ;
115 }
116 
117 
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 
121 Double_t RooEfficiency::analyticalIntegral(Int_t code, const char* /*rangeName*/) const
122 {
123  R__ASSERT(code==1) ;
124  return 1.0 ;
125 }
126 
127 
128 
129 
130 
131 
virtual ~RooEfficiency()
Destructor.
#define R__ASSERT(e)
Definition: TError.h:98
int Int_t
Definition: RtypesCore.h:41
STL namespace.
TString _sigCatName
Definition: RooEfficiency.h:47
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral. ...
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported...
RooRealProxy _effFunc
Definition: RooEfficiency.h:46
ClassImp(RooEfficiency)
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
virtual Double_t evaluate() const
Calculate the raw value of this p.d.f which is the effFunc value if cat==1 and it is (1-effFunc) if c...
#define name(a, b)
Definition: linkTestLib0.cpp:5
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
RooCategoryProxy _cat
Definition: RooEfficiency.h:45
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
const char * label() const