Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 "RooObjCacheManager.h"
24
25class AddCacheElem;
26
28public:
29
30 RooAddModel() ;
31 RooAddModel(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, bool ownPdfList=false) ;
32 RooAddModel(const RooAddModel& other, const char* name=nullptr) ;
33 TObject* clone(const char* newname) const override { return new RooAddModel(*this,newname) ; }
35
36 double evaluate() const override ;
37 bool checkObservables(const RooArgSet* nset) const override ;
38
39 void doEval(RooFit::EvalContext &) const override;
40 inline bool canComputeBatchWithCuda() const override { return true; }
41
42 Int_t basisCode(const char* name) const override ;
43
44 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
45 // Force RooRealIntegral to offer all observables for internal integration
46 return true ;
47 }
48 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
49 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
50
51 /// Model is self normalized when used as p.d.f
52 bool selfNormalized() const override {
53 return _basisCode==0 ? true : false ;
54 }
55
56 /// Return extended mode capabilities
57 ExtendMode extendMode() const override {
59 }
60
61 /// Return expected number of events for extended likelihood calculation, which
62 /// is the sum of all coefficients.
63 double expectedEvents(const RooArgSet* nset) const override ;
64
65 /// Return list of component p.d.fs
66 const RooArgList& pdfList() const {
67 return _pdfList ;
68 }
69
70 /// Return list of coefficients of component p.d.f.s
71 const RooArgList& coefList() const {
72 return _coefList ;
73 }
74
75 bool isDirectGenSafe(const RooAbsArg& arg) const override ;
76
77 Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
78 void generateEvent(Int_t code) override;
79
80
81 void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
82 void fixCoefRange(const char* rangeName) ;
83 void resetErrorCounters(Int_t resetValue=10) override ;
84
85 void printMetaArgs(std::ostream& os) const override ;
86
87protected:
88
89 friend class RooAddGenContext ;
90 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
91 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
92
93 void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
94 void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
95
96 mutable RooSetProxy _refCoefNorm ; ///<! Reference observable set for coefficient interpretation
97 mutable TNamed* _refCoefRangeName = nullptr; ///<! Reference range name for coefficient interpretation
98
99 mutable std::vector<double> _coefCache; ///<! Transient cache with transformed values of coefficients
100
101
102 mutable RooObjCacheManager _projCacheMgr ; ///<! Manager of cache with coefficient projections and transformations
103 AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
104 void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset) const ;
105
107 void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
109 public:
110 RooArgList _intList ; ///< List of component integrals
112 } ;
113
114 mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
115
116 mutable RooAICRegistry _codeReg = 10; ///<! Registry of component analytical integration codes
117
118 RooListProxy _pdfList ; ///< List of component PDFs
119 RooListProxy _coefList ; ///< List of coefficients
120 mutable RooArgList* _snormList{nullptr}; ///<! List of supplemental normalization factors
121
122 bool _haveLastCoef = false; ///< Flag indicating if last PDFs coefficient was supplied in the constructor
123 bool _allExtendable = false; ///< Flag indicating if all PDF components are extendable
124
125 mutable Int_t _coefErrCount ; ///<! Coefficient error counter
126
127 mutable RooArgSet _ownedComps ; ///<! Owned components
128
129private:
130
131 ClassDefOverride(RooAddModel,3) // Resolution model representing a sum of resolution models
132};
133
134#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
char name[80]
Definition TGX11.cxx:110
Utility class for operator p.d.f classes that keeps track of analytical integration codes and associa...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
Abstract base class for generator contexts of RooAbsPdf objects.
@ MustBeExtended
Definition RooAbsPdf.h:213
@ CanNotBeExtended
Definition RooAbsPdf.h:213
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.
RooAddModel is an efficient implementation of a sum of PDFs of the form.
Definition RooAddModel.h:27
RooAICRegistry _codeReg
! Registry of component analytical integration codes
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
RooObjCacheManager _projCacheMgr
! Manager of cache with coefficient projections and transformations
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:66
TObject * clone(const char *newname) const override
Definition RooAddModel.h:33
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:96
bool _allExtendable
Flag indicating if all PDF components are extendable.
bool selfNormalized() const override
Model is self normalized when used as p.d.f.
Definition RooAddModel.h:52
Int_t _coefErrCount
! Coefficient error counter
RooArgSet _ownedComps
! Owned components
const RooArgList & coefList() const
Return list of coefficients of component p.d.f.s.
Definition RooAddModel.h:71
RooListProxy _coefList
List of coefficients.
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:57
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:44
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
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 constructor.
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.
RooObjCacheManager _intCacheMgr
! Manager of cache with integrals
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:97
RooArgList * pRooArgList
std::vector< double > _coefCache
! Transient cache with transformed values of coefficients
Definition RooAddModel.h:99
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 ...
bool canComputeBatchWithCuda() const override
Definition RooAddModel.h:40
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:55
Container class to hold unbinned data.
Definition RooDataSet.h:57
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Implementation of a RooCacheManager<RooAbsCacheElement> that specializes in the storage of cache elem...
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