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
39
41
42//_____________________________________________________________________________
44{
45 // Default constructor
46 // coverity[UNINIT_CTOR]
47}
48
49//_____________________________________________________________________________
50RooRealSumFunc::RooRealSumFunc(const char *name, const char *title)
51 : RooAbsReal(name, title), _normIntMgr(this, 10), _haveLastCoef(false),
52 _funcList("!funcList", "List of functions", this), _coefList("!coefList", "List of coefficients", this)
53{
54 // Constructor with name and title
55}
56
57//_____________________________________________________________________________
60 : RooRealSumFunc{name, title}
61{
62 // Construct p.d.f consisting of coef1*func1 + (1-coef1)*func2
63 // The input coefficients and functions are allowed to be negative
64 // but the resulting sum is not, which is enforced at runtime
65
66 // Special constructor with two functions and one coefficient
67
71}
72
73//_____________________________________________________________________________
74RooRealSumFunc::RooRealSumFunc(const char *name, const char *title, const RooArgList &inFuncList,
76 : RooRealSumFunc{name, title}
77{
78 // Constructor p.d.f implementing sum_i [ coef_i * func_i ], if N_coef==N_func
79 // or sum_i [ coef_i * func_i ] + (1 - sum_i [ coef_i ] )* func_N if Ncoef==N_func-1
80 //
81 // All coefficients and functions are allowed to be negative
82 // but the sum is not, which is enforced at runtime.
83
85
86}
87
88//_____________________________________________________________________________
90 : RooAbsReal(other, name), _normIntMgr(other._normIntMgr, this), _haveLastCoef(other._haveLastCoef),
91 _funcList("!funcList", this, other._funcList), _coefList("!coefList", this, other._coefList),
92 _doFloor(other._doFloor)
93{
94 // Copy constructor
95
96}
97
98//_____________________________________________________________________________
102
103//_____________________________________________________________________________
108
109//_____________________________________________________________________________
111{
113}
114
115//_____________________________________________________________________________
121
122//_____________________________________________________________________________
127
128//_____________________________________________________________________________
129std::list<double> *RooRealSumFunc::binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
130{
131 return RooRealSumPdf::binBoundaries(_funcList, obs, xlo, xhi);
132}
133
134//_____________________________________________________________________________B
139
140//_____________________________________________________________________________
141std::list<double> *RooRealSumFunc::plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
142{
143 return RooRealSumPdf::plotSamplingHint(_funcList, obs, xlo, xhi);
144}
145
146//_____________________________________________________________________________
151
152/// Customized printing of arguments of a RooRealSumFunc to more intuitively
153/// reflect the contents of the product operator construction.
154
155void RooRealSumFunc::printMetaArgs(std::ostream &os) const
156{
158}
159
160std::unique_ptr<RooAbsArg> RooRealSumFunc::compileForNormSet(RooArgSet const &/*normSet*/, RooFit::Detail::CompileContext & ctx) const
161{
162 auto newArg = std::unique_ptr<RooAbsArg>{static_cast<RooAbsArg *>(Clone())};
164 ctx.compileServers(*newArg, {});
165 return newArg;
166}
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:148
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Definition RooAbsArg.h:88
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:63
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
! The integration cache manager
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.