102#include <sys/types.h>
108class ScaledDataWeightedAverage :
public RooAbsFunc {
110 ScaledDataWeightedAverage(RooAbsReal
const &arg, RooAbsData
const &data,
double scaleFactor, RooAbsRealLValue &var)
114 _arg->recursiveRedirectServers(RooArgList{var});
115 _evaluator = std::make_unique<RooFit::Evaluator>(*_arg);
116 std::stack<std::vector<double>>{}.swap(_vectorBuffers);
117 auto dataSpans = RooFit::BatchModeDataHelpers::getDataSpans(data,
"",
nullptr,
false,
120 for (
auto const& item : dataSpans) {
121 _evaluator->setInput(item.first->GetName(), item.second,
false);
125 double operator()(
const double xvector[])
const override
127 double oldVal = _var.getVal();
128 _var.setVal(xvector[0]);
131 std::span<const double> pdfValues = _evaluator->run();
132 if (_dataWeights.empty()) {
133 out = std::accumulate(pdfValues.begin(), pdfValues.end(), 0.0) / pdfValues.size();
135 double weightsSum = 0.0;
136 for (std::size_t i = 0; i < pdfValues.size(); ++i) {
137 out += pdfValues[i] * _dataWeights[i];
138 weightsSum += _dataWeights[i];
147 double getMinLimit(
UInt_t )
const override {
return _var.getMin(); }
148 double getMaxLimit(
UInt_t )
const override {
return _var.getMax(); }
151 RooAbsRealLValue &_var;
152 std::unique_ptr<RooAbsReal> _arg;
153 std::span<const double> _dataWeights;
155 std::unique_ptr<RooFit::Evaluator> _evaluator;
156 std::stack<std::vector<double>> _vectorBuffers;
159struct EvalErrorData {
160 using ErrorList = std::map<const RooAbsArg *, std::pair<std::string, std::list<RooAbsReal::EvalError>>>;
166EvalErrorData &evalErrorData()
168 static EvalErrorData data;
176 return evalErrorData().errorList.size();
181 return evalErrorData().errorList.begin();
211 double inMaxVal,
const char *unit) :
227 _specIntegratorConfig = std::make_unique<RooNumIntConfig>(*other._specIntegratorConfig) ;
249 return (
getVal()==value) ;
269 if (!assumeSameType) {
284 if(appendUnit && 0 != strlen(
getUnit())) {
329 <<
"): validation failed: " << value << std::endl ;
349 const RooArgSet* ,
const char* rangeName)
const
380 if (code==0)
return getVal(normSet) ;
394 coutF(Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << std::endl ;
455 os <<
indent <<
"--- RooAbsReal ---" << std::endl;
473 for (
auto const& arg : paramsOfInterest) {
484 auto out = std::make_unique<RooProfileLL>(
name.c_str(),(std::string(
"Profile of ") +
GetTitle()).c_str(),*
this,paramsOfInterest);
517 pc.
defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
518 pc.
defineSet(
"normSet",
"NormSet",0,
nullptr) ;
519 pc.
defineObject(
"numIntConfig",
"NumIntConfig",0,
nullptr) ;
522 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
528 const char* rangeName = pc.
getString(
"rangeName",
nullptr,
true) ;
553 if (!rangeName || strchr(rangeName,
',')==
nullptr) {
559 std::vector<std::string> tokens =
ROOT::Split(rangeName,
",");
562 std::stringstream errMsg;
563 errMsg <<
GetName() <<
" : integrating with respect to the variables " << iset <<
" on the ranges \"" << rangeName
564 <<
"\" is not possible because the ranges are overlapping";
565 const std::string errMsgString = errMsg.str();
566 coutE(Integration) << errMsgString << std::endl;
567 throw std::invalid_argument(errMsgString);
571 for (
const std::string& token : tokens) {
575 const std::string title = std::string(
"Integral of ") +
GetTitle();
578 auto out = std::make_unique<RooAddition>(fullName.c_str(), title.c_str(), components);
579 out->addOwnedComponents(std::move(components));
598 std::unique_ptr<RooAbsReal> integral;
603 const std::string title = std::string(
"Integral of ") +
GetTitle();
606 auto out = std::make_unique<RooRealIntegral>(
name.c_str(), title.c_str(), *
this, iset, nset, cfg, rangeName);
611 while(!iset.
empty()) {
620 if (innerSet.
empty()) {
626 const std::string title = std::string(
"Integral of ") + integrand->
GetTitle();
629 std::unique_ptr<RooAbsReal> innerIntegral = std::move(integral);
632 integral = std::make_unique<RooRealIntegral>(
name.c_str(),title.c_str(),*integrand,innerSet,nset,cfg,rangeName);
636 integral->addOwnedComponents(std::move(innerIntegral));
643 if (integrand ==
this && !iset.
empty()) {
644 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 ;
648 integrand = integral.get();
656 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;
663 if (cacheParamsStr && strlen(cacheParamsStr)) {
665 std::unique_ptr<RooArgSet> intParams{integral->getVariables()};
669 if (!cacheParams.
empty()) {
670 cxcoutD(Caching) <<
"RooAbsReal::createIntObj(" <<
GetName() <<
") INFO: constructing " << cacheParams.
size()
671 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << std::endl ;
672 std::string
name = std::string{integral->GetName()} +
"_CACHE_[" + cacheParams.
contentsString() +
"]";
673 auto cachedIntegral = std::make_unique<RooCachedReal>(
name.c_str(),
name.c_str(),*integral,cacheParams);
674 cachedIntegral->setInterpolationOrder(2) ;
675 cachedIntegral->addOwnedComponents(std::move(integral));
676 cachedIntegral->setCacheSource(
true) ;
677 if (integral->operMode()==
ADirty) {
678 cachedIntegral->setOperMode(
ADirty) ;
709 for (
const auto aarg : allObs) {
714 RooAbsBinning& binning = arglv->getBinning(rangeName,
false,
true) ;
723 obsWithParamRange.
add(*aarg) ;
724 obsWithFixedRange.
remove(*aarg) ;
725 obsServingAsRangeParams.
add(loBoundObs,
false) ;
726 obsServingAsRangeParams.
add(hiBoundObs,
false) ;
733 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
734 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
737 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
738 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
742 innerObs.
add(obsWithFixedRangeNP) ;
743 innerObs.
add(obsWithParamRangeNP) ;
758 name.Append(
"|" + std::string{rangeName});
761 }
else if (!omitEmpty) {
762 name.Append(
"_Int[]") ;
765 if (nset && !nset->
empty()) {
826 for (
const auto arg : dependentVars) {
829 <<
"\" of wrong type: " << arg->
ClassName() << std::endl;
836 <<
"\" is not a dependent and will be ignored." << std::endl;
841 leafNodes.
replace(*found,*arg);
843 leafNodes.
add(*arg) ;
848 for (
const auto lvs : lvDep) {
852 leafNodes.
add(*lvs) ;
859 if(
nullptr != projectedVars && projectedVars->
find(arg->
GetName())) {
861 <<
"\" cannot be both a dependent and a projected variable." << std::endl;
867 if(
nullptr != projectedVars) leafNodes.
remove(*projectedVars,
true);
872 coutE(Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << std::endl ;
883 std::unique_ptr<RooArgSet> plotLeafNodes{leafNodes.
selectCommon(dependentVars)};
888 if(
nullptr != projectedVars) normSet.
add(*projectedVars);
889 if(
nullptr != condObs) {
890 normSet.
remove(*condObs,
true,
true) ;
897 if(
nullptr == projectedVars) projectedVars= ∅
902 std::string title = std::string{
"Projection of "} +
GetTitle();
904 std::unique_ptr<RooAbsReal> projected{theClone->
createIntegral(*projectedVars,normSet,rangeName)};
906 if(
nullptr == projected || !projected->isValid()) {
907 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":createPlotProjection: cannot integrate out ";
913 static_cast<RooRealIntegral&
>(*projected).setAllowComponentSelection(
true);
916 projected->SetName(
name.c_str()) ;
917 projected->SetTitle(title.c_str()) ;
921 cloneSet->
addOwned(std::move(projected));
945 double scaleFactor,
const RooArgSet *projectedVars,
bool scaleForDensity,
946 const RooArgSet* condObs,
bool setError)
const
949 if(
nullptr == hist) {
950 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: no valid histogram to fill" << std::endl;
956 if(hdim !=
int(plotVars.
size())) {
957 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: plotVars has the wrong dimension" << std::endl;
965 for(std::size_t index= 0; index < plotVars.
size(); index++) {
968 if(
nullptr == realVar) {
970 <<
"\" of type " << var->
ClassName() << std::endl;
975 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << std::endl;
982 pc->recursiveRedirectServers(plotClones,
false,
false,
true) ;
988 allDeps.
add(*projectedVars) ;
991 coutE(InputArguments) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
999 cxcoutD(Plotting) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") plot projection object is " << projected->
GetName() << std::endl ;
1008 TAxis *xaxis =
nullptr;
1009 TAxis *yaxis =
nullptr;
1010 TAxis *zaxis =
nullptr;
1016 assert(
nullptr != zvar &&
nullptr != zaxis);
1022 assert(
nullptr != yvar &&
nullptr != yaxis);
1028 assert(
nullptr != xvar &&
nullptr != xaxis);
1031 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: cannot fill histogram with "
1032 << hdim <<
" dimensions" << std::endl;
1042 Int_t bins= xbins*ybins*zbins;
1043 for(
Int_t bin= 0; bin < bins; bin++) {
1046 if(bin % (xbins*ybins) == 0) {
1052 if(bin % xbins == 0) {
1053 ybin= (ybin%ybins) + 1;
1058 xbin= (xbin%xbins) + 1;
1062 coutE(InputArguments) <<
"RooAbsReal::fillHistogram: Internal Error!" << std::endl;
1067 double scaleFactorBin = scaleFactor;
1068 scaleFactorBin *= scaleForDensity && hdim > 2 ? hist->
GetZaxis()->
GetBinWidth(zbin) : 1.0;
1069 scaleFactorBin *= scaleForDensity && hdim > 1 ? hist->
GetYaxis()->
GetBinWidth(ybin) : 1.0;
1070 scaleFactorBin *= scaleForDensity && hdim > 0 ? hist->
GetXaxis()->
GetBinWidth(xbin) : 1.0;
1072 double result= scaleFactorBin * projected->
getVal();
1074 coutW(Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1075 if (hdim==2)
ccoutW(Plotting) <<
" [y]=" << yvar->
getVal() ;
1076 if (hdim==3)
ccoutW(Plotting) <<
" [z]=" << zvar->
getVal() ;
1077 ccoutW(Plotting) << std::endl ;
1119 bool correctForBinSize,
bool showProgress)
const
1122 if(
nullptr == hist) {
1123 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillDataHist: no valid RooDataHist to fill" << std::endl;
1130 coutE(InputArguments) <<
"RooAbsReal::fillDataHist(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1148 if (showProgress && (i%onePct==0)) {
1149 ccoutP(Eval) <<
"." << std::flush ;
1152 double binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1153 if (correctForBinSize) {
1156 hist->
set(i, binVal, 0.);
1182 std::vector<RooRealVar*> histVars(3,
nullptr);
1184 for(std::size_t iVar = 0; iVar < varNames.size(); ++iVar) {
1185 if(varNames[iVar].empty())
continue;
1187 std::stringstream errMsg;
1188 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR more than three variable names passed, but maximum number of supported variables is three";
1189 coutE(Plotting) << errMsg.str() << std::endl;
1190 throw std::invalid_argument(errMsg.str());
1192 auto var =
static_cast<RooRealVar*
>(vars->find(varNames[iVar].c_str()));
1194 std::stringstream errMsg;
1195 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR variable " << varNames[iVar] <<
" does not exist in argset: " << *vars;
1196 coutE(Plotting) << errMsg.str() << std::endl;
1197 throw std::runtime_error(errMsg.str());
1199 histVars[iVar] = var;
1227#define CREATE_CMD_LIST \
1229 l.Add((TObject *)&arg1); \
1230 l.Add((TObject *)&arg2); \
1231 l.Add((TObject *)&arg3); \
1232 l.Add((TObject *)&arg4); \
1233 l.Add((TObject *)&arg5); \
1234 l.Add((TObject *)&arg6); \
1235 l.Add((TObject *)&arg7); \
1236 l.Add((TObject *)&arg8);
1286 pc.
defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1287 pc.
defineInt(
"extended",
"Extended",0,2) ;
1289 pc.
defineSet(
"compSet",
"SelectCompSet",0);
1291 pc.
defineSet(
"projObs",
"ProjectedObservables",0,
nullptr) ;
1294 pc.
defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1296 pc.
defineMutex(
"IntrinsicBinning",
"BinningName") ;
1297 pc.
defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1316 auto projObs = pc.
getSet(
"projObs");
1319 bool doScaling = pc.
getInt(
"scaling") ;
1325 if (!pdfSelf && doExtended == 1) {
1326 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << std::endl ;
1330 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << std::endl ;
1333 if (pdfSelf && doExtended==2) {
1335 }
else if(!pdfSelf) {
1339 const char* compSpec = pc.
getString(
"compSpec") ;
1341 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1343 std::unique_ptr<RooBinning> intBinning;
1344 if (doIntBinning>0) {
1349 if (doIntBinning==1) {
1350 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1351 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< std::endl ;
1354 if (doIntBinning==2) {
1355 coutI(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1356 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< std::endl ;
1358 std::vector<double> edges(bl->size());
1360 for (
auto const& elem : *bl) { edges[i++] = elem ; }
1361 intBinning = std::make_unique<RooBinning>(bl->size()-1,edges.data()) ;
1366 RooCmdConfig::stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1368 TH1* histo(
nullptr) ;
1371 argListCreate.
Add(&tmp) ;
1387 branchNodeSet.
remove(*arg) ;
1391 std::unique_ptr<RooArgSet> dirSelNodes;
1393 dirSelNodes = std::unique_ptr<RooArgSet>{branchNodeSet.
selectCommon(*compSet)};
1395 dirSelNodes = std::unique_ptr<RooArgSet>{branchNodeSet.
selectByName(compSpec)};
1397 if (!dirSelNodes->empty()) {
1398 coutI(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << std::endl ;
1404 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << std::endl ;
1406 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << std::endl ;
1412 double scaleFactor(1.0) ;
1417 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,
false) ;
1444 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1445 const auto arg = branchNodeSet[i];
1447 branchNodeSet.
remove(*arg) ;
1454 for (
const auto arg : branchNodeSet) {
1463 for (
const auto arg : branchNodeSet) {
1464 for (
const auto selNode : *selNodes) {
1465 if (selNode->dependsOn(*arg,
nullptr,
true)) {
1472 for (
const auto arg : branchNodeSet) {
1473 if (arg->
dependsOn(*selNodes,
nullptr,
true)) {
1478 tmp.
remove(*selNodes,
true);
1481 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << std::endl ;
1484 for (
const auto arg : branchNodeSet) {
1485 bool select = selNodes->
find(arg->
GetName()) !=
nullptr;
1635 argList.
Add(&rnorm) ;
1639 rcmd->
setString(0, rangeString.c_str());
1649 pc.
defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
true) ;
1650 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1651 pc.
defineString(
"sliceCatState",
"SliceCat",0,
"",
true) ;
1654 pc.
defineSet(
"sliceSet",
"SliceVars",0) ;
1655 pc.
defineObject(
"sliceCatList",
"SliceCat",0,
nullptr,
true) ;
1664 pc.
defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1665 pc.
defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1666 pc.
defineSet(
"projDataSet",
"ProjData",0) ;
1670 pc.
defineSet(
"errorPars",
"VisualizeError",0) ;
1671 pc.
defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1672 pc.
defineInt(
"binProjData",
"ProjData",0,0) ;
1675 pc.
defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1676 pc.
defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1677 pc.
defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1681 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1682 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1684 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
1685 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1686 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1687 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
1688 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1690 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
1691 pc.
defineInt(
"showProg",
"ShowProgress",0,0) ;
1693 pc.
defineInt(
"interleave",
"NumCPU",1,0) ;
1697 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1701 pc.
defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1712 if (!drawOpt.
Contains(
"P") && errFR) {
1714 pc.
getInt(
"linearMethod"));
1734 std::unique_ptr<RooArgSet> sliceSet{sliceSetTmp ?
static_cast<RooArgSet*
>(sliceSetTmp->
Clone()) :
nullptr};
1740 if (
const char* sliceCatState = pc.
getString(
"sliceCatState",
nullptr,
true)) {
1745 sliceSet = std::make_unique<RooArgSet>();
1749 auto iter = sliceCatList.
begin();
1750 for (
auto const& catToken :
ROOT::Split(sliceCatState,
",")) {
1751 if (
auto scat =
static_cast<RooCategory*
>(*iter)) {
1753 scat->setLabel(catToken);
1755 sliceSet->add(*scat,
false) ;
1768 if (vlines==2) vlines=0 ;
1774 if (vlines==2) vlines=0 ;
1794 coutE(InputArguments) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") cannot find existing curve " << o.
addToCurveName <<
" to add to in RooPlot" << std::endl ;
1800 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << std::endl ;
1805 for (
const auto sliceArg : *sliceSet) {
1806 if (
RooAbsArg* arg = projectedVars.
find(sliceArg->GetName())) {
1807 projectedVars.
remove(*arg) ;
1809 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") slice variable "
1810 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
1813 }
else if (projSet) {
1814 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << std::endl ;
1817 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << std::endl ;
1822 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << std::endl ;
1837 if (lineColor!=-999)
ret->getAttLine()->SetLineColor(lineColor) ;
1838 if (lineStyle!=-999)
ret->getAttLine()->SetLineStyle(lineStyle) ;
1839 if (lineWidth!=-999)
ret->getAttLine()->SetLineWidth(lineWidth) ;
1840 if (fillColor!=-999)
ret->getAttFill()->SetFillColor(fillColor) ;
1841 if (fillStyle!=-999)
ret->getAttFill()->SetFillStyle(fillStyle) ;
1842 if (markerColor!=-999)
ret->getAttMarker()->SetMarkerColor(markerColor) ;
1843 if (markerStyle!=-999)
ret->getAttMarker()->SetMarkerStyle(markerStyle) ;
1844 if (markerSize!=-999)
ret->getAttMarker()->SetMarkerSize(markerSize) ;
1846 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1847 coutW(Plotting) <<
"Fill color or style was set for plotting \"" <<
GetName()
1848 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1885 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjData with observables = " << *o.
projData->
get() << std::endl ;
1888 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjDataSet = " << *o.
projDataSet <<
" will only use this subset of projData" << std::endl ;
1890 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") using full ProjData" << std::endl ;
1895 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") ProjDataVars = " << projDataVars << std::endl ;
1901 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have input projSet = " << *o.
projSet << std::endl ;
1903 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") calculated projectedVars = " << *o.
projSet << std::endl ;
1910 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << sliceSetTmp << std::endl ;
1912 sliceSetTmp.
remove(projectedVars,
true,
true) ;
1917 sliceSetTmp.
remove(*tmp,
true,
true) ;
1920 if (!sliceSetTmp.
empty()) {
1921 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on "
1922 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
1924 sliceSet.
add(sliceSetTmp) ;
1930 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << std::endl ;
1933 RooArgSet* projDataNeededVars = nullptr ;
1936 projDataNeededVars = projectedVars.
selectCommon(projDataVars);
1937 projectedVars.
remove(projDataVars,
true,
true) ;
1942 double oldPlotVarVal = plotVar->
getVal();
1945 if (!projectedVars.
empty()) {
1946 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->GetName()
1947 <<
" integrates over variables " << projectedVars
1950 if (projDataNeededVars && !projDataNeededVars->
empty()) {
1951 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->GetName()
1952 <<
" averages using data variables " << *projDataNeededVars << std::endl ;
1956 RooArgSet* projectionCompList = nullptr ;
1960 deps.
remove(projectedVars,
true,
true) ;
1961 if (projDataNeededVars) {
1962 deps.
remove(*projDataNeededVars,
true,
true) ;
1964 deps.
remove(*plotVar,
true,
true) ;
1965 deps.
add(*plotVar) ;
1971 coutE(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1972 if (projDataNeededVars)
delete projDataNeededVars ;
1977 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot projection object is " << projection->
GetName() << std::endl ;
1984 fullNormSet.
add(projectedVars) ;
1985 if (projDataNeededVars && !projDataNeededVars->
empty()) {
1986 fullNormSet.
add(*projDataNeededVars) ;
1989 std::unique_ptr<RooArgSet> projectionComponents(projection->
getComponents());
1992 pdf->selectNormalization(&fullNormSet) ;
1997 if (o.
projData && projDataNeededVars && !projDataNeededVars->
empty()) {
2001 std::unique_ptr<RooAbsData> projDataSelOwned;
2010 if (!cutString.empty()) {
2011 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2014 projDataSel = projDataSelOwned.get();
2016 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2025 if (!
dynamic_cast<RooCategory*
>(arg2)) allCat = false ;
2029 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2030 <<
" performing projection with binned copy for optimization." << std::endl ;
2037 projDataSelOwned = std::make_unique<RooDataHist>(std::string(projDataSel->
GetName()) +
"_binned",
"Binned projection data",*projDataSel->
get(),*projDataSel);
2038 projDataSel = projDataSelOwned.get();
2042 ScaledDataWeightedAverage scaleBind{*projection, *projDataSel, o.
scaleFactor, *plotVar};
2051 std::string curveName(projection->
GetName()) ;
2054 if (!sliceSet.
empty()) {
2068 curve->
SetName(curveName.c_str()) ;
2119 std::string curveName(projection->
GetName()) ;
2120 if (!sliceSet.
empty()) {
2146 curve->
SetName(curveName.c_str()) ;
2167 if (projDataNeededVars)
delete projDataNeededVars ;
2168 delete projectionCompList ;
2169 plotVar->setVal(oldPlotVarVal);
2200 projDataVars.
add(*tmp) ;
2208 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2209 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << std::endl ;
2215 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2216 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << std::endl ;
2230 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2235 sliceSetTmp.
remove(*tmp,
true,
true) ;
2238 if (!sliceSetTmp.
empty()) {
2239 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on "
2240 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
2242 sliceSet.
add(sliceSetTmp) ;
2250 RooArgSet* projDataNeededVars = nullptr ;
2252 projDataNeededVars = projectedVars.
selectCommon(projDataVars);
2253 projectedVars.
remove(projDataVars,
true,
true) ;
2266 if (!projectedVars.
empty()) {
2267 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2268 <<
" projects variables " << projectedVars << std::endl ;
2270 if (projDataNeededVars && !projDataNeededVars->
empty()) {
2271 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2272 <<
" averages using data variables "<< *projDataNeededVars << std::endl ;
2279 asymPos->setIndex(1) ;
2280 asymNeg->setIndex(-1) ;
2287 std::unique_ptr<RooAbsReal> funcPos{
static_cast<RooAbsReal*
>(custPos.
build())};
2288 std::unique_ptr<RooAbsReal> funcNeg{
static_cast<RooAbsReal*
>(custNeg.
build())};
2298 depPos.
add(projDataVars) ;
2299 depNeg.
add(projDataVars) ;
2303 if (!posProj || !negProj) {
2304 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << std::endl ;
2310 asymName.
Append(
"_Asym[") ;
2314 asymTitle.
Append(
" Asymmetry of ") ;
2322 std::unique_ptr<RooAbsData> projDataSelOwned;
2330 if (!cutString.empty()) {
2331 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2332 <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2335 projDataSel = projDataSelOwned.get();
2336 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2337 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2342 ScaledDataWeightedAverage scaleBind{funcAsym, *projDataSel, o.
scaleFactor, *plotVar};
2354 if (!sliceSet.
empty()) {
2372 ccoutW(Eval) << std::endl ;
2390 std::stringstream curveName;
2391 curveName << funcAsym.
GetName();
2392 if (!sliceSet.
empty()) {
2399 curve->
SetName(curveName.str().c_str());
2407 delete posProjCompList ;
2408 delete negProjCompList ;
2442 auto rrvInAbsReal =
static_cast<RooRealVar const*
>(allParamsInAbsReal.
find(*rrvFitRes));
2449 if (rrvFitRes->getError() <= std::abs(rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
continue;
2452 if(!rrvInAbsReal)
continue;
2456 if(std::abs(rrvInAbsReal->getVal() - rrvFitRes->getVal()) > 0.01 * rrvFitRes->getError()) {
2457 std::stringstream errMsg;
2458 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
2459 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
2461 throw std::runtime_error(errMsg.str());
2464 paramList.
add(*rrvInAbsReal);
2467 std::vector<double> plusVar;
2468 std::vector<double> minusVar;
2469 plusVar.reserve(paramList.
size());
2470 minusVar.reserve(paramList.
size());
2477 for (std::size_t ivar=0 ; ivar<paramList.
size() ; ivar++) {
2479 auto& rrv =
static_cast<RooRealVar&
>(paramList[ivar]);
2481 double cenVal = rrv.
getVal() ;
2482 double errVal = sqrt(V(ivar,ivar)) ;
2485 if(!rrv.inRange(cenVal+errVal,
nullptr) || !rrv.inRange(cenVal-errVal,
nullptr)) {
2486 std::stringstream ss;
2487 ss <<
"RooAbsReal::getPropagatedError(" <<
GetName() <<
"): the 1-sigma variations for the parameter "
2488 <<
"\"" << rrv.GetName() <<
"\" are invalid "
2489 <<
" because their values (" << cenVal-errVal <<
", " << cenVal+errVal
2490 <<
") are outside the defined range [" << rrv.getMin() <<
", " << rrv.getMax() <<
"]!\n"
2491 <<
" The variations will be clipped inside the range."
2492 <<
" This might or might not be acceptable in your usecase.";
2493 coutW(Plotting) << ss.str() << std::endl;
2497 rrv.setVal(std::min(cenVal+errVal, rrv.getMax())) ;
2498 plusVar.push_back(
getVal(nset)) ;
2501 rrv.setVal(std::max(cenVal-errVal, rrv.getMin())) ;
2502 minusVar.push_back(
getVal(nset)) ;
2504 rrv.setVal(cenVal) ;
2517 std::vector<double> errVec(paramList.
size()) ;
2518 for (std::size_t i=0 ; i<paramList.
size() ; i++) {
2519 errVec[i] = std::sqrt(V(i,i)) ;
2520 for (std::size_t j=i ; j<paramList.
size() ; j++) {
2521 C(i,j) = V(i,j) / std::sqrt(V(i,i)*V(j,j));
2528 for (std::size_t j=0 ; j<plusVar.size() ; j++) {
2529 F[j] = (plusVar[j]-minusVar[j]) * 0.5;
2533 double sum =
F*(C*
F) ;
2581 if (std::string(
"Normalization")==cmd->GetName()) {
2584 plotArgList.
Add(cmd) ;
2587 plotArgList.
Add(cmd) ;
2594 auto plotFunc = [&](
RooAbsReal const& absReal) {
2597 absReal.plotOn(frame, tmp);
2604 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOnWithErrorBand: no curve for central value available" << std::endl;
2607 frame->
remove(
nullptr,
false) ;
2631 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2632 << errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << std::endl ;
2637 std::unique_ptr<RooDataSet> generatedData{paramPdf->
generate(errorParams,
n)};
2638 std::vector<RooCurve*> cvec ;
2639 for (
int i=0 ; i<generatedData->numEntries() ; i++) {
2640 cloneParams.
assign(*generatedData->get(i)) ;
2641 plotFunc(*cloneFunc);
2642 cvec.push_back(frame->
getCurve()) ;
2643 frame->
remove(
nullptr,
false) ;
2655 for (std::vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2674 if (frv->getError() > frv->getVal() * std::numeric_limits<double>::epsilon()) {
2675 fpf_stripped.
add(*frv);
2693 std::vector<int> fpf_idx ;
2694 for (std::size_t i=0 ; i<fpf.
size() ; i++) {
2697 paramList.
add(*par) ;
2698 fpf_idx.push_back(i) ;
2702 std::vector<RooCurve *> plusVar;
2703 std::vector<RooCurve *> minusVar;
2712 for (std::size_t ivar=0 ; ivar<paramList.
size() ; ivar++) {
2716 double cenVal = rrv.
getVal() ;
2717 double errVal = sqrt(V(ivar,ivar)) ;
2719 auto * var =
static_cast<RooRealVar*
>(paramList.
at(ivar));
2723 if(!var->
inRange(cenVal+Z*errVal,
nullptr) || !var->
inRange(cenVal-Z*errVal,
nullptr)) {
2724 std::stringstream ss;
2725 ss <<
"RooAbsReal::plotOn(" <<
GetName() <<
"): the " << Z <<
"-sigma error band for the parameter "
2726 <<
"\"" << var->
GetName() <<
"\" is invalid"
2727 <<
" because the variations (" << cenVal-Z*errVal <<
", " << cenVal+Z*errVal
2728 <<
") are outside the defined range [" << var->
getMin() <<
", " << var->
getMax() <<
"]!\n"
2729 <<
" The variations will be clipped inside the range."
2730 <<
" This might or might not be acceptable in your usecase.";
2731 coutW(Plotting) << ss.str() << std::endl;
2737 plotFunc(*cloneFunc);
2738 plusVar.push_back(frame->
getCurve()) ;
2739 frame->
remove(
nullptr,
false) ;
2744 plotFunc(*cloneFunc);
2745 minusVar.push_back(frame->
getCurve()) ;
2746 frame->
remove(
nullptr,
false) ;
2752 std::vector<double> errVec(paramList.
size()) ;
2753 for (std::size_t i=0 ; i<paramList.
size() ; i++) {
2754 errVec[i] = sqrt(V(i,i)) ;
2755 for (std::size_t j=i ; j<paramList.
size() ; j++) {
2756 C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2766 for (std::vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2769 for (std::vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2776 if (!band)
return frame ;
2781 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
2782 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
2783 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
2784 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
2785 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
2786 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
2788 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
2789 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
2791 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
2792 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
2823 if (pc.
getString(
"curveName",
nullptr,
true)) {
2825 }
else if (pc.
getString(
"curveNameSuffix",
nullptr,
true)) {
2849 if(
nullptr == frame) {
2858 <<
":plotOn: frame does not specify a plot variable" << std::endl;
2871 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOn: WARNING: variable is not an explicit dependent: "
2872 << var->
GetName() << std::endl;
2890 RooArgSet& projectedVars,
bool silent)
const
2892 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") plotVar = " << plotVar->
GetName()
2893 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << std::endl ;
2899 projectedVars.
add(*allVars) ;
2904 projectedVars.
remove(*found);
2907 std::unique_ptr<RooArgSet> plotServers{plotVar->
getObservables(&projectedVars)};
2911 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") removing " << tmp->
GetName()
2912 <<
" from projection set because it a server of " << plotVar->
GetName() << std::endl ;
2913 projectedVars.
remove(*tmp) ;
2919 <<
") WARNING: cannot project out frame variable ("
2920 << found->
GetName() <<
"), ignoring" << std::endl ;
2927 projectedVars.
remove(*arg,
true) ;
2930 <<
") function doesn't depend on projection variable "
2931 << arg->
GetName() <<
", ignoring" << std::endl ;
2968 auto binding = std::make_unique<RooRealBinding>(*
this,vars,nset,clipInvalid);
2969 if(!binding->isValid()) {
2970 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":bindVars: cannot bind to " << vars << std::endl ;
2985 auto other =
static_cast<const RooAbsReal*
>(source);
2986 assert(
dynamic_cast<const RooAbsReal*
>(source));
2988 _value = other->_treeReadBuffer ? other->_treeReadBuffer->operator
double() : other->_value;
3028 coutE(Eval) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") ERROR: TTree branch " <<
GetName()
3029 <<
" is an array and cannot be attached to a RooAbsReal" << std::endl ;
3039 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3040 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3041 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3042 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3043 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3044 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3045 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3046 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3047 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3048 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3049 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3052 auto typeDetails = typeMap.find(typeName.
Data());
3053 if (typeDetails != typeMap.end()) {
3054 coutI(DataHandling) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") TTree " << typeDetails->first <<
" branch " <<
GetName()
3055 <<
" will be converted to double precision." << std::endl ;
3068 coutE(InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << std::endl ;
3090 coutE(Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree: " <<
cleanBranchName() << std::endl ;
3122 fund->setAttribute(
"fundamentalCopy");
3152 const TList &nameList)
const
3155 bool isMatched(
true);
3159 matched.
add(*found);
3169 if (isMatched &&
int(matched.
size())!=nameList.
GetSize()) {
3173 if(isMatched) matchedArgs.
add(matched);
3304 if (evalErrorData().mode ==
Ignore) {
3309 evalErrorData().count++ ;
3313 static bool inLogEvalError = false ;
3315 if (inLogEvalError) {
3318 inLogEvalError = true ;
3323 if (serverValueString) {
3328 oocoutE(
nullptr,Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << std::endl
3329 <<
" origin : " << origName << std::endl
3330 <<
" message : " << ee.
_msg << std::endl
3331 <<
" server values: " << ee.
_srvval << std::endl ;
3333 auto &evalErrorList = evalErrorData().errorList[originator];
3334 evalErrorList.first = origName ;
3335 evalErrorList.second.push_back(ee) ;
3339 inLogEvalError = false ;
3360 if (evalErrorData().mode ==
Ignore) {
3365 evalErrorData().count++ ;
3369 static bool inLogEvalError = false ;
3371 if (inLogEvalError) {
3374 inLogEvalError = true ;
3379 if (serverValueString) {
3382 std::string srvval ;
3383 std::ostringstream oss ;
3394 p->
print(oss,
true) ;
3399 std::ostringstream oss2 ;
3403 coutE(Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << std::endl
3404 <<
" origin : " << oss2.str() << std::endl
3405 <<
" message : " << ee.
_msg << std::endl
3406 <<
" server values: " << ee.
_srvval << std::endl ;
3408 auto &evalErrorList = evalErrorData().errorList[
this];
3409 if (evalErrorList.second.size() >= 2048) {
3412 const EvalError& oee = evalErrorList.second.front();
3416 <<
") delayed evaluation error, " << std::endl
3417 <<
" origin : " << oss2.str() << std::endl
3418 <<
" message : " << oee.
_msg << std::endl
3419 <<
" server values: " << oee.
_srvval << std::endl ;
3420 evalErrorList.second.pop_front();
3422 evalErrorList.first = oss2.str() ;
3423 evalErrorList.second.push_back(ee) ;
3426 inLogEvalError = false ;
3441 evalErrorData().errorList.clear() ;
3443 evalErrorData().count = 0 ;
3479 os << evalErrorData().count <<
" errors counted" << std::endl;
3485 for (
auto const &item : evalErrorData().errorList) {
3486 if (maxPerNode == 0) {
3489 os << item.second.first;
3491 os <<
" has " << item.second.second.size() <<
" errors" << std::endl;
3496 os << item.second.first << std::endl;
3500 for (
auto const &item2 : item.second.second) {
3501 os <<
" " << item2._msg <<
" @ " << item2._srvval << std::endl;
3502 if (i > maxPerNode) {
3503 os <<
" ... (remaining " << item.second.second.size() - maxPerNode <<
" messages suppressed)"
3520 auto &evalErrors = evalErrorData();
3522 return evalErrors.count;
3526 for (
auto const &elem : evalErrors.errorList) {
3527 ntot += elem.second.second.size();
3549 pdf->selectNormalization(addNormSet.
empty() ?
nullptr : &addNormSet,force);
3570 pdf->selectNormalizationRange(rangeName,force) ;
3588 orderedObs.
add(obs) ;
3646 pc.
defineSet(
"supNormSet",
"SupNormSet",0,
nullptr) ;
3647 pc.
defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3648 pc.
defineInt(
"intOrder",
"ScanParameters",1,2) ;
3649 pc.
defineInt(
"doScanNum",
"ScanNum",0,1) ;
3650 pc.
defineInt(
"doScanAll",
"ScanAll",0,0) ;
3651 pc.
defineInt(
"doScanNon",
"ScanNone",0,0) ;
3655 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3683 coutI(NumericIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << std::endl
3684 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3685 << intOrder <<
" interpolation on integrated histogram." << std::endl
3686 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << std::endl ;
3704 ivar->
setBins(numScanBins,
"numcdf") ;
3705 auto ret = std::make_unique<RooNumRunningInt>(
name.c_str(),
name.c_str(),*
this,*ivar,
"numrunint") ;
3706 ret->setInterpolationOrder(intOrder) ;
3725 coutW(InputArguments) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") WARNING ignoring non-RooRealVar input argument " << arg->
GetName() << std::endl ;
3743 cloneList.
add(*cloneArg) ;
3748 cloneLo->
setVal(rrv->getMin()) ;
3749 loList.
add(*cloneLo) ;
3761 finalNset.
add(cloneList,
true) ;
3762 std::unique_ptr<RooAbsReal> cdf{tmp->
createIntegral(cloneList,finalNset,
"CDF")};
3765 cdf->addOwnedComponents(*tmp) ;
3766 cdf->addOwnedComponents(cloneList) ;
3767 cdf->addOwnedComponents(loList) ;
3781 if (realObs.
size() != obs.
size()) {
3782 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
3787 if (realPars.
size() != pars.
size()) {
3788 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
3806 if (realObs.
size() != obs.
size()) {
3807 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
3812 if (realPars.
size() != pars.
size()) {
3813 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
3818 for (std::size_t i=0 ; i<obs.
size() ; i++) {
3820 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed observable " << obs.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
3824 for (std::size_t i=0 ; i<pars.
size() ; i++) {
3826 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed parameter " << pars.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
3834 switch(obs.
size()) {
3853 tf =
new TF3(
GetName(),
f,
x->getMin(),
x->getMax(),
y->getMin(),
y->getMax(),z->getMin(),z->getMax(),pars.
size()) ;
3857 coutE(InputArguments) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: " << obs.
size()
3858 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << std::endl ;
3863 for (std::size_t i=0 ; i<pars.
size() ; i++) {
3890 std::string title=
Form(
"%dDerivative of %s w.r.t %s ",order,
GetName(),obs.
GetName()) ;
3891 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
3906 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
3908 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
3909 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
3925 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
3927 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
3928 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
3929 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4016 return RooFit::FitHelpers::fitTo(*
this, data, cmdList,
true);
4064 return RooFit::FitHelpers::createChi2(*
this, data, cmdList);
4072 return evalErrorData().mode ;
4086 evalErrorData().mode =
m;
4095 for (
auto const* arg : paramVars) {
4097 coutW(InputArguments) <<
"RooAbsReal::setParameterizeIntegral(" <<
GetName()
4098 <<
") function does not depend on listed parameter " << arg->
GetName() <<
", ignoring" << std::endl ;
4101 if (!plist.empty()) plist +=
":" ;
4113 std::span<double> output = ctx.
output();
4119 std::span<const double> batch;
4125 std::vector<ServerData> ourServers;
4128 for (
auto server :
servers()) {
4129 auto serverValues = ctx.
at(server);
4130 if(serverValues.empty())
continue;
4132 if(!server->isValueServer(*
this))
continue;
4135 auto oldOperMode = server->operMode();
4140 ourServers.push_back({server,
4144 server->_valueDirty,
4145 server->_shapeDirty});
4151 struct RestoreStateRAII {
4152 RestoreStateRAII(std::vector<ServerData>&
servers) :
4155 ~RestoreStateRAII() {
4156 for (
auto& serverData : _servers) {
4157 serverData.server->setCachedValue(serverData.oldValue,
true);
4158 serverData.server->setOperMode(serverData.oldOperMode);
4159 serverData.server->_valueDirty = serverData.oldValueDirty;
4160 serverData.server->_shapeDirty = serverData.oldShapeDirty;
4164 std::vector<ServerData>& _servers;
4165 } restoreState{ourServers};
4171 coutI(FastEvaluations) <<
"The class " <<
ClassName() <<
" does not implement the faster batch evaluation interface."
4172 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4178 for (std::size_t i=0; i < output.size(); ++i) {
4179 for (
auto& serv : ourServers) {
4180 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4189 const bool tmpFast =
_fast;
4190 const double tmp =
_value;
4192 double fullEval = 0.;
4194 fullEval =
getValV(normalisationSet);
4196 catch (CachingError& error) {
4197 throw CachingError(std::move(error),
4198 FormatPdfTree() << *
this);
4203 if (std::isfinite(
ret) && (
ret != 0. ? (
ret - fullEval)/
ret :
ret - fullEval) > 1.E-9) {
4207 FormatPdfTree formatter;
4208 formatter <<
"--> (Scalar computation wrong here:)\n"
4209 <<
GetName() <<
" " <<
this <<
" _fast=" << tmpFast
4210 <<
"\n\tcached _value=" << std::setprecision(16) << tmp
4211 <<
"\n\treturning =" <<
ret
4212 <<
"\n\trecomputed =" << fullEval
4213 <<
"\n\tnew _value =" <<
_value <<
"] ";
4214 formatter <<
"\nServers:";
4220 throw CachingError(formatter);
4228 bool nameChange,
bool isRecursiveStep)
4240 if(
auto realArg =
dynamic_cast<RooAbsReal*
>(arg)) {
4241 realArg->enableOffsetting(flag) ;
4267 std::stringstream errMsg;
4268 errMsg <<
"calling RooAbsReal::getVal() with r-value references to the normalization set is not allowed, because "
4269 "it breaks RooFits caching logic and potentially introduces significant overhead. Please explicitly "
4270 "create the RooArgSet outside the call to getVal().";
4271 coutF(Eval) << errMsg.str() << std::endl;
4272 throw std::runtime_error(errMsg.str());
ROOT::RRangeCast< T, true, Range_t > dynamic_range_cast(Range_t &&coll)
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
float Size_t
Attribute size (float).
char Text_t
General string (char).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
static void indent(ostringstream &buf, int indent_level)
TMatrixTSym< Double_t > TMatrixDSym
TRObject operator()(const T1 &t1) const
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TVectorT< Double_t > TVectorD
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
bool recursiveRedirectServers(const RooAbsCollection &newSet, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
bool isValueDirtyAndClear() const
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
friend class RooRealIntegral
RooFit::OwningPtr< RooArgSet > getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
const RefCountList_t & servers() const
List of all servers of this object.
bool dependsOnValue(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr) const
Check whether this object depends on values from an element in the serverList.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree).
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Implement multi-line detailed printing.
virtual RooAbsArg * cloneTree(const char *newname=nullptr) const
Clone tree expression of objects.
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
Int_t numProxies() const
Return the number of registered proxies.
static bool _inhibitDirty
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
void setProxyNormSet(const RooArgSet *nset)
Forward a change in the cached normalization argset to all the registered proxies.
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool recurseNonDerived=false) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
RefCountList_t _serverList
void leafNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool recurseNonDerived=false) const
Fill supplied list with all leaf nodes of the arg tree, starting with ourself as top node.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset?
virtual bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep)
Function that is called at the end of redirectServers().
virtual bool checkObservables(const RooArgSet *nset) const
Overloadable function in which derived classes can implement consistency checks of the variables.
RooAbsArg()
Default constructor.
friend class RooAbsCollection
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool doBranch=true, bool doLeaf=true, bool valueOnly=false, bool recurseNonDerived=false) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
Abstract base class for RooRealVar binning definitions.
virtual bool isParameterized() const
Interface function.
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
bool isSignType(bool mustHaveZero=false) const
Determine if category has 2 or 3 states with index values -1,0,1.
RooFit::UniqueId< RooAbsCollection > const & uniqueId() const
Returns a unique ID that is different for every instantiated RooAbsCollection.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
bool overlaps(Iterator_t otherCollBegin, Iterator_t otherCollEnd) const
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
Storage_t::size_type size() const
RooAbsArg * first() const
virtual bool replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return true for success.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
std::string contentsString() const
Return comma separated list of contained object names as STL string.
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
RooFit::OwningPtr< RooAbsData > reduce(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a reduced copy of this dataset.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Abstract base class for objects that are lvalues, i.e.
Abstract interface for all probability density functions.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
const char * normRange() const
RooFit::OwningPtr< RooDataSet > generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={})
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
Abstract interface for proxy classes.
virtual void print(std::ostream &os, bool addContents=false) const
Print proxy name.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
TH1 * createHistogram(const char *name, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool inRange(const char *name) const override
Check if current value is inside range with given name.
void setServerValues(const char *tmp)
void setMessage(const char *tmp)
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, double scaleFactor, bool correctForBinVolume=false, bool showProgress=false) const
Fill a RooDataHist with values sampled from this function at the bin centers.
virtual void selectNormalizationRange(const char *rangeName=nullptr, bool force=false)
Interface function to force use of a given normalization range to interpret function value.
void plotOnCompSelect(RooArgSet *selNodes) const
Helper function for plotting of composite p.d.fs.
bool isSelectedComp() const
If true, the current pdf is a selected component (for use in plotting).
virtual std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
void selectComp(bool flag)
TString _label
Plot label for objects value.
bool _selectComp
! Component selection flag for RooAbsPdf::plotCompOn
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
double findRoot(RooRealVar &x, double xmin, double xmax, double yval)
Return value of x (in range xmin,xmax) at which function equals yval.
TreeReadBuffer * _treeReadBuffer
! A buffer for reading values from trees
virtual double getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
static Int_t numEvalErrorItems()
RooAbsReal()
coverity[UNINIT_CTOR] Default constructor
friend class RooRealBinding
virtual void fixAddCoefNormalization(const RooArgSet &addNormSet=RooArgSet(), bool force=true)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
virtual Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=nullptr) const
Variant of getAnalyticalIntegral that is also passed the normalization set that should be applied to ...
bool _forceNumInt
Force numerical integration if flag set.
~RooAbsReal() override
Destructor.
void setParameterizeIntegral(const RooArgSet ¶mVars)
bool matchArgsByName(const RooArgSet &allArgs, RooArgSet &matchedArgs, const TList &nameList) const
Check if allArgs contains matching elements for each name in nameList.
void setTreeBranchStatus(TTree &t, bool active) override
(De)Activate associated tree branch
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, double scaleFactor=1, const RooArgSet *projectedVars=nullptr, bool scaling=true, const RooArgSet *condObs=nullptr, bool setError=true) const
Fill the ROOT histogram 'hist' with values sampled from this function at the bin centers.
RooFit::OwningPtr< RooAbsReal > createScanRI(const RooArgSet &iset, const RooArgSet &nset, Int_t numScanBins, Int_t intOrder)
Utility function for createRunningIntegral that construct an object implementing the numeric scanning...
friend class RooVectorDataStore
double _DEBUG_getVal(const RooArgSet *normalisationSet) const
Debug version of getVal(), which is slow and does error checking.
RooFit::OwningPtr< RooAbsArg > createFundamental(const char *newname=nullptr) const override
Create a RooRealVar fundamental object with our properties.
bool plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
RooFit::OwningPtr< RooAbsFunc > bindVars(const RooArgSet &vars, const RooArgSet *nset=nullptr, bool clipInvalid=false) const
Create an interface adaptor f(vars) that binds us to the specified variables (in arbitrary order).
virtual void selectNormalization(const RooArgSet *depSet=nullptr, bool force=false)
Interface function to force use of a given set of observables to interpret function value.
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, double eps=0.001)
Return function representing first, second or third order derivative of this function.
TF1 * asTF(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables and parame...
TString _unit
Unit for objects value.
static RooNumIntConfig * defaultIntegratorConfig()
Returns the default numeric integration configuration for all RooAbsReals.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from stream (dummy for now).
void fillTreeBranch(TTree &t) override
Fill the tree branch that associated with this object with its current value.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
virtual RooPlot * plotAsymOn(RooPlot *frame, const RooAbsCategoryLValue &asymCat, PlotOpt o) const
bool operator==(double value) const
Equality operator comparing to a double.
static ErrorLoggingMode evalErrorLoggingMode()
Return current evaluation error logging mode.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
virtual bool isValidReal(double, bool printError=false) const
Interface function to check if given value is a valid value for this object. Returns true unless over...
void setIntegratorConfig()
Remove the specialized numeric integration configuration associated with this object.
void printValue(std::ostream &os) const override
Print object value.
bool isIdentical(const RooAbsArg &other, bool assumeSameType=false) const override
virtual RooFit::OwningPtr< RooAbsReal > createProfile(const RooArgSet ¶msOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
static bool _hideOffset
Offset hiding flag.
void attachToVStore(RooVectorDataStore &vstore) override
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy the cached value of another RooAbsArg to our cache.
TH1 * createHistogram(RooStringView varNameList, Int_t xbins=0, Int_t ybins=0, Int_t zbins=0) const
Create and fill a ROOT histogram TH1, TH2 or TH3 with the values of this function for the variables w...
virtual void fixAddCoefRange(const char *rangeName=nullptr, bool force=true)
Fix the interpretation of the coefficient of any RooAddPdf component in the expression tree headed by...
double _value
Cache for current value of object.
virtual double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
void attachToTree(TTree &t, Int_t bufSize=32000) override
Attach object to a branch of given TTree.
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to stream (dummy for now).
double traceEval(const RooArgSet *set) const
Calculate current value of object, with error tracing wrapper.
double getPropagatedError(const RooFitResult &fr, const RooArgSet &nset={}) const
Propagates parameter uncertainties to an uncertainty estimate for this RooAbsReal.
static void setHideOffset(bool flag)
static void globalSelectComp(bool flag)
Global switch controlling the activation of the selectComp() functionality.
RooAbsMoment * moment(RooRealVar &obs, Int_t order, bool central, bool takeRoot)
Return function representing moment of function of given order.
RooPlot * plotOnWithErrorBand(RooPlot *frame, const RooFitResult &fr, double Z, const RooArgSet *params, const RooLinkedList &argList, bool method1) const
Plot function or PDF on frame with support for visualization of the uncertainty encoded in the given ...
RooFit::UniqueId< RooArgSet >::Value_t _lastNormSetId
!
const char * getPlotLabel() const
Get the label associated with the variable.
RooFit::OwningPtr< RooAbsReal > createRunningIntegral(const RooArgSet &iset, const RooArgSet &nset={})
Calls createRunningIntegral(const RooArgSet&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&,...
std::unique_ptr< RooNumIntConfig > _specIntegratorConfig
std::unique_ptr< RooFitResult > chi2FitToImpl(RooDataHist &data, const RooLinkedList &cmdList)
virtual Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
static std::map< constRooAbsArg *, std::pair< std::string, std::list< RooAbsReal::EvalError > > >::iterator evalErrorIter()
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
double _plotMax
Maximum of plot range.
virtual void preferredObservableScanOrder(const RooArgSet &obs, RooArgSet &orderedObs) const
Interface method for function objects to indicate their preferred order of observables for scanning t...
virtual double maxVal(Int_t code) const
Return maximum value for set of observables identified by code assigned in getMaxVal.
void findInnerMostIntegration(const RooArgSet &allObs, RooArgSet &innerObs, const char *rangeName) const
Utility function for createIntObj() that aids in the construct of recursive integrals over functions ...
TString integralNameSuffix(const RooArgSet &iset, const RooArgSet *nset=nullptr, const char *rangeName=nullptr, bool omitEmpty=false) const
Construct string with unique suffix name to give to integral object that encodes integrated observabl...
virtual double evaluate() const =0
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
TString getTitle(bool appendUnit=false) const
Return this variable's title string.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
virtual double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
const Text_t * getUnit() const
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
RooFit::OwningPtr< RooAbsReal > createIntRI(const RooArgSet &iset, const RooArgSet &nset={})
Utility function for createRunningIntegral.
virtual void enableOffsetting(bool)
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooFit::OwningPtr< RooAbsReal > createIntObj(const RooArgSet &iset, const RooArgSet *nset, const RooNumIntConfig *cfg, const char *rangeName) const
Internal utility function for createIntegral() that creates the actual integral object.
RooFunctor * functor(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a RooFunctor object bound to this RooAbsReal with given definition of observables and paramete...
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={}, const RooCmdArg &arg10={}) const
Plot (project) PDF on specified frame.
Int_t _plotBins
Number of plot bins.
const RooAbsReal * createPlotProjection(const RooArgSet &depVars, const RooArgSet &projVars, RooArgSet *&cloneSet) const
Utility function for plotOn() that creates a projection of a function or p.d.f to be plotted on a Roo...
virtual std::list< double > * plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
void setPlotLabel(const char *label)
Set the label associated with this variable.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create an object that represents the integral of the function over one or more observables listed in ...
virtual void doEval(RooFit::EvalContext &) const
Base function for computing multiple values of a RooAbsReal.
void makeProjectionSet(const RooAbsArg *plotVar, const RooArgSet *allVars, RooArgSet &projectedVars, bool silent) const
Utility function for plotOn() that constructs the set of observables to project when plotting ourselv...
virtual Int_t getMaxVal(const RooArgSet &vars) const
Advertise capability to determine maximum value of function for given set of observables.
double _plotMin
Minimum of plot range.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
virtual double offset() const
std::unique_ptr< RooAbsReal > createChi2Impl(RooDataHist &data, const RooLinkedList &cmdList)
static bool _globalSelectComp
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooArgSet * selectByName(const char *nameList, bool verbose=false) const
Use RooAbsCollection::selectByName(), but return as RooArgSet.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Implement the abstract 1-dimensional root finding interface using the Brent-Decker method.
bool findRoot(double &result, double xlo, double xhi, double value=0) const
Do the root finding using the Brent-Decker method.
Object to represent discrete states.
Named container for two doubles, two integers two object points and three string pointers that can be...
static const RooCmdArg & none()
Return reference to null argument.
const char * getString(Int_t idx) const
Return string stored in slot idx.
void setString(Int_t idx, const char *value)
Configurable parser for RooCmdArg named arguments.
void defineMutex(const char *head, Args_t &&... tail)
Define arguments where any pair is mutually exclusive.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
bool hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
double getDouble(const char *name, double defaultValue=0.0) const
Return double property registered with name 'name'.
bool defineDouble(const char *name, const char *argName, int doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
static void stripCmdList(RooLinkedList &cmdList, const char *cmdsToPurge)
Utility function that strips command names listed (comma separated) in cmdsToPurge from cmdList.
RooArgSet * getSet(const char *name, RooArgSet *set=nullptr) const
Return RooArgSet property registered with name 'name'.
bool defineSet(const char *name, const char *argName, int setNum, const RooArgSet *set=nullptr)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
bool ok(bool verbose) const
Return true of parsing was successful.
bool defineObject(const char *name, const char *argName, int setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", bool convEmptyToNull=false) const
Return string property registered with name 'name'.
bool defineString(const char *name, const char *argName, int stringNum, const char *defValue="", bool appendMode=false)
Define double property name 'name' mapped to double in slot 'stringNum' in RooCmdArg with name argNam...
const RooLinkedList & getObjectList(const char *name) const
Return list of objects registered with name 'name'.
bool defineInt(const char *name, const char *argName, int intNum, int defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
void allowUndefined(bool flag=true)
If flag is true the processing of unrecognized RooCmdArgs is not considered an error.
int getInt(const char *name, int defaultValue=0) const
Return integer property registered with name 'name'.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
One-dimensional graphical representation of a real-valued function.
RooCurve * makeErrorBand(const std::vector< RooCurve * > &variations, double Z=1) const
Construct filled RooCurve represented error band that captures alpha% of the variations of the curves...
RooCustomizer is a factory class to produce clones of a prototype composite PDF object with the same ...
void setCloneBranchSet(RooArgSet &cloneBranchSet)
Releases ownership of list of cloned branch nodes.
void replaceArg(const RooAbsArg &orig, const RooAbsArg &subst)
Replace any occurrence of arg 'orig' with arg 'subst'.
RooAbsArg * build(const char *masterCatState, bool verbose=false)
Build a clone of the prototype executing all registered 'replace' rules and 'split' rules for the mas...
void setOwning(bool flag)
If flag is true, make customizer own all created components.
Container class to hold N-dimensional binned data.
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
double binVolume(std::size_t i) const
Return bin volume of i-th bin.
const RooArgSet * get() const override
Get bin centre of current bin.
Represents the first, second, or third order derivative of any RooAbsReal as calculated (numerically)...
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
TMatrixDSym reducedCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
RooAbsPdf * createHessePdf(const RooArgSet ¶ms) const
Return a p.d.f that represents the fit result as a multi-variate probability densisty function on the...
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
Lightweight interface adaptor that exports a RooAbsPdf as a functor.
Graphical representation of binned data based on the TGraphAsymmErrors class.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
void Delete(Option_t *o=nullptr) override
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
RooLinkedListIterImpl begin() const
TObject * FindObject(const char *name) const override
Return pointer to object with given name.
static RooMsgService & instance()
Return reference to singleton instance.
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
static RooNumIntConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
Implementation of RooAbsBinning that constructs a binning with a range definition that depends on ext...
Plot frame and a container for graphics objects within that frame.
void remove(const char *name=nullptr, bool deleteToo=true)
Remove object with given name, or last object added if no name is given.
bool drawBefore(const char *before, const char *target)
Change the order in which our contained objects are drawn so that the target object is drawn just bef...
TObject * findObject(const char *name, const TClass *tClass=nullptr) const
Find the named object in our list of items and return a pointer to it.
virtual void SetMinimum(double minimum=-1111)
Set minimum value of Y axis.
const RooArgSet * getNormVars() const
double GetMaximum(double maxval=FLT_MAX) const
TAttLine * getAttLine(const char *name=nullptr) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
TAttFill * getAttFill(const char *name=nullptr) const
Return a pointer to the fill attributes of the named object in this plot, or zero if the named object...
TObject * getObject(Int_t idx) const
Return the name of the object at slot 'idx' in this RooPlot.
virtual void SetMaximum(double maximum=-1111)
Set maximum value of Y axis.
RooAbsRealLValue * getPlotVar() const
TAttMarker * getAttMarker(const char *name=nullptr) const
Return a pointer to the marker attributes of the named object in this plot, or zero if the named obje...
RooCurve * getCurve(const char *name=nullptr) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", bool invisible=false, bool refreshNorm=false)
Add the specified plotable object to our plot.
double GetMinimum(double minval=-FLT_MAX) const
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setBins(Int_t nBins, const char *name=nullptr, bool shared=true)
Create a uniform binning under name 'name' for this variable.
void setBinning(const RooAbsBinning &binning, const char *name=nullptr, bool shared=true)
Add given binning under name 'name' with this variable.
The RooStringView is a wrapper around a C-style string that can also be constructed from a std::strin...
void setBuffer(RooAbsReal *real, double *newBuf)
RealVector * addReal(RooAbsReal *real)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
A TTree is a list of TBranches.
TObjArray * GetListOfLeaves()
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual void SetParameter(Int_t param, Double_t value)
virtual void SetParName(Int_t ipar, const char *name)
void SetName(const char *name="") override
Set the name of the TNamed.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetDimension() const
virtual Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
virtual Int_t GetNbinsX() const
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual const char * GetTypeName() const
virtual TLeaf * GetLeafCounter(Int_t &countval) const
Return a pointer to the counter of this leaf (if any) or store the number of elements that the leaf c...
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Collectable string class.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
TObject()
TObject constructor.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & Prepend(const char *cs)
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr, bool suppressMissingBranchError)
virtual void SetBranchStatus(const char *bname, bool status=true, UInt_t *found=nullptr)
Set branch status to Process or DoNotProcess.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
RooCmdArg ZVar(const RooAbsRealLValue &var, const RooCmdArg &arg={})
RooCmdArg SupNormSet(const RooArgSet &nset)
RooCmdArg SelectVars(const RooArgSet &vars)
RooCmdArg YVar(const RooAbsRealLValue &var, const RooCmdArg &arg={})
RooCmdArg Binning(const RooAbsBinning &binning)
RooCmdArg NormRange(const char *rangeNameList)
RooCmdArg Cut(const char *cutSpec)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
std::string makeSliceCutString(RooArgSet const &sliceDataSet)
std::unique_ptr< T > compileForNormSet(T const &arg, RooArgSet const &normSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
bool checkIfRangesOverlap(RooArgSet const &observables, std::vector< std::string > const &rangeNames)
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')
Double_t Erfc(Double_t x)
Computes the complementary error function erfc(x).
const char * normRangeName
RooFit::MPSplit interleave
const char * projectionRangeName
const RooArgSet * projDataSet
const char * curveNameSuffix
const char * addToCurveName
const RooFitResult * errorFR
const RooArgSet * projSet
const RooAbsData * projData
static constexpr Value_t nullval
The value of the nullid.
constexpr Value_t value() const
Return numerical value of ID.
static uint64_t sum(uint64_t i)