Logo ROOT  
Reference Guide
RooProdPdf.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooProdPdf.h,v 1.44 2007/07/16 21:04: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_PROD_PDF
17#define ROO_PROD_PDF
18
19#include "RooAbsPdf.h"
20#include "RooListProxy.h"
21#include "RooLinkedList.h"
22#include "RooAICRegistry.h"
23#include "RooCacheManager.h"
24#include "RooObjCacheManager.h"
25#include "RooCmdArg.h"
26#include <vector>
27
30
31class RooProdPdf : public RooAbsPdf {
32public:
33 RooProdPdf() ;
34 RooProdPdf(const char *name, const char *title, Double_t cutOff=0);
35 RooProdPdf(const char *name, const char *title,
36 RooAbsPdf& pdf1, RooAbsPdf& pdf2, Double_t cutOff=0) ;
37 RooProdPdf(const char* name, const char* title, const RooArgList& pdfList, Double_t cutOff=0) ;
38 RooProdPdf(const char* name, const char* title, const RooArgSet& fullPdfSet, const RooLinkedList& cmdArgList) ;
39
40 RooProdPdf(const char* name, const char* title, const RooArgSet& fullPdfSet,
41 const RooCmdArg& arg1 , const RooCmdArg& arg2=RooCmdArg(),
42 const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
43 const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(),
44 const RooCmdArg& arg7=RooCmdArg(), const RooCmdArg& arg8=RooCmdArg()) ;
45
46 RooProdPdf(const char* name, const char* title,
47 const RooCmdArg& arg1, const RooCmdArg& arg2=RooCmdArg(),
48 const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
49 const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(),
50 const RooCmdArg& arg7=RooCmdArg(), const RooCmdArg& arg8=RooCmdArg()) ;
51
52 RooProdPdf(const RooProdPdf& other, const char* name=0) ;
53 virtual TObject* clone(const char* newname) const { return new RooProdPdf(*this,newname) ; }
54 virtual ~RooProdPdf() ;
55
56 virtual Double_t getValV(const RooArgSet* set=0) const ;
57 virtual Bool_t checkObservables(const RooArgSet* nset) const ;
58
59 virtual Bool_t forceAnalyticalInt(const RooAbsArg& dep) const ;
60 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const ;
61 Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
62 virtual Bool_t selfNormalized() const { return _selfNorm ; }
63
64 virtual ExtendMode extendMode() const ;
65 virtual Double_t expectedEvents(const RooArgSet* nset) const ;
66 virtual Double_t expectedEvents(const RooArgSet& nset) const { return expectedEvents(&nset) ; }
67
68 const RooArgList& pdfList() const { return _pdfList ; }
69
70 virtual Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const;
71 virtual void initGenerator(Int_t code) ;
72 virtual void generateEvent(Int_t code);
73 virtual Bool_t isDirectGenSafe(const RooAbsArg& arg) const ;
74
75 // Constraint management
76 virtual RooArgSet* getConstraints(const RooArgSet& observables, RooArgSet& constrainedParams, Bool_t stripDisconnected) const ;
77
78 virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const ;
79 virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
80 Bool_t isBinnedDistribution(const RooArgSet& obs) const ;
81
82 void printMetaArgs(std::ostream& os) const ;
83
84 virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
85 void fixRefRange(const char* rangeName) ;
86
87 void setSelfNormalized(Bool_t flag) { _selfNorm = flag ; }
89
90
91 Bool_t redirectServersHook(const RooAbsCollection& /*newServerList*/, Bool_t /*mustReplaceAll*/, Bool_t /*nameChange*/, Bool_t /*isRecursive*/) ;
92
93 RooArgSet* getConnectedParameters(const RooArgSet& observables) const ;
94
95 RooArgSet* findPdfNSet(RooAbsPdf& pdf) const ;
96
97
98private:
99
100 Double_t evaluate() const ;
101 virtual RooSpan<double> evaluateBatch(std::size_t begin, std::size_t size) const;
102
103 RooAbsReal* makeCondPdfRatioCorr(RooAbsReal& term, const RooArgSet& termNset, const RooArgSet& termImpSet, const char* normRange, const char* refRange) const ;
104
105 virtual void getParametersHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/, Bool_t stripDisconnected) const ;
106
107 void initializeFromCmdArgList(const RooArgSet& fullPdfSet, const RooLinkedList& l) ;
108
109 void factorizeProduct(const RooArgSet& normSet, const RooArgSet& intSet,
110 RooLinkedList& termList, RooLinkedList& normList,
111 RooLinkedList& impDepList, RooLinkedList& crossDepList,
112 RooLinkedList& intList) const;
113 std::string makeRGPPName(const char* pfx, const RooArgSet& term, const RooArgSet& iset, const RooArgSet& nset, const char* isetRangeName) const ;
114 void groupProductTerms(RooLinkedList& groupedTerms, RooArgSet& outerIntDeps,
115 const RooLinkedList& terms, const RooLinkedList& norms,
116 const RooLinkedList& imps, const RooLinkedList& ints, const RooLinkedList& cross) const ;
117
118
119
120 Int_t getPartIntList(const RooArgSet* nset, const RooArgSet* iset, const char* isetRangeName=0) const ;
121
122 std::vector<RooAbsReal*> processProductTerm(const RooArgSet* nset, const RooArgSet* iset, const char* isetRangeName,
123 const RooArgSet* term,const RooArgSet& termNSet, const RooArgSet& termISet,
124 Bool_t& isOwned, Bool_t forceWrap=kFALSE) const ;
125
126
127 virtual CacheMode canNodeBeCached() const { return RooAbsArg::NotAdvised ; } ;
128 virtual void setCacheAndTrackHints(RooArgSet&) ;
129
130 // The cache object
132 public:
134 virtual ~CacheElem() = default;
135 // Payload
140 std::vector<std::unique_ptr<RooArgSet>> _normList;
142 std::unique_ptr<RooAbsReal> _rearrangedNum{};
143 std::unique_ptr<RooAbsReal> _rearrangedDen{};
144 // Cache management functions
146 virtual void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) ;
147 private:
149 } ;
150 mutable RooObjCacheManager _cacheMgr ; // The cache manager
151
152 void rearrangeProduct(CacheElem&) const;
153 RooAbsReal* specializeIntegral(RooAbsReal& orig, const char* targetRangeName) const ;
154 RooAbsReal* specializeRatio(RooFormulaVar& input, const char* targetRangeName) const ;
156
157
158 friend class RooProdGenContext ;
159 virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0,
160 const RooArgSet *auxProto=0, Bool_t verbose= kFALSE) const ;
161
162
163 mutable RooAICRegistry _genCode ; //! Registry of composite direct generator codes
164
165 mutable RooArgSet* _curNormSet = nullptr; //!
166 Double_t _cutOff ; // Cutoff parameter for running product
167 RooListProxy _pdfList ; // List of PDF components
168 RooLinkedList _pdfNSetList ; // List of PDF component normalization sets
169 Int_t _extendedIndex ; // Index of extended PDF (if any)
170
171 void useDefaultGen(Bool_t flag=kTRUE) { _useDefaultGen = flag ; }
172 Bool_t _useDefaultGen ; // Use default or distributed event generator
173
174 mutable TNamed* _refRangeName ; // Reference range name for interpretation of conditional products
175
176 Bool_t _selfNorm ; // Is self-normalized
177 RooArgSet _defNormSet ; // Default normalization set
178
179private:
180
181 ClassDef(RooProdPdf,4) // PDF representing a product of PDFs
182};
183
184
185#endif
RooArgList * pRooArgList
Definition: RooProdPdf.h:28
RooLinkedList * pRooLinkedList
Definition: RooProdPdf.h:29
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
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 (of arbitrary type) an...
Definition: RooAbsArg.h:71
@ NotAdvised
Definition: RooAbsArg.h:370
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.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
const char * normRange() const
Definition: RooAbsPdf.h:261
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:59
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:28
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:96
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:28
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
A RooFormulaVar is a generic implementation of a real-valued object, which takes a RooArgList of serv...
Definition: RooFormulaVar.h:29
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:36
RooListProxy is the concrete proxy for RooArgList objects.
Definition: RooListProxy.h:25
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
RooProdGenContext is an efficient implementation of the generator context specific for RooProdPdf PDF...
virtual ~CacheElem()=default
virtual void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t)
Hook function to print cache contents in tree printing of RooProdPdf.
std::unique_ptr< RooAbsReal > _rearrangedNum
Definition: RooProdPdf.h:142
RooArgList _ownedList
Definition: RooProdPdf.h:139
RooArgList _partList
Definition: RooProdPdf.h:136
std::vector< std::unique_ptr< RooArgSet > > _normList
Definition: RooProdPdf.h:140
std::unique_ptr< RooAbsReal > _rearrangedDen
Definition: RooProdPdf.h:143
virtual RooArgList containedArgs(Action)
Return RooAbsArg components contained in the cache.
CacheElem(const CacheElem &)
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
virtual Double_t expectedEvents(const RooArgSet &nset) const
Definition: RooProdPdf.h:66
void rearrangeProduct(CacheElem &) const
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return the expected number of events associated with the extendable input PDF in the product.
void factorizeProduct(const RooArgSet &normSet, const RooArgSet &intSet, RooLinkedList &termList, RooLinkedList &normList, RooLinkedList &impDepList, RooLinkedList &crossDepList, RooLinkedList &intList) const
Factorize product in irreducible terms for given choice of integration/normalization.
Definition: RooProdPdf.cxx:566
void useDefaultGen(Bool_t flag=kTRUE)
Definition: RooProdPdf.h:171
void groupProductTerms(RooLinkedList &groupedTerms, RooArgSet &outerIntDeps, const RooLinkedList &terms, const RooLinkedList &norms, const RooLinkedList &imps, const RooLinkedList &ints, const RooLinkedList &cross) const
Group product into terms that can be calculated independently.
RooArgSet * _curNormSet
Registry of composite direct generator codes.
Definition: RooProdPdf.h:165
Int_t _extendedIndex
Definition: RooProdPdf.h:169
Int_t getPartIntList(const RooArgSet *nset, const RooArgSet *iset, const char *isetRangeName=0) const
Return list of (partial) integrals of product terms for integration of p.d.f over observables iset wh...
Definition: RooProdPdf.cxx:751
RooProdPdf()
Default constructor.
Definition: RooProdPdf.cxx:83
virtual Bool_t checkObservables(const RooArgSet *nset) const
Obsolete.
Double_t _cutOff
Definition: RooProdPdf.h:166
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooProdPdf to more intuitively reflect the contents of the prod...
Double_t evaluate() const
Calculate current value of object.
Definition: RooProdPdf.cxx:465
TNamed * _refRangeName
Definition: RooProdPdf.h:174
RooAICRegistry _genCode
Definition: RooProdPdf.h:163
RooListProxy _pdfList
Definition: RooProdPdf.h:167
Bool_t isBinnedDistribution(const RooArgSet &obs) const
If all components that depend on obs are binned that so is the product.
virtual Bool_t isDirectGenSafe(const RooAbsArg &arg) const
Forward determination of safety of internal generator code to component p.d.f that would generate the...
Bool_t _useDefaultGen
Definition: RooProdPdf.h:172
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.
RooAbsReal * specializeIntegral(RooAbsReal &orig, const char *targetRangeName) const
virtual ExtendMode extendMode() const
If this product contains exactly one extendable p.d.f return the extension abilities of that p....
RooObjCacheManager _cacheMgr
Definition: RooProdPdf.h:150
virtual void initGenerator(Int_t code)
Forward one-time initialization call to component generation initialization methods.
std::string makeRGPPName(const char *pfx, const RooArgSet &term, const RooArgSet &iset, const RooArgSet &nset, const char *isetRangeName) const
Make an appropriate automatic name for a RooGenProdProj object in getPartIntList()
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Return analytical integral defined by given scenario code.
virtual ~RooProdPdf()
Destructor.
Definition: RooProdPdf.cxx:443
virtual void getParametersHook(const RooArgSet *, RooArgSet *, Bool_t stripDisconnected) const
virtual Double_t getValV(const RooArgSet *set=0) const
Overload getVal() to intercept normalization set for use in evaluate()
Definition: RooProdPdf.cxx:454
Bool_t _selfNorm
Definition: RooProdPdf.h:176
RooAbsReal * makeCondPdfRatioCorr(RooAbsReal &term, const RooArgSet &termNset, const RooArgSet &termImpSet, const char *normRange, const char *refRange) const
For single normalization ranges.
RooArgSet * findPdfNSet(RooAbsPdf &pdf) const
Look up user specified normalization set for given input PDF component.
virtual RooSpan< double > evaluateBatch(std::size_t begin, std::size_t size) const
Evaluate function for a batch of input data points.
Definition: RooProdPdf.cxx:517
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooProdPdf with cache-and-track, and label all RooProdPdf descendants wit...
virtual RooArgSet * getConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, Bool_t stripDisconnected) const
Return all parameter constraint p.d.f.s on parameters listed in constrainedParams.
RooLinkedList _pdfNSetList
Definition: RooProdPdf.h:168
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const
Query internal generation capabilities of component p.d.f.s and aggregate capabilities into master co...
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 conditiona...
void setSelfNormalized(Bool_t flag)
Definition: RooProdPdf.h:87
RooArgSet * getConnectedParameters(const RooArgSet &observables) const
Return all parameter constraint p.d.f.s on parameters listed in constrainedParams.
Double_t calculate(const RooProdPdf::CacheElem &cache, Bool_t verbose=kFALSE) const
Calculate running product of pdfs terms, using the supplied normalization set in 'normSetList' for ea...
Definition: RooProdPdf.cxx:486
RooArgSet _defNormSet
Definition: RooProdPdf.h:177
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs.
RooAbsReal * specializeRatio(RooFormulaVar &input, const char *targetRangeName) const
Bool_t redirectServersHook(const RooAbsCollection &, Bool_t, Bool_t, Bool_t)
Implement support for node removal.
const RooArgList & pdfList() const
Definition: RooProdPdf.h:68
void fixRefRange(const char *rangeName)
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force RooRealIntegral to offer all observables for internal integration.
virtual TObject * clone(const char *newname) const
Definition: RooProdPdf.h:53
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Return generator context optimized for generating events from product p.d.f.s.
void initializeFromCmdArgList(const RooArgSet &fullPdfSet, const RooLinkedList &l)
Initialize RooProdPdf configuration from given list of RooCmdArg configuration arguments and set of '...
Definition: RooProdPdf.cxx:376
virtual Bool_t selfNormalized() const
Definition: RooProdPdf.h:62
virtual CacheMode canNodeBeCached() const
Definition: RooProdPdf.h:127
virtual void generateEvent(Int_t code)
Generate a single event with configuration specified by 'code' Defer internal generation to component...
std::vector< RooAbsReal * > processProductTerm(const RooArgSet *nset, const RooArgSet *iset, const char *isetRangeName, const RooArgSet *term, const RooArgSet &termNSet, const RooArgSet &termISet, Bool_t &isOwned, Bool_t forceWrap=kFALSE) const
Calculate integrals of factorized product terms over observables iset while normalized to observables...
void setDefNormSet(const RooArgSet &nset)
Definition: RooProdPdf.h:88
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs.
A simple container to hold a batch of data values.
Definition: RooSpan.h:32
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
auto * l
Definition: textangle.C:4