Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealSumPdf.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooRealSumPdf.h,v 1.10 2007/05/11 09:11:30 verkerke 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_REAL_SUM_PDF
17#define ROO_REAL_SUM_PDF
18
19#include "RooAbsPdf.h"
20#include "RooListProxy.h"
21#include "RooAICRegistry.h"
22#include "RooObjCacheManager.h"
23
24class RooRealSumPdf : public RooAbsPdf {
25public:
26
28 RooRealSumPdf(const char *name, const char *title);
29 RooRealSumPdf(const char *name, const char *title, const RooArgList& funcList, const RooArgList& coefList, bool extended=false) ;
30 RooRealSumPdf(const char *name, const char *title,
31 RooAbsReal& func1, RooAbsReal& func2, RooAbsReal& coef1) ;
32 RooRealSumPdf(const RooRealSumPdf& other, const char* name=nullptr) ;
33 TObject* clone(const char* newname) const override { return new RooRealSumPdf(*this,newname) ; }
34 ~RooRealSumPdf() override ;
35
36 double evaluate() const override ;
37 bool checkObservables(const RooArgSet* nset) const override ;
38
39 void computeBatch(double* output, size_t size, RooFit::Detail::DataMap const&) const override;
40
41 bool forceAnalyticalInt(const RooAbsArg& arg) const override { return arg.isFundamental() ; }
42 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
43 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
44
45 const RooArgList& funcList() const { return _funcList ; }
46 const RooArgList& coefList() const { return _coefList ; }
47
48 ExtendMode extendMode() const override ;
49
50 /// Return expected number of events for extended likelihood calculation, which
51 /// is the sum of all coefficients.
52 double expectedEvents(const RooArgSet* nset) const override ;
53
54 bool selfNormalized() const override { return getAttribute("BinnedLikelihoodActive") ; }
55
56 void printMetaArgs(std::ostream& os) const override ;
57
58
59 std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
60 std::list<double>* plotSamplingHint(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
61 bool isBinnedDistribution(const RooArgSet& obs) const override ;
62
63 void setFloor(bool flag) { _doFloor = flag ; }
64 bool getFloor() const { return _doFloor ; }
65 static void setFloorGlobal(bool flag) { _doFloorGlobal = flag ; }
66 static bool getFloorGlobal() { return _doFloorGlobal ; }
67
68 CacheMode canNodeBeCached() const override { return RooAbsArg::NotAdvised ; } ;
69 void setCacheAndTrackHints(RooArgSet&) override ;
70
71 std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
72
73 std::unique_ptr<RooAbsReal> createExpectedEventsFunc(const RooArgSet* nset) const override;
74
75 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
76
77protected:
78
80 public:
81 CacheElem() {} ;
82 RooArgList containedArgs(Action) override { RooArgList ret(_funcIntList) ; ret.add(_funcNormList) ; return ret ; }
85 } ;
86 mutable RooObjCacheManager _normIntMgr ; ///<! The integration cache manager
87
88
89 RooListProxy _funcList ; ///< List of component FUNCs
90 RooListProxy _coefList ; ///< List of coefficients
91 bool _extended ; ///< Allow use as extended p.d.f.
92
93 bool _doFloor = false; ///< Introduce floor at zero in pdf
94 mutable bool _haveWarned{false}; ///<!
95 static bool _doFloorGlobal ; ///< Global flag for introducing floor at zero in pdf
96
97private:
98
99 friend class RooAddPdf;
100 friend class RooAddition;
101 friend class RooRealSumFunc;
102
103 static void initializeFuncsAndCoefs(RooAbsReal const& caller,
104 const RooArgList& inFuncList, const RooArgList& inCoefList,
106
107 static double evaluate(RooAbsReal const& caller,
108 RooArgList const& funcList,
109 RooArgList const& coefList,
110 bool doFloor,
111 bool & hasWarnedBefore);
112
113 static void translateImpl(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const *klass, RooArgList const &funcList,
114 RooArgList const &coefList);
115
116 static bool checkObservables(RooAbsReal const &caller, RooArgSet const *nset, RooArgList const &funcList,
117 RooArgList const &coefList);
118
119 static Int_t getAnalyticalIntegralWN(RooAbsReal const& caller, RooObjCacheManager & normIntMgr,
120 RooArgList const& funcList, RooArgList const& coefList,
121 RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName);
122 static double analyticalIntegralWN(RooAbsReal const& caller, RooObjCacheManager & normIntMgr,
123 RooArgList const& funcList, RooArgList const& coefList,
124 Int_t code, const RooArgSet* normSet, const char* rangeName,
125 bool hasWarnedBefore);
126
127 static std::list<double>* binBoundaries(
128 RooArgList const& funcList, RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/);
129 static std::list<double>* plotSamplingHint(
130 RooArgList const& funcList, RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/);
131 static bool isBinnedDistribution(RooArgList const& funcList, const RooArgSet& obs);
132
133 static void printMetaArgs(RooArgList const& funcList, RooArgList const& coefList, std::ostream& os);
134
135 static void setCacheAndTrackHints(RooArgList const& funcList, RooArgSet& trackNodes);
136
137 ClassDefOverride(RooRealSumPdf, 5) // PDF constructed from a sum of (non-pdf) functions
138};
139
140#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:79
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition RooAbsArg.h:251
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
Efficient implementation of a sum of PDFs of the form.
Definition RooAddPdf.h:33
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
Definition RooAddition.h:27
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
A class to maintain the context for squashing of RooFit models into code.
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
RooArgList containedArgs(Action) override
Implements a PDF constructed from a sum of functions:
void setCacheAndTrackHints(RooArgSet &) override
Label OK'ed components of a RooRealSumPdf with cache-and-track.
CacheMode canNodeBeCached() const override
bool forceAnalyticalInt(const RooAbsArg &arg) const override
static bool getFloorGlobal()
static bool _doFloorGlobal
Global flag for introducing floor at zero in pdf.
TObject * clone(const char *newname) const override
bool _doFloor
Introduce floor at zero in pdf.
std::unique_ptr< RooAbsReal > createExpectedEventsFunc(const RooArgSet *nset) const override
Returns an object that represents the expected number of events for a given normalization set,...
bool checkObservables(const RooArgSet *nset) const override
Check if FUNC is valid for given normalization set.
const RooArgList & funcList() const
~RooRealSumPdf() override
Destructor.
RooObjCacheManager _normIntMgr
! The integration cache manager
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
std::list< double > * plotSamplingHint(RooAbsRealLValue &, double, double) const override
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
double evaluate() const override
Calculate the current value.
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
RooListProxy _coefList
List of coefficients.
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
RooListProxy _funcList
List of component FUNCs.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
RooRealSumPdf()
Default constructor coverity[UNINIT_CTOR].
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooRealSumPdf to more intuitively reflect the contents of the p...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Advertise that all integrals can be handled internally.
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events for extended likelihood calculation, which is the sum of all coeffic...
void computeBatch(double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implement analytical integrations by deferring integration of component functions to integrators of c...
bool getFloor() const
static void setFloorGlobal(bool flag)
static void translateImpl(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const *klass, RooArgList const &funcList, RooArgList const &coefList)
void translate(RooFit::Detail::CodeSquashContext &ctx) const override
This function defines a translation for each RooAbsReal based object that can be used to express the ...
void setFloor(bool flag)
static void initializeFuncsAndCoefs(RooAbsReal const &caller, const RooArgList &inFuncList, const RooArgList &inCoefList, RooArgList &funcList, RooArgList &coefList)
const RooArgList & coefList() const
bool _extended
Allow use as extended p.d.f.
bool isBinnedDistribution(const RooArgSet &obs) const override
Check if all components that depend on obs are binned.
Mother of all ROOT objects.
Definition TObject.h:41
static void output()