Logo ROOT   6.12/07
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 
29 class RooAddPdf : public RooAbsPdf {
30 public:
31 
32  RooAddPdf() ;
33  RooAddPdf(const char *name, const char *title=0);
34  RooAddPdf(const char *name, const char *title,
35  RooAbsPdf& pdf1, RooAbsPdf& pdf2, RooAbsReal& coef1) ;
36  RooAddPdf(const char *name, const char *title, const RooArgList& pdfList) ;
37  RooAddPdf(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, Bool_t recursiveFraction=kFALSE) ;
38 
39  RooAddPdf(const RooAddPdf& other, const char* name=0) ;
40  virtual TObject* clone(const char* newname) const { return new RooAddPdf(*this,newname) ; }
41  virtual ~RooAddPdf() ;
42 
43  Double_t evaluate() const ;
44  virtual Bool_t checkObservables(const RooArgSet* nset) const ;
45 
46  virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const {
47  // Force RooRealIntegral to offer all observables for internal integration
48  return kTRUE ;
49  }
50  Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const ;
51  Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
52  virtual Bool_t selfNormalized() const {
53  // P.d.f is self normalized
54  return kTRUE ;
55  }
56 
57  virtual ExtendMode extendMode() const {
58  // Return extended mode capabilities
60  }
61  virtual Double_t expectedEvents(const RooArgSet* nset) const ;
62  virtual Double_t expectedEvents(const RooArgSet& nset) const {
63  // Return expected number of events for extended likelihood calculation
64  // which is the sum of all coefficients
65  return expectedEvents(&nset) ;
66  }
67 
68  const RooArgList& pdfList() const {
69  // Return list of component p.d.fs
70  return _pdfList ;
71  }
72  const RooArgList& coefList() const {
73  // Return list of coefficients of component p.d.f.s
74  return _coefList ;
75  }
76 
77  void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
78  void fixCoefRange(const char* rangeName) ;
79 
80  const RooArgSet& getCoefNormalization() const { return _refCoefNorm ; }
81  const char* getCoefRange() const { return _refCoefRangeName?RooNameReg::str(_refCoefRangeName):"" ; }
82 
83  virtual void resetErrorCounters(Int_t resetValue=10) ;
84 
85  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const ;
86  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
87  Bool_t isBinnedDistribution(const RooArgSet& obs) const ;
88 
89  void printMetaArgs(std::ostream& os) const ;
90 
91  virtual CacheMode canNodeBeCached() const { return RooAbsArg::NotAdvised ; } ;
92  virtual void setCacheAndTrackHints(RooArgSet&) ;
93 
94 protected:
95 
96  virtual void selectNormalization(const RooArgSet* depSet=0, Bool_t force=kFALSE) ;
97  virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
98 
99  mutable RooSetProxy _refCoefNorm ; // Reference observable set for coefficient interpretation
100  mutable TNamed* _refCoefRangeName ; // Reference range name for coefficient interpreation
101 
102  Bool_t _projectCoefs ; // If true coefficients need to be projected for use in evaluate()
103  mutable Double_t* _coefCache ; //! Transiet cache with transformed values of coefficients
104 
105 
106  class CacheElem : public RooAbsCacheElement {
107  public:
108  virtual ~CacheElem() {} ;
109 
110  RooArgList _suppNormList ; // Supplemental normalization list
111  Bool_t _needSupNorm ; // Does the above list contain any non-unit entries?
112 
113  RooArgList _projList ; // Projection integrals to be multiplied with coefficients
114  RooArgList _suppProjList ; // Projection integrals to be multiplied with coefficients for supplemental normalization terms
115  RooArgList _refRangeProjList ; // Range integrals to be multiplied with coefficients (reference range)
116  RooArgList _rangeProjList ; // Range integrals to be multiplied with coefficients (target range)
117 
118  virtual RooArgList containedArgs(Action) ;
119 
120  } ;
121  mutable RooObjCacheManager _projCacheMgr ; // Manager of cache with coefficient projections and transformations
122  CacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=0, const char* rangeName=0) const ;
123  void updateCoefficients(CacheElem& cache, const RooArgSet* nset) const ;
124 
125 
126  friend class RooAddGenContext ;
127  virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0,
128  const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
129 
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 ; //! List of supplemental normalization factors
136  TIterator* _pdfIter ; //! Iterator over PDF list
137  TIterator* _coefIter ; //! Iterator over coefficient list
138 
139  Bool_t _haveLastCoef ; // Flag indicating if last PDFs coefficient was supplied in the ctor
140  Bool_t _allExtendable ; // Flag indicating if all PDF components are extendable
141  Bool_t _recursive ; // Flag indicating is fractions are treated recursively
142 
143  mutable Int_t _coefErrCount ; //! Coefficient error counter
144 
145 private:
146 
147  ClassDef(RooAddPdf,3) // PDF representing a sum of PDFs
148 };
149 
150 #endif
void fixCoefRange(const char *rangeName)
By default the interpretation of the fraction coefficients is performed in the default range...
Definition: RooAddPdf.cxx:416
void updateCoefficients(CacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction...
Definition: RooAddPdf.cxx:679
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:29
RooArgList _suppNormList
Definition: RooAddPdf.h:108
virtual ~CacheElem()
Definition: RooAddPdf.h:108
Bool_t _haveLastCoef
Iterator over coefficient list.
Definition: RooAddPdf.h:139
virtual RooArgList containedArgs(Action)
List all RooAbsArg derived contents in this cache element.
Definition: RooAddPdf.cxx:1167
virtual TObject * clone(const char *newname) const
Definition: RooAddPdf.h:40
void fixCoefNormalization(const RooArgSet &refCoefNorm)
By default the interpretation of the fraction coefficients is performed in the contextual choice of o...
Definition: RooAddPdf.cxx:389
Bool_t _projectCoefs
Definition: RooAddPdf.h:102
const char * getCoefRange() const
Definition: RooAddPdf.h:81
Bool_t _recursive
Definition: RooAddPdf.h:141
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:1049
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition: RooNameReg.cxx:135
RooListProxy _pdfList
Registry of component analytical integration codes.
Definition: RooAddPdf.h:133
RooAddPdf()
Default constructor used for persistence.
Definition: RooAddPdf.cxx:92
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:1118
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: RooAddPdf.cxx:431
Transiet cache with transformed values of coefficients.
Definition: RooAddPdf.h:106
Double_t * _coefCache
Definition: RooAddPdf.h:103
const RooArgList & pdfList() const
Definition: RooAddPdf.h:68
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:1313
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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:1141
RooArgList * _snormList
Definition: RooAddPdf.h:135
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:1183
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:1230
Iterator abstract base class.
Definition: TIterator.h:30
#define ClassDef(name, id)
Definition: Rtypes.h:320
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
const RooArgSet & getCoefNormalization() const
Definition: RooAddPdf.h:80
RooAICRegistry _codeReg
Definition: RooAddPdf.h:131
TIterator * _pdfIter
List of supplemental normalization factors.
Definition: RooAddPdf.h:136
virtual CacheMode canNodeBeCached() const
Definition: RooAddPdf.h:91
Int_t _coefErrCount
Definition: RooAddPdf.h:143
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
virtual Bool_t checkObservables(const RooArgSet *nset) const
Check if PDF is valid for given normalization set.
Definition: RooAddPdf.cxx:880
virtual ~RooAddPdf()
Destructor.
Definition: RooAddPdf.cxx:368
RooListProxy _coefList
Definition: RooAddPdf.h:134
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:1156
RooArgList _refRangeProjList
Definition: RooAddPdf.h:115
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual ExtendMode extendMode() const
Definition: RooAddPdf.h:57
Double_t evaluate() const
Calculate and return the current value.
Definition: RooAddPdf.cxx:815
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:29
Bool_t _allExtendable
Definition: RooAddPdf.h:140
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:25
RooArgList _suppProjList
Definition: RooAddPdf.h:114
const Bool_t kFALSE
Definition: RtypesCore.h:88
TNamed * _refCoefRangeName
Definition: RooAddPdf.h:100
virtual Double_t expectedEvents(const RooArgSet &nset) const
Definition: RooAddPdf.h:62
virtual void resetErrorCounters(Int_t resetValue=10)
Reset error counter to given value, limiting the number of future error messages for this pdf to &#39;res...
Definition: RooAddPdf.cxx:867
RooAICRegistry is a utility class for operator p.d.f classes that keeps track of analytical integrati...
const RooArgList & coefList() const
Definition: RooAddPdf.h:72
RooObjCacheManager _projCacheMgr
Definition: RooAddPdf.h:121
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK&#39;ed components of a RooAddPdf with cache-and-track.
Definition: RooAddPdf.cxx:1295
virtual Bool_t selfNormalized() const
Definition: RooAddPdf.h:52
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAddPdf.h:46
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
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:911
TIterator * _coefIter
Iterator over PDF list.
Definition: RooAddPdf.h:137
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
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:988
RooAddGenContext is an efficient implementation of the generator context specific for RooAddPdf PDFs...
RooArgList _projList
Definition: RooAddPdf.h:113
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:24
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: RtypesCore.h:87
RooSetProxy _refCoefNorm
Definition: RooAddPdf.h:99
char name[80]
Definition: TGX11.cxx:109
RooArgList _rangeProjList
Definition: RooAddPdf.h:116
Bool_t isBinnedDistribution(const RooArgSet &obs) const
If all components that depend on obs are binned that so is the product.
Definition: RooAddPdf.cxx:1278