78 _funcList(
"!funcList",
"List of functions",
this),
79 _coefList(
"!coefList",
"List of coefficients",
this),
141 const std::string className =
caller.ClassName();
146 <<
") number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1" << std::endl;
147 throw std::invalid_argument(className +
": Number of PDFs and coefficients is inconsistent.");
151 for (
unsigned int i = 0; i <
inCoefList.size(); ++i) {
155 if (!
dynamic_cast<const RooAbsReal*
>(&coef)) {
156 oocoutW(&
caller, InputArguments) <<
constructorName <<
"(" <<
caller.GetName() <<
") coefficient " << coef.GetName() <<
" is not of type RooAbsReal, ignored" << std::endl ;
159 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
169 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
170 oocoutE(&
caller, InputArguments) <<
constructorName <<
"(" <<
caller.GetName() <<
") last func " << func.GetName() <<
" is not of type RooAbsReal, fatal error" << std::endl ;
171 throw std::invalid_argument(className +
": Function passed as is not of type RooAbsReal.");
187 _funcList(
"!funcList",
this,
other._funcList),
188 _coefList(
"!coefList",
this,
other._coefList),
189 _extended(
other._extended),
190 _doFloor(
other._doFloor)
215 const double coefVal = coef !=
nullptr ? coef->getVal() : (1. -
sumCoeff);
221 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
222 <<
sumCoeff <<
". This means that the PDF is not properly normalised."
223 <<
" If the PDF was meant to be extended, provide as many coefficients as functions." << std::endl;
230 if (func->isSelectedComp()) {
253 std::size_t nEvents =
output.size();
264 if (func->isSelectedComp()) {
267 for (
unsigned int j = 0;
j < nEvents; ++
j) {
271 for (
unsigned int j = 0;
j < nEvents; ++
j) {
281 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
282 <<
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;
294 for (
unsigned int j = 0;
j < nEvents; ++
j) {
316 std::string code =
"for(int " + iterator +
" = 0; " + iterator +
" < " +
coeffSize +
"; " + iterator +
"++) {\n" +
323 }
else if (normalize) {
345 if (func.observableOverlaps(nset, coef)) {
347 <<
"): ERROR: coefficient " << coef.GetName()
348 <<
" and FUNC " << func.GetName() <<
" have one or more observables in common" << std::endl;
351 if (coef.dependsOn(*nset)) {
353 <<
"): ERROR coefficient " << coef.GetName()
354 <<
" depends on one or more of the following observables" ; nset->
Print(
"1") ;
393 if (allVars.
empty())
return 0 ;
394 if (
caller.getForceNumInt())
return 0 ;
398 std::unique_ptr<RooArgSet>
normSet;
400 normSet = std::make_unique<RooArgSet>();
420 std::unique_ptr<RooAbsReal>
funcInt{func->createIntegral(
analVars,rangeName)};
422 cache->_funcIntList.addOwned(std::move(
funcInt));
424 cache->_funcNormList.addOwned(std::unique_ptr<RooAbsReal>{func->createIntegral(*
normSet)});
458 if (cache==
nullptr) {
461 caller.getParameters(
nullptr, vars);
486 if (
normSet2 ==
nullptr || func->isSelectedComp()) {
498 const auto func =
static_cast<const RooAbsReal*
>(*funcIt);
502 if (
normSet2 ==
nullptr || func->isSelectedComp()) {
510 <<
" WARNING: sum of FUNC coefficients not in range [0-1], value="
568 std::unique_ptr<std::list<double>>
sumBinB;
574 std::unique_ptr<std::list<double>>
funcBinB{func->binBoundaries(obs, xlo, xhi)};
615 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
635 std::unique_ptr<std::list<double>>
sumHint;
642 std::unique_ptr<std::list<double>>
funcHint{func->plotSamplingHint(obs, xlo, xhi)};
721 os << coef->GetName() <<
" * " << func->GetName();
725 os <<
" + [%] * " << (*funcIter)->GetName() ;
735 os << func->GetName() ;
742std::unique_ptr<RooAbsArg>
759 pdfClone->setAttribute(
"BinnedLikelihoodActive");
770 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.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
const_iterator end() const
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...
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 ...
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.
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...
A class to maintain the context for squashing of RooFit models into code.
void addResult(RooAbsArg const *key, std::string const &value)
A function to save an expression that includes/depends on the result of the input node.
void addToCodeBody(RooAbsArg const *klass, std::string const &in)
Adds the input string to the squashed code body.
std::string getTmpVarName() const
Get a unique variable name to be used in the generated code.
std::string buildArg(RooAbsCollection const &x)
Function to save a RooListProxy as an array in the squashed code.
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.
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 std::string translateImpl(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const *klass, RooArgList const &funcList, RooArgList const &coefList, bool normalize=false)
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 ...
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.
static uint64_t sum(uint64_t i)