77 _funcList(
"!funcList",
"List of functions",
this),
78 _coefList(
"!coefList",
"List of coefficients",
this),
140 const std::string className =
caller.ClassName();
145 <<
") number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1" << std::endl;
146 throw std::invalid_argument(className +
": Number of PDFs and coefficients is inconsistent.");
150 for (
unsigned int i = 0; i <
inCoefList.size(); ++i) {
154 if (!
dynamic_cast<const RooAbsReal*
>(&coef)) {
155 oocoutW(&
caller, InputArguments) <<
constructorName <<
"(" <<
caller.GetName() <<
") coefficient " << coef.GetName() <<
" is not of type RooAbsReal, ignored" << std::endl ;
158 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
168 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
169 oocoutE(&
caller, InputArguments) <<
constructorName <<
"(" <<
caller.GetName() <<
") last func " << func.GetName() <<
" is not of type RooAbsReal, fatal error" << std::endl ;
170 throw std::invalid_argument(className +
": Function passed as is not of type RooAbsReal.");
186 _funcList(
"!funcList",
this,
other._funcList),
187 _coefList(
"!coefList",
this,
other._coefList),
188 _extended(
other._extended),
189 _doFloor(
other._doFloor)
226 for (
unsigned int i = 0; i <
funcList.size(); ++i) {
229 const double coefVal = coef !=
nullptr ? coef->getVal() : (1. -
sumCoeff);
235 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
236 <<
sumCoeff <<
". This means that the PDF is not properly normalised."
237 <<
" If the PDF was meant to be extended, provide as many coefficients as functions." << std::endl;
244 if (func->isSelectedComp()) {
267 std::size_t nEvents =
output.size();
278 if (func->isSelectedComp()) {
281 for (
unsigned int j = 0;
j < nEvents; ++
j) {
285 for (
unsigned int j = 0;
j < nEvents; ++
j) {
295 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
296 <<
sumCoeff <<
". This means that the PDF is not properly normalised. If the PDF was meant to be extended, provide as many coefficients as functions." << std::endl;
308 for (
unsigned int j = 0;
j < nEvents; ++
j) {
319 for (
unsigned int i=0; i <
coefList.size(); ++i) {
323 if (func.observableOverlaps(nset, coef)) {
325 <<
"): ERROR: coefficient " << coef.GetName()
326 <<
" and FUNC " << func.GetName() <<
" have one or more observables in common" << std::endl;
329 if (coef.dependsOn(*nset)) {
331 <<
"): ERROR coefficient " << coef.GetName()
332 <<
" depends on one or more of the following observables" ; nset->
Print(
"1") ;
371 if (allVars.
empty())
return 0 ;
372 if (
caller.getForceNumInt())
return 0 ;
376 std::unique_ptr<RooArgSet>
normSet;
378 normSet = std::make_unique<RooArgSet>();
400 cache->_funcIntList.addOwned(std::move(
funcInt));
402 cache->_funcNormList.addOwned(std::unique_ptr<RooAbsReal>{func->createIntegral(*
normSet)});
421 if (cache ==
nullptr) {
426 caller.getParameters(
nullptr, vars);
474 if (
normSet2 ==
nullptr || func->isSelectedComp()) {
486 const auto func =
static_cast<const RooAbsReal*
>(*funcIt);
490 if (
normSet2 ==
nullptr || func->isSelectedComp()) {
498 <<
" WARNING: sum of FUNC coefficients not in range [0-1], value="
556 std::unique_ptr<std::list<double>>
sumBinB;
562 std::unique_ptr<std::list<double>>
funcBinB{func->binBoundaries(obs, xlo, xhi)};
603 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
623 std::unique_ptr<std::list<double>>
sumHint;
630 std::unique_ptr<std::list<double>>
funcHint{func->plotSamplingHint(obs, xlo, xhi)};
709 os << coef->GetName() <<
" * " << func->GetName();
713 os <<
" + [%] * " << (*funcIter)->GetName() ;
723 os << func->GetName() ;
730std::unique_ptr<RooAbsArg>
747 pdfClone->setAttribute(
"BinnedLikelihoodActive");
758 pdfClone->setAttribute(
"BinnedLikelihoodActiveYields");
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
Abstract base class for objects to be stored in RooAbsCache cache manager objects.
Storage_t::size_type size() const
const_iterator begin() const
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract interface for all probability density functions.
double getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
const char * normRange() const
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...
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create an object that represents the integral of the function over one or more observables listed in ...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
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 setBinnedLikelihoodMode(bool flag)
void markAsCompiled(RooAbsArg &arg) const
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
bool likelihoodMode() const
bool binWidthFuncFlag() const
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
Implementation of a RooCacheManager<RooAbsCacheElement> that specializes in the storage of cache elem...
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
void setCacheAndTrackHints(RooArgSet &) override
Label OK'ed components of a RooRealSumPdf with cache-and-track.
static bool _doFloorGlobal
Global flag for introducing floor at zero in pdf.
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.
void setExtended(bool extended)
const RooArgList & funcList() const
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.
const RooArgList & funcIntListFromCache(Int_t code, const char *rangeName=nullptr) const
Collect the list of functions to be integrated from the cache.
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 doEval(RooFit::EvalContext &) 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...
static const CacheElem * getCacheElem(RooAbsReal const &caller, RooObjCacheManager &normIntMgr, Int_t code, const char *rangeName)
Collect cache elements for given code to use in codegen.
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.
const char * GetName() const override
Returns name of object.
static double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.