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 "RooObjCacheManager.h"
23
24class AddCacheElem;
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=nullptr) ;
32 TObject* clone(const char* newname=nullptr) const override { return new RooAddModel(*this,newname) ; }
34
35 double evaluate() const override ;
36 bool checkObservables(const RooArgSet* nset) const override ;
37
38 void doEval(RooFit::EvalContext &) const override;
39 inline bool canComputeBatchWithCuda() const override { return true; }
40
41 Int_t basisCode(const char* name) const override ;
42
43 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
44 // Force RooRealIntegral to offer all observables for internal integration
45 return true ;
46 }
47 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
48 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
49
50 /// Model is self normalized when used as p.d.f
51 bool selfNormalized() const override {
52 return _basisCode==0 ? true : false ;
53 }
54
55 /// Return extended mode capabilities
59
60 /// Return expected number of events for extended likelihood calculation, which
61 /// is the sum of all coefficients.
62 double expectedEvents(const RooArgSet* nset) const override ;
63
64 /// Return list of component p.d.fs
65 const RooArgList& pdfList() const {
66 return _pdfList ;
67 }
68
69 /// Return list of coefficients of component p.d.f.s
70 const RooArgList& coefList() const {
71 return _coefList ;
72 }
73
74 bool isDirectGenSafe(const RooAbsArg& arg) const override ;
75
76 Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
77 void generateEvent(Int_t code) override;
78
79
81 void fixCoefRange(const char* rangeName) ;
82 void resetErrorCounters(Int_t resetValue=10) override ;
83
84 void printMetaArgs(std::ostream& os) const override ;
85
86protected:
87
88 friend class RooAddGenContext ;
89 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
90 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
91
92 void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
93 void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
94
95 mutable RooSetProxy _refCoefNorm ; ///<! Reference observable set for coefficient interpretation
96 mutable TNamed* _refCoefRangeName = nullptr; ///<! Reference range name for coefficient interpretation
97
98 mutable std::vector<double> _coefCache; ///<! Transient cache with transformed values of coefficients
99
100
101 mutable RooObjCacheManager _projCacheMgr ; ///<! Manager of cache with coefficient projections and transformations
102 AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
103 void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset) const ;
104
106 void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
108 public:
109 RooArgList _intList ; ///< List of component integrals
111 } ;
112
113 mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
114
115 RooListProxy _pdfList ; ///< List of component PDFs
116 RooListProxy _coefList ; ///< List of coefficients
117 mutable RooArgList* _snormList{nullptr}; ///<! List of supplemental normalization factors
118
119 bool _haveLastCoef = false; ///< Flag indicating if last PDFs coefficient was supplied in the constructor
120 bool _allExtendable = false; ///< Flag indicating if all PDF components are extendable
121
122 mutable Int_t _coefErrCount ; ///<! Coefficient error counter
123
124 mutable RooArgSet _ownedComps ; ///<! Owned components
125
126private:
127
128 ClassDefOverride(RooAddModel,3) // Resolution model representing a sum of resolution models
129};
130
131#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
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:148
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
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:208
@ CanNotBeExtended
Definition RooAbsPdf.h:208
friend class AddCacheElem
Definition RooAbsReal.h:407
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:26
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:65
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:95
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:51
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:70
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:56
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:43
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...
TObject * clone(const char *newname=nullptr) const override
Definition RooAddModel.h:32
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:96
RooArgList * pRooArgList
std::vector< double > _coefCache
! Transient cache with transformed values of coefficients
Definition RooAddModel.h:98
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:39
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:24
Container class to hold unbinned data.
Definition RooDataSet.h:32
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:42