35 #include <sys/types.h>
115 using namespace std ;
144 RooAbsArg(
name,title), _plotMin(0), _plotMax(0), _plotBins(100),
145 _value(0), _unit(unit), _forceNumInt(
kFALSE), _specIntegratorConfig(0), _selectComp(
kTRUE), _lastNSet(0)
158 Double_t inMaxVal,
const char *unit) :
159 RooAbsArg(
name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _plotBins(100),
160 _value(0), _unit(unit), _forceNumInt(
kFALSE), _specIntegratorConfig(0), _selectComp(
kTRUE), _lastNSet(0)
173 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
174 _forceNumInt(other._forceNumInt), _selectComp(other._selectComp), _lastNSet(0)
179 _specIntegratorConfig = 0 ;
225 return (
getVal()==value) ;
245 if (!assumeSameType) {
261 if(appendUnit && 0 != strlen(
getUnit())) {
313 auto item = evalData.
spans.find(
this);
314 if (item != evalData.
spans.end()) {
367 <<
"): validation failed: " << value << endl ;
387 const RooArgSet* ,
const char* rangeName)
const
418 if (code==0)
return getVal(normSet) ;
432 coutF(
Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << endl ;
493 os <<
indent <<
"--- RooAbsReal ---" << endl;
581 pc.defineString(
"rangeName",
"RangeWithName",0,
"",
kTRUE) ;
582 pc.defineObject(
"normSet",
"NormSet",0,0) ;
583 pc.defineObject(
"numIntConfig",
"NumIntConfig",0,0) ;
586 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
592 const char* rangeName =
pc.getString(
"rangeName",0,
kTRUE) ;
617 if (!rangeName || strchr(rangeName,
',')==0) {
627 for (
const std::string& token : tokens) {
629 components.
add(*compIntegral);
633 title.
Prepend(
"Integral of ") ;
661 title.
Prepend(
"Integral of ") ;
686 title.
Prepend(
"Integral of ") ;
695 if (integrand !=
this) {
703 if (integrand ==
this && iset.
getSize()>0) {
704 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 ;
708 integrand = integral ;
716 coutE(
Integration) <<
GetName() <<
" : ERROR while defining recursive integral over observables with parameterized integration ranges, please check that integration rangs specify uniquely defined integral " << endl;
725 if (cacheParamsStr && strlen(cacheParamsStr)) {
733 if (cacheParams->
getSize()>0) {
735 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << *cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << endl ;
745 integral = cachedIntegral ;
776 for (
const auto aarg : allObs) {
789 obsWithParamRange.
add(*aarg) ;
790 obsWithFixedRange.
remove(*aarg) ;
791 obsServingAsRangeParams.
add(*loBoundObs,
kFALSE) ;
792 obsServingAsRangeParams.
add(*hiBoundObs,
kFALSE) ;
801 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
802 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
805 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
806 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
810 innerObs.
add(obsWithFixedRangeNP) ;
811 innerObs.
add(obsWithParamRangeNP) ;
828 name.Append(
"_Int[") ;
843 name.Append(rangeName) ;
846 }
else if (!omitEmpty) {
847 name.Append(
"_Int[]") ;
850 if (nset && nset->
getSize()>0 ) {
855 name.Append(
"_Norm[") ;
942 for (
const auto arg : dependentVars) {
943 if(!arg->isFundamental() && !
dynamic_cast<const RooAbsLValue*
>(arg)) {
945 <<
"\" of wrong type: " << arg->ClassName() << endl;
952 <<
"\" is not a dependent and will be ignored." << endl;
957 leafNodes.
replace(*found,*arg);
959 leafNodes.
add(*arg) ;
962 RooArgSet* lvDep = arg->getObservables(&leafNodes) ;
963 for (
const auto lvs : *lvDep) {
967 leafNodes.
add(*lvs) ;
974 if(0 != projectedVars && projectedVars->
find(arg->GetName())) {
976 <<
"\" cannot be both a dependent and a projected variable." << endl;
982 if(0 != projectedVars) leafNodes.
remove(*projectedVars,
kTRUE);
987 coutE(
Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << endl ;
1000 delete plotLeafNodes ;
1004 if(0 != projectedVars) normSet.
add(*projectedVars);
1013 if(0 == projectedVars) projectedVars= ∅
1019 title.
Prepend(
"Projection of ");
1024 if(0 == projected || !projected->
isValid()) {
1028 if(0 != projected)
delete projected;
1033 static_cast<RooRealIntegral*
>(projected)->setAllowComponentSelection(
true);
1076 if(hdim != plotVars.
getSize()) {
1085 for(
Int_t index= 0; index < plotVars.
getSize(); index++) {
1090 <<
"\" of type " << var->
ClassName() << endl;
1095 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << endl;
1111 if (projectedVars) {
1112 allDeps.
add(*projectedVars) ;
1138 assert(0 != zvar && 0 != zaxis);
1139 if (scaleForDensity) {
1147 assert(0 != yvar && 0 != yaxis);
1148 if (scaleForDensity) {
1156 assert(0 != xvar && 0 != xaxis);
1157 if (scaleForDensity) {
1163 << hdim <<
" dimensions" << endl;
1170 Int_t xbin(0),ybin(0),zbin(0);
1172 for(
Int_t bin= 0; bin < bins; bin++) {
1175 if(bin % (
xbins*ybins) == 0) {
1181 if(bin %
xbins == 0) {
1182 ybin= (ybin%ybins) + 1;
1187 xbin= (xbin%
xbins) + 1;
1197 coutW(
Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1270 if (showProgress && (i%onePct==0)) {
1274 Double_t binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1275 if (correctForBinSize) {
1278 hist->
set(i, binVal, 0.);
1307 strlcpy(buf,varNameList,1024) ;
1308 char* varName = strtok(buf,
",:") ;
1313 varName = strtok(0,
",") ;
1315 varName = strtok(0,
",") ;
1407 pc.defineInt(
"scaling",
"Scaling",0,1) ;
1408 pc.defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1409 pc.defineInt(
"extended",
"Extended",0,2) ;
1411 pc.defineObject(
"compSet",
"SelectCompSet",0) ;
1412 pc.defineString(
"compSpec",
"SelectCompSpec",0) ;
1413 pc.defineSet(
"projObs",
"ProjectedObservables",0,0) ;
1414 pc.defineObject(
"yvar",
"YVar",0,0) ;
1415 pc.defineObject(
"zvar",
"ZVar",0,0) ;
1416 pc.defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1417 pc.defineMutex(
"IntrinsicBinning",
"Binning") ;
1418 pc.defineMutex(
"IntrinsicBinning",
"BinningName") ;
1419 pc.defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1420 pc.allowUndefined() ;
1423 pc.process(argList) ;
1441 Bool_t doScaling =
pc.getInt(
"scaling") ;
1442 Int_t doIntBinning =
pc.getInt(
"intBinning") ;
1443 Int_t doExtended =
pc.getInt(
"extended") ;
1447 if (!pdfSelf && doExtended>0) {
1448 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << endl ;
1452 coutW(
InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << endl ;
1455 if (pdfSelf && doExtended==2) {
1459 const char* compSpec =
pc.getString(
"compSpec") ;
1461 Bool_t haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1464 if (doIntBinning>0) {
1469 if (doIntBinning==1) {
1471 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< endl ;
1474 if (doIntBinning==2) {
1476 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< endl ;
1479 for (list<double>::iterator it=bl->begin() ; it!=bl->end() ; ++it) { ba[i++] = *it ; }
1480 intBinning =
new RooBinning(bl->size()-1,ba) ;
1486 pc.stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1491 argListCreate.
Add(&tmp) ;
1510 branchNodeSet.
remove(*arg) ;
1521 if (dirSelNodes->
getSize()>0) {
1522 coutI(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << endl ;
1528 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << endl ;
1530 coutE(
Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << endl ;
1534 delete dirSelNodes ;
1570 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1571 const auto arg = branchNodeSet[i];
1573 branchNodeSet.
remove(*arg) ;
1580 for (
const auto arg : branchNodeSet) {
1589 for (
const auto arg : branchNodeSet) {
1590 for (
const auto selNode : *selNodes) {
1591 if (selNode->dependsOn(*arg)) {
1598 for (
const auto arg : branchNodeSet) {
1599 if (arg->dependsOn(*selNodes)) {
1604 tmp.
remove(*selNodes,
true);
1607 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << endl ;
1610 for (
const auto arg : branchNodeSet) {
1611 Bool_t select = selNodes->
find(arg->GetName()) !=
nullptr;
1759 argList.
Add(&rnorm) ;
1761 std::vector<string> rlist;
1765 rlist.emplace_back(rangeNameToken);
1768 for (
const auto& rangeString : rlist) {
1770 rcmd->
setString(0, rangeString.c_str());
1779 pc.defineString(
"drawOption",
"DrawOption",0,
"L") ;
1780 pc.defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
kTRUE) ;
1781 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1782 pc.defineString(
"sliceCatState",
"SliceCat",0,
"",
kTRUE) ;
1783 pc.defineDouble(
"scaleFactor",
"Normalization",0,1.0) ;
1784 pc.defineInt(
"scaleType",
"Normalization",0,
Relative) ;
1785 pc.defineObject(
"sliceSet",
"SliceVars",0) ;
1786 pc.defineObject(
"sliceCatList",
"SliceCat",0,0,
kTRUE) ;
1787 pc.defineObject(
"projSet",
"Project",0) ;
1788 pc.defineObject(
"asymCat",
"Asymmetry",0) ;
1789 pc.defineDouble(
"precision",
"Precision",0,1
e-3) ;
1790 pc.defineDouble(
"evalErrorVal",
"EvalErrorValue",0,0) ;
1791 pc.defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1792 pc.defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1793 pc.defineObject(
"projDataSet",
"ProjData",0) ;
1794 pc.defineObject(
"projData",
"ProjData",1) ;
1795 pc.defineObject(
"errorFR",
"VisualizeError",0) ;
1796 pc.defineDouble(
"errorZ",
"VisualizeError",0,1.) ;
1797 pc.defineSet(
"errorPars",
"VisualizeError",0) ;
1798 pc.defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1799 pc.defineInt(
"binProjData",
"ProjData",0,0) ;
1800 pc.defineDouble(
"rangeLo",
"Range",0,-999.) ;
1801 pc.defineDouble(
"rangeHi",
"Range",1,-999.) ;
1802 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1803 pc.defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1804 pc.defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1805 pc.defineInt(
"VLines",
"VLines",0,2) ;
1806 pc.defineString(
"rangeName",
"RangeWithName",0,
"") ;
1807 pc.defineString(
"normRangeName",
"NormRange",0,
"") ;
1808 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1809 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1810 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
1811 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
1812 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1813 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1814 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
1815 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1816 pc.defineString(
"curveName",
"Name",0,
"") ;
1817 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
1818 pc.defineInt(
"showProg",
"ShowProgress",0,0) ;
1819 pc.defineInt(
"numCPU",
"NumCPU",0,1) ;
1820 pc.defineInt(
"interleave",
"NumCPU",1,0) ;
1821 pc.defineString(
"addToCurveName",
"AddTo",0,
"") ;
1822 pc.defineDouble(
"addToWgtSelf",
"AddTo",0,1.) ;
1823 pc.defineDouble(
"addToWgtOther",
"AddTo",1,1.) ;
1824 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1825 pc.defineMutex(
"SliceVars",
"Project") ;
1826 pc.defineMutex(
"AddTo",
"Asymmetry") ;
1827 pc.defineMutex(
"Range",
"RangeWithName") ;
1828 pc.defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1831 pc.process(argList) ;
1837 TString drawOpt(
pc.getString(
"drawOption"));
1842 Bool_t linMethod =
pc.getInt(
"linearMethod") ;
1843 if (!drawOpt.
Contains(
"P") && errFR) {
1850 o.
numee =
pc.getInt(
"numee") ;
1860 o.
eeval =
pc.getDouble(
"evalErrorVal") ;
1870 const char* sliceCatState =
pc.getString(
"sliceCatState",0,
kTRUE) ;
1871 const RooLinkedList& sliceCatList =
pc.getObjectList(
"sliceCatList") ;
1872 if (sliceCatState) {
1881 std::unique_ptr<TIterator> iter( sliceCatList.
MakeIterator() );
1882 for (
unsigned int i=0; i < catTokens.size(); ++i) {
1883 auto scat =
static_cast<RooCategory*
>(iter->Next());
1895 Int_t vlines =
pc.getInt(
"VLines");
1896 if (
pc.hasProcessed(
"Range")) {
1900 if (vlines==2) vlines=0 ;
1901 }
else if (
pc.hasProcessed(
"RangeWithName")) {
1906 if (vlines==2) vlines=0 ;
1911 if (
pc.hasProcessed(
"NormRange")) {
1932 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << endl ;
1937 for (
const auto sliceArg : *sliceSet) {
1940 projectedVars.
remove(*arg) ;
1943 << sliceArg->GetName() <<
" was not projected anyway" << endl ;
1946 }
else if (projSet) {
1947 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << endl ;
1950 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << endl ;
1955 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << endl ;
1970 Int_t lineColor =
pc.getInt(
"lineColor") ;
1971 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
1972 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
1973 Int_t markerColor =
pc.getInt(
"markerColor") ;
1974 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
1975 Size_t markerSize =
pc.getDouble(
"markerSize") ;
1976 Int_t fillColor =
pc.getInt(
"fillColor") ;
1977 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
1987 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1989 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1993 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
2032 projDataVars.
add(*tmp) ;
2055 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << *sliceSetTmp << endl ;
2068 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << *sliceSetTmp << endl ;
2070 sliceSet.
add(*sliceSetTmp) ;
2071 delete sliceSetTmp ;
2077 cxcoutD(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << endl ;
2090 if (!plotCloneSet) {
2091 coutE(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Couldn't deep-clone self, abort," << endl ;
2097 if (projectedVars.
getSize()) {
2099 <<
" integrates over variables " << projectedVars
2102 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2104 <<
" averages using data variables " << *projDataNeededVars << endl ;
2112 if (projDataNeededVars) {
2116 deps->
add(*plotVar) ;
2122 coutE(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << endl ;
2124 delete plotCloneSet ;
2125 if (projDataNeededVars)
delete projDataNeededVars ;
2140 fullNormSet.
add(projectedVars) ;
2141 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2142 fullNormSet.
add(*projDataNeededVars) ;
2158 if (o.
projData && projDataNeededVars && projDataNeededVars->
getSize()>0) {
2168 if (sliceDataSet->
getSize()>0) {
2189 delete sliceDataSet ;
2191 if (!cutString.
IsNull()) {
2193 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << endl ;
2198 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2214 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2215 <<
" performing projection with binned copy for optimization." << endl ;
2223 if (projDataSel!=o.
projData)
delete projDataSel ;
2230 projection->
getVal(projDataSel->
get()) ;
2288 if (projDataSel!=o.
projData)
delete projDataSel ;
2371 if (projDataNeededVars)
delete projDataNeededVars ;
2373 delete projectionCompList ;
2374 delete plotCloneSet ;
2396 projectedVars.
remove(*arg) ;
2399 << sliceArg->
GetName() <<
" was not projected anyway" << endl ;
2442 projDataVars.
add(*tmp) ;
2452 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << endl ;
2459 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << endl ;
2483 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << *sliceSetTmp << endl ;
2485 sliceSet.
add(*sliceSetTmp) ;
2486 delete sliceSetTmp ;
2510 if (projectedVars.
getSize()) {
2512 <<
" projects variables " << projectedVars << endl ;
2514 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2516 <<
" averages using data variables "<< *projDataNeededVars << endl ;
2535 RooArgSet *posProjCompList, *negProjCompList ;
2541 depPos.
add(projDataVars) ;
2542 depNeg.
add(projDataVars) ;
2546 if (!posProj || !negProj) {
2547 coutE(
Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << endl ;
2553 asymName.
Append(
"_Asym[") ;
2557 asymTitle.
Append(
" Asymmetry of ") ;
2570 if (sliceDataSet->
getSize()>0) {
2591 delete sliceDataSet ;
2593 if (!cutString.
IsNull()) {
2596 <<
") reducing given projection dataset to entries with " << cutString << endl ;
2601 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << endl ;
2611 ((
RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2612 ((
RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2646 if (projDataSel!=o.
projData)
delete projDataSel ;
2685 delete posProjCompList ;
2686 delete negProjCompList ;
2720 fpf_stripped.
add(*frv);
2734 vector<int> fpf_idx;
2738 paramList.
add(*par);
2739 fpf_idx.push_back(i);
2743 vector<Double_t> plusVar, minusVar ;
2750 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2758 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal+errVal) ;
2759 plusVar.push_back(cloneFunc->
getVal(nset)) ;
2762 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal-errVal) ;
2763 minusVar.push_back(cloneFunc->
getVal(nset)) ;
2769 vector<double> errVec(paramList.
getSize()) ;
2770 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2771 errVec[i] =
sqrt(V(i,i)) ;
2772 for (
int j=i ; j<paramList.
getSize() ; j++) {
2773 C(i,j) = V(i,j)/
sqrt(V(i,i)*V(j,j)) ;
2780 for (
unsigned int j=0 ; j<plusVar.size() ; j++) {
2781 F[j] = (plusVar[j]-minusVar[j])/2 ;
2788 delete errorParams ;
2840 pc.stripCmdList(plotArgListTmp,
"VisualizeError,MoveToBack") ;
2847 if (std::string(
"Normalization")==cmd->
GetName()) {
2850 plotArgList.
Add(cmd) ;
2853 plotArgList.
Add(cmd) ;
2884 coutI(
Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2885 << *errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << endl ;
2891 vector<RooCurve*> cvec ;
2892 for (
int i=0 ; i<
d->numEntries() ; i++) {
2893 *cloneParams = (*
d->get(i)) ;
2895 cloneFunc->
plotOn(frame,tmp2) ;
2896 cvec.push_back(frame->
getCurve()) ;
2909 for (vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2931 fpf_stripped.
add(*frv);
2944 vector<int> fpf_idx ;
2948 paramList.add(*par) ;
2949 fpf_idx.push_back(i) ;
2953 vector<RooCurve*> plusVar, minusVar ;
2962 for (
Int_t ivar=0 ; ivar<paramList.getSize() ; ivar++) {
2970 ((
RooRealVar*)paramList.at(ivar))->setVal(cenVal+Z*errVal) ;
2974 cloneFunc->
plotOn(frame,tmp2) ;
2975 plusVar.push_back(frame->
getCurve()) ;
2980 ((
RooRealVar*)paramList.at(ivar))->setVal(cenVal-Z*errVal) ;
2982 cloneFunc->
plotOn(frame,tmp3) ;
2983 minusVar.push_back(frame->
getCurve()) ;
2986 ((
RooRealVar*)paramList.at(ivar))->setVal(cenVal) ;
2990 vector<double> errVec(paramList.getSize()) ;
2991 for (
int i=0 ; i<paramList.getSize() ; i++) {
2992 errVec[i] =
sqrt(V(i,i)) ;
2993 for (
int j=i ; j<paramList.getSize() ; j++) {
2994 C(i,j) = V(i,j)/
sqrt(V(i,i)*V(j,j)) ;
3004 for (vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
3007 for (vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
3014 if (!band)
return frame ;
3017 pc.defineString(
"drawOption",
"DrawOption",0,
"F") ;
3018 pc.defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
3019 pc.defineInt(
"lineColor",
"LineColor",0,-999) ;
3020 pc.defineInt(
"lineStyle",
"LineStyle",0,-999) ;
3021 pc.defineInt(
"lineWidth",
"LineWidth",0,-999) ;
3022 pc.defineInt(
"markerColor",
"MarkerColor",0,-999) ;
3023 pc.defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
3024 pc.defineDouble(
"markerSize",
"MarkerSize",0,-999) ;
3025 pc.defineInt(
"fillColor",
"FillColor",0,-999) ;
3026 pc.defineInt(
"fillStyle",
"FillStyle",0,-999) ;
3027 pc.defineString(
"curveName",
"Name",0,
"") ;
3028 pc.defineInt(
"curveInvisible",
"Invisible",0,0) ;
3029 pc.defineInt(
"moveToBack",
"MoveToBack",0,0) ;
3030 pc.allowUndefined() ;
3033 pc.process(argList) ;
3039 frame->
addPlotable(band,
pc.getString(
"drawOption"),
pc.getInt(
"curveInvisible")) ;
3042 Int_t lineColor =
pc.getInt(
"lineColor") ;
3043 Int_t lineStyle =
pc.getInt(
"lineStyle") ;
3044 Int_t lineWidth =
pc.getInt(
"lineWidth") ;
3045 Int_t markerColor =
pc.getInt(
"markerColor") ;
3046 Int_t markerStyle =
pc.getInt(
"markerStyle") ;
3047 Size_t markerSize =
pc.getDouble(
"markerSize") ;
3048 Int_t fillColor =
pc.getInt(
"fillColor") ;
3049 Int_t fillStyle =
pc.getInt(
"fillStyle") ;
3060 if (
pc.getString(
"curveName",0,
kTRUE)) {
3062 }
else if (
pc.getString(
"curveNameSuffix",0,
kTRUE)) {
3064 name.Append(
pc.getString(
"curveNameSuffix",0,
kTRUE)) ;
3069 if (
pc.getInt(
"moveToBack") && frame->
numItems()>1) {
3095 <<
":plotOn: frame does not specify a plot variable" << endl;
3130 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << endl ;
3133 if (!allVars) return ;
3136 projectedVars.
add(*allVars) ;
3141 projectedVars.
remove(*found);
3151 <<
" from projection set because it a server of " << plotVar->
GetName() << endl ;
3152 projectedVars.
remove(*tmp) ;
3156 delete plotServers ;
3160 <<
") WARNING: cannot project out frame variable ("
3161 << found->
GetName() <<
"), ignoring" << endl ;
3173 <<
") function doesn't depend on projection variable "
3174 << arg->
GetName() <<
", ignoring" << endl ;
3213 if(binding && !binding->
isValid()) {
3223 struct TreeReadBuffer {
3224 virtual ~TreeReadBuffer() =
default;
3225 virtual operator double() = 0;
3236 auto other =
static_cast<const RooAbsReal*
>(source);
3237 assert(
dynamic_cast<const RooAbsReal*
>(source));
3239 _value = other->_treeReadBuffer ? other->_treeReadBuffer->operator
double() : other->_value;
3259 template<
typename T>
3260 struct TypedTreeReadBuffer final :
public TreeReadBuffer {
3261 operator double()
override {
3271 template<
typename T>
3272 std::unique_ptr<TreeReadBuffer> createTreeReadBuffer(
const TString& branchName,
TTree&
tree) {
3273 auto buf =
new TypedTreeReadBuffer<T>();
3274 tree.SetBranchAddress(branchName.
Data(), &buf->_value);
3275 return std::unique_ptr<TreeReadBuffer>(buf);
3306 <<
" is an array and cannot be attached to a RooAbsReal" << endl ;
3316 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3317 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3318 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3319 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3320 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3321 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3322 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3323 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3324 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3325 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3326 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3329 auto typeDetails = typeMap.find(typeName.
Data());
3330 if (typeDetails != typeMap.end()) {
3332 <<
" will be converted to double precision." << endl ;
3342 coutE(
InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << endl ;
3505 const TList &nameList)
const
3514 matched.
add(*found);
3528 if(isMatched) matchedArgs.
add(matched);
3577 if (config)
return config ;
3590 if (config)
return config ;
3692 if (inLogEvalError) {
3695 inLogEvalError =
kTRUE ;
3700 if (serverValueString) {
3705 oocoutE((
TObject*)0,
Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << endl
3706 <<
" origin : " << origName << endl
3707 <<
" message : " << ee.
_msg << endl
3708 <<
" server values: " << ee.
_srvval << endl ;
3715 inLogEvalError =
kFALSE ;
3747 if (inLogEvalError) {
3750 inLogEvalError =
kTRUE ;
3755 if (serverValueString) {
3775 ostringstream oss2 ;
3779 coutE(
Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << endl
3780 <<
" origin : " << oss2.str() << endl
3781 <<
" message : " << ee.
_msg << endl
3782 <<
" server values: " << ee.
_srvval << endl ;
3791 <<
") delayed evaluation error, " << endl
3792 <<
" origin : " << oss2.str() << endl
3793 <<
" message : " << oee.
_msg << endl
3794 <<
" server values: " << oee.
_srvval << endl ;
3801 inLogEvalError =
kFALSE ;
3857 if (maxPerNode<0) return ;
3859 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter =
_evalErrorList.begin() ;
3862 if (maxPerNode==0) {
3865 os << iter->second.first ;
3867 os <<
" has " << iter->second.second.size() <<
" errors" << endl ;
3872 os << iter->second.first << endl ;
3876 std::list<EvalError>::iterator iter2 = iter->second.second.begin() ;
3877 for(;iter2!=iter->second.second.end() ; ++iter2, i++) {
3878 os <<
" " << iter2->_msg <<
" @ " << iter2->_srvval << endl ;
3880 os <<
" ... (remaining " << iter->second.second.size() - maxPerNode <<
" messages suppressed)" << endl ;
3900 map<const RooAbsArg*,pair<string,list<EvalError> > >::iterator iter =
_evalErrorList.begin() ;
3902 ntot += iter->second.second.size() ;
3977 orderedObs.
add(obs) ;
4035 pc.defineObject(
"supNormSet",
"SupNormSet",0,0) ;
4036 pc.defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
4037 pc.defineInt(
"intOrder",
"ScanParameters",1,2) ;
4038 pc.defineInt(
"doScanNum",
"ScanNum",0,1) ;
4039 pc.defineInt(
"doScanAll",
"ScanAll",0,0) ;
4040 pc.defineInt(
"doScanNon",
"ScanNone",0,0) ;
4041 pc.defineMutex(
"ScanNum",
"ScanAll",
"ScanNone") ;
4044 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4055 Int_t numScanBins =
pc.getInt(
"numScanBins") ;
4056 Int_t intOrder =
pc.getInt(
"intOrder") ;
4057 Int_t doScanNum =
pc.getInt(
"doScanNum") ;
4058 Int_t doScanAll =
pc.getInt(
"doScanAll") ;
4059 Int_t doScanNon =
pc.getInt(
"doScanNon") ;
4074 coutI(
NumIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << endl
4075 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
4076 << intOrder <<
" interpolation on integrated histogram." << endl
4077 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
4095 ivar->
setBins(numScanBins,
"numcdf") ;
4139 cloneList.
add(*cloneArg) ;
4145 loList.
add(*cloneLo) ;
4178 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4184 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4205 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << endl ;
4211 coutE(
InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << endl ;
4219 for (
int i=0 ; i<obs.
getSize() ; i++) {
4225 for (
int i=0 ; i<pars.
getSize() ; i++) {
4259 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << endl ;
4264 for (
int i=0 ; i<pars.
getSize() ; i++) {
4294 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
4309 string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4311 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
4312 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
4328 string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4330 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
4331 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
4332 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4433 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"Range,RangeWithName,NumCPU,Optimize,IntegrateBins") ;
4467 return new RooChi2Var(
name.c_str(),
name.c_str(),*
this,data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4492 return createChi2(data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4558 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"YVar,Integrate") ;
4607 pc.defineInt(
"integrate",
"Integrate",0,0) ;
4608 pc.defineObject(
"yvar",
"YVar",0,0) ;
4611 pc.process(cmdList) ;
4617 Bool_t integrate =
pc.getInt(
"integrate") ;
4642 pc.defineString(
"fitOpt",
"FitOptions",0,
"") ;
4644 pc.defineInt(
"optConst",
"Optimize",0,1) ;
4645 pc.defineInt(
"verbose",
"Verbose",0,0) ;
4646 pc.defineInt(
"doSave",
"Save",0,0) ;
4647 pc.defineInt(
"doTimer",
"Timer",0,0) ;
4648 pc.defineInt(
"plevel",
"PrintLevel",0,1) ;
4649 pc.defineInt(
"strat",
"Strategy",0,1) ;
4650 pc.defineInt(
"initHesse",
"InitialHesse",0,0) ;
4651 pc.defineInt(
"hesse",
"Hesse",0,1) ;
4652 pc.defineInt(
"minos",
"Minos",0,0) ;
4653 pc.defineInt(
"ext",
"Extended",0,2) ;
4654 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
4655 pc.defineInt(
"doWarn",
"Warnings",0,1) ;
4656 pc.defineString(
"mintype",
"Minimizer",0,
"Minuit") ;
4657 pc.defineString(
"minalg",
"Minimizer",1,
"minuit") ;
4658 pc.defineObject(
"minosSet",
"Minos",0,0) ;
4660 pc.defineMutex(
"FitOptions",
"Verbose") ;
4661 pc.defineMutex(
"FitOptions",
"Save") ;
4662 pc.defineMutex(
"FitOptions",
"Timer") ;
4663 pc.defineMutex(
"FitOptions",
"Strategy") ;
4664 pc.defineMutex(
"FitOptions",
"InitialHesse") ;
4665 pc.defineMutex(
"FitOptions",
"Hesse") ;
4666 pc.defineMutex(
"FitOptions",
"Minos") ;
4669 pc.process(cmdList) ;
4675 const char* fitOpt =
pc.getString(
"fitOpt",0,
kTRUE) ;
4676 #ifdef __ROOFIT_NOROOMINIMIZER
4677 const char* minType =0 ;
4679 const char* minType =
pc.getString(
"mintype",
"Minuit") ;
4680 const char* minAlg =
pc.getString(
"minalg",
"minuit") ;
4682 Int_t optConst =
pc.getInt(
"optConst") ;
4684 Int_t doSave =
pc.getInt(
"doSave") ;
4685 Int_t doTimer =
pc.getInt(
"doTimer") ;
4686 Int_t plevel =
pc.getInt(
"plevel") ;
4687 Int_t strat =
pc.getInt(
"strat") ;
4688 Int_t initHesse=
pc.getInt(
"initHesse") ;
4689 Int_t hesse =
pc.getInt(
"hesse") ;
4690 Int_t minos =
pc.getInt(
"minos") ;
4691 Int_t numee =
pc.getInt(
"numee") ;
4692 Int_t doWarn =
pc.getInt(
"doWarn") ;
4697 #ifdef __ROOFIT_NOROOMINIMIZER
4700 if (
"OldMinuit" ==
string(minType)) {
4709 m.setPrintEvalErrors(numee) ;
4711 m.setPrintLevel(plevel) ;
4716 m.optimizeConst(optConst);
4722 ret =
m.fit(fitOpt) ;
4737 m.setStrategy(strat) ;
4756 m.minos(*minosSet) ;
4765 string title =
Form(
"Result of fit of %s ",
GetName()) ;
4766 ret =
m.save(
name.c_str(),title.c_str()) ;
4771 #ifndef __ROOFIT_NOROOMINIMIZER
4774 m.setMinimizerType(minType);
4780 m.setPrintEvalErrors(numee) ;
4782 m.setPrintLevel(plevel) ;
4787 m.optimizeConst(optConst);
4793 ret =
m.fit(fitOpt) ;
4808 m.setStrategy(strat) ;
4817 m.minimize(minType, minAlg) ;
4827 m.minos(*minosSet) ;
4836 string title =
Form(
"Result of fit of %s ",
GetName()) ;
4837 ret =
m.save(
name.c_str(),title.c_str()) ;
4879 while((arg=iter.
next())) {
4882 <<
") function does not depend on listed parameter " << arg->
GetName() <<
", ignoring" << endl ;
4885 if (plist.size()>0) plist +=
":" ;
4917 coutI(
FastEvaluations) <<
"The class " << IsA()->GetName() <<
" does not implement the faster batch evaluation interface."
4918 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4925 std::vector<RooAbsRealLValue*> settableLeaves;
4926 std::vector<RooSpan<const double>> leafValues;
4927 std::vector<double> oldLeafValues;
4929 for (
auto item : allLeafs) {
4935 settableLeaves.push_back(leaf);
4936 oldLeafValues.push_back(leaf->getVal());
4938 auto knownLeaf = evalData.
spans.find(leaf);
4939 if (knownLeaf != evalData.
spans.end()) {
4941 leafValues.push_back(knownLeaf->second);
4943 auto result = leaf->getValues(evalData, normSet);
4944 leafValues.push_back(result);
4949 for (
auto& i:leafValues) {
4950 dataSize=std::max(dataSize, i.size());
4952 auto outputData = evalData.
makeBatch(
this, dataSize);
4962 for (std::size_t i=0; i < outputData.size(); ++i) {
4963 for (
unsigned int j=0; j < settableLeaves.size(); ++j) {
4964 if (leafValues[j].size() > i)
4965 settableLeaves[j]->setVal(leafValues[j][i], evalData.
rangeName);
4973 for (
unsigned int j=0; j < settableLeaves.size(); ++j) {
4974 settableLeaves[j]->setVal(oldLeafValues[j]);
4984 const bool tmpFast =
_fast;
4985 const double tmp =
_value;
4987 double fullEval = 0.;
4989 fullEval =
getValV(normalisationSet);
4998 if (std::isfinite(ret) && ( ret != 0. ? (ret - fullEval)/ret : ret - fullEval) > 1.E-9) {
5003 formatter <<
"--> (Scalar computation wrong here:)\n"
5004 <<
GetName() <<
" " <<
this <<
" _fast=" << tmpFast
5005 <<
"\n\tcached _value=" << std::setprecision(16) << tmp
5006 <<
"\n\treturning =" << ret
5007 <<
"\n\trecomputed =" << fullEval
5008 <<
"\n\tnew _value =" <<
_value <<
"] ";
5009 formatter <<
"\nServers:";
5035 auto realServer =
dynamic_cast<RooAbsReal*
>(server);
5044 const auto item = evalData.
spans.find(
this);
5045 if (item == evalData.
spans.end())
5048 auto batch = item->second;
5049 const double value =
getVal(normSet);
5050 const double batchVal = batch.size() == 1 ? batch[0] : batch[evtNo];
5051 const double relDiff = value != 0. ? (value - batchVal)/value : value - batchVal;
5053 if (
fabs(relDiff) > relAccuracy &&
fabs(value) > 1.E-300) {
5055 formatter <<
"--> (Batch computation wrong:)\n";
5057 formatter <<
"\n batch=" << batch.data() <<
" size=" << batch.size() << std::setprecision(17)
5058 <<
"\n batch[" << std::setw(7) << evtNo-1 <<
"]= " << (evtNo > 0 && evtNo - 1 < batch.size() ? std::to_string(batch[evtNo-1]) :
"---")
5059 <<
"\n batch[" << std::setw(7) << evtNo <<
"]= " << batchVal <<
" !!!"
5060 <<
"\n expected ('value'): " << value
5061 <<
"\n eval(unnorm.) : " <<
evaluate()
5062 <<
"\n delta " <<
" = " << value - batchVal
5063 <<
"\n rel delta " <<
" = " << relDiff
5064 <<
"\n _batch[" << std::setw(7) << evtNo+1 <<
"]= " << (batch.size() > evtNo+1 ? std::to_string(batch[evtNo+1]) :
"---");
5068 formatter <<
"\nServers: ";
5070 formatter <<
"\n - ";
5072 formatter << std::setprecision(17);
5074 auto serverAsReal =
dynamic_cast<RooAbsReal*
>(server);
5077 if (serverBatch.size() > evtNo) {
5078 formatter <<
"\n _batch[" << evtNo-1 <<
"]=" << (serverBatch.size() > evtNo-1 ? std::to_string(serverBatch[evtNo-1]) :
"---")
5079 <<
"\n _batch[" << evtNo <<
"]=" << serverBatch[evtNo]
5080 <<
"\n _batch[" << evtNo+1 <<
"]=" << (serverBatch.size() > evtNo+1 ? std::to_string(serverBatch[evtNo+1]) :
"---");
5083 formatter << std::setprecision(17)
5084 <<
"\n getVal()=" << serverAsReal->getVal(normSet);