Logo ROOT  
Reference Guide
RooAddPdf.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_PDF
17 #define ROO_ADD_PDF
18 
19 #include "RooAbsPdf.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 #include "RooNameReg.h"
28 #include <vector>
29 #include <list>
30 #include <utility>
31 
32 class RooAddPdf : public RooAbsPdf {
33 public:
34 
35  RooAddPdf() ;
36  RooAddPdf(const char *name, const char *title=0);
37  RooAddPdf(const char *name, const char *title,
38  RooAbsPdf& pdf1, RooAbsPdf& pdf2, RooAbsReal& coef1) ;
39  RooAddPdf(const char *name, const char *title, const RooArgList& pdfList) ;
40  RooAddPdf(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, Bool_t recursiveFraction=kFALSE) ;
41 
42  RooAddPdf(const RooAddPdf& other, const char* name=0) ;
43  virtual TObject* clone(const char* newname) const { return new RooAddPdf(*this,newname) ; }
44  virtual ~RooAddPdf() ;
45 
46  virtual Bool_t checkObservables(const RooArgSet* nset) const ;
47 
48  virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const {
49  // Force RooRealIntegral to offer all observables for internal integration
50  return kTRUE ;
51  }
52  Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const ;
53  Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
54  virtual Bool_t selfNormalized() const {
55  // P.d.f is self normalized
56  return kTRUE ;
57  }
58 
59  virtual ExtendMode extendMode() const {
60  // Return extended mode capabilities
62  }
63  virtual Double_t expectedEvents(const RooArgSet* nset) const ;
64  virtual Double_t expectedEvents(const RooArgSet& nset) const {
65  // Return expected number of events for extended likelihood calculation
66  // which is the sum of all coefficients
67  return expectedEvents(&nset) ;
68  }
69 
70  const RooArgList& pdfList() const {
71  // Return list of component p.d.fs
72  return _pdfList ;
73  }
74  const RooArgList& coefList() const {
75  // Return list of coefficients of component p.d.f.s
76  return _coefList ;
77  }
78 
79  void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
80  void fixCoefRange(const char* rangeName) ;
81 
82  const RooArgSet& getCoefNormalization() const { return _refCoefNorm ; }
83  const char* getCoefRange() const { return _refCoefRangeName?RooNameReg::str(_refCoefRangeName):"" ; }
84 
85  virtual void resetErrorCounters(Int_t resetValue=10) ;
86 
87  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const ;
88  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
89  Bool_t isBinnedDistribution(const RooArgSet& obs) const ;
90 
91  void printMetaArgs(std::ostream& os) const ;
92 
93  virtual CacheMode canNodeBeCached() const { return RooAbsArg::NotAdvised ; } ;
94  virtual void setCacheAndTrackHints(RooArgSet&) ;
95 
96 protected:
97 
98  virtual void selectNormalization(const RooArgSet* depSet=0, Bool_t force=kFALSE) ;
99  virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
100 
101  mutable RooSetProxy _refCoefNorm ; // Reference observable set for coefficient interpretation
102  mutable TNamed* _refCoefRangeName ; // Reference range name for coefficient interpreation
103 
104  Bool_t _projectCoefs ; // If true coefficients need to be projected for use in evaluate()
105  std::vector<double> _coefCache; //! Transient cache with transformed values of coefficients
106 
107 
108  class CacheElem : public RooAbsCacheElement {
109  public:
110  virtual ~CacheElem() {} ;
111 
112  RooArgList _suppNormList ; // Supplemental normalization list
113  Bool_t _needSupNorm ; // Does the above list contain any non-unit entries?
114 
115  RooArgList _projList ; // Projection integrals to be multiplied with coefficients
116  RooArgList _suppProjList ; // Projection integrals to be multiplied with coefficients for supplemental normalization terms
117  RooArgList _refRangeProjList ; // Range integrals to be multiplied with coefficients (reference range)
118  RooArgList _rangeProjList ; // Range integrals to be multiplied with coefficients (target range)
119 
120  virtual RooArgList containedArgs(Action) ;
121 
122  } ;
123  mutable RooObjCacheManager _projCacheMgr ; // Manager of cache with coefficient projections and transformations
124  CacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=0, const char* rangeName=0) const ;
125  void updateCoefficients(CacheElem& cache, const RooArgSet* nset) const ;
126 
127 
128  friend class RooAddGenContext ;
129  virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0,
130  const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
131 
132 
133  Double_t evaluate() const;
134  virtual RooSpan<double> evaluateBatch(std::size_t begin, std::size_t batchSize) const;
135 
136 
137  mutable RooAICRegistry _codeReg ; //! Registry of component analytical integration codes
138 
139  RooListProxy _pdfList ; // List of component PDFs
140  RooListProxy _coefList ; // List of coefficients
141  mutable RooArgList* _snormList{nullptr}; //! List of supplemental normalization factors
142 
143  Bool_t _haveLastCoef ; // Flag indicating if last PDFs coefficient was supplied in the ctor
144  Bool_t _allExtendable ; // Flag indicating if all PDF components are extendable
145  Bool_t _recursive ; // Flag indicating is fractions are treated recursively
146 
147  mutable Int_t _coefErrCount ; //! Coefficient error counter
148 
149 private:
150  std::pair<const RooArgSet*, CacheElem*> getNormAndCache() const;
151 
152  ClassDef(RooAddPdf,3) // PDF representing a sum of PDFs
153 };
154 
155 #endif
RooAddPdf::checkObservables
virtual Bool_t checkObservables(const RooArgSet *nset) const
Check if PDF is valid for given normalization set.
Definition: RooAddPdf.cxx:879
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooCacheManager.h
RooAddPdf
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:32
RooAddPdf::updateCoefficients
void updateCoefficients(CacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction,...
Definition: RooAddPdf.cxx:665
RooAddPdf::isBinnedDistribution
Bool_t isBinnedDistribution(const RooArgSet &obs) const
If all components that depend on obs are binned that so is the product.
Definition: RooAddPdf.cxx:1257
RooAddPdf::CacheElem::_projList
RooArgList _projList
Definition: RooAddPdf.h:115
RooAddPdf::plotSamplingHint
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Loop over components for plot sampling hints and merge them if there are multiple.
Definition: RooAddPdf.cxx:1166
RooAddPdf::fixCoefRange
void fixCoefRange(const char *rangeName)
By default, fraction coefficients are assumed to refer to the default fit range.
Definition: RooAddPdf.cxx:403
RooAddPdf::_haveLastCoef
Bool_t _haveLastCoef
List of supplemental normalization factors.
Definition: RooAddPdf.h:143
RooAddPdf::clone
virtual TObject * clone(const char *newname) const
Definition: RooAddPdf.h:43
RooAICRegistry
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
Definition: RooAICRegistry.h:26
RooAddPdf::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: RooAddPdf.cxx:1124
RooAddPdf::forceAnalyticalInt
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAddPdf.h:48
RooAddPdf::_projectCoefs
Bool_t _projectCoefs
Definition: RooAddPdf.h:104
RooSetProxy
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:23
RooAddPdf::evaluateBatch
virtual RooSpan< double > evaluateBatch(std::size_t begin, std::size_t batchSize) const
Compute addition of PDFs in batches.
Definition: RooAddPdf.cxx:832
RooAddPdf::_recursive
Bool_t _recursive
Definition: RooAddPdf.h:145
RooAddPdf::evaluate
Double_t evaluate() const
Calculate and return the current value.
Definition: RooAddPdf.cxx:800
RooArgList
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooAddPdf::analyticalIntegralWN
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Return analytical integral defined by given scenario code.
Definition: RooAddPdf.cxx:975
RooAddPdf::_projCacheMgr
RooObjCacheManager _projCacheMgr
Definition: RooAddPdf.h:123
RooAddPdf::_refCoefRangeName
TNamed * _refCoefRangeName
Definition: RooAddPdf.h:102
RooAddPdf::extendMode
virtual ExtendMode extendMode() const
Definition: RooAddPdf.h:59
RooAddPdf::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: RooAddPdf.cxx:1101
RooAddPdf::pdfList
const RooArgList & pdfList() const
Definition: RooAddPdf.h:70
RooNameSet.h
RooAbsReal
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAddPdf::_snormList
RooArgList * _snormList
Definition: RooAddPdf.h:141
RooAddPdf::CacheElem::_suppProjList
RooArgList _suppProjList
Definition: RooAddPdf.h:116
RooAbsArg::CacheMode
CacheMode
Definition: RooAbsArg.h:409
RooAddPdf::CacheElem::_suppNormList
RooArgList _suppNormList
Definition: RooAddPdf.h:110
RooAddPdf::CacheElem
Transient cache with transformed values of coefficients.
Definition: RooAddPdf.h:108
RooSetProxy.h
RooAddPdf::canNodeBeCached
virtual CacheMode canNodeBeCached() const
Definition: RooAddPdf.h:93
RooAbsCacheElement
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Definition: RooAbsCacheElement.h:26
RooAddPdf::CacheElem::_refRangeProjList
RooArgList _refRangeProjList
Definition: RooAddPdf.h:117
RooAddPdf::getCoefRange
const char * getCoefRange() const
Definition: RooAddPdf.h:83
bool
RooAddPdf::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: RooAddPdf.cxx:866
RooAddPdf::binBoundaries
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Loop over components for plot sampling hints and merge them if there are multiple.
Definition: RooAddPdf.cxx:1211
RooAddPdf::_allExtendable
Bool_t _allExtendable
Definition: RooAddPdf.h:144
RooNormSetCache.h
RooAbsPdf::ExtendMode
ExtendMode
Definition: RooAbsPdf.h:229
RooAbsPdf::MustBeExtended
@ MustBeExtended
Definition: RooAbsPdf.h:229
RooAddPdf::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: RooAddPdf.cxx:1032
RooAddPdf::_refCoefNorm
RooSetProxy _refCoefNorm
Definition: RooAddPdf.h:101
RooAddPdf::getCoefNormalization
const RooArgSet & getCoefNormalization() const
Definition: RooAddPdf.h:82
RooAbsPdf::CanNotBeExtended
@ CanNotBeExtended
Definition: RooAbsPdf.h:229
RooAICRegistry.h
RooAbsPdf.h
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooAddPdf::_coefList
RooListProxy _coefList
Definition: RooAddPdf.h:140
RooAddPdf::getNormAndCache
std::pair< const RooArgSet *, CacheElem * > getNormAndCache() const
Coefficient error counter.
Definition: RooAddPdf.cxx:781
RooAbsGenContext
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
Definition: RooAbsGenContext.h:26
RooListProxy
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:24
RooAddPdf::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: RooAddPdf.h:54
RooAddGenContext
RooAddGenContext is an efficient implementation of the generator context specific for RooAddPdf PDFs.
Definition: RooAddGenContext.h:32
RooObjCacheManager.h
RooAddPdf::getAnalyticalIntegralWN
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const
Determine which part (if any) of given integral can be performed analytically.
Definition: RooAddPdf.cxx:907
RooAddPdf::CacheElem::~CacheElem
virtual ~CacheElem()
Definition: RooAddPdf.h:110
RooAddPdf::CacheElem::_rangeProjList
RooArgList _rangeProjList
Definition: RooAddPdf.h:118
RooListProxy.h
RooAddPdf::CacheElem::containedArgs
virtual RooArgList containedArgs(Action)
List all RooAbsArg derived contents in this cache element.
Definition: RooAddPdf.cxx:1150
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAddPdf::expectedEvents
virtual Double_t expectedEvents(const RooArgSet &nset) const
Definition: RooAddPdf.h:64
RooAddPdf::printMetaArgs
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooAddPdf to more intuitively reflect the contents of the produ...
Definition: RooAddPdf.cxx:1291
RooAddPdf::coefList
const RooArgList & coefList() const
Definition: RooAddPdf.h:74
RooAddPdf::fixCoefNormalization
void fixCoefNormalization(const RooArgSet &refCoefNorm)
By default the interpretation of the fraction coefficients is performed in the contextual choice of o...
Definition: RooAddPdf.cxx:376
RooObjCacheManager
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
Definition: RooObjCacheManager.h:32
RooAbsCacheElement::Action
Action
Definition: RooAbsCacheElement.h:39
RooAddPdf::~RooAddPdf
virtual ~RooAddPdf()
Destructor.
Definition: RooAddPdf.cxx:359
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
RooAddPdf::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 RooAddPdfs return RooAbsPdf::genCo...
Definition: RooAddPdf.cxx:1139
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooAddPdf::_pdfList
RooListProxy _pdfList
Registry of component analytical integration codes.
Definition: RooAddPdf.h:139
RooNameReg::str
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition: RooNameReg.cxx:103
RooAbsArg::NotAdvised
@ NotAdvised
Definition: RooAbsArg.h:409
RooAddPdf::RooAddPdf
RooAddPdf()
Default constructor used for persistence.
Definition: RooAddPdf.cxx:98
name
char name[80]
Definition: TGX11.cxx:110
RooAddPdf::setCacheAndTrackHints
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooAddPdf with cache-and-track.
Definition: RooAddPdf.cxx:1273
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAddPdf::_coefCache
std::vector< double > _coefCache
Definition: RooAddPdf.h:105
RooDataSet
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooAddPdf::CacheElem::_needSupNorm
Bool_t _needSupNorm
Definition: RooAddPdf.h:113
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
RooAbsPdf
Definition: RooAbsPdf.h:40
RooAddPdf::getProjCache
CacheElem * getProjCache(const RooArgSet *nset, const RooArgSet *iset=0, const char *rangeName=0) const
Retrieve cache element for the computation of the PDF normalisation.
Definition: RooAddPdf.cxx:422
RooAbsRealLValue
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Definition: RooAbsRealLValue.h:31
RooAddPdf::_coefErrCount
Int_t _coefErrCount
Definition: RooAddPdf.h:147
RooNameReg.h
RooAddPdf::_codeReg
RooAICRegistry _codeReg
Definition: RooAddPdf.h:137
RooSpan
A simple container to hold a batch of data values.
Definition: RooSpan.h:33
RooArgSet
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
int