46 typedef RooProduct::ProdMap::iterator RPPMIter ;
47 std::pair<RPPMIter,RPPMIter> findOverlap2nd(RPPMIter i, RPPMIter end) ;
48 void dump_map(ostream& os, RPPMIter i, RPPMIter end) ;
78 _compRSet(
"!compRSet",
"Set of real product components",this),
79 _compCSet(
"!compCSet",
"Set of category product components",this),
82 for (
auto comp : prodSet) {
95 _compRSet(
"!compRSet",this,other._compRSet),
96 _compCSet(
"!compCSet",this,other._compCSet),
97 _cacheMgr(other._cacheMgr,this)
111 coutE(InputArguments) <<
"RooProduct::addTerm(" <<
GetName() <<
") ERROR: component " << term->
GetName()
112 <<
" is not of type RooAbsReal or RooAbsCategory" << endl ;
113 throw std::invalid_argument(
"RooProduct can only handle terms deriving from RooAbsReal or RooAbsCategory.");
154 map->push_back( std::make_pair(
new RooArgSet(),indep) );
171 map->push_back( std::make_pair(vars,comps) );
177 std::pair<ProdMap::iterator,ProdMap::iterator> i = findOverlap2nd(map->begin(),map->end());
178 overlap = (i.first!=i.second);
180 i.first->first->add(*i.second->first);
183 RooFIter it = i.second->second->fwdIterator() ;
185 while ((targ = it.
next())) {
186 if (!i.first->second->find(*targ)) {
187 i.first->second->add(*targ) ;
192 delete i.second->first;
193 delete i.second->second;
194 map->erase(i.second);
201 int nVar=0;
int nFunc=0;
202 for (ProdMap::iterator i = map->begin();i!=map->end();++i) {
203 nVar+=i->first->getSize();
204 nFunc+=i->second->getSize();
206 assert(nVar==allVars.
getSize());
223 Int_t sterileIndex(-1);
232 cxcoutD(Integration) <<
"RooProduct::getPartIntList(" <<
GetName() <<
") groupProductTerms returned map" ;
233 if (
dologD(Integration)) {
234 dump_map(
ccoutD(Integration),map->begin(),map->end());
235 ccoutD(Integration) << endl;
241 for (ProdMap::iterator iter = map->begin() ; iter != map->end() ; ++iter) {
243 delete iter->second ;
251 for (ProdMap::const_iterator i = map->begin();i!=map->end();++i) {
253 if (i->second->getSize()>1) {
257 cxcoutD(Integration) <<
"RooProduct::getPartIntList(" <<
GetName() <<
") created subexpression " << term->
GetName() << endl;
259 assert(i->second->getSize()==1);
260 RooFIter j = i->second->fwdIterator();
264 if (i->first->getSize()==0) {
266 cxcoutD(Integration) <<
"RooProduct::getPartIntList(" <<
GetName() <<
") adding simple factor " << term->
GetName() << endl;
271 cxcoutD(Integration) <<
"RooProduct::getPartIntList(" <<
GetName() <<
") adding integral for " << term->
GetName() <<
" : " << integral->
GetName() << endl;
277 cxcoutD(Integration) <<
"RooProduct::getPartIntList(" <<
GetName() <<
") created list " << cache->
_prodList <<
" with code " << code+1 << endl
278 <<
" for iset=" << *iset <<
" @" << iset <<
" range: " << (isetRange?isetRange:
"<none>") << endl ;
280 for (ProdMap::iterator iter = map->begin() ; iter != map->end() ; ++iter) {
282 delete iter->second ;
294 const char* rangeName)
const
302 analVars.
add(allVars) ;
335 for (
const auto arg : partIntList) {
336 const auto term =
static_cast<const RooAbsReal*
>(arg);
373 auto rcomp =
static_cast<const RooAbsReal*
>(item);
375 prod *= rcomp->getVal(nset) ;
381 prod *= ccomp->getCurrentIndex() ;
390 for (
unsigned int i = 0; i < nEvents; ++i) {
395 auto rcomp =
static_cast<const RooAbsReal*
>(item);
396 auto componentValues = dataMap.
at(rcomp);
398 for (
unsigned int i = 0; i < nEvents; ++i) {
399 output[i] *= componentValues.size() == 1 ? componentValues[0] : componentValues[i];
407 for (
unsigned int i = 0; i < nEvents; ++i) {
420 auto func =
static_cast<const RooAbsReal*
>(item);
438 auto func =
static_cast<const RooAbsReal*
>(item);
440 if (func->dependsOn(obs) && !func->isBinnedDistribution(obs)) {
456 auto func =
static_cast<const RooAbsReal*
>(item);
495 for (
const auto parg : comp) {
496 if (parg->isDerived()) {
497 if (parg->canNodeBeCached()==
Always) {
498 trackNodes.
add(*parg) ;
519 os << rcomp->GetName() ;
526 os << ccomp->GetName() ;
538std::pair<RPPMIter,RPPMIter> findOverlap2nd(RPPMIter i, RPPMIter end)
541 for (; i!=end; ++i)
for ( RPPMIter j(i+1); j!=end; ++j) {
542 if (i->second->overlaps(*j->second)) {
543 return std::make_pair(i,j);
546 return std::make_pair(end,end);
550void dump_map(ostream& os, RPPMIter i, RPPMIter end)
557 else { os <<
" , " ; }
558 os << *(i->first) <<
" -> " << *(i->second) ;
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
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...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual value_type getCurrentIndex() const
Return index number of current state.
RooFIter fwdIterator() const
One-time forward iterator.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
RooAbsArg * first() const
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...
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...
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)
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)
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
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.
virtual ~CacheElem()
Destructor.
virtual RooArgList containedArgs(Action)
Return list of all RooAbsArgs in cache element.
A RooProduct represents the product of a given set of RooAbsReal objects.
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooProduct to more intuitively reflect the contents of the prod...
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &, Double_t, Double_t) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const
Base function for computing multiple values of a RooAbsReal.
void addTerm(RooAbsArg *term)
Add a term to this product.
virtual ~RooProduct()
Destructor.
ProdMap * groupProductTerms(const RooArgSet &) const
Group observables into subsets in which the product factorizes and that can thus be integrated separa...
double calculate(const RooArgList &partIntList) const
The cache manager.
double evaluate() const
Evaluate product of input functions.
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Declare that we handle all integrations internally.
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Forward the plot sampling hint from the p.d.f. that defines the observable obs
const char * makeFPName(const char *pfx, const RooArgSet &terms) const
Construct automatic name for internal product terms.
virtual Bool_t forceAnalyticalInt(const RooAbsArg &dep) const
Force internal handling of integration of given observable if any of the product terms depend on it.
virtual Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Calculate integral internally from appropriate partial integral cache.
RooProduct()
Default constructor.
RooObjCacheManager _cacheMgr
Int_t getPartIntList(const RooArgSet *iset, const char *rangeName=0) const
Return list of (partial) integrals whose product defines the integral of this RooProduct over the obs...
virtual void setCacheAndTrackHints(RooArgSet &)
Label OK'ed components of a RooProduct with cache-and-track.
virtual Bool_t isBinnedDistribution(const RooArgSet &obs) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
TString & Append(const char *cs)
static void output(int code)