143 RooAbsArg(
name,title), _plotMin(0), _plotMax(0), _plotBins(100),
144 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
157 double inMaxVal,
const char *unit) :
158 RooAbsArg(
name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _plotBins(100),
159 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
171 RooAbsArg(other,
name), _plotMin(other._plotMin), _plotMax(other._plotMax),
172 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
173 _forceNumInt(other._forceNumInt), _selectComp(other._selectComp), _lastNSet(0)
244 if (!assumeSameType) {
260 if(appendUnit && 0 != strlen(
getUnit())) {
312 auto item = evalData.
spans.find(
this);
313 if (item != evalData.
spans.end()) {
319 std::map<RooFit::Detail::DataKey, RooSpan<const double>> dataSpans;
320 for (
auto const &evalDataItem : evalData.
spans) {
321 dataSpans[evalDataItem.first] = evalDataItem.second;
327 results = driver.getValues();
328 evalData.
spans[
this] = results;
372 <<
"): validation failed: " <<
value << endl ;
392 const RooArgSet* ,
const char* rangeName)
const
423 if (code==0)
return getVal(normSet) ;
437 coutF(
Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << endl ;
498 os <<
indent <<
"--- RooAbsReal ---" << endl;
516 for (
auto const& arg : paramsOfInterest) {
522 name.append(arg->GetName()) ;
561 pc.defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
562 pc.defineObject(
"normSet",
"NormSet",0,0) ;
563 pc.defineObject(
"numIntConfig",
"NumIntConfig",0,0) ;
566 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
572 const char* rangeName =
pc.getString(
"rangeName",0,
true) ;
597 if (!rangeName || strchr(rangeName,
',')==0) {
607 for (
const std::string& token : tokens) {
609 components.
add(*compIntegral);
613 title.
Prepend(
"Integral of ") ;
641 title.
Prepend(
"Integral of ") ;
659 if (innerSet.
empty()) {
666 title.
Prepend(
"Integral of ") ;
675 if (integrand !=
this) {
683 if (integrand ==
this && iset.
getSize()>0) {
684 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" << endl ;
688 integrand = integral ;
696 coutE(
Integration) <<
GetName() <<
" : ERROR while defining recursive integral over observables with parameterized integration ranges, please check that integration rangs specify uniquely defined integral " << endl;
705 if (cacheParamsStr && strlen(cacheParamsStr)) {
713 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << endl ;
723 integral = cachedIntegral ;
753 for (
const auto aarg : allObs) {
768 obsWithParamRange.
add(*aarg) ;
769 obsWithFixedRange.
remove(*aarg) ;
770 obsServingAsRangeParams.
add(loBoundObs,
false) ;
771 obsServingAsRangeParams.
add(hiBoundObs,
false) ;
778 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
779 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
782 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
783 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
787 innerObs.
add(obsWithFixedRangeNP) ;
788 innerObs.
add(obsWithParamRangeNP) ;
805 name.Append(
"_Int[") ;
813 name.Append(arg->GetName()) ;
817 name.Append(rangeName) ;
820 }
else if (!omitEmpty) {
821 name.Append(
"_Int[]") ;
824 if (nset && nset->
getSize()>0 ) {
829 name.Append(
"_Norm[") ;
837 name.Append(arg->GetName()) ;
899 for (
const auto arg : dependentVars) {
900 if(!arg->isFundamental() && !
dynamic_cast<const RooAbsLValue*
>(arg)) {
902 <<
"\" of wrong type: " << arg->ClassName() << endl;
909 <<
"\" is not a dependent and will be ignored." << endl;
914 leafNodes.
replace(*found,*arg);
916 leafNodes.
add(*arg) ;
920 arg->getObservables(&leafNodes, lvDep);
921 for (
const auto lvs : lvDep) {
925 leafNodes.
add(*lvs) ;
932 if(0 != projectedVars && projectedVars->
find(arg->GetName())) {
934 <<
"\" cannot be both a dependent and a projected variable." << endl;
940 if(0 != projectedVars) leafNodes.
remove(*projectedVars,
true);
945 coutE(
Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << endl ;
958 delete plotLeafNodes ;
962 if(0 != projectedVars) normSet.
add(*projectedVars);
964 normSet.
remove(*condObs,
true,
true) ;
971 if(0 == projectedVars) projectedVars= ∅
977 title.
Prepend(
"Projection of ");
982 if(0 == projected || !projected->
isValid()) {
986 if(0 != projected)
delete projected;
991 static_cast<RooRealIntegral*
>(projected)->setAllowComponentSelection(
true);
1023 double scaleFactor,
const RooArgSet *projectedVars,
bool scaleForDensity,
1024 const RooArgSet* condObs,
bool setError)
const
1034 if(hdim != plotVars.
getSize()) {
1048 <<
"\" of type " << var->
ClassName() << endl;
1053 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << endl;
1055 plotClones.
addClone(*realVar,
true);
1060 pc->recursiveRedirectServers(plotClones,
false,
false,
true) ;
1065 if (projectedVars) {
1066 allDeps.
add(*projectedVars) ;
1092 assert(0 != zvar && 0 != zaxis);
1093 if (scaleForDensity) {
1101 assert(0 != yvar && 0 != yaxis);
1102 if (scaleForDensity) {
1110 assert(0 != xvar && 0 != xaxis);
1111 if (scaleForDensity) {
1117 << hdim <<
" dimensions" << endl;
1124 Int_t xbin(0),ybin(0),zbin(0);
1126 for(
Int_t bin= 0; bin < bins; bin++) {
1129 if(bin % (
xbins*ybins) == 0) {
1135 if(bin %
xbins == 0) {
1136 ybin= (ybin%ybins) + 1;
1141 xbin= (xbin%
xbins) + 1;
1151 coutW(
Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1196 bool correctForBinSize,
bool showProgress)
const
1224 if (showProgress && (i%onePct==0)) {
1228 double binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1229 if (correctForBinSize) {
1232 hist->
set(i, binVal, 0.);
1261 strlcpy(buf,varNameList,1024) ;
1262 char* varName = strtok(buf,
",:") ;
1267 varName = strtok(0,
",") ;
1269 varName = strtok(0,
",") ;
1362 pc.defineInt(
"scaling",
"Scaling",0,1) ;
1363 pc.defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1364 pc.defineInt(
"extended",
"Extended",0,2) ;
1366 pc.defineObject(
"compSet",
"SelectCompSet",0) ;
1367 pc.defineString(
"compSpec",
"SelectCompSpec",0) ;
1368 pc.defineObject(
"projObs",
"ProjectedObservables",0,0) ;
1369 pc.defineObject(
"yvar",
"YVar",0,0) ;
1370 pc.defineObject(
"zvar",
"ZVar",0,0) ;
1371 pc.defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1372 pc.defineMutex(
"IntrinsicBinning",
"Binning") ;
1373 pc.defineMutex(
"IntrinsicBinning",
"BinningName") ;
1374 pc.defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1375 pc.allowUndefined() ;
1378 pc.process(argList) ;
1393 auto projObs =
static_cast<RooArgSet*
>(
pc.getObject(
"projObs")) ;
1396 bool doScaling =
pc.getInt(
"scaling") ;
1397 Int_t doIntBinning =
pc.getInt(
"intBinning") ;
1398 Int_t doExtended =
pc.getInt(
"extended") ;
1402 if (!pdfSelf && doExtended>0) {
1403 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << endl ;
1407 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << endl ;
1410 if (pdfSelf && doExtended==2) {
1414 const char* compSpec =
pc.getString(
"compSpec") ;
1416 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1419 if (doIntBinning>0) {
1424 if (doIntBinning==1) {
1426 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< endl ;
1429 if (doIntBinning==2) {
1431 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< endl ;
1433 double* ba =
new double[bl->size()] ;
int i=0 ;
1434 for (list<double>::iterator it=bl->begin() ; it!=bl->end() ; ++it) { ba[i++] = *it ; }
1435 intBinning =
new RooBinning(bl->size()-1,ba) ;
1441 pc.stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1446 argListCreate.
Add(&tmp) ;
1463 branchNodeSet.
remove(*arg) ;
1467 std::unique_ptr<RooArgSet> dirSelNodes;
1473 if (!dirSelNodes->empty()) {
1474 coutI(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << endl ;
1480 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << endl ;
1482 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << endl ;
1488 double scaleFactor(1.0) ;
1494 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,
false) ;
1521 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1522 const auto arg = branchNodeSet[i];
1524 branchNodeSet.
remove(*arg) ;
1531 for (
const auto arg : branchNodeSet) {
1540 for (
const auto arg : branchNodeSet) {
1541 for (
const auto selNode : *selNodes) {
1542 if (selNode->dependsOn(*arg)) {
1549 for (
const auto arg : branchNodeSet) {
1550 if (arg->dependsOn(*selNodes)) {
1555 tmp.
remove(*selNodes,
true);
1558 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << endl ;
1561 for (
const auto arg : branchNodeSet) {
1562 bool select = selNodes->
find(arg->GetName()) !=
nullptr;
1716 argList.
Add(&rnorm) ;
1718 std::vector<string> rlist;
1722 rlist.emplace_back(rangeNameToken);
1725 for (
const auto& rangeString : rlist) {
1727 rcmd->
setString(0, rangeString.c_str());
1736 pc.defineString(
"drawOption",
"DrawOption",0,
"L") ;
1737 pc.defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
true) ;
1738 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1739 pc.defineString(
"sliceCatState",
"SliceCat",0,
"",
true) ;
1740 pc.defineDouble(
"scaleFactor",
"Normalization",0,1.0) ;
1741 pc.defineInt(
"scaleType",
"Normalization",0,
Relative) ;
1742 pc.defineObject(
"sliceSet",
"SliceVars",0) ;
1743 pc.defineObject(
"sliceCatList",
"SliceCat",0,0,
true) ;
1747 pc.defineObject(
"dummy1",
"SliceCatMany",0) ;
1748 pc.defineObject(
"projSet",
"Project",0) ;
1749 pc.defineObject(
"asymCat",
"Asymmetry",0) ;
1750 pc.defineDouble(
"precision",
"Precision",0,1
e-3) ;
1751 pc.defineDouble(
"evalErrorVal",
"EvalErrorValue",0,0) ;
1752 pc.defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1753 pc.defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1754 pc.defineObject(
"projDataSet",
"ProjData",0) ;
1755 pc.defineObject(
"projData",
"ProjData",1) ;
1756 pc.defineObject(
"errorFR",
"VisualizeError",0) ;
1757 pc.defineDouble(
"errorZ",
"VisualizeError",0,1.) ;
1758 pc.defineSet(
"errorPars",
"VisualizeError",0) ;
1759 pc.defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1760 pc.defineInt(
"binProjData",
"ProjData",0,0) ;
1761 pc.defineDouble(
"rangeLo",
"Range",0,-999.) ;
1762 pc.defineDouble(
"rangeHi",
"Range",1,-999.) ;
1763 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1764 pc.defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1765 pc.defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1766 pc.defineInt(
"VLines",
"VLines",0,2) ;
1767 pc.defineString(
"rangeName",
"RangeWithName",0,
"") ;
1768 pc.defineString(
"normRangeName",
"NormRange",0,
"") ;
1769 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1770 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1771 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
1772 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
1773 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1774 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1775 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
1776 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1777 pc.defineString(
"curveName",
"Name",0,
"") ;
1778 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
1779 pc.defineInt(
"showProg",
"ShowProgress",0,0) ;
1780 pc.defineInt(
"numCPU",
"NumCPU",0,1) ;
1781 pc.defineInt(
"interleave",
"NumCPU",1,0) ;
1782 pc.defineString(
"addToCurveName",
"AddTo",0,
"") ;
1783 pc.defineDouble(
"addToWgtSelf",
"AddTo",0,1.) ;
1784 pc.defineDouble(
"addToWgtOther",
"AddTo",1,1.) ;
1785 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1786 pc.defineMutex(
"SliceVars",
"Project") ;
1787 pc.defineMutex(
"AddTo",
"Asymmetry") ;
1788 pc.defineMutex(
"Range",
"RangeWithName") ;
1789 pc.defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1792 pc.process(argList) ;
1798 TString drawOpt(
pc.getString(
"drawOption"));
1801 double errZ =
pc.getDouble(
"errorZ") ;
1803 bool linMethod =
pc.getInt(
"linearMethod") ;
1804 if (!drawOpt.
Contains(
"P") && errFR) {
1811 o.
numee =
pc.getInt(
"numee") ;
1821 o.
eeval =
pc.getDouble(
"evalErrorVal") ;
1831 const char* sliceCatState =
pc.getString(
"sliceCatState",0,
true) ;
1832 const RooLinkedList& sliceCatList =
pc.getObjectList(
"sliceCatList") ;
1833 if (sliceCatState) {
1842 auto iter = sliceCatList.
begin();
1843 for (
unsigned int i=0; i < catTokens.size(); ++i) {
1844 if (
auto scat =
static_cast<RooCategory*
>(*iter)) {
1846 scat->setLabel(catTokens[i]) ;
1848 sliceSet->
add(*scat,
false) ;
1856 Int_t vlines =
pc.getInt(
"VLines");
1857 if (
pc.hasProcessed(
"Range")) {
1861 if (vlines==2) vlines=0 ;
1862 }
else if (
pc.hasProcessed(
"RangeWithName")) {
1867 if (vlines==2) vlines=0 ;
1872 if (
pc.hasProcessed(
"NormRange")) {
1893 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << endl ;
1898 for (
const auto sliceArg : *sliceSet) {
1901 projectedVars.
remove(*arg) ;
1904 << sliceArg->GetName() <<
" was not projected anyway" << endl ;
1907 }
else if (projSet) {
1908 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << endl ;
1911 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << endl ;
1916 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << endl ;
1931 Int_t lineColor =
pc.getInt(
"lineColor") ;
1932 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
1933 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
1934 Int_t markerColor =
pc.getInt(
"markerColor") ;
1935 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
1936 Size_t markerSize =
pc.getDouble(
"markerSize") ;
1937 Int_t fillColor =
pc.getInt(
"fillColor") ;
1938 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
1948 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1950 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1954 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
1993 projDataVars.
add(*tmp) ;
2017 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << sliceSetTmp << endl ;
2019 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2024 sliceSetTmp.
remove(*tmp,
true,
true) ;
2028 if (!sliceSetTmp.
empty()) {
2030 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << endl ;
2032 sliceSet.
add(sliceSetTmp) ;
2038 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << endl ;
2045 projectedVars.
remove(projDataVars,
true,
true) ;
2051 if (!plotCloneSet) {
2052 coutE(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Couldn't deep-clone self, abort," << endl ;
2058 if (projectedVars.
getSize()) {
2060 <<
" integrates over variables " << projectedVars
2063 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2065 <<
" averages using data variables " << *projDataNeededVars << endl ;
2073 deps.
remove(projectedVars,
true,
true) ;
2074 if (projDataNeededVars) {
2075 deps.
remove(*projDataNeededVars,
true,
true) ;
2077 deps.
remove(*plotVar,
true,
true) ;
2078 deps.
add(*plotVar) ;
2084 coutE(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << endl ;
2085 delete plotCloneSet ;
2086 if (projDataNeededVars)
delete projDataNeededVars ;
2101 fullNormSet.
add(projectedVars) ;
2102 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2103 fullNormSet.
add(*projDataNeededVars) ;
2106 std::unique_ptr<RooArgSet> projectionComponents(projection->
getComponents());
2107 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*projectionComponents)) {
2109 pdf->selectNormalization(&fullNormSet) ;
2114 if (o.
projData && projDataNeededVars && projDataNeededVars->
getSize()>0) {
2124 if (!sliceDataSet->empty()) {
2126 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2143 if (!cutString.
IsNull()) {
2145 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << endl ;
2150 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2159 if (!
dynamic_cast<RooCategory*
>(arg2)) allCat = false ;
2163 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2164 <<
" performing projection with binned copy for optimization." << endl ;
2172 if (projDataSel!=o.
projData)
delete projDataSel ;
2179 projection->
getVal(projDataSel->
get()) ;
2187 std::move(cfg),
true) ;
2241 if (projDataSel!=o.
projData)
delete projDataSel ;
2324 if (projDataNeededVars)
delete projDataNeededVars ;
2325 delete projectionCompList ;
2326 delete plotCloneSet ;
2346 projectedVars.
remove(*arg) ;
2349 << sliceArg->GetName() <<
" was not projected anyway" << endl ;
2391 projDataVars.
add(*tmp) ;
2401 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << endl ;
2408 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << endl ;
2422 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2427 sliceSetTmp.
remove(*tmp,
true,
true) ;
2431 if (!sliceSetTmp.
empty()) {
2433 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << endl ;
2435 sliceSet.
add(sliceSetTmp) ;
2446 projectedVars.
remove(projDataVars,
true,
true) ;
2459 if (projectedVars.
getSize()) {
2461 <<
" projects variables " << projectedVars << endl ;
2463 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2465 <<
" averages using data variables "<< *projDataNeededVars << endl ;
2484 RooArgSet *posProjCompList, *negProjCompList ;
2490 depPos.
add(projDataVars) ;
2491 depNeg.
add(projDataVars) ;
2495 if (!posProj || !negProj) {
2496 coutE(
Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << endl ;
2502 asymName.
Append(
"_Asym[") ;
2506 asymTitle.
Append(
" Asymmetry of ") ;
2519 if (!sliceDataSet->
empty()) {
2521 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2537 delete sliceDataSet ;
2539 if (!cutString.
IsNull()) {
2542 <<
") reducing given projection dataset to entries with " << cutString << endl ;
2547 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2555 std::move(cfg),
true) ;
2561 ((
RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2562 ((
RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2596 if (projDataSel!=o.
projData)
delete projDataSel ;
2635 delete posProjCompList ;
2636 delete negProjCompList ;
2670 for(
auto * rrvInFitResult : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2671 if (rrvInFitResult->getError() > 1
e-20) {
2672 auto * rrvInAbsReal =
static_cast<RooRealVar*
>(allParamsInAbsReal.
find(*rrvInFitResult));
2674 if(rrvInAbsReal->getVal() != rrvInFitResult->getVal()) {
2675 throw std::runtime_error(
2676 std::string(
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have") +
2677 "the same values as in the fit result! The logic of getPropagatedError is broken in this case.");
2680 paramList.
add(*rrvInAbsReal);
2684 std::vector<double> plusVar, minusVar ;
2685 plusVar.reserve(paramList.
size());
2686 minusVar.reserve(paramList.
size());
2693 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2695 auto& rrv =
static_cast<RooRealVar&
>(paramList[ivar]);
2697 double cenVal = rrv.
getVal() ;
2698 double errVal =
sqrt(V(ivar,ivar)) ;
2701 rrv.setVal(cenVal+errVal) ;
2702 plusVar.push_back(
getVal(nset)) ;
2705 rrv.setVal(cenVal-errVal) ;
2706 minusVar.push_back(
getVal(nset)) ;
2708 rrv.setVal(cenVal) ;
2721 vector<double> errVec(paramList.
getSize()) ;
2722 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2723 errVec[i] =
sqrt(V(i,i)) ;
2724 for (
int j=i ; j<paramList.
getSize() ; j++) {
2725 C(i,j) = V(i,j)/
sqrt(V(i,i)*V(j,j)) ;
2732 for (
unsigned int j=0 ; j<plusVar.size() ; j++) {
2733 F[j] = (plusVar[j]-minusVar[j])/2 ;
2788 pc.stripCmdList(plotArgListTmp,
"VisualizeError,MoveToBack") ;
2792 for (
auto * cmd : static_range_cast<RooCmdArg*>(plotArgListTmp)) {
2793 if (std::string(
"Normalization")==cmd->GetName()) {
2796 plotArgList.
Add(cmd) ;
2799 plotArgList.
Add(cmd) ;
2835 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2836 << errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << endl ;
2842 vector<RooCurve*> cvec ;
2843 for (
int i=0 ; i<
d->numEntries() ; i++) {
2844 cloneParams.
assign(*
d->get(i)) ;
2846 cloneFunc->
plotOn(frame,tmp2) ;
2847 cvec.push_back(frame->
getCurve()) ;
2860 for (vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2882 fpf_stripped.
add(*frv);
2900 vector<int> fpf_idx ;
2904 paramList.
add(*par) ;
2905 fpf_idx.push_back(i) ;
2909 vector<RooCurve*> plusVar, minusVar ;
2918 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2922 double cenVal = rrv.
getVal() ;
2923 double errVal =
sqrt(V(ivar,ivar)) ;
2926 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal+Z*errVal) ;
2930 cloneFunc->
plotOn(frame,tmp2) ;
2931 plusVar.push_back(frame->
getCurve()) ;
2936 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal-Z*errVal) ;
2938 cloneFunc->
plotOn(frame,tmp3) ;
2939 minusVar.push_back(frame->
getCurve()) ;
2946 vector<double> errVec(paramList.
getSize()) ;
2947 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2948 errVec[i] =
sqrt(V(i,i)) ;
2949 for (
int j=i ; j<paramList.
getSize() ; j++) {
2950 C(i,j) = V(i,j)/
sqrt(V(i,i)*V(j,j)) ;
2960 for (vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2963 for (vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2970 if (!band)
return frame ;
2973 pc.defineString(
"drawOption",
"DrawOption",0,
"F") ;
2974 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
2975 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
2976 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
2977 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
2978 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
2979 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
2980 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
2981 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
2982 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
2983 pc.defineString(
"curveName",
"Name",0,
"") ;
2984 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
2985 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
2986 pc.allowUndefined() ;
2989 pc.process(argList) ;
2995 frame->
addPlotable(band,
pc.getString(
"drawOption"),
pc.getInt(
"curveInvisible")) ;
2998 Int_t lineColor =
pc.getInt(
"lineColor") ;
2999 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
3000 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
3001 Int_t markerColor =
pc.getInt(
"markerColor") ;
3002 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
3003 Size_t markerSize =
pc.getDouble(
"markerSize") ;
3004 Int_t fillColor =
pc.getInt(
"fillColor") ;
3005 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
3016 if (
pc.getString(
"curveName",0,
true)) {
3017 band->
SetName(
pc.getString(
"curveName",0,
true)) ;
3018 }
else if (
pc.getString(
"curveNameSuffix",0,
true)) {
3020 name.Append(
pc.getString(
"curveNameSuffix",0,
true)) ;
3025 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
3051 <<
":plotOn: frame does not specify a plot variable" << endl;
3083 RooArgSet& projectedVars,
bool silent)
const
3086 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << endl ;
3089 if (!allVars) return ;
3092 projectedVars.
add(*allVars) ;
3097 projectedVars.
remove(*found);
3100 std::unique_ptr<RooArgSet> plotServers{plotVar->
getObservables(&projectedVars)};
3105 <<
" from projection set because it a server of " << plotVar->
GetName() << endl ;
3106 projectedVars.
remove(*tmp) ;
3112 <<
") WARNING: cannot project out frame variable ("
3113 << found->
GetName() <<
"), ignoring" << endl ;
3120 projectedVars.
remove(*arg,
true) ;
3123 <<
") function doesn't depend on projection variable "
3124 << arg->GetName() <<
", ignoring" << endl ;
3162 if(binding && !binding->
isValid()) {
3179 auto other =
static_cast<const RooAbsReal*
>(source);
3180 assert(
dynamic_cast<const RooAbsReal*
>(source));
3224 <<
" is an array and cannot be attached to a RooAbsReal" << endl ;
3234 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3235 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3236 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3237 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3238 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3239 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3240 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3241 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3242 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3243 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3244 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3247 auto typeDetails = typeMap.find(typeName.
Data());
3248 if (typeDetails != typeMap.end()) {
3250 <<
" will be converted to double precision." << endl ;
3260 coutE(
InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << endl ;
3420 const TList &nameList)
const
3425 bool isMatched(
true);
3429 matched.
add(*found);
3443 if(isMatched) matchedArgs.
add(matched);
3492 if (config)
return config ;
3505 if (config)
return config ;
3605 static bool inLogEvalError = false ;
3607 if (inLogEvalError) {
3610 inLogEvalError = true ;
3615 if (serverValueString) {
3620 oocoutE(
nullptr,
Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << endl
3621 <<
" origin : " << origName << endl
3622 <<
" message : " << ee.
_msg << endl
3623 <<
" server values: " << ee.
_srvval << endl ;
3630 inLogEvalError = false ;
3660 static bool inLogEvalError = false ;
3662 if (inLogEvalError) {
3665 inLogEvalError = true ;
3670 if (serverValueString) {
3685 p->print(oss,
true) ;
3690 ostringstream oss2 ;
3694 coutE(
Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << endl
3695 <<
" origin : " << oss2.str() << endl
3696 <<
" message : " << ee.
_msg << endl
3697 <<
" server values: " << ee.
_srvval << endl ;
3706 <<
") delayed evaluation error, " << endl
3707 <<
" origin : " << oss2.str() << endl
3708 <<
" message : " << oee.
_msg << endl
3709 <<
" server values: " << oee.
_srvval << endl ;
3716 inLogEvalError = false ;
3772 if (maxPerNode<0) return ;
3774 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter =
_evalErrorList.begin() ;
3777 if (maxPerNode==0) {
3780 os << iter->second.first ;
3782 os <<
" has " << iter->second.second.size() <<
" errors" << endl ;
3787 os << iter->second.first << endl ;
3791 std::list<EvalError>::iterator iter2 = iter->second.second.begin() ;
3792 for(;iter2!=iter->second.second.end() ; ++iter2, i++) {
3793 os <<
" " << iter2->_msg <<
" @ " << iter2->_srvval << endl ;
3795 os <<
" ... (remaining " << iter->second.second.size() - maxPerNode <<
" messages suppressed)" << endl ;
3815 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter =
_evalErrorList.begin() ;
3817 ntot += iter->second.second.size() ;
3837 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3840 pdf->selectNormalization(&addNormSet,force) ;
3842 pdf->selectNormalization(0,force) ;
3862 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3864 pdf->selectNormalizationRange(rangeName,force) ;
3882 orderedObs.
add(obs) ;
3940 pc.defineObject(
"supNormSet",
"SupNormSet",0,0) ;
3941 pc.defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3942 pc.defineInt(
"intOrder",
"ScanParameters",1,2) ;
3943 pc.defineInt(
"doScanNum",
"ScanNum",0,1) ;
3944 pc.defineInt(
"doScanAll",
"ScanAll",0,0) ;
3945 pc.defineInt(
"doScanNon",
"ScanNone",0,0) ;
3946 pc.defineMutex(
"ScanNum",
"ScanAll",
"ScanNone") ;
3949 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3960 Int_t numScanBins =
pc.getInt(
"numScanBins") ;
3961 Int_t intOrder =
pc.getInt(
"intOrder") ;
3962 Int_t doScanNum =
pc.getInt(
"doScanNum") ;
3963 Int_t doScanAll =
pc.getInt(
"doScanAll") ;
3964 Int_t doScanNon =
pc.getInt(
"doScanNon") ;
3979 coutI(
NumIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << endl
3980 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3981 << intOrder <<
" interpolation on integrated histogram." << endl
3982 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
4000 ivar->
setBins(numScanBins,
"numcdf") ;
4021 coutW(
InputArguments) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << endl ;
4035 for(
auto * rrv : static_range_cast<RooRealVar*>(ilist)) {
4039 cloneList.
add(*cloneArg) ;
4044 cloneLo->
setVal(rrv->getMin()) ;
4045 loList.
add(*cloneLo) ;
4057 finalNset.
add(cloneList,
true) ;
4077 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4083 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4104 if (realObs.
size() != obs.
size()) {
4105 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4110 if (realPars.
size() != pars.
size()) {
4111 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4116 for (
int i=0 ; i<obs.
getSize() ; i++) {
4122 for (
int i=0 ; i<pars.
getSize() ; i++) {
4156 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << endl ;
4161 for (
int i=0 ; i<pars.
getSize() ; i++) {
4191 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
4206 string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4208 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
4209 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
4225 string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4227 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
4228 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
4229 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4328 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"Range,RangeWithName,NumCPU,Optimize,IntegrateBins") ;
4364 return new RooChi2Var(
name.c_str(),
name.c_str(),*
this,
data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4390 return createChi2(
data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4454 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"YVar,Integrate") ;
4503 pc.defineInt(
"integrate",
"Integrate",0,0) ;
4504 pc.defineObject(
"yvar",
"YVar",0,0) ;
4507 pc.process(cmdList) ;
4513 bool integrate =
pc.getInt(
"integrate") ;
4538 pc.defineInt(
"optConst",
"Optimize",0,1) ;
4539 pc.defineInt(
"verbose",
"Verbose",0,0) ;
4540 pc.defineInt(
"doSave",
"Save",0,0) ;
4541 pc.defineInt(
"doTimer",
"Timer",0,0) ;
4542 pc.defineInt(
"plevel",
"PrintLevel",0,1) ;
4543 pc.defineInt(
"strat",
"Strategy",0,1) ;
4544 pc.defineInt(
"initHesse",
"InitialHesse",0,0) ;
4545 pc.defineInt(
"hesse",
"Hesse",0,1) ;
4546 pc.defineInt(
"minos",
"Minos",0,0) ;
4547 pc.defineInt(
"ext",
"Extended",0,2) ;
4548 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
4549 pc.defineInt(
"doWarn",
"Warnings",0,1) ;
4550 pc.defineString(
"mintype",
"Minimizer",0,
"") ;
4551 pc.defineString(
"minalg",
"Minimizer",1,
"minuit") ;
4552 pc.defineObject(
"minosSet",
"Minos",0,0) ;
4555 pc.process(cmdList) ;
4561 const char* minType =
pc.getString(
"mintype",
"") ;
4562 const char* minAlg =
pc.getString(
"minalg",
"minuit") ;
4563 Int_t optConst =
pc.getInt(
"optConst") ;
4565 Int_t doSave =
pc.getInt(
"doSave") ;
4566 Int_t doTimer =
pc.getInt(
"doTimer") ;
4567 Int_t plevel =
pc.getInt(
"plevel") ;
4568 Int_t strat =
pc.getInt(
"strat") ;
4569 Int_t initHesse=
pc.getInt(
"initHesse") ;
4570 Int_t hesse =
pc.getInt(
"hesse") ;
4571 Int_t minos =
pc.getInt(
"minos") ;
4572 Int_t numee =
pc.getInt(
"numee") ;
4573 Int_t doWarn =
pc.getInt(
"doWarn") ;
4580 m.setMinimizerType(minType);
4586 m.setPrintEvalErrors(numee) ;
4588 m.setPrintLevel(plevel) ;
4593 m.optimizeConst(optConst);
4607 m.setStrategy(strat) ;
4616 m.minimize(minType, minAlg) ;
4626 m.minos(*minosSet) ;
4635 string title =
Form(
"Result of fit of %s ",
GetName()) ;
4636 ret =
m.save(
name.c_str(),title.c_str()) ;
4675 while((arg=iter.
next())) {
4678 <<
") function does not depend on listed parameter " << arg->
GetName() <<
", ignoring" << endl ;
4681 if (plist.size()>0) plist +=
":" ;
4721 std::vector<ServerData> ourServers;
4722 std::size_t dataSize = 1;
4724 for (
auto absArgServer :
servers()) {
4725 if (absArgServer->IsA()->InheritsFrom(
RooAbsReal::Class()) && absArgServer->isValueServer(*
this)) {
4726 auto server =
static_cast<RooAbsReal*
>(absArgServer);
4727 ourServers.push_back({server,
4728 server->getValues(evalData, normSet),
4729 server->getVal(normSet),
4730 server->operMode()});
4733 dataSize = std::max(dataSize, ourServers.back().batch.size());
4739 struct RestoreStateRAII {
4740 RestoreStateRAII(std::vector<ServerData>&
servers) :
4743 ~RestoreStateRAII() {
4744 for (
auto& serverData : _servers) {
4745 serverData.server->setCachedValue(serverData.oldValue,
true);
4746 serverData.server->setOperMode(serverData.oldOperMode);
4750 std::vector<ServerData>& _servers;
4751 } restoreState{ourServers};
4758 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4763 auto outputData = evalData.
makeBatch(
this, dataSize);
4765 for (std::size_t i=0; i < outputData.size(); ++i) {
4766 for (
auto& serv : ourServers) {
4767 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4792 std::vector<ServerData> ourServers;
4795 for (
auto server :
servers()) {
4797 auto oldOperMode = server->operMode();
4802 ourServers.push_back({server,