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
22A 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
38
39#include "TError.h"
40
42
43
44////////////////////////////////////////////////////////////////////////////////
45/// Construct an N+1 dimensional efficiency p.d.f from an N-dimensional efficiency
46/// function and a category cat with two states (0,1) that indicate if a given
47/// event should be counted as rejected or accepted respectively
48
49RooEfficiency::RooEfficiency(const char *name, const char *title, const RooAbsReal& effFunc, const RooAbsCategory& cat, const char* sigCatName) :
50 RooAbsPdf(name,title),
51 _cat("cat","Signal/Background category",this,(RooAbsCategory&)cat),
52 _effFunc("effFunc","Efficiency modeling function",this,(RooAbsReal&)effFunc),
53 _sigCatName(sigCatName)
54{
55}
56
57
58
59////////////////////////////////////////////////////////////////////////////////
60/// Copy constructor
61
63 RooAbsPdf(other, name),
64 _cat("cat",this,other._cat),
65 _effFunc("effFunc",this,other._effFunc),
66 _sigCatName(other._sigCatName)
67{
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Calculate the raw value of this p.d.f which is the effFunc
72/// value if cat==1 and it is (1-effFunc) if cat==0
73
75{
76 const int sigCatIndex = _cat->lookupIndex(_sigCatName.Data());
78}
79
80int RooEfficiency::getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char * /*rangeName*/) const
81{
82 return matchArgs(allVars, analVars, _cat) ? 1 : 0;
83}
84
85double RooEfficiency::analyticalIntegral(int /*code*/, const char * /*rangeName*/) const
86{
87 return 1.0;
88}
89
91{
92 int sigCatIndex = _cat->lookupIndex(_sigCatName.Data());
93 ctx.addResult(this, ctx.buildCall("RooFit::Detail::EvaluateFuncs::efficiencyEvaluate", _effFunc, _cat, sigCatIndex));
94}
95
96std::string RooEfficiency::buildCallToAnalyticIntegral(int /*code*/, const char * /*rangeName*/,
98{
99 return "1.0";
100}
#define ClassImp(name)
Definition Rtypes.h:377
char name[80]
Definition TGX11.cxx:110
A space to attach TBranches.
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
bool 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:55
A PDF helper class to fit efficiencies parameterized by a supplied function F.
TString _sigCatName
Name of accept state of accept/reject category.
RooCategoryProxy _cat
Accept/reject categort.
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooEfficiency()
Default constructor.
std::string buildCallToAnalyticIntegral(Int_t code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override
This function defines the analytical integral translation for the class.
RooRealProxy _effFunc
Efficiency modeling function.
double evaluate() const override
Calculate the raw value of this p.d.f which is the effFunc value if cat==1 and it is (1-effFunc) if c...
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
A class to maintain the context for squashing of RooFit models into code.
std::string buildCall(std::string const &funcname, Args_t const &...args)
Build the code to call the function with name funcname, passing some arguments.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
const char * Data() const
Definition TString.h:376
double efficiencyEvaluate(double effFuncVal, int catIndex, int sigCatIndex)