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