91 _funcList(
"!funcList",
"List of functions",this),
92 _coefList(
"!coefList",
"List of coefficients",this),
109 _normIntMgr(this,10),
110 _funcList(
"!funcList",
"List of functions",this),
111 _coefList(
"!coefList",
"List of coefficients",this),
152 _normIntMgr(this,10),
153 _funcList(
"!funcList",
"List of functions",this),
154 _coefList(
"!coefList",
"List of coefficients",this),
160 <<
") number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1" << endl ;
165 for (
unsigned int i = 0; i < inCoefList.
size(); ++i) {
166 const auto& func = inFuncList[i];
167 const auto& coef = inCoefList[i];
169 if (!
dynamic_cast<const RooAbsReal*
>(&coef)) {
170 coutW(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") coefficient " << coef.GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
173 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
174 coutW(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") func " << func.GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
181 if (inFuncList.
size() == inCoefList.
size() + 1) {
182 const auto& func = inFuncList[inFuncList.
size()-1];
183 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
184 coutE(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") last func " << func.GetName() <<
" is not of type RooAbsReal, fatal error" << endl ;
200 _normIntMgr(other._normIntMgr,this),
201 _funcList(
"!funcList",this,other._funcList),
202 _coefList(
"!coefList",this,other._coefList),
203 _extended(other._extended),
204 _doFloor(other._doFloor)
247 auto func =
static_cast<const RooAbsReal*
>(*funcIt++);
248 auto coef =
static_cast<const RooAbsReal*
>(coefArg);
252 cxcoutD(
Eval) <<
"RooRealSumPdf::eval(" <<
GetName() <<
") coefVal = " << coefVal <<
" funcVal = " << func->IsA()->GetName() <<
"::" << func->GetName() <<
" = " << func->getVal() << endl ;
253 if (func->isSelectedComp()) {
254 value += func->getVal()*coefVal ;
256 lastCoef -= coef->getVal() ;
263 auto func =
static_cast<const RooAbsReal*
>(*funcIt);
264 if (func->isSelectedComp()) {
265 value += func->
getVal()*lastCoef ;
268 cxcoutD(
Eval) <<
"RooRealSumPdf::eval(" <<
GetName() <<
") lastCoef = " << lastCoef <<
" funcVal = " << func->getVal() << endl ;
271 if (lastCoef<0 || lastCoef>1) {
273 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
274 << 1-lastCoef <<
". This means that the PDF is not properly normalised. If the PDF was meant to be extended, provide as many coefficients as functions." << endl ;
305 if (func.observableOverlaps(nset, coef)) {
307 <<
" and FUNC " << func.GetName() <<
" have one or more observables in common" << endl ;
310 if (coef.dependsOn(*nset)) {
312 <<
" depends on one or more of the following observables" ; nset->
Print(
"1") ;
327 const RooArgSet* normSet2,
const char* rangeName)
const
330 if (allVars.
getSize()==0)
return 0 ;
334 analVars.
add(allVars) ;
339 Int_t sterileIdx(-1) ;
351 const auto func =
static_cast<RooAbsReal*
>(elm);
356 if (normSet && normSet->
getSize()>0) {
383 if (code==0)
return getVal(normSet2) ;
408 const auto coef =
static_cast<const RooAbsReal*
>(coefArg);
409 const auto func =
static_cast<const RooAbsReal*
>(*funcIt++);
410 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt++);
415 if (normSet2 ==0 || func->isSelectedComp()) {
417 value += funcInt->getVal()*coefVal ;
419 lastCoef -= coef->getVal(normSet2) ;
425 const auto func =
static_cast<const RooAbsReal*
>(*funcIt);
426 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt);
429 if (normSet2 ==0 || func->isSelectedComp()) {
431 value += funcInt->getVal()*lastCoef ;
435 if (lastCoef<0 || lastCoef>1) {
437 <<
" WARNING: sum of FUNC coefficients not in range [0-1], value="
438 << 1-lastCoef << endl ;
443 if (normSet2 && normSet2->
getSize()>0) {
449 auto coef =
static_cast<RooAbsReal*
>(coefAsArg);
450 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter++);
455 normVal += funcNorm->getVal()*coefVal ;
461 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter);
464 normVal += funcNorm->getVal()*lastCoef;
468 return value / normVal;
488 list<Double_t>* sumBinB = 0 ;
495 list<Double_t>* funcBinB = func->
binBoundaries(obs,xlo,xhi) ;
504 list<Double_t>* newSumBinB =
new list<Double_t>(sumBinB->size()+funcBinB->size()) ;
507 merge(funcBinB->begin(),funcBinB->end(),sumBinB->begin(),sumBinB->end(),newSumBinB->begin()) ;
512 sumBinB = newSumBinB ;
520 list<Double_t>::iterator new_end = unique(sumBinB->begin(),sumBinB->end()) ;
521 sumBinB->erase(new_end,sumBinB->end()) ;
537 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
553 list<Double_t>* sumHint = 0 ;
571 list<Double_t>* newSumHint =
new list<Double_t>(sumHint->size()+funcHint->size()) ;
574 merge(funcHint->begin(),funcHint->end(),sumHint->begin(),sumHint->end(),newSumHint->begin()) ;
578 sumHint = newSumHint ;
586 list<Double_t>::iterator new_end = unique(sumHint->begin(),sumHint->end()) ;
587 sumHint->erase(new_end,sumHint->end()) ;
602 if (sarg->canNodeBeCached()==
Always) {
603 trackNodes.
add(*sarg) ;
629 const auto func = *(funcIter++);
630 os << coef->GetName() <<
" * " << func->GetName();
634 os <<
" + [%] * " << (*funcIter)->GetName() ;
644 os << func->GetName() ;
static RooMathCoreReg dummy
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Return the observables of this pdf given a set of observables.
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) 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 addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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.
TIterator end() and range-based for loops.")
Double_t getNorm(const RooArgSet &nset) const
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...
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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 ...
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.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
const RooNameSet * nameSet2ByIndex(Int_t index) const
Retrieve RooNameSet associated with slot at given index.
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
const RooNameSet * nameSet1ByIndex(Int_t index) const
Retrieve RooNameSet associated with slot at given index.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
RooArgSet * select(const RooArgSet &list) const
Construct a RooArgSet of objects in input 'list' whose names match to those in the internal name list...
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
RooObjCacheManager _normIntMgr
Double_t evaluate() const
Calculate the current value.
RooRealSumPdf()
Default constructor coverity[UNINIT_CTOR].
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
Bool_t isBinnedDistribution(const RooArgSet &obs) const
static Bool_t _doFloorGlobal
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
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
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
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".