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