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 "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 void computeBatch(cudaStream_t*, double* output, size_t nEvents, RooFit::Detail::DataMap const&) const override;
41 inline bool canComputeBatchWithCuda() const override { return true; }
42
43 Int_t basisCode(const char* name) const override ;
44
45 bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
46 // Force RooRealIntegral to offer all observables for internal integration
47 return true ;
48 }
49 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
50 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
51
52 /// Model is self normalized when used as p.d.f
53 bool selfNormalized() const override {
54 return _basisCode==0 ? true : false ;
55 }
56
57 /// Return extended mode capabilities
58 ExtendMode extendMode() const override {
60 }
61
62 /// Return expected number of events for extended likelihood calculation, which
63 /// is the sum of all coefficients.
64 double expectedEvents(const RooArgSet* nset) const override ;
65
66 /// Return list of component p.d.fs
67 const RooArgList& pdfList() const {
68 return _pdfList ;
69 }
70
71 /// Return list of coefficients of component p.d.f.s
72 const RooArgList& coefList() const {
73 return _coefList ;
74 }
75
76 bool isDirectGenSafe(const RooAbsArg& arg) const override ;
77
78 Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
79 void generateEvent(Int_t code) override;
80
81
82 void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
83 void fixCoefRange(const char* rangeName) ;
84 void resetErrorCounters(Int_t resetValue=10) override ;
85
86 void printMetaArgs(std::ostream& os) const override ;
87
88protected:
89
90 friend class RooAddGenContext ;
91 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
92 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
93
94 void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
95 void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
96
97 mutable RooSetProxy _refCoefNorm ; ///<! Reference observable set for coefficient interpretation
98 mutable TNamed* _refCoefRangeName = nullptr; ///<! Reference range name for coefficient interpretation
99
100 mutable std::vector<double> _coefCache; ///<! Transiet cache with transformed values of coefficients
101
102
103 mutable RooObjCacheManager _projCacheMgr ; ///<! Manager of cache with coefficient projections and transformations
104 AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
105 void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset) const ;
106
108 void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
110 public:
111 ~IntCacheElem() override {} ;
112 RooArgList _intList ; ///< List of component integrals
114 } ;
115
116 mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
117
118 mutable RooAICRegistry _codeReg = 10; ///<! Registry of component analytical integration codes
119
120 RooListProxy _pdfList ; ///< List of component PDFs
121 RooListProxy _coefList ; ///< List of coefficients
122 mutable RooArgList* _snormList{nullptr}; ///<! List of supplemental normalization factors
123
124 bool _haveLastCoef = false; ///< Flag indicating if last PDFs coefficient was supplied in the ctor
125 bool _allExtendable = false; ///< Flag indicating if all PDF components are extendable
126
127 mutable Int_t _coefErrCount ; ///<! Coefficient error counter
128
129 mutable RooArgSet _ownedComps ; ///<! Owned components
130
131private:
132
133 ClassDefOverride(RooAddModel,3) // Resolution model representing a sum of resolution models
134};
135
136#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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:74
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:272
@ CanNotBeExtended
Definition RooAbsPdf.h:272
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.
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
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:67
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:97
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:53
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:72
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
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:58
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:45
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.
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:98
RooArgList * pRooArgList
std::vector< double > _coefCache
! Transiet cache with transformed values of coefficients
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:41
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
RooDataSet is a 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...
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
static void output()