Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMultiBinomial.cxx
Go to the documentation of this file.
1
2/*****************************************************************************
3 * Project: RooFit *
4 * Package: RooFitCore *
5 * @(#)root/roofitcore:$Id$
6 * Author: *
7 * Tristan du Pree, Nikhef, Amsterdam, tdupree@nikhef.nl *
8 * *
9 * Redistribution and use in source and binary forms, *
10 * with or without modification, are permitted according to the terms *
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
12 *****************************************************************************/
13
14/** \class RooMultiBinomial
15 \ingroup Roofit
16
17RooMultiBinomial is an efficiency function which makes all combinations of
18efficiencies given as input different efficiency functions for different categories.
19
20Given a dataset with a category C that determines if a given
21event is accepted (1) or rejected (0) for the efficiency to be measured,
22this class evaluates as F if C is 'accept' and as (1-F) if
23C is 'reject'. Values of F below 0 and above 1 are clipped.
24F may have an arbitrary number of dependents and parameters
25
26The combination only 'reject' can be chosen to be visible or not visible
27(and hence this efficiency is then equal to zero).
28**/
29
30#include "RooMultiBinomial.h"
31#include "RooStreamParser.h"
32#include "RooArgList.h"
33#include "RooAbsCategory.h"
34#include "RooMsgService.h"
35#include <string>
36#include <vector>
37
38using std::endl, std::vector, std::string;
39
40
41////////////////////////////////////////////////////////////////////////////////
42/// Construct the efficiency functions from a list of efficiency functions
43/// and a list of categories cat with two states (0,1) that indicate if a given
44/// event should be counted as rejected or accepted respectively
45
46RooMultiBinomial::RooMultiBinomial(const char *name, const char *title,
48 const RooArgList& catList,
49 bool ignoreNonVisible) :
50 RooAbsReal(name,title),
51 _catList("catList","list of cats", this),
52 _effFuncList("effFuncList","list of eff funcs",this),
53 _ignoreNonVisible(ignoreNonVisible)
54{
57
58 if (_catList.size() != effFuncList.size()) {
59 coutE(InputArguments) << "RooMultiBinomial::ctor(" << GetName() << ") ERROR: Wrong input, should have equal number of categories and efficiencies." << std::endl;
60 throw string("RooMultiBinomial::ctor() ERROR: Wrong input, should have equal number of categories and efficiencies") ;
61 }
62
63}
64
65////////////////////////////////////////////////////////////////////////////////
66/// Copy constructor
67
70 _catList("catList",this,other._catList),
71 _effFuncList("effFuncList",this,other._effFuncList),
72 _ignoreNonVisible(other._ignoreNonVisible)
73{
74}
75
76////////////////////////////////////////////////////////////////////////////////
77/// Calculate the raw value of the function which is the effFunc
78/// value if cat==1 and it is (1-effFunc) if cat==0
79
81{
83
84 // Get efficiency function for category i
85
87 for (int i=0; i<effFuncListSize; ++i) {
88 effFuncVal[i] = (static_cast<RooAbsReal&>(_effFuncList[i])).getVal() ;
89 }
90
91 // Truncate efficiency functions in range 0.0-1.0
92
93 for (int i=0; i<effFuncListSize; ++i) {
94 if (effFuncVal[i]>1) {
95 coutW(Eval) << "WARNING: Efficiency >1 (equal to " << effFuncVal[i]
96 << " ), for i = " << i << "...TRUNCATED" << std::endl;
97 effFuncVal[i] = 1.0 ;
98 } else if (effFuncVal[i]<0) {
99 effFuncVal[i] = 0.0 ;
100 coutW(Eval) << "WARNING: Efficiency <0 (equal to " << effFuncVal[i]
101 << " ), for i = " << i << "...TRUNCATED" << std::endl;
102 }
103 }
104
106 bool notVisible = true;
107
108 // Calculate efficiency per accept/reject decision
109
110 for (int i=0; i<effFuncListSize; ++i) {
111 if ( (static_cast<RooAbsCategory&>(_catList[i])).getCurrentIndex() == 1) {
112 // Accept case
113 effValue[i] = effFuncVal[i] ;
114 notVisible = false;
115 } else if ( (static_cast<RooAbsCategory&>(_catList[i])).getCurrentIndex() == 0){
116 // Reject case
117 effValue[i] = 1 - effFuncVal[i] ;
118 } else {
119 coutW(Eval) << "WARNING: WRONG CATEGORY NAMES GIVEN!, label = " << (static_cast<RooAbsCategory&>(_catList[i])).getCurrentIndex() << std::endl;
120 effValue[i] = 0;
121 }
122 }
123
124 double _effVal = 1.;
125
126 // Calculate efficiency for combination of accept/reject categories
127 // put equal to zero if combination of only zeros AND chosen to be invisible
128
129 for (int i=0; i<effFuncListSize; ++i) {
132 _effVal=0;
133 }
134 }
135
136 return _effVal;
137
138}
#define coutW(a)
#define coutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
A space to attach TBranches.
Storage_t::size_type size() const
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooMultiBinomial is an efficiency function which makes all combinations of efficiencies given as inpu...
RooListProxy _effFuncList
double evaluate() const override
Calculate the raw value of the function which is the effFunc value if cat==1 and it is (1-effFunc) if...
RooListProxy _catList
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47