108#include <sys/types.h>
137 RooAbsArg(
name,title), _plotMin(0), _plotMax(0), _plotBins(100),
138 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
151 double inMaxVal,
const char *unit) :
152 RooAbsArg(
name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _plotBins(100),
153 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
165 RooAbsArg(other,
name), _plotMin(other._plotMin), _plotMax(other._plotMax),
166 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
167 _forceNumInt(other._forceNumInt), _selectComp(other._selectComp), _lastNSet(0)
212 if (!assumeSameType) {
228 if(appendUnit && 0 != strlen(
getUnit())) {
280 auto item = evalData.
spans.find(
this);
281 if (item != evalData.
spans.end()) {
287 std::map<RooFit::Detail::DataKey, RooSpan<const double>> dataSpans;
288 for (
auto const &evalDataItem : evalData.
spans) {
289 dataSpans[evalDataItem.first] = evalDataItem.second;
292 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, normSet ? *normSet :
RooArgSet{});
294 driver.setData(dataSpans);
296 results = driver.getValues();
297 evalData.
spans[
this] = results;
304 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, *
data.get());
342 <<
"): validation failed: " <<
value << std::endl ;
362 const RooArgSet* ,
const char* rangeName)
const
393 if (code==0)
return getVal(normSet) ;
407 coutF(
Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << std::endl ;
468 os <<
indent <<
"--- RooAbsReal ---" << std::endl;
486 for (
auto const& arg : paramsOfInterest) {
492 name.append(arg->GetName()) ;
531 pc.defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
532 pc.defineSet(
"normSet",
"NormSet",0,0) ;
533 pc.defineObject(
"numIntConfig",
"NumIntConfig",0,0) ;
536 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
542 const char* rangeName =
pc.getString(
"rangeName",0,
true) ;
567 if (!rangeName || strchr(rangeName,
',')==0) {
575 std::vector<std::string> tokens =
ROOT::Split(rangeName,
",");
578 std::stringstream errMsg;
579 errMsg <<
GetName() <<
" : integrating with respect to the variables " << iset <<
" on the ranges \"" << rangeName
580 <<
"\" is not possible because the ranges are overlapping";
581 const std::string errMsgString = errMsg.str();
583 throw std::invalid_argument(errMsgString);
586 for (
const std::string& token : tokens) {
588 components.
add(*compIntegral);
592 title.
Prepend(
"Integral of ") ;
620 title.
Prepend(
"Integral of ") ;
638 if (innerSet.
empty()) {
645 title.
Prepend(
"Integral of ") ;
654 if (integrand !=
this) {
662 if (integrand ==
this && iset.
getSize()>0) {
663 coutI(
Integration) <<
GetName() <<
" : multidimensional integration over observables with parameterized ranges in terms of other integrated observables detected, using recursive integration strategy to construct final integral" << std::endl ;
667 integrand = integral ;
675 coutE(
Integration) <<
GetName() <<
" : ERROR while defining recursive integral over observables with parameterized integration ranges, please check that integration rangs specify uniquely defined integral " << std::endl;
684 if (cacheParamsStr && strlen(cacheParamsStr)) {
686 std::unique_ptr<RooArgSet> intParams{integral->
getVariables()};
692 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << std::endl ;
702 integral = cachedIntegral ;
730 for (
const auto aarg : allObs) {
745 obsWithParamRange.
add(*aarg) ;
746 obsWithFixedRange.
remove(*aarg) ;
747 obsServingAsRangeParams.
add(loBoundObs,
false) ;
748 obsServingAsRangeParams.
add(hiBoundObs,
false) ;
755 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
756 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
759 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
760 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
764 innerObs.
add(obsWithFixedRangeNP) ;
765 innerObs.
add(obsWithParamRangeNP) ;
782 name.Append(
"_Int[") ;
790 name.Append(arg->GetName()) ;
794 name.Append(rangeName) ;
797 }
else if (!omitEmpty) {
798 name.Append(
"_Int[]") ;
801 if (nset && nset->
getSize()>0 ) {
806 name.Append(
"_Norm[") ;
814 name.Append(arg->GetName()) ;
876 for (
const auto arg : dependentVars) {
877 if(!arg->isFundamental() && !
dynamic_cast<const RooAbsLValue*
>(arg)) {
879 <<
"\" of wrong type: " << arg->ClassName() << std::endl;
886 <<
"\" is not a dependent and will be ignored." << std::endl;
891 leafNodes.
replace(*found,*arg);
893 leafNodes.
add(*arg) ;
897 arg->getObservables(&leafNodes, lvDep);
898 for (
const auto lvs : lvDep) {
902 leafNodes.
add(*lvs) ;
909 if(0 != projectedVars && projectedVars->
find(arg->GetName())) {
911 <<
"\" cannot be both a dependent and a projected variable." << std::endl;
917 if(0 != projectedVars) leafNodes.
remove(*projectedVars,
true);
922 coutE(
Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << std::endl ;
933 std::unique_ptr<RooArgSet> plotLeafNodes{
static_cast<RooArgSet*
>(leafNodes.
selectCommon(dependentVars))};
938 if(0 != projectedVars) normSet.
add(*projectedVars);
940 normSet.
remove(*condObs,
true,
true) ;
947 if(0 == projectedVars) projectedVars= ∅
953 title.
Prepend(
"Projection of ");
958 if(0 == projected || !projected->
isValid()) {
962 if(0 != projected)
delete projected;
967 static_cast<RooRealIntegral*
>(projected)->setAllowComponentSelection(
true);
999 double scaleFactor,
const RooArgSet *projectedVars,
bool scaleForDensity,
1000 const RooArgSet* condObs,
bool setError)
const
1010 if(hdim != plotVars.
getSize()) {
1024 <<
"\" of type " << var->
ClassName() << std::endl;
1029 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << std::endl;
1031 plotClones.
addClone(*realVar,
true);
1036 pc->recursiveRedirectServers(plotClones,
false,
false,
true) ;
1041 if (projectedVars) {
1042 allDeps.
add(*projectedVars) ;
1068 assert(0 != zvar && 0 != zaxis);
1069 if (scaleForDensity) {
1077 assert(0 != yvar && 0 != yaxis);
1078 if (scaleForDensity) {
1086 assert(0 != xvar && 0 != xaxis);
1087 if (scaleForDensity) {
1093 << hdim <<
" dimensions" << std::endl;
1100 Int_t xbin(0),ybin(0),zbin(0);
1102 for(
Int_t bin= 0; bin < bins; bin++) {
1105 if(bin % (
xbins*ybins) == 0) {
1111 if(bin %
xbins == 0) {
1112 ybin= (ybin%ybins) + 1;
1117 xbin= (xbin%
xbins) + 1;
1127 coutW(
Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1172 bool correctForBinSize,
bool showProgress)
const
1201 if (showProgress && (i%onePct==0)) {
1205 double binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1206 if (correctForBinSize) {
1209 hist->
set(i, binVal, 0.);
1234 strlcpy(buf,varNameList,1024) ;
1235 char* varName = strtok(buf,
",:") ;
1240 varName = strtok(0,
",") ;
1242 varName = strtok(0,
",") ;
1333 pc.defineInt(
"scaling",
"Scaling",0,1) ;
1334 pc.defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1335 pc.defineInt(
"extended",
"Extended",0,2) ;
1337 pc.defineSet(
"compSet",
"SelectCompSet",0);
1338 pc.defineString(
"compSpec",
"SelectCompSpec",0) ;
1339 pc.defineSet(
"projObs",
"ProjectedObservables",0,0) ;
1340 pc.defineObject(
"yvar",
"YVar",0,0) ;
1341 pc.defineObject(
"zvar",
"ZVar",0,0) ;
1342 pc.defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1343 pc.defineMutex(
"IntrinsicBinning",
"Binning") ;
1344 pc.defineMutex(
"IntrinsicBinning",
"BinningName") ;
1345 pc.defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1346 pc.allowUndefined() ;
1349 pc.process(argList) ;
1364 auto projObs =
pc.getSet(
"projObs");
1367 bool doScaling =
pc.getInt(
"scaling") ;
1368 Int_t doIntBinning =
pc.getInt(
"intBinning") ;
1369 Int_t doExtended =
pc.getInt(
"extended") ;
1373 if (!pdfSelf && doExtended>0) {
1374 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << std::endl ;
1378 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << std::endl ;
1381 if (pdfSelf && doExtended==2) {
1385 const char* compSpec =
pc.getString(
"compSpec") ;
1387 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1389 std::unique_ptr<RooBinning> intBinning;
1390 if (doIntBinning>0) {
1395 if (doIntBinning==1) {
1397 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< std::endl ;
1400 if (doIntBinning==2) {
1402 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< std::endl ;
1404 std::vector<double> ba(bl->size());
1406 for (
auto const& elem : *bl) { ba[i++] = elem ; }
1407 intBinning = std::make_unique<RooBinning>(bl->size()-1,ba.data()) ;
1412 RooCmdConfig::stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1417 argListCreate.
Add(&tmp) ;
1433 branchNodeSet.
remove(*arg) ;
1437 std::unique_ptr<RooArgSet> dirSelNodes;
1443 if (!dirSelNodes->empty()) {
1444 coutI(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << std::endl ;
1450 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << std::endl ;
1452 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << std::endl ;
1458 double scaleFactor(1.0) ;
1464 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,
false) ;
1491 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1492 const auto arg = branchNodeSet[i];
1494 branchNodeSet.
remove(*arg) ;
1501 for (
const auto arg : branchNodeSet) {
1510 for (
const auto arg : branchNodeSet) {
1511 for (
const auto selNode : *selNodes) {
1512 if (selNode->dependsOn(*arg)) {
1519 for (
const auto arg : branchNodeSet) {
1520 if (arg->dependsOn(*selNodes)) {
1525 tmp.
remove(*selNodes,
true);
1528 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << std::endl ;
1531 for (
const auto arg : branchNodeSet) {
1532 bool select = selNodes->
find(arg->GetName()) !=
nullptr;
1686 argList.
Add(&rnorm) ;
1688 std::vector<std::string> rlist;
1692 rlist.emplace_back(rangeNameToken);
1695 for (
const auto& rangeString : rlist) {
1697 rcmd->
setString(0, rangeString.c_str());
1706 pc.defineString(
"drawOption",
"DrawOption",0,
"L") ;
1707 pc.defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
true) ;
1708 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1709 pc.defineString(
"sliceCatState",
"SliceCat",0,
"",
true) ;
1710 pc.defineDouble(
"scaleFactor",
"Normalization",0,1.0) ;
1711 pc.defineInt(
"scaleType",
"Normalization",0,
Relative) ;
1712 pc.defineSet(
"sliceSet",
"SliceVars",0) ;
1713 pc.defineObject(
"sliceCatList",
"SliceCat",0,0,
true) ;
1717 pc.defineObject(
"dummy1",
"SliceCatMany",0) ;
1718 pc.defineSet(
"projSet",
"Project",0) ;
1719 pc.defineObject(
"asymCat",
"Asymmetry",0) ;
1720 pc.defineDouble(
"precision",
"Precision",0,1
e-3) ;
1721 pc.defineDouble(
"evalErrorVal",
"EvalErrorValue",0,0) ;
1722 pc.defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1723 pc.defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1724 pc.defineSet(
"projDataSet",
"ProjData",0) ;
1725 pc.defineObject(
"projData",
"ProjData",1) ;
1726 pc.defineObject(
"errorFR",
"VisualizeError",0) ;
1727 pc.defineDouble(
"errorZ",
"VisualizeError",0,1.) ;
1728 pc.defineSet(
"errorPars",
"VisualizeError",0) ;
1729 pc.defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1730 pc.defineInt(
"binProjData",
"ProjData",0,0) ;
1731 pc.defineDouble(
"rangeLo",
"Range",0,-999.) ;
1732 pc.defineDouble(
"rangeHi",
"Range",1,-999.) ;
1733 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1734 pc.defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1735 pc.defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1736 pc.defineInt(
"VLines",
"VLines",0,2) ;
1737 pc.defineString(
"rangeName",
"RangeWithName",0,
"") ;
1738 pc.defineString(
"normRangeName",
"NormRange",0,
"") ;
1739 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1740 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1741 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
1742 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
1743 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1744 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1745 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
1746 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1747 pc.defineString(
"curveName",
"Name",0,
"") ;
1748 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
1749 pc.defineInt(
"showProg",
"ShowProgress",0,0) ;
1750 pc.defineInt(
"numCPU",
"NumCPU",0,1) ;
1751 pc.defineInt(
"interleave",
"NumCPU",1,0) ;
1752 pc.defineString(
"addToCurveName",
"AddTo",0,
"") ;
1753 pc.defineDouble(
"addToWgtSelf",
"AddTo",0,1.) ;
1754 pc.defineDouble(
"addToWgtOther",
"AddTo",1,1.) ;
1755 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1756 pc.defineMutex(
"SliceVars",
"Project") ;
1757 pc.defineMutex(
"AddTo",
"Asymmetry") ;
1758 pc.defineMutex(
"Range",
"RangeWithName") ;
1759 pc.defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1762 pc.process(argList) ;
1768 TString drawOpt(
pc.getString(
"drawOption"));
1771 double errZ =
pc.getDouble(
"errorZ") ;
1773 bool linMethod =
pc.getInt(
"linearMethod") ;
1774 if (!drawOpt.
Contains(
"P") && errFR) {
1781 o.
numee =
pc.getInt(
"numee") ;
1791 o.
eeval =
pc.getDouble(
"evalErrorVal") ;
1794 const RooArgSet* sliceSetTmp =
pc.getSet(
"sliceSet");
1795 std::unique_ptr<RooArgSet> sliceSet{sliceSetTmp ?
static_cast<RooArgSet*
>(sliceSetTmp->
Clone()) :
nullptr};
1801 const char* sliceCatState =
pc.getString(
"sliceCatState",0,
true) ;
1802 const RooLinkedList& sliceCatList =
pc.getObjectList(
"sliceCatList") ;
1803 if (sliceCatState) {
1807 sliceSet = std::make_unique<RooArgSet>();
1812 auto iter = sliceCatList.
begin();
1813 for (
unsigned int i=0; i < catTokens.size(); ++i) {
1814 if (
auto scat =
static_cast<RooCategory*
>(*iter)) {
1816 scat->setLabel(catTokens[i]) ;
1818 sliceSet->add(*scat,
false) ;
1826 Int_t vlines =
pc.getInt(
"VLines");
1827 if (
pc.hasProcessed(
"Range")) {
1831 if (vlines==2) vlines=0 ;
1832 }
else if (
pc.hasProcessed(
"RangeWithName")) {
1837 if (vlines==2) vlines=0 ;
1842 if (
pc.hasProcessed(
"NormRange")) {
1863 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << std::endl ;
1868 for (
const auto sliceArg : *sliceSet) {
1871 projectedVars.
remove(*arg) ;
1874 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
1877 }
else if (projSet) {
1878 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << std::endl ;
1881 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << std::endl ;
1886 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << std::endl ;
1899 Int_t lineColor =
pc.getInt(
"lineColor") ;
1900 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
1901 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
1902 Int_t markerColor =
pc.getInt(
"markerColor") ;
1903 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
1904 Size_t markerSize =
pc.getDouble(
"markerSize") ;
1905 Int_t fillColor =
pc.getInt(
"fillColor") ;
1906 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
1916 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1918 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1922 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
1961 projDataVars.
add(*tmp) ;
1969 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") ProjDataVars = " << projDataVars << std::endl ;
1984 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << sliceSetTmp << std::endl ;
1986 sliceSetTmp.
remove(projectedVars,
true,
true) ;
1991 sliceSetTmp.
remove(*tmp,
true,
true) ;
1994 if (!sliceSetTmp.
empty()) {
1996 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
1998 sliceSet.
add(sliceSetTmp) ;
2004 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << std::endl ;
2011 projectedVars.
remove(projDataVars,
true,
true) ;
2016 double oldPlotVarVal = plotVar->
getVal();
2019 if (projectedVars.
getSize()) {
2021 <<
" integrates over variables " << projectedVars
2024 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2026 <<
" averages using data variables " << *projDataNeededVars << std::endl ;
2034 deps.
remove(projectedVars,
true,
true) ;
2035 if (projDataNeededVars) {
2036 deps.
remove(*projDataNeededVars,
true,
true) ;
2038 deps.
remove(*plotVar,
true,
true) ;
2039 deps.
add(*plotVar) ;
2045 coutE(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
2046 if (projDataNeededVars)
delete projDataNeededVars ;
2058 fullNormSet.
add(projectedVars) ;
2059 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2060 fullNormSet.
add(*projDataNeededVars) ;
2063 std::unique_ptr<RooArgSet> projectionComponents(projection->
getComponents());
2064 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*projectionComponents)) {
2066 pdf->selectNormalization(&fullNormSet) ;
2071 if (o.
projData && projDataNeededVars && projDataNeededVars->
getSize()>0) {
2081 if (!sliceDataSet->empty()) {
2083 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2100 if (!cutString.
IsNull()) {
2102 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2107 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2116 if (!
dynamic_cast<RooCategory*
>(arg2)) allCat = false ;
2120 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2121 <<
" performing projection with binned copy for optimization." << std::endl ;
2129 if (projDataSel!=o.
projData)
delete projDataSel ;
2136 projection->
getVal(projDataSel->
get()) ;
2144 std::move(cfg),
true) ;
2198 if (projDataSel!=o.
projData)
delete projDataSel ;
2279 if (projDataNeededVars)
delete projDataNeededVars ;
2280 delete projectionCompList ;
2281 plotVar->setVal(oldPlotVarVal);
2301 projectedVars.
remove(*arg) ;
2304 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
2346 projDataVars.
add(*tmp) ;
2355 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << std::endl ;
2362 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << std::endl ;
2376 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2381 sliceSetTmp.
remove(*tmp,
true,
true) ;
2384 if (!sliceSetTmp.
empty()) {
2386 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
2388 sliceSet.
add(sliceSetTmp) ;
2399 projectedVars.
remove(projDataVars,
true,
true) ;
2412 if (projectedVars.
getSize()) {
2414 <<
" projects variables " << projectedVars << std::endl ;
2416 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2418 <<
" averages using data variables "<< *projDataNeededVars << std::endl ;
2426 asymNeg->setIndex(-1) ;
2432 custNeg.replaceArg(asymCat,*asymNeg) ;
2433 std::unique_ptr<RooAbsReal> funcPos{
static_cast<RooAbsReal*
>(custPos.build())};
2434 std::unique_ptr<RooAbsReal> funcNeg{
static_cast<RooAbsReal*
>(custNeg.build())};
2437 RooArgSet *posProjCompList, *negProjCompList ;
2443 depPos.
add(projDataVars) ;
2444 depNeg.
add(projDataVars) ;
2448 if (!posProj || !negProj) {
2449 coutE(
Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << std::endl ;
2455 asymName.
Append(
"_Asym[") ;
2459 asymTitle.
Append(
" Asymmetry of ") ;
2472 if (!sliceDataSet->
empty()) {
2474 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2490 delete sliceDataSet ;
2492 if (!cutString.
IsNull()) {
2495 <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2500 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2508 std::move(cfg),
true) ;
2514 ((
RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2515 ((
RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2526 TString curveName(funcAsym.GetName()) ;
2539 RooCurve *curve =
new RooCurve(funcAsym.GetName(),funcAsym.GetTitle(),scaleBind,
2549 if (projDataSel!=o.
projData)
delete projDataSel ;
2568 TString curveName(funcAsym.GetName()) ;
2584 delete posProjCompList ;
2585 delete negProjCompList ;
2615 for(
auto * rrvFitRes : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2617 auto rrvInAbsReal =
static_cast<RooRealVar const*
>(allParamsInAbsReal.
find(*rrvFitRes));
2627 if(!rrvInAbsReal)
continue;
2631 if(
std::abs(rrvInAbsReal->getVal() - rrvFitRes->getVal()) > 0.01 * rrvFitRes->getError()) {
2632 std::stringstream errMsg;
2633 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
2634 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
2636 throw std::runtime_error(errMsg.str());
2639 paramList.
add(*rrvInAbsReal);
2642 std::vector<double> plusVar;
2643 std::vector<double> minusVar;
2644 plusVar.reserve(paramList.
size());
2645 minusVar.reserve(paramList.
size());
2652 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2654 auto& rrv =
static_cast<RooRealVar&
>(paramList[ivar]);
2656 double cenVal = rrv.
getVal() ;
2657 double errVal =
sqrt(V(ivar,ivar)) ;
2660 rrv.setVal(cenVal+errVal) ;
2661 plusVar.push_back(
getVal(nset)) ;
2664 rrv.setVal(cenVal-errVal) ;
2665 minusVar.push_back(
getVal(nset)) ;
2667 rrv.setVal(cenVal) ;
2680 std::vector<double> errVec(paramList.
getSize()) ;
2681 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2683 for (
int j=i ; j<paramList.
getSize() ; j++) {
2691 for (
unsigned int j=0 ; j<plusVar.size() ; j++) {
2692 F[j] = (plusVar[j]-minusVar[j])/2 ;
2743 for (
auto * cmd : static_range_cast<RooCmdArg*>(plotArgListTmp)) {
2744 if (std::string(
"Normalization")==cmd->GetName()) {
2747 plotArgList.
Add(cmd) ;
2750 plotArgList.
Add(cmd) ;
2757 auto plotFunc = [&](
RooAbsReal const& absReal) {
2760 absReal.plotOn(frame, tmp);
2794 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2795 << errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << std::endl ;
2801 std::vector<RooCurve*> cvec ;
2802 for (
int i=0 ; i<
d->numEntries() ; i++) {
2803 cloneParams.
assign(*
d->get(i)) ;
2804 plotFunc(*cloneFunc);
2805 cvec.push_back(frame->
getCurve()) ;
2818 for (std::vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2836 for (
auto const* frv : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2838 fpf_stripped.
add(*frv);
2856 std::vector<int> fpf_idx ;
2860 paramList.
add(*par) ;
2861 fpf_idx.push_back(i) ;
2865 std::vector<RooCurve*> plusVar, minusVar ;
2874 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2878 double cenVal = rrv.
getVal() ;
2879 double errVal =
sqrt(V(ivar,ivar)) ;
2882 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal+Z*errVal) ;
2885 plotFunc(*cloneFunc);
2886 plusVar.push_back(frame->
getCurve()) ;
2891 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal-Z*errVal) ;
2892 plotFunc(*cloneFunc);
2893 minusVar.push_back(frame->
getCurve()) ;
2900 std::vector<double> errVec(paramList.
getSize()) ;
2901 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2902 errVec[i] =
sqrt(V(i,i)) ;
2903 for (
int j=i ; j<paramList.
getSize() ; j++) {
2904 C(i,j) = V(i,j)/
sqrt(V(i,i)*V(j,j)) ;
2914 for (std::vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2917 for (std::vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2924 if (!band)
return frame ;
2928 pc.defineString(
"drawOption",
"DrawOption",0,
"F") ;
2929 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
2930 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
2931 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
2932 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
2933 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
2934 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
2935 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
2936 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
2937 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
2938 pc.defineString(
"curveName",
"Name",0,
"") ;
2939 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
2940 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
2941 pc.allowUndefined() ;
2944 pc.process(argList) ;
2950 frame->
addPlotable(band,
pc.getString(
"drawOption"),
pc.getInt(
"curveInvisible")) ;
2953 Int_t lineColor =
pc.getInt(
"lineColor") ;
2954 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
2955 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
2956 Int_t markerColor =
pc.getInt(
"markerColor") ;
2957 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
2958 Size_t markerSize =
pc.getDouble(
"markerSize") ;
2959 Int_t fillColor =
pc.getInt(
"fillColor") ;
2960 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
2971 if (
pc.getString(
"curveName",0,
true)) {
2972 band->
SetName(
pc.getString(
"curveName",0,
true)) ;
2973 }
else if (
pc.getString(
"curveNameSuffix",0,
true)) {
2975 name.Append(
pc.getString(
"curveNameSuffix",0,
true)) ;
2980 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
3006 <<
":plotOn: frame does not specify a plot variable" << std::endl;
3020 << var->
GetName() << std::endl;
3038 RooArgSet& projectedVars,
bool silent)
const
3041 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << std::endl ;
3044 if (!allVars) return ;
3047 projectedVars.
add(*allVars) ;
3052 projectedVars.
remove(*found);
3055 std::unique_ptr<RooArgSet> plotServers{plotVar->
getObservables(&projectedVars)};
3060 <<
" from projection set because it a server of " << plotVar->
GetName() << std::endl ;
3061 projectedVars.
remove(*tmp) ;
3067 <<
") WARNING: cannot project out frame variable ("
3068 << found->
GetName() <<
"), ignoring" << std::endl ;
3075 projectedVars.
remove(*arg,
true) ;
3078 <<
") function doesn't depend on projection variable "
3079 << arg->GetName() <<
", ignoring" << std::endl ;
3117 if(binding && !binding->
isValid()) {
3134 auto other =
static_cast<const RooAbsReal*
>(source);
3135 assert(
dynamic_cast<const RooAbsReal*
>(source));
3137 _value = other->_treeReadBuffer ? other->_treeReadBuffer->operator
double() : other->_value;
3179 <<
" is an array and cannot be attached to a RooAbsReal" << std::endl ;
3189 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3190 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3191 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3192 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3193 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3194 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3195 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3196 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3197 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3198 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3199 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3202 auto typeDetails = typeMap.find(typeName.
Data());
3203 if (typeDetails != typeMap.end()) {
3205 <<
" will be converted to double precision." << std::endl ;
3215 coutE(
InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << std::endl ;
3375 const TList &nameList)
const
3378 bool isMatched(
true);
3379 for(
auto *
name : static_range_cast<TObjString*>(nameList)) {
3382 matched.
add(*found);
3396 if(isMatched) matchedArgs.
add(matched);
3445 if (config)
return config ;
3458 if (config)
return config ;
3558 static bool inLogEvalError = false ;
3560 if (inLogEvalError) {
3563 inLogEvalError = true ;
3568 if (serverValueString) {
3573 oocoutE(
nullptr,
Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << std::endl
3574 <<
" origin : " << origName << std::endl
3575 <<
" message : " << ee.
_msg << std::endl
3576 <<
" server values: " << ee.
_srvval << std::endl ;
3583 inLogEvalError = false ;
3613 static bool inLogEvalError = false ;
3615 if (inLogEvalError) {
3618 inLogEvalError = true ;
3623 if (serverValueString) {
3626 std::string srvval ;
3627 std::ostringstream oss ;
3638 p->print(oss,
true) ;
3643 std::ostringstream oss2 ;
3647 coutE(
Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << std::endl
3648 <<
" origin : " << oss2.str() << std::endl
3649 <<
" message : " << ee.
_msg << std::endl
3650 <<
" server values: " << ee.
_srvval << std::endl ;
3659 <<
") delayed evaluation error, " << std::endl
3660 <<
" origin : " << oss2.str() << std::endl
3661 <<
" message : " << oee.
_msg << std::endl
3662 <<
" server values: " << oee.
_srvval << std::endl ;
3669 inLogEvalError = false ;
3725 if (maxPerNode<0) return ;
3728 if (maxPerNode==0) {
3731 os << iter->second.first ;
3733 os <<
" has " << iter->second.second.size() <<
" errors" << std::endl ;
3738 os << iter->second.first << std::endl ;
3742 for(
auto iter2 = iter->second.second.begin();iter2!=iter->second.second.end() ; ++iter2, i++) {
3743 os <<
" " << iter2->_msg <<
" @ " << iter2->_srvval << std::endl ;
3745 os <<
" ... (remaining " << iter->second.second.size() - maxPerNode <<
" messages suppressed)" << std::endl ;
3766 ntot += elem.second.second.size() ;
3786 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3789 pdf->selectNormalization(&addNormSet,force) ;
3791 pdf->selectNormalization(0,force) ;
3811 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3813 pdf->selectNormalizationRange(rangeName,force) ;
3831 orderedObs.
add(obs) ;
3889 pc.defineSet(
"supNormSet",
"SupNormSet",0,0) ;
3890 pc.defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3891 pc.defineInt(
"intOrder",
"ScanParameters",1,2) ;
3892 pc.defineInt(
"doScanNum",
"ScanNum",0,1) ;
3893 pc.defineInt(
"doScanAll",
"ScanAll",0,0) ;
3894 pc.defineInt(
"doScanNon",
"ScanNone",0,0) ;
3895 pc.defineMutex(
"ScanNum",
"ScanAll",
"ScanNone") ;
3898 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3905 if (
const RooArgSet* snset =
pc.getSet(
"supNormSet",0)) {
3908 Int_t numScanBins =
pc.getInt(
"numScanBins") ;
3909 Int_t intOrder =
pc.getInt(
"intOrder") ;
3910 Int_t doScanNum =
pc.getInt(
"doScanNum") ;
3911 Int_t doScanAll =
pc.getInt(
"doScanAll") ;
3912 Int_t doScanNon =
pc.getInt(
"doScanNon") ;
3923 Int_t isNum= (tmp->numIntRealVars().size()==1) ;
3926 coutI(
NumIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << std::endl
3927 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3928 << intOrder <<
" interpolation on integrated histogram." << std::endl
3929 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << std::endl ;
3947 ivar->
setBins(numScanBins,
"numcdf") ;
3968 coutW(
InputArguments) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << std::endl ;
3982 for(
auto * rrv : static_range_cast<RooRealVar*>(ilist)) {
3986 cloneList.
add(*cloneArg) ;
3991 cloneLo->
setVal(rrv->getMin()) ;
3992 loList.
add(*cloneLo) ;
4004 finalNset.
add(cloneList,
true) ;
4024 if (realObs.
size() != obs.
size()) {
4025 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
4030 if (realPars.
size() != pars.
size()) {
4031 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4049 if (realObs.
size() != obs.
size()) {
4050 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
4055 if (realPars.
size() != pars.
size()) {
4056 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4061 for (
int i=0 ; i<obs.
getSize() ; i++) {
4067 for (
int i=0 ; i<pars.
getSize() ; i++) {
4101 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << std::endl ;
4106 for (
int i=0 ; i<pars.
getSize() ; i++) {
4136 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
4151 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4153 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
4154 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
4170 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4172 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
4173 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
4174 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4253 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"Range,RangeWithName,NumCPU,Optimize,IntegrateBins") ;
4281 return new RooChi2Var(
name.c_str(),
name.c_str(),*
this,
data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4297 for(
auto * arg : static_range_cast<RooCmdArg*>(cmdList)) {
4304 return createChi2(
data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4368 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"YVar,Integrate") ;
4370 std::unique_ptr<RooAbsReal> xychi2{
createChi2(xydata,chi2CmdList)};
4415 pc.defineInt(
"integrate",
"Integrate",0,0) ;
4416 pc.defineObject(
"yvar",
"YVar",0,0) ;
4419 pc.process(cmdList) ;
4425 bool integrate =
pc.getInt(
"integrate") ;
4450 pc.defineInt(
"optConst",
"Optimize",0,1) ;
4451 pc.defineInt(
"verbose",
"Verbose",0,0) ;
4452 pc.defineInt(
"doSave",
"Save",0,0) ;
4453 pc.defineInt(
"doTimer",
"Timer",0,0) ;
4454 pc.defineInt(
"plevel",
"PrintLevel",0,1) ;
4455 pc.defineInt(
"strat",
"Strategy",0,1) ;
4456 pc.defineInt(
"initHesse",
"InitialHesse",0,0) ;
4457 pc.defineInt(
"hesse",
"Hesse",0,1) ;
4458 pc.defineInt(
"minos",
"Minos",0,0) ;
4459 pc.defineInt(
"ext",
"Extended",0,2) ;
4460 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
4461 pc.defineInt(
"doWarn",
"Warnings",0,1) ;
4462 pc.defineString(
"mintype",
"Minimizer",0,
"") ;
4463 pc.defineString(
"minalg",
"Minimizer",1,
"minuit") ;
4464 pc.defineSet(
"minosSet",
"Minos",0,
nullptr) ;
4467 pc.process(cmdList) ;
4473 const char* minType =
pc.getString(
"mintype",
"") ;
4474 const char* minAlg =
pc.getString(
"minalg",
"minuit") ;
4475 Int_t optConst =
pc.getInt(
"optConst") ;
4477 Int_t doSave =
pc.getInt(
"doSave") ;
4478 Int_t doTimer =
pc.getInt(
"doTimer") ;
4479 Int_t plevel =
pc.getInt(
"plevel") ;
4480 Int_t strat =
pc.getInt(
"strat") ;
4481 Int_t initHesse=
pc.getInt(
"initHesse") ;
4482 Int_t hesse =
pc.getInt(
"hesse") ;
4483 Int_t minos =
pc.getInt(
"minos") ;
4484 Int_t numee =
pc.getInt(
"numee") ;
4485 Int_t doWarn =
pc.getInt(
"doWarn") ;
4486 const RooArgSet* minosSet =
pc.getSet(
"minosSet");
4492 m.setMinimizerType(minType);
4498 m.setPrintEvalErrors(numee) ;
4500 m.setPrintLevel(plevel) ;
4505 m.optimizeConst(optConst);
4519 m.setStrategy(strat) ;
4528 m.minimize(minType, minAlg) ;
4538 m.minos(*minosSet) ;
4547 std::string title =
Form(
"Result of fit of %s ",
GetName()) ;
4548 ret =
m.save(
name.c_str(),title.c_str()) ;
4585 for (
auto const* arg : paramVars) {
4588 <<
") function does not depend on std::listed parameter " << arg->GetName() <<
", ignoring" << std::endl ;
4591 if (plist.size()>0) plist +=
":" ;
4592 plist += arg->GetName() ;
4631 std::vector<ServerData> ourServers;
4632 std::size_t dataSize = 1;
4634 for (
auto absArgServer :
servers()) {
4635 if (absArgServer->IsA()->InheritsFrom(
RooAbsReal::Class()) && absArgServer->isValueServer(*
this)) {
4636 auto server =
static_cast<RooAbsReal*
>(absArgServer);
4637 ourServers.push_back({server,
4638 server->getValues(evalData, normSet),
4639 server->getVal(normSet),
4640 server->operMode()});
4643 dataSize = std::max(dataSize, ourServers.back().batch.size());
4649 struct RestoreStateRAII {
4650 RestoreStateRAII(std::vector<ServerData>&
servers) :
4653 ~RestoreStateRAII() {
4654 for (
auto& serverData : _servers) {
4655 serverData.server->setCachedValue(serverData.oldValue,
true);
4656 serverData.server->setOperMode(serverData.oldOperMode);
4660 std::vector<ServerData>& _servers;
4661 } restoreState{ourServers};
4668 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4673 auto outputData = evalData.
makeBatch(
this, dataSize);
4675 for (std::size_t i=0; i < outputData.size(); ++i) {
4676 for (
auto& serv : ourServers) {
4677 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4703 std::vector<ServerData> ourServers;
4706 for (
auto server :
servers()) {
4707 auto serverValues = dataMap.
at(server);
4708 if(serverValues.empty())
continue;
4711 auto oldOperMode = server->operMode();
4716 ourServers.push_back({server,
4720 server->_valueDirty,
4721 server->_shapeDirty});
4727 struct RestoreStateRAII {
4728 RestoreStateRAII(std::vector<ServerData>&
servers) :
4731 ~RestoreStateRAII() {
4732 for (
auto& serverData : _servers) {
4733 serverData.server->setCachedValue(serverData.oldValue,
true);
4734 serverData.server->setOperMode(serverData.oldOperMode);
4735 serverData.server->_valueDirty = serverData.oldValueDirty;
4736 serverData.server->_shapeDirty = serverData.oldShapeDirty;
4740 std::vector<ServerData>& _servers;
4741 } restoreState{ourServers};
4748 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4754 for (std::size_t i=0; i < nEvents; ++i) {
4755 for (
auto& serv : ourServers) {
4756 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4768 const bool tmpFast =
_fast;
4769 const double tmp =
_value;
4771 double fullEval = 0.;
4773 fullEval =
getValV(normalisationSet);
4782 if (std::isfinite(ret) && ( ret != 0. ? (ret - fullEval)/ret : ret - fullEval) > 1.E-9) {
4787 formatter <<
"--> (Scalar computation wrong here:)\n"
4788 <<
GetName() <<
" " <<
this <<
" _fast=" << tmpFast
4789 <<
"\n\tcached _value=" << std::setprecision(16) << tmp
4790 <<
"\n\treturning =" << ret
4791 <<
"\n\trecomputed =" << fullEval
4792 <<
"\n\tnew _value =" <<
_value <<
"] ";
4793 formatter <<
"\nServers:";