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
26class AddCacheElem;
27
29public:
30
31 RooAddModel() ;
32 RooAddModel(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, bool ownPdfList=false) ;
33 RooAddModel(const RooAddModel& other, const char* name=nullptr) ;
34 TObject* clone(const char* newname) const override { return new RooAddModel(*this,newname) ; }
36
37 double evaluate() const override ;
38 bool checkObservables(const RooArgSet* nset) const override ;
39
40 Int_t basisCode(const char* name) const override ;
41
42 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
43 // Force RooRealIntegral to offer all observables for internal integration
44 return true ;
45 }
46 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
47 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
48
49 /// Model is self normalized when used as p.d.f
50 bool selfNormalized() const override {
51 return _basisCode==0 ? true : false ;
52 }
53
54 /// Return extended mode capabilities
55 ExtendMode extendMode() const override {
57 }
58
59 /// Return expected number of events for extended likelihood calculation, which
60 /// is the sum of all coefficients.
61 double expectedEvents(const RooArgSet* nset) const override ;
62
63 /// Return list of component p.d.fs
64 const RooArgList& pdfList() const {
65 return _pdfList ;
66 }
67
68 /// Return list of coefficients of component p.d.f.s
69 const RooArgList& coefList() const {
70 return _coefList ;
71 }
72
73 bool isDirectGenSafe(const RooAbsArg& arg) const override ;
74
75 Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
76 void generateEvent(Int_t code) override;
77
78
79 void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
80 void fixCoefRange(const char* rangeName) ;
81 void resetErrorCounters(Int_t resetValue=10) override ;
82
83 void printMetaArgs(std::ostream& os) const override ;
84
85protected:
86
87 friend class RooAddGenContext ;
88 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
89 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
90
91 void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
92 void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
93
94 mutable RooSetProxy _refCoefNorm ; ///<! Reference observable set for coefficient interpretation
95 mutable TNamed* _refCoefRangeName = nullptr; ///<! Reference range name for coefficient interpretation
96
97 mutable std::vector<double> _coefCache; ///<! Transiet cache with transformed values of coefficients
98
99
100 mutable RooObjCacheManager _projCacheMgr ; ///<! Manager of cache with coefficient projections and transformations
101 AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
102 void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset) const ;
103
105 void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
107 public:
108 ~IntCacheElem() override {} ;
109 RooArgList _intList ; ///< List of component integrals
111 } ;
112
113 mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
114
115 mutable RooAICRegistry _codeReg = 10; ///<! Registry of component analytical integration codes
116
117 RooListProxy _pdfList ; ///< List of component PDFs
118 RooListProxy _coefList ; ///< List of coefficients
119 mutable RooArgList* _snormList{nullptr}; ///<! List of supplemental normalization factors
120
121 bool _haveLastCoef = false; ///< Flag indicating if last PDFs coefficient was supplied in the ctor
122 bool _allExtendable = false; ///< Flag indicating if all PDF components are extendable
123
124 mutable Int_t _coefErrCount ; ///<! Coefficient error counter
125
126 mutable RooArgSet _ownedComps ; ///<! Owned components
127
128private:
129
130 ClassDefOverride(RooAddModel,3) // Resolution model representing a sum of resolution models
131};
132
133#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:71
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:264
@ CanNotBeExtended
Definition: RooAbsPdf.h:264
RooAddGenContext is an efficient implementation of the generator context specific for RooAddPdf PDFs.
RooArgList containedArgs(Action) override
List all RooAbsArg derived contents in this cache element.
RooArgList _intList
List of component integrals.
Definition: RooAddModel.h:109
RooAddModel is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddModel.h:28
RooAICRegistry _codeReg
! Registry of component analytical integration codes
Definition: RooAddModel.h:115
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const override
Return specialized context to efficiently generate toy events from RooAddModels.
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:119
RooObjCacheManager _projCacheMgr
! Manager of cache with coefficient projections and transformations
Definition: RooAddModel.h:100
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:64
TObject * clone(const char *newname) const override
Definition: RooAddModel.h:34
void selectNormalization(const RooArgSet *depSet=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of observables for interpretation of frac...
RooSetProxy _refCoefNorm
! Reference observable set for coefficient interpretation
Definition: RooAddModel.h:94
bool _allExtendable
Flag indicating if all PDF components are extendable.
Definition: RooAddModel.h:122
bool selfNormalized() const override
Model is self normalized when used as p.d.f.
Definition: RooAddModel.h:50
Int_t _coefErrCount
! Coefficient error counter
Definition: RooAddModel.h:124
RooArgSet _ownedComps
! Owned components
Definition: RooAddModel.h:126
const RooArgList & coefList() const
Return list of coefficients of component p.d.f.s.
Definition: RooAddModel.h:69
RooListProxy _coefList
List of coefficients.
Definition: RooAddModel.h:118
void selectNormalizationRange(const char *rangeName=nullptr, bool force=false) override
Interface function used by test statistics to freeze choice of range for interpretation of fraction c...
ExtendMode extendMode() const override
Return extended mode capabilities.
Definition: RooAddModel.h:55
Int_t basisCode(const char *name) const override
Return code for basis function representing by 'name' string.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Return analytical integral defined by given scenario code.
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:42
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:121
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:117
RooObjCacheManager _intCacheMgr
! Manager of cache with integrals
Definition: RooAddModel.h:113
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...
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:95
RooArgList * pRooArgList
Definition: RooAddModel.h:104
std::vector< double > _coefCache
! Transiet cache with transformed values of coefficients
Definition: RooAddModel.h:97
double evaluate() const override
Calculate the current value.
void updateCoefficients(AddCacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction,...
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)
AddCacheElem * getProjCache(const RooArgSet *nset, const RooArgSet *iset=nullptr) const
Retrieve cache element with for calculation of p.d.f value with normalization set nset and integrated...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) 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:56
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:41