85 _funcList(
"!funcList",
"List of functions",this),
86 _coefList(
"!coefList",
"List of coefficients",this),
145 coutE(InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName()
146 <<
") number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1" << endl ;
147 throw std::invalid_argument(
"RooRealSumPdf: Number of PDFs and coefficients is inconsistent.");
151 for (
unsigned int i = 0; i < inCoefList.
size(); ++i) {
152 const auto& func = inFuncList[i];
153 const auto& coef = inCoefList[i];
155 if (!
dynamic_cast<const RooAbsReal*
>(&coef)) {
156 coutW(InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") coefficient " << coef.
GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
159 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
160 coutW(InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") func " << func.GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
167 if (inFuncList.
size() == inCoefList.
size() + 1) {
168 const auto& func = inFuncList[inFuncList.
size()-1];
169 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
170 coutE(InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") last func " << func.
GetName() <<
" is not of type RooAbsReal, fatal error" << endl ;
171 throw std::invalid_argument(
"RooRealSumPdf: Function passed as is not of type RooAbsReal.");
186 _normIntMgr(other._normIntMgr,this),
187 _funcList(
"!funcList",this,other._funcList),
188 _coefList(
"!coefList",this,other._coefList),
189 _extended(other._extended),
190 _doFloor(other._doFloor)
226 double sumCoeff = 0.;
230 const double coefVal = coef !=
nullptr ? coef->
getVal() : (1. - sumCoeff);
233 if (coef ==
nullptr && (coefVal < 0 || coefVal > 1.)) {
236 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
237 << sumCoeff <<
". This means that the PDF is not properly normalised. If the PDF was meant to be extended, provide as many coefficients as functions." << endl ;
244 if (func->isSelectedComp()) {
245 value += func->getVal() * coefVal;
262 for (
unsigned int j = 0; j < nEvents; ++j) {
266 double sumCoeff = 0.;
270 const double coefVal = coef !=
nullptr ? dataMap.
at(coef)[0] : (1. - sumCoeff);
272 if (func->isSelectedComp()) {
273 auto funcValues = dataMap.
at(func);
274 if(funcValues.size() == 1) {
275 for (
unsigned int j = 0; j < nEvents; ++j) {
276 output[j] += funcValues[0] * coefVal;
279 for (
unsigned int j = 0; j < nEvents; ++j) {
280 output[j] += funcValues[j] * coefVal;
286 if (coef ==
nullptr && (coefVal < 0 || coefVal > 1.)) {
288 coutW(Eval) <<
"RooRealSumPdf::evaluateSpan(" <<
GetName()
289 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
290 << sumCoeff <<
". This means that the PDF is not properly normalised. If the PDF was meant to be extended, provide as many coefficients as functions." << endl ;
302 for (
unsigned int j = 0; j < nEvents; ++j) {
325 if (func.observableOverlaps(nset, coef)) {
326 coutE(InputArguments) <<
"RooRealSumPdf::checkObservables(" <<
GetName() <<
"): ERROR: coefficient " << coef.
GetName()
327 <<
" and FUNC " << func.GetName() <<
" have one or more observables in common" << endl ;
330 if (coef.dependsOn(*nset)) {
331 coutE(InputArguments) <<
"RooRealPdf::checkObservables(" <<
GetName() <<
"): ERROR coefficient " << coef.GetName()
332 <<
" depends on one or more of the following observables" ; nset->
Print(
"1") ;
347 const RooArgSet* normSet2,
const char* rangeName)
const
350 if (allVars.
getSize()==0)
return 0 ;
354 analVars.
add(allVars) ;
359 Int_t sterileIdx(-1) ;
371 const auto func =
static_cast<RooAbsReal*
>(elm);
376 if (normSet && normSet->
getSize()>0) {
403 if (code==0)
return getVal(normSet2) ;
428 const auto coef =
static_cast<const RooAbsReal*
>(coefArg);
429 const auto func =
static_cast<const RooAbsReal*
>(*funcIt++);
430 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt++);
432 Double_t coefVal = coef->getVal(normSet2) ;
435 if (normSet2 ==0 || func->isSelectedComp()) {
437 value += funcInt->getVal()*coefVal ;
439 lastCoef -= coef->getVal(normSet2) ;
445 const auto func =
static_cast<const RooAbsReal*
>(*funcIt);
446 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt);
449 if (normSet2 ==0 || func->isSelectedComp()) {
451 value += funcInt->getVal()*lastCoef ;
457 <<
" WARNING: sum of FUNC coefficients not in range [0-1], value="
458 << 1-lastCoef << endl ;
463 if (normSet2 && normSet2->
getSize()>0) {
469 auto coef =
static_cast<RooAbsReal*
>(coefAsArg);
470 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter++);
472 Double_t coefVal = coef->getVal(normSet2);
475 normVal += funcNorm->getVal()*coefVal ;
481 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter);
484 normVal += funcNorm->getVal()*lastCoef;
488 return value / normVal;
508 list<Double_t>* sumBinB = 0 ;
515 list<Double_t>* funcBinB = func->
binBoundaries(obs,xlo,xhi) ;
524 list<Double_t>* newSumBinB =
new list<Double_t>(sumBinB->size()+funcBinB->size()) ;
527 merge(funcBinB->begin(),funcBinB->end(),sumBinB->begin(),sumBinB->end(),newSumBinB->begin()) ;
532 sumBinB = newSumBinB ;
540 list<Double_t>::iterator new_end = unique(sumBinB->begin(),sumBinB->end()) ;
541 sumBinB->erase(new_end,sumBinB->end()) ;
555 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
571 list<Double_t>* sumHint = 0 ;
589 list<Double_t>* newSumHint =
new list<Double_t>(sumHint->size()+funcHint->size()) ;
592 merge(funcHint->begin(),funcHint->end(),sumHint->begin(),sumHint->end(),newSumHint->begin()) ;
596 sumHint = newSumHint ;
604 list<Double_t>::iterator new_end = unique(sumHint->begin(),sumHint->end()) ;
605 sumHint->erase(new_end,sumHint->end()) ;
620 if (sarg->canNodeBeCached()==
Always) {
621 trackNodes.
add(*sarg) ;
647 const auto func = *(funcIter++);
648 os << coef->GetName() <<
" * " << func->GetName();
652 os <<
" + [%] * " << (*funcIter)->GetName() ;
662 os << func->GetName() ;
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
const_iterator end() const
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
Storage_t::size_type size() const
const_iterator begin() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
const char * GetName() const
Returns name of object.
Double_t getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
RooArgSet selectFromSet1(RooArgSet const &argSet, int index) const
Create RooArgSet contatining the objects that are both in the cached set 1.
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
RooArgSet selectFromSet2(RooArgSet const &argSet, int index) const
Create RooArgSet contatining the objects that are both in the cached set 2.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
auto & at(RooAbsArg const *arg, RooAbsArg const *=nullptr)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
The class RooRealSumPdf implements a PDF constructed from a sum of functions:
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
RooObjCacheManager _normIntMgr
Double_t evaluate() const
Calculate the current value.
RooListProxy _funcList
The integration cache manager.
RooRealSumPdf()
Default constructor coverity[UNINIT_CTOR].
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events for extended likelihood calculation, which is the sum of all coeffic...
Bool_t isBinnedDistribution(const RooArgSet &obs) const
Check if all components that depend on obs are binned.
static Bool_t _doFloorGlobal
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
virtual ~RooRealSumPdf()
Destructor.
virtual Bool_t checkObservables(const RooArgSet *nset) const
Check if FUNC is valid for given normalization set.
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooRealSumPdf to more intuitively reflect the contents of the p...
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooRealSumPdf with cache-and-track.
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Retrieve bin boundaries if this distribution is binned in obs.
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertise that all integrals can be handled internally.
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implement analytical integrations by deferring integration of component functions to integrators of c...
bool haveLastCoef() const
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const
Base function for computing multiple values of a RooAbsReal.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
static double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.
static void output(int code)