86 _useDefaultGen(false),
104 _pdfList(
"!pdfs",
"List of PDFs",this),
106 _useDefaultGen(false),
139 _pdfList(
"!pdfs",
"List of PDFs",this),
141 _useDefaultGen(false),
146 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset")) ;
152 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset")) ;
158 <<
") multiple components with extended terms detected,"
159 <<
" product will not be extendible." << endl ;
192 _pdfList(
"!pdfs",
"List of PDFs",this),
194 _useDefaultGen(false),
198 Int_t numExtended(0) ;
203 << arg->GetName() <<
" is not a PDF, ignored" << endl ;
208 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset")) ;
219 <<
") WARNING: multiple components with extended terms detected,"
220 <<
" product will not be extendible." << endl ;
271 _pdfList(
"!pdfs",
"List of PDFs",this),
273 _useDefaultGen(false),
301 _pdfList(
"!pdfList",
"List of PDFs",this),
303 _useDefaultGen(false),
327 _pdfList(
"!pdfs",
"List of PDFs",this),
329 _useDefaultGen(false),
344 _cacheMgr(other._cacheMgr,this),
345 _genCode(other._genCode),
346 _cutOff(other._cutOff),
347 _pdfList(
"!pdfs",this,other._pdfList),
348 _extendedIndex(other._extendedIndex),
349 _useDefaultGen(other._useDefaultGen),
350 _refRangeName(other._refRangeName),
351 _selfNorm(other._selfNorm),
352 _defNormSet(other._defNormSet)
356 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(nset->GetName()));
370 Int_t numExtended(0) ;
373 for(
auto const* pdf : static_range_cast<RooAbsPdf*>(fullPdfSet)) {
375 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset")) ;
377 if (pdf->canBeExtended()) {
385 for(
auto * carg : static_range_cast<RooCmdArg*>(
l)) {
387 if (0 == strcmp(carg->GetName(),
"Conditional")) {
389 Int_t argType = carg->getInt(0) ;
393 for(
auto * thePdf : static_range_cast<RooAbsPdf*>(*pdfSet)) {
396 _pdfNSetList.emplace_back(std::make_unique<RooArgSet>(0 == argType ?
"nset" :
"cset"));
399 if (thePdf->canBeExtended()) {
406 }
else if (0 != strlen(carg->GetName())) {
414 <<
") WARNING: multiple components with extended terms detected,"
415 <<
" product will not be extendible." << endl ;
464 cxcoutD(
Eval) <<
"RooProdPdf::calculate(" <<
GetName() <<
") rearranged product calculation"
478 const auto normSet = cache.
_normList[i].get();
480 const double piVal = partInt.getVal(normSet->getSize() > 0 ? normSet :
nullptr);
495 auto span = dataMap.at(i);
499 if(span.size() == 1)
continue;
500 pdfs.push_back(span);
510void eraseNullptrs(std::vector<T*>&
v) {
511 v.erase(std::remove_if(
v.begin(),
v.end(), [](
T*
x){ return x == nullptr; } ),
v.end());
514void removeCommon(std::vector<RooAbsArg*> &
v, std::span<RooAbsArg * const> other) {
516 for (
auto const& arg : other) {
517 auto namePtrMatch = [&arg](
const RooAbsArg* elm) {
518 return elm !=
nullptr && elm->namePtr() == arg->namePtr();
521 auto found = std::find_if(
v.begin(),
v.end(), namePtrMatch);
522 if(found !=
v.end()) {
529void addCommon(std::vector<RooAbsArg*> &
v, std::vector<RooAbsArg*>
const& o1, std::vector<RooAbsArg*>
const& o2) {
531 for (
auto const& arg : o1) {
532 auto namePtrMatch = [&arg](
const RooAbsArg* elm) {
533 return elm->namePtr() == arg->namePtr();
536 if(std::find_if(o2.begin(), o2.end(), namePtrMatch) != o2.end()) {
554 std::vector<RooArgSet> depAllList;
555 std::vector<RooArgSet> depIntNoNormList;
563 std::vector<RooAbsArg*> pdfIntNoNormDeps;
564 std::vector<RooAbsArg*> pdfIntSet;
565 std::vector<RooAbsArg*> pdfNSet;
566 std::vector<RooAbsArg*> pdfCSet;
567 std::vector<RooAbsArg*> pdfNormDeps;
568 std::vector<RooAbsArg*> pdfAllDeps;
571 for(std::size_t iPdf = 0; iPdf <
_pdfList.
size(); ++iPdf) {
582 RooArgSet pdfLeafList(
"leafNodeServerList") ;
584 auto getObservablesOfCurrentPdf = [&pdfLeafList](
585 std::vector<RooAbsArg*> & out,
587 for (
const auto arg : pdfLeafList) {
588 if (arg->dependsOnValue(dataList) && arg->isLValue()) {
595 if (0 == strcmp(
"nset", pdfNSetOrig.
GetName())) {
596 getObservablesOfCurrentPdf(pdfNSet, pdfNSetOrig);
597 }
else if (0 == strcmp(
"cset", pdfNSetOrig.
GetName())) {
598 getObservablesOfCurrentPdf(pdfNSet, normSet);
599 removeCommon(pdfNSet, pdfNSetOrig.
get());
600 pdfCSet = pdfNSetOrig.
get();
603 getObservablesOfCurrentPdf(pdfNSet, pdfNSetOrig);
611 getObservablesOfCurrentPdf(pdfAllDeps, normSet);
617 if (!pdfNSet.empty()) {
619 addCommon(pdfNormDeps, pdfAllDeps, pdfNSet);
622 pdfNormDeps = pdfAllDeps;
628 getObservablesOfCurrentPdf(pdfIntSet, intSet) ;
631 if (pdfNormDeps.empty() && !pdfCSet.empty()) {
632 removeCommon(pdfIntSet, pdfCSet);
636 pdfIntNoNormDeps.clear();
637 pdfIntNoNormDeps = pdfIntSet;
638 removeCommon(pdfIntNoNormDeps, pdfNormDeps);
645 auto lIter = termList.
begin();
646 auto ldIter = normList.
begin();
647 for(;lIter != termList.
end(); (++lIter, ++ldIter, ++j)) {
648 termNormDeps =
static_cast<RooArgSet*
>(*ldIter);
656 bool normOverlap = termNormDeps->
overlaps(pdfNormDeps.begin(), pdfNormDeps.end());
663 termNormDeps->
add(pdfNormDeps.begin(), pdfNormDeps.end(),
false);
664 depAllList[j].add(pdfAllDeps.begin(), pdfAllDeps.end(),
false);
666 termIntDeps->
add(pdfIntSet.begin(), pdfIntSet.end(),
false);
668 if (termIntNoNormDeps) {
669 termIntNoNormDeps->
add(pdfIntNoNormDeps.begin(), pdfIntNoNormDeps.end(),
false);
671 termIntNoNormDeps->
add(pdfIntNoNormDeps.begin(), pdfIntNoNormDeps.end(),
false);
678 if (!(pdfNormDeps.empty() && pdfAllDeps.empty() &&
679 pdfIntSet.empty()) || 0 == normSet.
getSize()) {
682 termNormDeps =
new RooArgSet(
"termNormDeps");
683 depAllList.emplace_back(pdfAllDeps.begin(), pdfAllDeps.end(),
"termAllDeps");
684 termIntDeps =
new RooArgSet(pdfIntSet.begin(), pdfIntSet.end(),
"termIntDeps");
685 depIntNoNormList.emplace_back(pdfIntNoNormDeps.begin(), pdfIntNoNormDeps.end(),
"termIntNoNormDeps");
686 termIntNoNormDeps = &depIntNoNormList.back();
689 termNormDeps->
add(pdfNormDeps.begin(), pdfNormDeps.end(),
false);
692 normList.
Add(termNormDeps);
693 intList.
Add(termIntDeps);
702 auto lIter = termList.
begin();
703 auto ldIter = normList.
begin();
704 for(;lIter != termList.
end(); (++lIter, ++ldIter, ++i)) {
705 normDeps =
static_cast<RooArgSet*
>(*ldIter);
709 impDeps.
remove(*normDeps,
true,
true);
715 auto crossDeps = std::unique_ptr<RooAbsCollection>{depIntNoNormList[i].selectCommon(*normDeps)};
716 crossDepList.
Add(crossDeps->snapshot());
740 Int_t sterileIdx(-1);
764 std::list<std::vector<RooArgSet*>> groupedList;
772 map<string, RooArgSet> ratioTerms;
773 for (
auto const&
group : groupedList) {
774 if (1 ==
group.size()) {
782 RooArgSet termNSet(*norm), termImpSet(*imps);
792 bool rangeIdentical(
true);
793 RooFIter niter = termNSet.fwdIterator();
810 if (!rangeIdentical ) {
813 ostringstream str; termImpSet.
printValue(str);
815 ratioTerms[str.str()].add(*ratio);
823 for (
auto const& term :
group) {
828 RooArgSet termNSet(*norm), termImpSet(*imps);
833 bool rangeIdentical(
true);
834 RooFIter niter = termNSet.fwdIterator();
849 if (!rangeIdentical ) {
852 ostringstream str; termImpSet.
printValue(str);
853 ratioTerms[str.str()].add(*ratio);
863 for (
auto const&
group : groupedList) {
864 if (1 ==
group.size()) {
870 RooArgSet termNSet(*norm), termImpSet(*imps);
873 ostringstream str; termNSet.printValue(str);
874 if (ratioTerms[str.str()].getSize() > 0) {
876 term->
add(ratioTerms[str.str()]);
880 for (
auto const& term :
group) {
884 RooArgSet termNSet(*norm), termImpSet(*imps);
887 ostringstream str; termNSet.printValue(str);
888 if (ratioTerms[str.str()].getSize() > 0) {
890 term->add(ratioTerms[str.str()]);
896 for (
auto const&
group : groupedList) {
900 if (1 ==
group.size()) {
910 RooArgSet termNSet, termISet, termXSet, termImpSet;
913 termISet.
add(*integ);
917 termXSet.
add(*xdeps);
918 termImpSet.
add(*imps);
927 vector<RooAbsReal*> func =
processProductTerm(nset, iset, isetRangeName, term, termNSet, termISet, isOwned);
942 RooArgSet compTermSet, compTermNorm, compTermNum, compTermDen;
943 for (
auto const& term :
group) {
951 RooArgSet termNSet, termISet, termXSet, termImpSet;
952 termISet.
add(*integ);
954 termXSet.
add(*xdeps);
955 termImpSet.
add(*imps);
958 termISet.
remove(outerIntDeps,
true,
true);
966 bool isOwned =
false;
967 vector<RooAbsReal*> func =
processProductTerm(nset, iset, isetRangeName, term, termNSet, termISet, isOwned,
true);
970 compTermSet.
add(*func[0]);
972 compTermNorm.
add(*norm,
false);
974 compTermNum.
add(*func[1]);
975 compTermDen.
add(*func[2]);
994 const std::string prodname =
makeRGPPName(
"SPECPROD", compTermSet, outerIntDeps,
RooArgSet(), isetRangeName);
998 const std::string intname =
makeRGPPName(
"SPECINT", compTermSet, outerIntDeps,
RooArgSet(), isetRangeName);
1007 RooProduct* prodtmp_num =
new RooProduct(prodname_num.c_str(), prodname_num.c_str(), compTermNum);
1013 RooProduct* prodtmp_den =
new RooProduct(prodname_den.c_str(), prodname_den.c_str(), compTermDen);
1018 string name =
Form(
"SPEC_RATIO(%s,%s)", prodname_num.c_str(), prodname_den.c_str());
1098 list<string> rangeComps ;
1103 char* token = R__STRTOK_R(buf,
",",&save) ;
1105 rangeComps.push_back(token) ;
1106 token = R__STRTOK_R(0,
",",&save) ;
1112 map<string,RooArgSet> denListList ;
1114 string specIntRange ;
1140 std::unique_ptr<RooArgSet> components{orig->
getComponents()};
1142 if (carg->getAttribute(
"RATIO_TERM")) {
1154 nomList.
add(*funcCust) ;
1156 nomList.
add(*func) ;
1171 if (arg->getAttribute(
"RATIO_TERM")) {
1174 origNumTerm.
add(*arg) ;
1182 nomList.
add(origNumTerm) ;
1189 for (list<string>::iterator iter = rangeComps.begin() ; iter != rangeComps.end() ; ++iter) {
1235 partCust = cust.
build() ;
1240 partCust = cust.
build() ;
1250 string name =
Form(
"%s_divided_by_ratio",specializedPartCust->
GetName()) ;
1253 denListList[*iter].add(*specIntFinal) ;
1274 tmp.
add(*specRatio) ;
1286 throw string(
"this should not happen") ;
1292 denListList[*iter].add(*specIntFinal) ;
1314 for (map<string,RooArgSet>::iterator iter = denListList.begin() ; iter != denListList.end() ; ++iter) {
1319 products.
add(*prod_comp) ;
1325 if (specIntDeps.
getSize()>0) {
1334 numerator = numtmp ;
1408 for(
auto * term : static_range_cast<RooArgSet*>(terms)) {
1409 groupedTerms.emplace_back();
1410 groupedTerms.back().emplace_back(term) ;
1415 for(
auto * impDeps : static_range_cast<RooArgSet*>(imps)) {
1416 allImpDeps.
add(*impDeps,
false) ;
1421 for(
auto * intDeps : static_range_cast<RooArgSet*>(ints)) {
1422 allIntDeps.
add(*intDeps,
false) ;
1429 for(
RooAbsArg * outerIntDep : outerIntDeps) {
1432 std::vector<RooArgSet*>* newGroup = nullptr ;
1435 bool needMerge = false ;
1436 auto group = groupedTerms.begin();
1437 auto nGroups = groupedTerms.size();
1438 for (
size_t iGroup = 0; iGroup < nGroups; ++iGroup) {
1441 for (
auto const& term2 : *
group) {
1448 if (termNormDeps->
contains(*outerIntDep) ||
1449 termIntDeps->
contains(*outerIntDep) ||
1450 termImpDeps->
contains(*outerIntDep)) {
1458 if (newGroup==
nullptr) {
1459 groupedTerms.emplace_back() ;
1460 newGroup = &groupedTerms.back() ;
1464 for (
auto& term2 : *
group) {
1465 newGroup->emplace_back(term2) ;
1486 bool& isOwned,
bool forceWrap)
const
1498 vector<RooAbsReal*> ret(3) ; ret[0] = 0 ; ret[1] = 0 ; ret[2] = 0 ;
1514 if (nset && termNSet.
getSize()==0) {
1522 if (iset && termISet.
getSize()>0) {
1553 const std::string
name =
makeRGPPName(
"GENPROJ_",*term,termISet,termNSet,isetRangeName) ;
1580 const std::string
name =
makeRGPPName(
"GENPROJ_",*term,termISet,termNSet,isetRangeName) ;
1613 name.Append(
"_NORM[") ;
1660 coutE(
Eval) <<
"RooProdPdf::processProductTerm(" <<
GetName() <<
") unidentified term!!!" << endl ;
1671 const RooArgSet& nset,
const char* isetRangeName)
const
1675 std::ostringstream os(pfx);
1683 if (!
first) os <<
"_X_";
1720 const RooArgSet* normSet,
const char* rangeName)
const
1725 analVars.
add(allVars) ;
1800 coutF(
Generation) <<
"Requesting expected number of events from a RooProdPdf that does not contain an extended p.d.f" << endl ;
1801 throw std::logic_error(std::string(
"RooProdPdf ") +
GetName() +
" could not be extended.");
1840 std::vector<Int_t> code;
1846 code.push_back(pdfCode);
1848 generateVars.
add(pdfDirect) ;
1853 if (generateVars.
getSize()>0) {
1855 return masterCode+1 ;
1876 if (codeList[i]!=0) {
1899 if (codeList[i]!=0) {
1931 os <<
indent <<
"RooProdPdf begin partial integral cache" << endl ;
1934 auto indent2 = std::string(
indent) +
"[" + std::to_string(curElem) +
"]";
1935 for(
auto const& arg : _partList) {
1936 arg->printCompactTree(os,indent2.c_str()) ;
1939 if (curElem==maxElem) {
1940 os <<
indent <<
"RooProdPdf end partial integral cache" << endl ;
1964 if (thePdf)
return false ;
1981 if (idx<0)
return nullptr;
1999 for(
auto * pdf : static_range_cast<RooAbsPdf*>(
_pdfList)) {
2003 if (!pdf->dependsOnValue(observables) && pdf->dependsOnValue(constrainedParams)) {
2004 constraints.
add(*pdf) ;
2005 pdf->getParameters(&observables, tmp);
2006 conParams.
add(tmp,
true) ;
2008 pdf->getParameters(&observables, tmp);
2009 pdfParams.
add(tmp,
true) ;
2015 for(
auto * pdf : static_range_cast<RooAbsPdf*>(constraints)) {
2016 if (pdf->dependsOnValue(pdfParams) || !stripDisconnected) {
2017 finalConstraints->
add(*pdf) ;
2020 <<
" as constraint term as it does not share any parameters with the other pdfs in product. "
2021 <<
"To force inclusion in likelihood, add an explicit Constrain() argument for the target parameter" << endl ;
2027 std::unique_ptr<RooArgSet> cexl{
static_cast<RooArgSet*
>(conParams.
selectCommon(constrainedParams))};
2028 cexl->
remove(pdfParams,
true,
true) ;
2029 constrainedParams.
remove(*cexl,
true,
true) ;
2031 return finalConstraints ;
2048 if (arg->dependsOn(observables)) {
2050 arg->getParameters(&observables, tmp);
2051 connectedPars->
add(tmp) ;
2054 return connectedPars ;
2064 if (!stripDisconnected) return ;
2065 if (!nset || nset->
getSize()==0) return ;
2073 for (
auto param : *params) {
2074 bool anyDep(
false) ;
2075 for (
auto term : plist) {
2076 if (term->dependsOnValue(*param)) {
2081 tostrip.
add(*param) ;
2086 params->
remove(tostrip,
true,
true);
2185 if (parg->canNodeBeCached()==
Always) {
2186 trackNodes.
add(*parg) ;
2194 if (
string(
"nset")==pdf_nset->
GetName() && pdf_nset->
getSize()>0) {
2197 if (
string(
"cset")==pdf_nset->
GetName()) {
2201 coutW(
Optimization) <<
"RooProdPdf::setCacheAndTrackHints(" <<
GetName() <<
") WARNING product pdf does not specify a normalization set for component " << parg->GetName() << endl ;
2216 if (i>0) os <<
" * " ;
2220 if (
string(
"nset")==ncset->
GetName()) {
2265 for(std::unique_ptr<RooArgSet>
const& normSet :
_pdfNSetList) {
2270 normSet->releaseOwnership();
2271 normSet->replace(*arg, *newArg->cloneTree());
2272 normSet->takeOwnership();
2283 os <<
"_partList\n";
2289 os <<
"_ownedList\n";
2291 os <<
"_normList\n";
2292 for(
auto const& set : _normList) {
2295 os <<
"_isRearranged" <<
"\n";
2296 os << _isRearranged <<
"\n";
2297 os <<
"_rearrangedNum" <<
"\n";
2298 if(_rearrangedNum) {
2301 os <<
"nullptr" <<
"\n";
2303 os <<
"_rearrangedDen" <<
"\n";
2304 if(_rearrangedDen) {
2307 os <<
"nullptr" <<
"\n";
2317 if (pdfNset && !pdfNset->empty()) {
2318 for(
auto * arg : *pdfNset)
if(server.
dependsOn(*arg)) serverNormSet.
add(*arg);
2320 for(
auto * arg : normSet)
if(server.
dependsOn(*arg)) serverNormSet.
add(*arg);
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
const std::vector< Int_t > & retrieve(Int_t masterCode) const
Retrieve the array of integer codes associated with the given master code.
Int_t store(const std::vector< Int_t > &codeList, RooArgSet *set1=0, RooArgSet *set2=0, RooArgSet *set3=0, RooArgSet *set4=0)
Store given arrays of integer codes, and up to four RooArgSets in the registry (each setX pointer may...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooExpensiveObjectCache & expensiveObjectCache() const
TObject * Clone(const char *newname=0) const override
Make a clone of an object using the Streamer facility.
void setOperMode(OperMode mode, bool recurseADirty=true)
Set the operation mode of this node.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, bool doBranch=true, bool doLeaf=true, bool valueOnly=false, bool recurseNonDerived=false) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache)
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
RooArgSet * getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
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...
RooAbsArg * findNewServer(const RooAbsCollection &newSet, bool nameChange) const
Find the new server in the specified set that matches the old server.
OperMode operMode() const
Query the operation mode of this node.
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Storage_t const & get() const
Const access to the underlying stl container.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
void printValue(std::ostream &os) const override
Print value of collection, i.e.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
RooFIter fwdIterator() const
One-time forward iterator.
bool overlaps(Iterator_t otherCollBegin, Iterator_t otherCollEnd) const
Storage_t::size_type size() const
RooAbsArg * first() const
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
friend class CacheElem
The cache manager.
virtual void generateEvent(Int_t code)
Interface for generation of an event using the algorithm corresponding to the specified code.
TString _normRange
Normalization range.
virtual bool isDirectGenSafe(const RooAbsArg &arg) const
Check if given observable can be safely generated using the pdfs internal generator mechanism (if tha...
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
friend class RooRealIntegral
const char * normRange() const
virtual void initGenerator(Int_t code)
Interface for one-time initialization to setup the generator for the specified code.
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, bool verbose=false) const
Interface function to create a generator context from a p.d.f.
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual double getMax(const char *name=0) const
Get maximum of currently defined range.
virtual double getMin(const char *name=0) const
Get minimum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
double 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 ...
bool _forceNumInt
Force numerical integration if flag set.
TString integralNameSuffix(const RooArgSet &iset, const RooArgSet *nset=0, const char *rangeName=0, bool omitEmpty=false) const
Construct string with unique suffix name to give to integral object that encodes integrated observabl...
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
virtual std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
const RooArgList & list1() const
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
virtual void compute(cudaStream_t *, Computer, RestrictArr, size_t, const VarVector &, const ArgVector &={})=0
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Getter function without integration set.
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.
void reset()
Clear the cache.
Int_t lastIndex() const
Return index of slot used in last get or set operation.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
Setter function without integration set.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
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...
bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false) override
Remove object 'var' from set and deregister 'var' as server to owner.
TObject * clone(const char *newname) const override
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurence of arg 'orig' with arg 'subst'.
RooAbsArg * build(const char *masterCatState, bool verbose=false)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
RooDataSet is a container class to hold unbinned data.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooGenProdProj is an auxiliary class for RooProdPdf that calculates a general normalised projection o...
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TObject * At(int index) const
Return object stored in sequential position given by index.
RooLinkedListIterImpl end() const
void Delete(Option_t *o=0) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
RooLinkedListIterImpl begin() const
Int_t IndexOf(const char *name) const
Return position of given object in list.
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
static const TNamed * ptr(const char *stringPtr)
Return a unique TNamed pointer for given C++ string.
RooArgList containedArgs(Action) override
Return RooAbsArg components contained in the cache.
std::unique_ptr< RooAbsReal > _rearrangedNum
void printCompactTreeHook(std::ostream &, const char *, Int_t, Int_t) override
Hook function to print cache contents in tree printing of RooProdPdf.
std::vector< std::unique_ptr< RooArgSet > > _normList
std::unique_ptr< RooAbsReal > _rearrangedDen
void writeToStream(std::ostream &os) const
RooProdPdf is an efficient implementation of a product of PDFs of the form.
void setCacheAndTrackHints(RooArgSet &) override
Label OK'ed components of a RooProdPdf with cache-and-track, and label all RooProdPdf descendants wit...
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Query internal generation capabilities of component p.d.f.s and aggregate capabilities into master co...
void rearrangeProduct(CacheElem &) const
void factorizeProduct(const RooArgSet &normSet, const RooArgSet &intSet, RooLinkedList &termList, RooLinkedList &normList, RooLinkedList &impDepList, RooLinkedList &crossDepList, RooLinkedList &intList) const
Factorize product in irreducible terms for given choice of integration/normalization.
~RooProdPdf() override
Destructor.
Int_t _extendedIndex
Index of extended PDF (if any)
Int_t getPartIntList(const RooArgSet *nset, const RooArgSet *iset, const char *isetRangeName=0) const
Return list of (partial) integrals of product terms for integration of p.d.f over observables iset wh...
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Evaluate product of PDFs in batch mode.
RooProdPdf()
Default constructor.
RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, bool verbose=false) const override
Return generator context optimized for generating events from product p.d.f.s.
bool checkObservables(const RooArgSet *nset) const override
Obsolete.
bool _useDefaultGen
Use default or distributed event generator.
std::vector< std::unique_ptr< RooArgSet > > _pdfNSetList
List of PDF component normalization sets.
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &numVars, const RooArgSet *normSet, const char *rangeName=0) const override
Determine which part (if any) of given integral can be performed analytically.
bool forceAnalyticalInt(const RooAbsArg &dep) const override
Force RooRealIntegral to offer all observables for internal integration.
void writeCacheToStream(std::ostream &os, RooArgSet const *nset) const
void getParametersHook(const RooArgSet *, RooArgSet *, bool stripDisconnected) const override
TNamed * _refRangeName
Reference range name for interpretation of conditional products.
RooAICRegistry _genCode
! Registry of composite direct generator codes
RooListProxy _pdfList
List of PDF components.
void selectNormalizationRange(const char *rangeName=0, bool force=false) override
Interface function used by test statistics to freeze choice of range for interpretation of conditiona...
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooProdPdf to more intuitively reflect the contents of the prod...
std::list< double > * binBoundaries(RooAbsRealLValue &, double, double) const override
Forward the plot sampling hint from the p.d.f. that defines the observable obs.
RooAbsReal * specializeIntegral(RooAbsReal &orig, const char *targetRangeName) const
void fillNormSetForServer(RooArgSet const &normSet, RooAbsArg const &server, RooArgSet &serverNormSet) const override
Fills a RooArgSet to be used as the normalization set for a server, given a normalization set for thi...
RooObjCacheManager _cacheMgr
std::string makeRGPPName(const char *pfx, const RooArgSet &term, const RooArgSet &iset, const RooArgSet &nset, const char *isetRangeName) const
Make an appropriate automatic name for a RooGenProdProj object in getPartIntList()
bool isDirectGenSafe(const RooAbsArg &arg) const override
Forward determination of safety of internal generator code to component p.d.f that would generate the...
RooArgSet * findPdfNSet(RooAbsPdf const &pdf) const
Look up user specified normalization set for given input PDF component.
RooAbsReal * makeCondPdfRatioCorr(RooAbsReal &term, const RooArgSet &termNset, const RooArgSet &termImpSet, const char *normRange, const char *refRange) const
For single normalization ranges.
ExtendMode extendMode() const override
If this product contains exactly one extendable p.d.f return the extension abilities of that p....
std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override
Forward the plot sampling hint from the p.d.f. that defines the observable obs.
double expectedEvents(const RooArgSet *nset) const override
Return the expected number of events associated with the extendable input PDF in the product.
std::vector< RooAbsReal * > processProductTerm(const RooArgSet *nset, const RooArgSet *iset, const char *isetRangeName, const RooArgSet *term, const RooArgSet &termNSet, const RooArgSet &termISet, bool &isOwned, bool forceWrap=false) const
Calculate integrals of factorized product terms over observables iset while normalized to observables...
TObject * clone(const char *newname) const override
bool isBinnedDistribution(const RooArgSet &obs) const override
If all components that depend on obs are binned that so is the product.
friend class RooProdGenContext
RooArgSet * getConnectedParameters(const RooArgSet &observables) const
Return all parameter constraint p.d.f.s on parameters listed in constrainedParams.
double calculate(const RooProdPdf::CacheElem &cache, bool verbose=false) const
Calculate running product of pdfs terms, using the supplied normalization set in 'normSetList' for ea...
RooArgSet _defNormSet
Default normalization set.
RooArgSet * getConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, bool stripDisconnected) const override
Return all parameter constraint p.d.f.s on parameters listed in constrainedParams.
RooAbsReal * specializeRatio(RooFormulaVar &input, const char *targetRangeName) const
CacheElem * getCacheElem(RooArgSet const *nset) const
The cache manager.
bool redirectServersHook(const RooAbsCollection &, bool, bool, bool) override
Implement support for node removal.
void initGenerator(Int_t code) override
Forward one-time initialization call to component generation initialization methods.
void generateEvent(Int_t code) override
Generate a single event with configuration specified by 'code' Defer internal generation to component...
void groupProductTerms(std::list< std::vector< RooArgSet * > > &groupedTerms, RooArgSet &outerIntDeps, const RooLinkedList &terms, const RooLinkedList &norms, const RooLinkedList &imps, const RooLinkedList &ints, const RooLinkedList &cross) const
Group product into terms that can be calculated independently.
void fixRefRange(const char *rangeName)
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const override
Return analytical integral defined by given scenario code.
double evaluate() const override
Calculate current value of object.
void initializeFromCmdArgList(const RooArgSet &fullPdfSet, const RooLinkedList &l)
Initialize RooProdPdf configuration from given list of RooCmdArg configuration arguments and set of '...
double _cutOff
Cutoff parameter for running product.
A RooProduct represents the product of a given set of RooAbsReal objects.
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooArgSet intVars() const
const RooAbsReal & integrand() const
RooRealVar represents a variable that can be changed from the outside.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
RooConstVar & RooConst(double val)
std::vector< RooSpan< const double > > VarVector
R__EXTERN RooBatchComputeInterface * dispatchCUDA
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
std::vector< double > ArgVector
std::map< DataKey, RooSpan< const double > > DataMap
std::string getColonSeparatedNameString(RooArgSet const &argSet)
Create a string with all sorted names of RooArgSet elements separated by colons.