Logo ROOT  
Reference Guide
RooAddModel.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAddPdf.h,v 1.46 2007/07/12 20:30:28 wouter Exp $
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#ifndef ROO_ADD_MODEL
17#define ROO_ADD_MODEL
18
19#include "RooResolutionModel.h"
20#include "RooListProxy.h"
21#include "RooSetProxy.h"
22#include "RooAICRegistry.h"
23#include "RooNormSetCache.h"
24#include "RooObjCacheManager.h"
25
27public:
28
29 RooAddModel() ;
30 RooAddModel(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, bool ownPdfList=false) ;
31 RooAddModel(const RooAddModel& other, const char* name=0) ;
32 TObject* clone(const char* newname) const override { return new RooAddModel(*this,newname) ; }
34 ~RooAddModel() override ;
35
36 double evaluate() const override ;
37 bool checkObservables(const RooArgSet* nset) const override ;
38
39 Int_t basisCode(const char* name) const override ;
40
41 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
42 // Force RooRealIntegral to offer all observables for internal integration
43 return true ;
44 }
45 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const override ;
46 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const override ;
47
48 /// Model is self normalized when used as p.d.f
49 bool selfNormalized() const override {
50 return _basisCode==0 ? true : false ;
51 }
52
53 /// Return extended mode capabilities
54 ExtendMode extendMode() const override {
56 }
57
58 /// Return expected number of events for extended likelihood calculation, which
59 /// is the sum of all coefficients.
60 double expectedEvents(const RooArgSet* nset) const override ;
61
62 /// Return list of component p.d.fs
63 const RooArgList& pdfList() const {
64 return _pdfList ;
65 }
66
67 /// Return list of coefficients of component p.d.f.s
68 const RooArgList& coefList() const {
69 return _coefList ;
70 }
71
72 bool isDirectGenSafe(const RooAbsArg& arg) const override ;
73
74 Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
75 void generateEvent(Int_t code) override;
76
77
78 void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
79 void fixCoefRange(const char* rangeName) ;
80 void resetErrorCounters(Int_t resetValue=10) override ;
81
82 void printMetaArgs(std::ostream& os) const override ;
83
84protected:
85
86 friend class RooAddGenContext ;
87 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0,
88 const RooArgSet* auxProto=0, bool verbose= false) const override ;
89
90 void selectNormalization(const RooArgSet* depSet=0, bool force=false) override ;
91 void selectNormalizationRange(const char* rangeName=0, bool force=false) override ;
92
93 mutable RooSetProxy _refCoefNorm ; ///<! Reference observable set for coefficient interpretation
94 mutable TNamed* _refCoefRangeName ; ///<! Reference range name for coefficient interpretation
95
96 bool _projectCoefs ; ///< If true coefficients need to be projected for use in evaluate()
97 mutable double* _coefCache ; ///<! Transiet cache with transformed values of coefficients
98
99
101 public:
102 ~CacheElem() override {} ;
103
104 RooArgList _suppNormList ; ///< Supplemental normalization list
105
106 RooArgList _projList ; ///< Projection integrals to be multiplied with coefficients
107 RooArgList _suppProjList ; ///< Projection integrals to be multiplied with coefficients for supplemental normalization terms
108 RooArgList _refRangeProjList ; ///< Range integrals to be multiplied with coefficients (reference range)
109 RooArgList _rangeProjList ; ///< Range integrals to be multiplied with coefficients (target range)
110
112
113 } ;
114 mutable RooObjCacheManager _projCacheMgr ; ///<! Manager of cache with coefficient projections and transformations
115 CacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=0, const char* rangeName=0) const ;
116 void updateCoefficients(CacheElem& cache, const RooArgSet* nset) const ;
117
119 void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
121 public:
122 ~IntCacheElem() override {} ;
123 RooArgList _intList ; ///< List of component integrals
125 } ;
126
127 mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
128
129 mutable RooAICRegistry _codeReg ; ///<! Registry of component analytical integration codes
130
131 RooListProxy _pdfList ; ///< List of component PDFs
132 RooListProxy _coefList ; ///< List of coefficients
133 mutable RooArgList* _snormList{nullptr}; ///<! List of supplemental normalization factors
134
135 bool _haveLastCoef ; ///< Flag indicating if last PDFs coefficient was supplied in the ctor
136 bool _allExtendable ; ///< Flag indicating if all PDF components are extendable
137
138 mutable Int_t _coefErrCount ; ///<! Coefficient error counter
139
140 mutable RooArgSet _ownedComps ; ///<! Owned components
141
142private:
143
144 ClassDefOverride(RooAddModel,2) // Resolution model representing a sum of resolution models
145};
146
147#endif
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
char name[80]
Definition: TGX11.cxx:110
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
@ MustBeExtended
Definition: RooAbsPdf.h:257
@ CanNotBeExtended
Definition: RooAbsPdf.h:257
RooAddGenContext is an efficient implementation of the generator context specific for RooAddPdf PDFs.
RooArgList _rangeProjList
Range integrals to be multiplied with coefficients (target range)
Definition: RooAddModel.h:109
RooArgList _suppProjList
Projection integrals to be multiplied with coefficients for supplemental normalization terms.
Definition: RooAddModel.h:107
RooArgList _projList
Projection integrals to be multiplied with coefficients.
Definition: RooAddModel.h:106
RooArgList _refRangeProjList
Range integrals to be multiplied with coefficients (reference range)
Definition: RooAddModel.h:108
RooArgList _suppNormList
Supplemental normalization list.
Definition: RooAddModel.h:104
RooArgList containedArgs(Action) override
List all RooAbsArg derived contents in this cache element.
RooArgList containedArgs(Action) override
List all RooAbsArg derived contents in this cache element.
RooArgList _intList
List of component integrals.
Definition: RooAddModel.h:123
RooAddModel is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddModel.h:26
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Return analytical integral defined by given scenario code.
RooAICRegistry _codeReg
! Registry of component analytical integration codes
Definition: RooAddModel.h:129
void selectNormalization(const RooArgSet *depSet=0, bool force=false) override
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
bool _projectCoefs
If true coefficients need to be projected for use in evaluate()
Definition: RooAddModel.h:96
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooAddModel to more intuitively reflect the contents of the pro...
RooArgList * _snormList
! List of supplemental normalization factors
Definition: RooAddModel.h:133
RooObjCacheManager _projCacheMgr
! Manager of cache with coefficient projections and transformations
Definition: RooAddModel.h:114
CacheElem * getProjCache(const RooArgSet *nset, const RooArgSet *iset=0, const char *rangeName=0) const
Retrieve cache element with for calculation of p.d.f value with normalization set nset and integrated...
void getCompIntList(const RooArgSet *nset, const RooArgSet *iset, pRooArgList &compIntList, Int_t &code, const char *isetRangeName) const
Check if this configuration was created before.
const RooArgList & pdfList() const
Return list of component p.d.fs.
Definition: RooAddModel.h:63
TObject * clone(const char *newname) const override
Definition: RooAddModel.h:32
~RooAddModel() override
Destructor.
RooSetProxy _refCoefNorm
! Reference observable set for coefficient interpretation
Definition: RooAddModel.h:93
bool _allExtendable
Flag indicating if all PDF components are extendable.
Definition: RooAddModel.h:136
bool selfNormalized() const override
Model is self normalized when used as p.d.f.
Definition: RooAddModel.h:49
Int_t _coefErrCount
! Coefficient error counter
Definition: RooAddModel.h:138
void updateCoefficients(CacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction,...
RooArgSet _ownedComps
! Owned components
Definition: RooAddModel.h:140
const RooArgList & coefList() const
Return list of coefficients of component p.d.f.s.
Definition: RooAddModel.h:68
RooListProxy _coefList
List of coefficients.
Definition: RooAddModel.h:132
ExtendMode extendMode() const override
Return extended mode capabilities.
Definition: RooAddModel.h:54
Int_t basisCode(const char *name) const override
Return code for basis function representing by 'name' string.
RooResolutionModel * convolution(RooFormulaVar *basis, RooAbsArg *owner) const override
Instantiate a clone of this resolution model representing a convolution with given basis function.
bool forceAnalyticalInt(const RooAbsArg &) const override
Definition: RooAddModel.h:41
bool checkObservables(const RooArgSet *nset) const override
Check if PDF is valid for given normalization set.
void generateEvent(Int_t code) override
This function should never be called as RooAddModel implements a custom generator context.
bool _haveLastCoef
Flag indicating if last PDFs coefficient was supplied in the ctor.
Definition: RooAddModel.h:135
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events for extended likelihood calculation, which is the sum of all coeffic...
RooListProxy _pdfList
List of component PDFs.
Definition: RooAddModel.h:131
RooObjCacheManager _intCacheMgr
! Manager of cache with integrals
Definition: RooAddModel.h:127
void resetErrorCounters(Int_t resetValue=10) override
Reset error counter to given value, limiting the number of future error messages for this pdf to 'res...
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, bool verbose=false) const override
Return specialized context to efficiently generate toy events from RooAddModels.
void fixCoefNormalization(const RooArgSet &refCoefNorm)
By default the interpretation of the fraction coefficients is performed in the contextual choice of o...
void fixCoefRange(const char *rangeName)
By default the interpretation of the fraction coefficients is performed in the default range.
TNamed * _refCoefRangeName
! Reference range name for coefficient interpretation
Definition: RooAddModel.h:94
RooArgList * pRooArgList
Definition: RooAddModel.h:118
double * _coefCache
! Transiet cache with transformed values of coefficients
Definition: RooAddModel.h:97
double evaluate() const override
Calculate the current value.
bool isDirectGenSafe(const RooAbsArg &arg) const override
Direct generation is safe if all components say so.
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Return pseud-code that indicates if all components can do internal generation (1) or not (0)
void selectNormalizationRange(const char *rangeName=0, bool force=false) override
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const override
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:57
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:30
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
Int_t _basisCode
Identifier code for selected basis function.
const RooFormulaVar & basis() const
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37