|
ROOT
Reference Guide |
|
Go to the documentation of this file.
85 _funcList(
"!funcList",
"List of functions",this),
86 _coefList(
"!coefList",
"List of coefficients",this),
103 _normIntMgr(this,10),
104 _funcList(
"!funcList",
"List of functions",this),
105 _coefList(
"!coefList",
"List of coefficients",this),
146 _normIntMgr(this,10),
147 _funcList(
"!funcList",
"List of functions",this),
148 _coefList(
"!coefList",
"List of coefficients",this),
154 <<
") number of pdfs and coefficients inconsistent, must have Nfunc=Ncoef or Nfunc=Ncoef+1" << endl ;
155 throw std::invalid_argument(
"RooRealSumPdf: Number of PDFs and coefficients is inconsistent.");
159 for (
unsigned int i = 0; i < inCoefList.
size(); ++i) {
160 const auto& func = inFuncList[i];
161 const auto& coef = inCoefList[i];
163 if (!
dynamic_cast<const RooAbsReal*
>(&coef)) {
164 coutW(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") coefficient " << coef.GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
167 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
168 coutW(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") func " << func.GetName() <<
" is not of type RooAbsReal, ignored" << endl ;
175 if (inFuncList.
size() == inCoefList.
size() + 1) {
176 const auto& func = inFuncList[inFuncList.
size()-1];
177 if (!
dynamic_cast<const RooAbsReal*
>(&func)) {
178 coutE(
InputArguments) <<
"RooRealSumPdf::RooRealSumPdf(" <<
GetName() <<
") last func " << func.GetName() <<
" is not of type RooAbsReal, fatal error" << endl ;
179 throw std::invalid_argument(
"RooRealSumPdf: Function passed as is not of type RooAbsReal.");
194 _normIntMgr(other._normIntMgr,this),
195 _funcList(
"!funcList",this,other._funcList),
196 _coefList(
"!coefList",this,other._coefList),
197 _extended(other._extended),
198 _doFloor(other._doFloor)
234 double sumCoeff = 0.;
238 const double coefVal = coef !=
nullptr ? coef->
getVal() : (1. - sumCoeff);
241 if (coef ==
nullptr && (coefVal < 0 || coefVal > 1.)) {
244 <<
") WARNING: sum of FUNC coefficients not in range [0-1], value="
245 << 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 ;
252 if (func->isSelectedComp()) {
253 value += func->getVal() * coefVal;
286 if (func.observableOverlaps(nset, coef)) {
288 <<
" and FUNC " << func.GetName() <<
" have one or more observables in common" << endl ;
291 if (coef.dependsOn(*nset)) {
293 <<
" depends on one or more of the following observables" ; nset->
Print(
"1") ;
308 const RooArgSet* normSet2,
const char* rangeName)
const
311 if (allVars.
getSize()==0)
return 0 ;
315 analVars.
add(allVars) ;
320 Int_t sterileIdx(-1) ;
332 const auto func =
static_cast<RooAbsReal*
>(elm);
337 if (normSet && normSet->
getSize()>0) {
364 if (code==0)
return getVal(normSet2) ;
389 const auto coef =
static_cast<const RooAbsReal*
>(coefArg);
390 const auto func =
static_cast<const RooAbsReal*
>(*funcIt++);
391 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt++);
393 Double_t coefVal = coef->getVal(normSet2) ;
396 if (normSet2 ==0 || func->isSelectedComp()) {
398 value += funcInt->getVal()*coefVal ;
400 lastCoef -= coef->getVal(normSet2) ;
406 const auto func =
static_cast<const RooAbsReal*
>(*funcIt);
407 const auto funcInt =
static_cast<RooAbsReal*
>(*funcIntIt);
410 if (normSet2 ==0 || func->isSelectedComp()) {
412 value += funcInt->getVal()*lastCoef ;
418 <<
" WARNING: sum of FUNC coefficients not in range [0-1], value="
419 << 1-lastCoef << endl ;
425 if (normSet2 && normSet2->
getSize()>0) {
431 auto coef =
static_cast<RooAbsReal*
>(coefAsArg);
432 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter++);
434 Double_t coefVal = coef->getVal(normSet2);
437 normVal += funcNorm->getVal()*coefVal ;
443 auto funcNorm =
static_cast<RooAbsReal*
>(*funcNormIter);
446 normVal += funcNorm->getVal()*lastCoef;
450 return value / normVal;
470 list<Double_t>* sumBinB = 0 ;
477 list<Double_t>* funcBinB = func->
binBoundaries(obs,xlo,xhi) ;
486 list<Double_t>* newSumBinB =
new list<Double_t>(sumBinB->size()+funcBinB->size()) ;
489 merge(funcBinB->begin(),funcBinB->end(),sumBinB->begin(),sumBinB->end(),newSumBinB->begin()) ;
494 sumBinB = newSumBinB ;
502 list<Double_t>::iterator new_end = unique(sumBinB->begin(),sumBinB->end()) ;
503 sumBinB->erase(new_end,sumBinB->end()) ;
519 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
535 list<Double_t>* sumHint = 0 ;
553 list<Double_t>* newSumHint =
new list<Double_t>(sumHint->size()+funcHint->size()) ;
556 merge(funcHint->begin(),funcHint->end(),sumHint->begin(),sumHint->end(),newSumHint->begin()) ;
560 sumHint = newSumHint ;
568 list<Double_t>::iterator new_end = unique(sumHint->begin(),sumHint->end()) ;
569 sumHint->erase(new_end,sumHint->end()) ;
584 if (sarg->canNodeBeCached()==
Always) {
585 trackNodes.
add(*sarg) ;
611 const auto func = *(funcIter++);
612 os << coef->GetName() <<
" * " << func->GetName();
616 os <<
" + [%] * " << (*funcIter)->GetName() ;
626 os << func->GetName() ;
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
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...
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
static double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.
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.
RooRealSumPdf()
Default constructor coverity[UNINIT_CTOR].
RooArgList is a container object that can hold multiple RooAbsArg objects.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertise that all integrals can be handled internally.
const RooNameSet * nameSet2ByIndex(Int_t index) const
Retrieve RooNameSet associated with slot at given index.
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooRealSumPdf with cache-and-track.
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Bool_t isBinnedDistribution(const RooArgSet &obs) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooArgSet * select(const RooArgSet &list) const
Construct a RooArgSet of objects in input 'list' whose names match to those in the internal name list...
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
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...
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooObjCacheManager _normIntMgr
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...
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Double_t getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
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 add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
Storage_t::size_type size() const
const RooNameSet * nameSet1ByIndex(Int_t index) const
Retrieve RooNameSet associated with slot at given index.
bool haveLastCoef() const
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooRealSumPdf to more intuitively reflect the contents of the p...
static Bool_t _doFloorGlobal
const_iterator end() const
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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...
const_iterator begin() const
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Return the observables of this pdf given a set of observables.
virtual Bool_t checkObservables(const RooArgSet *nset) const
Check if FUNC is valid for given normalization set.
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Retrieve bin boundaries if this distribution is binned in obs.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
virtual const char * GetName() const
Returns name of object.
virtual ~RooRealSumPdf()
Destructor.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
The class RooRealSumPdf implements a PDF constructed from a sum of functions:
Double_t evaluate() const
Calculate the current value.
RooArgSet is a container object that can hold multiple RooAbsArg objects.