Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealSumFunc.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
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
17//////////////////////////////////////////////////////////////////////////////
18///
19/// Class RooRealSumFunc implements a PDF constructed from a sum of
20/// functions:
21/// ```
22/// Sum(i=1,n-1) coef_i * func_i(x) + [ 1 - (Sum(i=1,n-1) coef_i ] * func_n(x)
23/// pdf(x) = ------------------------------------------------------------------------------
24/// Sum(i=1,n-1) coef_i * Int(func_i)dx + [ 1 - (Sum(i=1,n-1) coef_i ] * Int(func_n)dx
25///
26/// ```
27/// where coef_i and func_i are RooAbsReal objects, and x is the collection of dependents.
28/// In the present version coef_i may not depend on x, but this limitation may be removed in the future
29///
30/// ### Difference between RooAddPdf / RooRealSum{Func|Pdf}
31/// - RooAddPdf is a PDF of PDFs, *i.e.* its components need to be normalised and non-negative.
32/// - RooRealSumPdf is a PDF of functions, *i.e.*, its components can be negative, but their sum cannot be. The normalisation
33/// is computed automatically, unless the PDF is extended (see above).
34/// - RooRealSumFunc is a sum of functions. It is neither normalised, nor need it be positive.
35
36#include "RooRealSumFunc.h"
37#include "RooRealSumPdf.h"
38#include "RooTrace.h"
39
40
42
43//_____________________________________________________________________________
45{
46 // Default constructor
47 // coverity[UNINIT_CTOR]
49}
50
51//_____________________________________________________________________________
52RooRealSumFunc::RooRealSumFunc(const char *name, const char *title)
53 : RooAbsReal(name, title), _normIntMgr(this, 10), _haveLastCoef(false),
54 _funcList("!funcList", "List of functions", this), _coefList("!coefList", "List of coefficients", this)
55{
56 // Constructor with name and title
58}
59
60//_____________________________________________________________________________
63 : RooRealSumFunc{name, title}
64{
65 // Construct p.d.f consisting of coef1*func1 + (1-coef1)*func2
66 // The input coefficients and functions are allowed to be negative
67 // but the resulting sum is not, which is enforced at runtime
68
69 // Special constructor with two functions and one coefficient
70
75}
76
77//_____________________________________________________________________________
78RooRealSumFunc::RooRealSumFunc(const char *name, const char *title, const RooArgList &inFuncList,
80 : RooRealSumFunc{name, title}
81{
82 // Constructor p.d.f implementing sum_i [ coef_i * func_i ], if N_coef==N_func
83 // or sum_i [ coef_i * func_i ] + (1 - sum_i [ coef_i ] )* func_N if Ncoef==N_func-1
84 //
85 // All coefficients and functions are allowed to be negative
86 // but the sum is not, which is enforced at runtime.
87
89
91}
92
93//_____________________________________________________________________________
95 : RooAbsReal(other, name), _normIntMgr(other._normIntMgr, this), _haveLastCoef(other._haveLastCoef),
96 _funcList("!funcList", this, other._funcList), _coefList("!coefList", this, other._coefList),
97 _doFloor(other._doFloor)
98{
99 // Copy constructor
100
102}
103
104//_____________________________________________________________________________
109
110//_____________________________________________________________________________
115
116//_____________________________________________________________________________
118{
120}
121
122//_____________________________________________________________________________
128
129//_____________________________________________________________________________
134
135//_____________________________________________________________________________
136std::list<double> *RooRealSumFunc::binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
137{
138 return RooRealSumPdf::binBoundaries(_funcList, obs, xlo, xhi);
139}
140
141//_____________________________________________________________________________B
146
147//_____________________________________________________________________________
148std::list<double> *RooRealSumFunc::plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
149{
150 return RooRealSumPdf::plotSamplingHint(_funcList, obs, xlo, xhi);
151}
152
153//_____________________________________________________________________________
158
159/// Customized printing of arguments of a RooRealSumFunc to more intuitively
160/// reflect the contents of the product operator construction.
161
162void RooRealSumFunc::printMetaArgs(std::ostream &os) const
163{
165}
166
167std::unique_ptr<RooAbsArg> RooRealSumFunc::compileForNormSet(RooArgSet const &/*normSet*/, RooFit::Detail::CompileContext & ctx) const
168{
169 auto newArg = std::unique_ptr<RooAbsArg>{static_cast<RooAbsArg *>(Clone())};
171 ctx.compileServers(*newArg, {});
172 return newArg;
173}
#define TRACE_DESTROY
Definition RooTrace.h:24
#define TRACE_CREATE
Definition RooTrace.h:23
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:77
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooAbsArg.h:89
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
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:24
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
void markAsCompiled(RooAbsArg &arg) const
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooRealSumFunc to more intuitively reflect the contents of the ...
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
bool _doFloor
Introduce floor at zero in pdf.
~RooRealSumFunc() override
RooListProxy _funcList
List of component FUNCs.
RooObjCacheManager _normIntMgr
static bool _doFloorGlobal
Global flag for introducing floor at zero in pdf.
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
RooListProxy _coefList
List of coefficients.
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
bool checkObservables(const RooArgSet *nset) const override
Overloadable function in which derived classes can implement consistency checks of the variables.
void setCacheAndTrackHints(RooArgSet &) 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...
void setCacheAndTrackHints(RooArgSet &) override
Label OK'ed components of a RooRealSumPdf with cache-and-track.
bool checkObservables(const RooArgSet *nset) const override
Check if FUNC is valid for given normalization set.
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.
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Retrieve bin boundaries if this distribution is binned in obs.
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 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...
static void initializeFuncsAndCoefs(RooAbsReal const &caller, const RooArgList &inFuncList, const RooArgList &inCoefList, RooArgList &funcList, RooArgList &coefList)
bool isBinnedDistribution(const RooArgSet &obs) const override
Check if all components that depend on obs are binned.