Logo ROOT  
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 \file RooEfficiency.cxx
19 \class RooEfficiency
20 \ingroup Roofitcore
21 
22 RooEfficiency is a PDF helper class to fit efficiencies parameterized
23 by a supplied function F.
24 
25 Given a dataset with a category C that determines if a given
26 event is accepted or rejected for the efficiency to be measured,
27 this class evaluates as F if C is 'accept' and as (1-F) if
28 C is 'reject'. Values of F below 0 and above 1 are clipped.
29 F may have an arbitrary number of dependents and parameters
30 **/
31 
32 #include "RooEfficiency.h"
33 
34 #include "RooStreamParser.h"
35 #include "RooArgList.h"
36 
37 #include "TError.h"
38 
39 using namespace std;
40 
42  ;
43 
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 /// Construct an N+1 dimensional efficiency p.d.f from an N-dimensional efficiency
47 /// function and a category cat with two states (0,1) that indicate if a given
48 /// event should be counted as rejected or accepted respectively
49 
50 RooEfficiency::RooEfficiency(const char *name, const char *title, const RooAbsReal& effFunc, const RooAbsCategory& cat, const char* sigCatName) :
51  RooAbsPdf(name,title),
52  _cat("cat","Signal/Background category",this,(RooAbsCategory&)cat),
53  _effFunc("effFunc","Efficiency modeling function",this,(RooAbsReal&)effFunc),
54  _sigCatName(sigCatName)
55 {
56 }
57 
58 
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// Copy constructor
62 
63 RooEfficiency::RooEfficiency(const RooEfficiency& other, const char* name) :
64  RooAbsPdf(other, name),
65  _cat("cat",this,other._cat),
66  _effFunc("effFunc",this,other._effFunc),
67  _sigCatName(other._sigCatName)
68 {
69 }
70 
71 
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Destructor
75 
77 {
78 }
79 
80 
81 
82 ////////////////////////////////////////////////////////////////////////////////
83 /// Calculate the raw value of this p.d.f which is the effFunc
84 /// value if cat==1 and it is (1-effFunc) if cat==0
85 
87 {
88  Double_t effFuncVal = _effFunc ;
89 
90  // Truncate efficiency function in range 0.0-1.0
91  if (_effFunc>1) {
92  effFuncVal = 1.0 ;
93  } else if (_effFunc<0) {
94  effFuncVal = 0.0 ;
95  }
96 
97  if (_cat.label() == _sigCatName) {
98  // Accept case
99  return effFuncVal ;
100  } else {
101  // Reject case
102  return 1 - effFuncVal ;
103  }
104 }
105 
106 
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 
110 Int_t RooEfficiency::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
111 {
112  if (matchArgs(allVars,analVars,_cat)) return 1 ;
113  return 0 ;
114 }
115 
116 
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 
120 Double_t RooEfficiency::analyticalIntegral(Int_t code, const char* /*rangeName*/) const
121 {
122  R__ASSERT(code==1) ;
123  return 1.0 ;
124 }
125 
126 
127 
128 
129 
130 
RooStreamParser.h
RooEfficiency::_sigCatName
TString _sigCatName
Definition: RooEfficiency.h:47
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
RooEfficiency::analyticalIntegral
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
Definition: RooEfficiency.cxx:120
RooAbsReal
Definition: RooAbsReal.h:61
RooEfficiency::_effFunc
RooRealProxy _effFunc
Definition: RooEfficiency.h:46
RooEfficiency::~RooEfficiency
virtual ~RooEfficiency()
Destructor.
Definition: RooEfficiency.cxx:76
RooAbsCategory
Definition: RooAbsCategory.h:38
RooEfficiency::RooEfficiency
RooEfficiency()
Definition: RooEfficiency.h:30
RooEfficiency.h
RooTemplateProxy::label
const char * label() const
Get the label of the current category state. This function only makes sense for category proxies.
Definition: RooTemplateProxy.h:249
RooEfficiency::getAnalyticalIntegral
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
Definition: RooEfficiency.cxx:110
RooEfficiency::evaluate
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...
Definition: RooEfficiency.cxx:86
Double_t
double Double_t
Definition: RtypesCore.h:59
R__ASSERT
#define R__ASSERT(e)
Definition: TError.h:120
name
char name[80]
Definition: TGX11.cxx:110
RooEfficiency
Definition: RooEfficiency.h:27
RooAbsReal::matchArgs
Bool_t matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
Definition: RooAbsReal.cxx:3400
RooAbsPdf
Definition: RooAbsPdf.h:40
RooArgList.h
RooEfficiency::_cat
RooCategoryProxy _cat
Definition: RooEfficiency.h:45
RooArgSet
Definition: RooArgSet.h:28
int
TError.h