Logo ROOT  
Reference Guide
Go to the documentation of this file.
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
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 "RooObjCacheManager.h"
26#include "RooNameReg.h"
28#include <vector>
29#include <list>
30#include <utility>
32class RooAddPdf : public RooAbsPdf {
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) ;
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() ;
46 virtual Bool_t checkObservables(const RooArgSet* nset) const ;
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 }
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 }
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 }
79 void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
80 void fixCoefRange(const char* rangeName) ;
82 const RooArgSet& getCoefNormalization() const { return _refCoefNorm ; }
85 virtual void resetErrorCounters(Int_t resetValue=10) ;
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 ;
91 void printMetaArgs(std::ostream& os) const ;
93 virtual CacheMode canNodeBeCached() const { return RooAbsArg::NotAdvised ; } ;
94 virtual void setCacheAndTrackHints(RooArgSet&) ;
98 virtual void selectNormalization(const RooArgSet* depSet=0, Bool_t force=kFALSE) ;
99 virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
101 mutable RooSetProxy _refCoefNorm ; // Reference observable set for coefficient interpretation
102 mutable TNamed* _refCoefRangeName ; // Reference range name for coefficient interpreation
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
109 public:
110 virtual ~CacheElem() {} ;
112 RooArgList _suppNormList ; // Supplemental normalization list
113 Bool_t _needSupNorm ; // Does the above list contain any non-unit entries?
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)
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 ;
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 ;
133 Double_t evaluate() const;
134 RooSpan<double> evaluateSpan(RooBatchCompute::RunContext& evalData, const RooArgSet* normSet) const;
137 mutable RooAICRegistry _codeReg ; //! Registry of component analytical integration codes
139 RooListProxy _pdfList ; // List of component PDFs
140 RooListProxy _coefList ; // List of coefficients
141 mutable RooArgList* _snormList{nullptr}; //! List of supplemental normalization factors
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
147 mutable Int_t _coefErrCount ; //! Coefficient error counter
149 bool redirectServersHook(const RooAbsCollection&, bool, bool, bool) {
150 // If a server is redirected, the cached normalization set might not point
151 // to the right observables anymore. We need to reset it.
152 _copyOfLastNormSet.reset();
153 return false;
154 }
157 std::pair<const RooArgSet*, CacheElem*> getNormAndCache(const RooArgSet* defaultNorm = nullptr) const;
158 mutable RooArgSet const* _pointerToLastUsedNormSet = nullptr; //!
159 mutable std::unique_ptr<const RooArgSet> _copyOfLastNormSet = nullptr; //!
161 ClassDef(RooAddPdf,3) // PDF representing a sum of PDFs
const Bool_t kFALSE
Definition: RtypesCore.h:92
double Double_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:91
#define ClassDef(name, id)
Definition: Rtypes.h:325
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:72
@ NotAdvised
Definition: RooAbsArg.h:407
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
@ MustBeExtended
Definition: RooAbsPdf.h:232
@ CanNotBeExtended
Definition: RooAbsPdf.h:232
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:61
RooAddGenContext is an efficient implementation of the generator context specific for RooAddPdf PDFs.
Transient cache with transformed values of coefficients.
Definition: RooAddPdf.h:108
virtual RooArgList containedArgs(Action)
List all RooAbsArg derived contents in this cache element.
Definition: RooAddPdf.cxx:1191
virtual ~CacheElem()
Definition: RooAddPdf.h:110
RooArgList _rangeProjList
Definition: RooAddPdf.h:118
RooArgList _refRangeProjList
Definition: RooAddPdf.h:117
RooArgList _projList
Definition: RooAddPdf.h:115
RooArgList _suppNormList
Definition: RooAddPdf.h:112
RooArgList _suppProjList
Definition: RooAddPdf.h:116
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:32
RooListProxy _coefList
Definition: RooAddPdf.h:140
virtual CacheMode canNodeBeCached() const
Definition: RooAddPdf.h:93
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:905
RooArgList * _snormList
Definition: RooAddPdf.h:141
Bool_t _recursive
Definition: RooAddPdf.h:145
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooAddPdf with cache-and-track.
Definition: RooAddPdf.cxx:1313
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:1073
RooAICRegistry _codeReg
Definition: RooAddPdf.h:137
const char * getCoefRange() const
Definition: RooAddPdf.h:83
std::pair< const RooArgSet *, CacheElem * > getNormAndCache(const RooArgSet *defaultNorm=nullptr) const
Look up projection cache and per-PDF norm sets.
Definition: RooAddPdf.cxx:783
std::unique_ptr< const RooArgSet > _copyOfLastNormSet
Definition: RooAddPdf.h:159
Bool_t isBinnedDistribution(const RooArgSet &obs) const
If all components that depend on obs are binned, so is their sum.
Definition: RooAddPdf.cxx:1297
virtual TObject * clone(const char *newname) const
Definition: RooAddPdf.h:43
Int_t _coefErrCount
Definition: RooAddPdf.h:147
Bool_t _allExtendable
Definition: RooAddPdf.h:144
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:1165
Double_t evaluate() const
Calculate and return the current value.
Definition: RooAddPdf.cxx:839
void updateCoefficients(CacheElem &cache, const RooArgSet *nset) const
Update the coefficient values in the given cache element: calculate new remainder fraction,...
Definition: RooAddPdf.cxx:659
virtual ~RooAddPdf()
Definition: RooAddPdf.cxx:353
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:416
const RooArgList & coefList() const
Definition: RooAddPdf.h:74
RooObjCacheManager _projCacheMgr
Definition: RooAddPdf.h:123
RooArgSet const * _pointerToLastUsedNormSet
Definition: RooAddPdf.h:158
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:1331
Default constructor used for persistence.
Definition: RooAddPdf.cxx:92
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:1207
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:1252
void fixCoefNormalization(const RooArgSet &refCoefNorm)
By default the interpretation of the fraction coefficients is performed in the contextual choice of o...
Definition: RooAddPdf.cxx:370
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:1180
RooSetProxy _refCoefNorm
Definition: RooAddPdf.h:101
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
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:1016
virtual Bool_t forceAnalyticalInt(const RooAbsArg &) const
Definition: RooAddPdf.h:48
RooSpan< double > evaluateSpan(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet) const
Compute addition of PDFs in batches.
Definition: RooAddPdf.cxx:867
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:1142
void fixCoefRange(const char *rangeName)
By default, fraction coefficients are assumed to refer to the default fit range.
Definition: RooAddPdf.cxx:397
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
Definition: RooAddPdf.h:59
virtual Double_t expectedEvents(const RooArgSet &nset) const
Return expected number of events to be used in calculation of extended likelihood.
Definition: RooAddPdf.h:64
RooListProxy _pdfList
Registry of component analytical integration codes.
Definition: RooAddPdf.h:139
TNamed * _refCoefRangeName
Definition: RooAddPdf.h:102
const RooArgList & pdfList() const
Definition: RooAddPdf.h:70
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:948
bool redirectServersHook(const RooAbsCollection &, bool, bool, bool)
Coefficient error counter.
Definition: RooAddPdf.h:149
Bool_t _projectCoefs
Definition: RooAddPdf.h:104
std::vector< double > _coefCache
Definition: RooAddPdf.h:105
const RooArgSet & getCoefNormalization() const
Definition: RooAddPdf.h:82
Bool_t _haveLastCoef
List of supplemental normalization factors.
Definition: RooAddPdf.h:143
virtual Bool_t checkObservables(const RooArgSet *nset) const
Check if PDF is valid for given normalization set.
Definition: RooAddPdf.cxx:918
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:29
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:24
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
Definition: RooNameReg.cxx:103
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
RooSetProxy is the concrete proxy for RooArgSet objects.
Definition: RooSetProxy.h:23
A simple container to hold a batch of data values.
Definition: RooSpan.h:34
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37
This struct enables passing computation data around between elements of a computation graph.
Definition: RunContext.h:31