Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "RooEfficiency.h"
33
34#include "RooStreamParser.h"
35#include "RooArgList.h"
36
37#include "TError.h"
38
39using 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
50RooEfficiency::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
63RooEfficiency::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
110Int_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
120Double_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
#define ClassImp(name)
Definition Rtypes.h:364
#define R__ASSERT(e)
Definition TError.h:120
char name[80]
Definition TGX11.cxx:110
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:61
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:29
RooEfficiency is a PDF helper class to fit efficiencies parameterized by a supplied function F.
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
RooCategoryProxy _cat
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
virtual ~RooEfficiency()
Destructor.
const char * label() const
Get the label of the current category state. This function only makes sense for category proxies.