109#include <sys/types.h>
138 RooAbsArg(
name,title), _plotMin(0), _plotMax(0), _plotBins(100),
139 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
152 double inMaxVal,
const char *unit) :
153 RooAbsArg(
name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _plotBins(100),
154 _value(0), _unit(unit), _forceNumInt(false), _specIntegratorConfig(0), _selectComp(true), _lastNSet(0)
166 RooAbsArg(other,
name), _plotMin(other._plotMin), _plotMax(other._plotMax),
167 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
168 _forceNumInt(other._forceNumInt), _selectComp(other._selectComp), _lastNSet(0)
213 if (!assumeSameType) {
229 if(appendUnit && 0 != strlen(
getUnit())) {
281 auto item = evalData.
spans.find(
this);
282 if (item != evalData.
spans.end()) {
288 std::map<RooFit::Detail::DataKey, RooSpan<const double>> dataSpans;
289 for (
auto const &evalDataItem : evalData.
spans) {
290 dataSpans[evalDataItem.first] = evalDataItem.second;
293 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, normSet ? *normSet :
RooArgSet{});
295 driver.setData(dataSpans);
297 results = driver.getValues();
298 evalData.
spans[
this] = results;
305 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, *
data.get());
343 <<
"): validation failed: " <<
value << std::endl ;
363 const RooArgSet* ,
const char* rangeName)
const
394 if (code==0)
return getVal(normSet) ;
408 coutF(Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << std::endl ;
469 os <<
indent <<
"--- RooAbsReal ---" << std::endl;
487 for (
auto const& arg : paramsOfInterest) {
493 name.append(arg->GetName()) ;
532 pc.
defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
537 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
543 const char* rangeName = pc.
getString(
"rangeName",0,
true) ;
568 if (!rangeName || strchr(rangeName,
',')==0) {
574 std::vector<std::string> tokens =
ROOT::Split(rangeName,
",");
577 std::stringstream errMsg;
578 errMsg <<
GetName() <<
" : integrating with respect to the variables " << iset <<
" on the ranges \"" << rangeName
579 <<
"\" is not possible because the ranges are overlapping";
580 const std::string errMsgString = errMsg.str();
581 coutE(Integration) << errMsgString << std::endl;
582 throw std::invalid_argument(errMsgString);
586 for (
const std::string& token : tokens) {
591 title.
Prepend(
"Integral of ") ;
595 auto out = std::make_unique<RooAddition>(fullName.
Data(), title.
Data(), components);
596 out->addOwnedComponents(std::move(components));
597 return RooFit::Detail::owningPtr<RooAbsReal>(std::move(out));
615 std::unique_ptr<RooAbsReal> integral;
620 const std::string title = std::string(
"Integral of ") +
GetTitle();
623 auto out = std::make_unique<RooRealIntegral>(
name.c_str(), title.c_str(), *
this, iset, nset, cfg, rangeName);
624 return RooFit::Detail::owningPtr<RooAbsReal>(std::move(out));
628 while(!iset.
empty()) {
637 if (innerSet.
empty()) {
643 const std::string title = std::string(
"Integral of ") + integrand->
GetTitle();
646 std::unique_ptr<RooAbsReal> innerIntegral = std::move(integral);
649 integral = std::make_unique<RooRealIntegral>(
name.c_str(),title.c_str(),*integrand,innerSet,nset,cfg,rangeName);
653 integral->addOwnedComponents(std::move(innerIntegral));
660 if (integrand ==
this && !iset.
empty()) {
661 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 ;
665 integrand = integral.get();
673 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;
680 if (cacheParamsStr && strlen(cacheParamsStr)) {
682 std::unique_ptr<RooArgSet> intParams{integral->getVariables()};
686 if (!cacheParams.
empty()) {
687 cxcoutD(Caching) <<
"RooAbsReal::createIntObj(" <<
GetName() <<
") INFO: constructing " << cacheParams.
size()
688 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << std::endl ;
690 auto cachedIntegral = std::make_unique<RooCachedReal>(
name.c_str(),
name.c_str(),*integral,cacheParams);
691 cachedIntegral->setInterpolationOrder(2) ;
692 cachedIntegral->addOwnedComponents(std::move(integral));
693 cachedIntegral->setCacheSource(
true) ;
694 if (integral->operMode()==
ADirty) {
695 cachedIntegral->setOperMode(
ADirty) ;
698 return RooFit::Detail::owningPtr<RooAbsReal>(std::move(cachedIntegral));
726 for (
const auto aarg : allObs) {
741 obsWithParamRange.
add(*aarg) ;
742 obsWithFixedRange.
remove(*aarg) ;
743 obsServingAsRangeParams.
add(loBoundObs,
false) ;
744 obsServingAsRangeParams.
add(hiBoundObs,
false) ;
751 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
752 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
755 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
756 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
760 innerObs.
add(obsWithFixedRangeNP) ;
761 innerObs.
add(obsWithParamRangeNP) ;
778 name.Append(
"_Int[") ;
786 name.Append(arg->GetName()) ;
790 name.Append(rangeName) ;
793 }
else if (!omitEmpty) {
794 name.Append(
"_Int[]") ;
797 if (nset && nset->
getSize()>0 ) {
802 name.Append(
"_Norm[") ;
810 name.Append(arg->GetName()) ;
872 for (
const auto arg : dependentVars) {
873 if(!arg->isFundamental() && !
dynamic_cast<const RooAbsLValue*
>(arg)) {
874 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":createPlotProjection: variable \"" << arg->GetName()
875 <<
"\" of wrong type: " << arg->ClassName() << std::endl;
882 <<
"\" is not a dependent and will be ignored." << std::endl;
887 leafNodes.
replace(*found,*arg);
889 leafNodes.
add(*arg) ;
893 arg->getObservables(&leafNodes, lvDep);
894 for (
const auto lvs : lvDep) {
898 leafNodes.
add(*lvs) ;
905 if(0 != projectedVars && projectedVars->
find(arg->GetName())) {
907 <<
"\" cannot be both a dependent and a projected variable." << std::endl;
913 if(0 != projectedVars) leafNodes.
remove(*projectedVars,
true);
918 coutE(Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << std::endl ;
929 std::unique_ptr<RooArgSet> plotLeafNodes{
static_cast<RooArgSet*
>(leafNodes.
selectCommon(dependentVars))};
934 if(0 != projectedVars) normSet.
add(*projectedVars);
936 normSet.
remove(*condObs,
true,
true) ;
943 if(0 == projectedVars) projectedVars= ∅
949 title.
Prepend(
"Projection of ");
952 std::unique_ptr<RooAbsReal> projected{theClone->
createIntegral(*projectedVars,normSet,rangeName)};
954 if(
nullptr == projected || !projected->isValid()) {
955 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":createPlotProjection: cannot integrate out ";
964 projected->SetName(
name.Data()) ;
965 projected->SetTitle(title.
Data()) ;
969 cloneSet->
addOwned(std::move(projected));
994 double scaleFactor,
const RooArgSet *projectedVars,
bool scaleForDensity,
995 const RooArgSet* condObs,
bool setError)
const
999 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: no valid histogram to fill" << std::endl;
1005 if(hdim != plotVars.
getSize()) {
1006 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: plotVars has the wrong dimension" << std::endl;
1019 <<
"\" of type " << var->
ClassName() << std::endl;
1024 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << std::endl;
1026 plotClones.
addClone(*realVar,
true);
1036 if (projectedVars) {
1037 allDeps.
add(*projectedVars) ;
1040 coutE(InputArguments) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1048 cxcoutD(Plotting) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") plot projection object is " << projected->
GetName() << std::endl ;
1051 Int_t xbins(0),ybins(1),zbins(1);
1063 assert(0 != zvar && 0 != zaxis);
1064 if (scaleForDensity) {
1072 assert(0 != yvar && 0 != yaxis);
1073 if (scaleForDensity) {
1081 assert(0 != xvar && 0 != xaxis);
1082 if (scaleForDensity) {
1087 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: cannot fill histogram with "
1088 << hdim <<
" dimensions" << std::endl;
1095 Int_t xbin(0),ybin(0),zbin(0);
1096 Int_t bins= xbins*ybins*zbins;
1097 for(
Int_t bin= 0; bin < bins; bin++) {
1100 if(bin % (xbins*ybins) == 0) {
1106 if(bin % xbins == 0) {
1107 ybin= (ybin%ybins) + 1;
1112 xbin= (xbin%xbins) + 1;
1116 coutE(InputArguments) <<
"RooAbsReal::fillHistogram: Internal Error!" << std::endl;
1122 coutW(Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1123 if (hdim==2)
ccoutW(Plotting) <<
" [y]=" << yvar->
getVal() ;
1124 if (hdim==3)
ccoutW(Plotting) <<
" [z]=" << zvar->
getVal() ;
1125 ccoutW(Plotting) << std::endl ;
1167 bool correctForBinSize,
bool showProgress)
const
1171 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillDataHist: no valid RooDataHist to fill" << std::endl;
1178 coutE(InputArguments) <<
"RooAbsReal::fillDataHist(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1195 if (showProgress && (i%onePct==0)) {
1196 ccoutP(Eval) <<
"." << std::flush ;
1199 double binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1200 if (correctForBinSize) {
1203 hist->
set(i, binVal, 0.);
1229 std::vector<RooRealVar*> histVars(3,
nullptr);
1231 for(std::size_t iVar = 0; iVar < varNames.size(); ++iVar) {
1232 if(varNames[iVar].empty())
continue;
1234 std::stringstream errMsg;
1235 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR more than three variable names passed, but maxumum number of supported variables is three";
1236 coutE(Plotting) << errMsg.str() << std::endl;
1237 throw std::invalid_argument(errMsg.str());
1239 auto var =
static_cast<RooRealVar*
>(vars->find(varNames[iVar].c_str()));
1241 std::stringstream errMsg;
1242 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR variable " << varNames[iVar] <<
" does not exist in argset: " << *vars;
1243 coutE(Plotting) << errMsg.str() << std::endl;
1244 throw std::runtime_error(errMsg.str());
1246 histVars[iVar] = var;
1328 pc.
defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1329 pc.
defineInt(
"extended",
"Extended",0,2) ;
1331 pc.
defineSet(
"compSet",
"SelectCompSet",0);
1333 pc.
defineSet(
"projObs",
"ProjectedObservables",0,0) ;
1336 pc.
defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1338 pc.
defineMutex(
"IntrinsicBinning",
"BinningName") ;
1339 pc.
defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1358 auto projObs = pc.
getSet(
"projObs");
1361 bool doScaling = pc.
getInt(
"scaling") ;
1367 if (!pdfSelf && doExtended == 1) {
1368 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << std::endl ;
1372 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << std::endl ;
1375 if (pdfSelf && doExtended==2) {
1377 }
else if(!pdfSelf) {
1381 const char* compSpec = pc.
getString(
"compSpec") ;
1383 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1385 std::unique_ptr<RooBinning> intBinning;
1386 if (doIntBinning>0) {
1391 if (doIntBinning==1) {
1392 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1393 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< std::endl ;
1396 if (doIntBinning==2) {
1397 coutI(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1398 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< std::endl ;
1400 std::vector<double> ba(bl->size());
1402 for (
auto const& elem : *bl) { ba[i++] = elem ; }
1403 intBinning = std::make_unique<RooBinning>(bl->size()-1,ba.data()) ;
1408 RooCmdConfig::stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1413 argListCreate.
Add(&tmp) ;
1429 branchNodeSet.
remove(*arg) ;
1433 std::unique_ptr<RooArgSet> dirSelNodes;
1439 if (!dirSelNodes->empty()) {
1440 coutI(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << std::endl ;
1446 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << std::endl ;
1448 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << std::endl ;
1454 double scaleFactor(1.0) ;
1460 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,
false) ;
1487 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1488 const auto arg = branchNodeSet[i];
1490 branchNodeSet.
remove(*arg) ;
1497 for (
const auto arg : branchNodeSet) {
1506 for (
const auto arg : branchNodeSet) {
1507 for (
const auto selNode : *selNodes) {
1508 if (selNode->dependsOn(*arg)) {
1515 for (
const auto arg : branchNodeSet) {
1516 if (arg->dependsOn(*selNodes)) {
1521 tmp.
remove(*selNodes,
true);
1524 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << std::endl ;
1527 for (
const auto arg : branchNodeSet) {
1528 bool select = selNodes->
find(arg->GetName()) !=
nullptr;
1682 argList.
Add(&rnorm) ;
1684 std::vector<std::string> rlist;
1688 rlist.emplace_back(rangeNameToken);
1691 for (
const auto& rangeString : rlist) {
1693 rcmd->
setString(0, rangeString.c_str());
1703 pc.
defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
true) ;
1704 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1705 pc.
defineString(
"sliceCatState",
"SliceCat",0,
"",
true) ;
1708 pc.
defineSet(
"sliceSet",
"SliceVars",0) ;
1718 pc.
defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1719 pc.
defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1720 pc.
defineSet(
"projDataSet",
"ProjData",0) ;
1724 pc.
defineSet(
"errorPars",
"VisualizeError",0) ;
1725 pc.
defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1726 pc.
defineInt(
"binProjData",
"ProjData",0,0) ;
1729 pc.
defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1730 pc.
defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1731 pc.
defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1735 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1736 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1738 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
1739 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1740 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1741 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
1742 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1744 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
1745 pc.
defineInt(
"showProg",
"ShowProgress",0,0) ;
1747 pc.
defineInt(
"interleave",
"NumCPU",1,0) ;
1751 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1755 pc.
defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1769 bool linMethod = pc.
getInt(
"linearMethod") ;
1770 if (!drawOpt.
Contains(
"P") && errFR) {
1791 std::unique_ptr<RooArgSet> sliceSet{sliceSetTmp ?
static_cast<RooArgSet*
>(sliceSetTmp->
Clone()) :
nullptr};
1797 const char* sliceCatState = pc.
getString(
"sliceCatState",0,
true) ;
1799 if (sliceCatState) {
1803 sliceSet = std::make_unique<RooArgSet>();
1808 auto iter = sliceCatList.
begin();
1809 for (
unsigned int i=0; i < catTokens.size(); ++i) {
1810 if (
auto scat =
static_cast<RooCategory*
>(*iter)) {
1812 scat->setLabel(catTokens[i]) ;
1814 sliceSet->add(*scat,
false) ;
1827 if (vlines==2) vlines=0 ;
1833 if (vlines==2) vlines=0 ;
1853 coutE(InputArguments) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") cannot find existing curve " << o.
addToCurveName <<
" to add to in RooPlot" << std::endl ;
1859 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << std::endl ;
1864 for (
const auto sliceArg : *sliceSet) {
1867 projectedVars.
remove(*arg) ;
1869 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") slice variable "
1870 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
1873 }
else if (projSet) {
1874 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << std::endl ;
1877 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << std::endl ;
1882 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << std::endl ;
1912 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1913 coutW(Plotting) <<
"Fill color or style was set for plotting \"" <<
GetName()
1914 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1954 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjData with observables = " << *o.
projData->
get() << std::endl ;
1957 projDataVars.
add(*tmp) ;
1958 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjDataSet = " << *o.
projDataSet <<
" will only use this subset of projData" << std::endl ;
1960 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") using full ProjData" << std::endl ;
1965 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") ProjDataVars = " << projDataVars << std::endl ;
1971 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have input projSet = " << *o.
projSet << std::endl ;
1973 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") calculated projectedVars = " << *o.
projSet << std::endl ;
1980 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << sliceSetTmp << std::endl ;
1982 sliceSetTmp.
remove(projectedVars,
true,
true) ;
1987 sliceSetTmp.
remove(*tmp,
true,
true) ;
1990 if (!sliceSetTmp.
empty()) {
1991 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on "
1992 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
1994 sliceSet.
add(sliceSetTmp) ;
2000 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << std::endl ;
2007 projectedVars.
remove(projDataVars,
true,
true) ;
2012 double oldPlotVarVal = plotVar->
getVal();
2015 if (projectedVars.
getSize()) {
2016 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->GetName()
2017 <<
" integrates over variables " << projectedVars
2020 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2021 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2022 <<
" averages using data variables " << *projDataNeededVars << std::endl ;
2030 deps.
remove(projectedVars,
true,
true) ;
2031 if (projDataNeededVars) {
2032 deps.
remove(*projDataNeededVars,
true,
true) ;
2034 deps.
remove(*plotVar,
true,
true) ;
2035 deps.
add(*plotVar) ;
2041 coutE(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
2042 if (projDataNeededVars)
delete projDataNeededVars ;
2047 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot projection object is " << projection->
GetName() << std::endl ;
2054 fullNormSet.
add(projectedVars) ;
2055 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2056 fullNormSet.
add(*projDataNeededVars) ;
2059 std::unique_ptr<RooArgSet> projectionComponents(projection->
getComponents());
2060 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*projectionComponents)) {
2062 pdf->selectNormalization(&fullNormSet) ;
2067 if (o.
projData && projDataNeededVars && projDataNeededVars->
getSize()>0) {
2077 if (!sliceDataSet->empty()) {
2079 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2096 if (!cutString.
IsNull()) {
2098 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2103 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2112 if (!
dynamic_cast<RooCategory*
>(arg2)) allCat =
false ;
2116 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2117 <<
" performing projection with binned copy for optimization." << std::endl ;
2125 if (projDataSel!=o.
projData)
delete projDataSel ;
2132 projection->
getVal(projDataSel->
get()) ;
2140 std::move(cfg),
true) ;
2194 if (projDataSel!=o.
projData)
delete projDataSel ;
2275 if (projDataNeededVars)
delete projDataNeededVars ;
2276 delete projectionCompList ;
2277 plotVar->setVal(oldPlotVarVal);
2297 projectedVars.
remove(*arg) ;
2299 coutI(Plotting) <<
"RooAbsReal::plotSliceOn(" <<
GetName() <<
") slice variable "
2300 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
2342 projDataVars.
add(*tmp) ;
2350 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2351 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << std::endl ;
2357 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2358 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << std::endl ;
2372 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2377 sliceSetTmp.
remove(*tmp,
true,
true) ;
2380 if (!sliceSetTmp.
empty()) {
2381 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on "
2382 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
2384 sliceSet.
add(sliceSetTmp) ;
2395 projectedVars.
remove(projDataVars,
true,
true) ;
2408 if (projectedVars.
getSize()) {
2409 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2410 <<
" projects variables " << projectedVars << std::endl ;
2412 if (projDataNeededVars && projDataNeededVars->
getSize()>0) {
2413 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2414 <<
" averages using data variables "<< *projDataNeededVars << std::endl ;
2422 asymNeg->setIndex(-1) ;
2428 custNeg.replaceArg(asymCat,*asymNeg) ;
2429 std::unique_ptr<RooAbsReal> funcPos{
static_cast<RooAbsReal*
>(custPos.build())};
2430 std::unique_ptr<RooAbsReal> funcNeg{
static_cast<RooAbsReal*
>(custNeg.build())};
2433 RooArgSet *posProjCompList, *negProjCompList ;
2439 depPos.
add(projDataVars) ;
2440 depNeg.
add(projDataVars) ;
2444 if (!posProj || !negProj) {
2445 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << std::endl ;
2451 asymName.
Append(
"_Asym[") ;
2455 asymTitle.
Append(
" Asymmetry of ") ;
2468 if (!sliceDataSet->
empty()) {
2470 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2486 delete sliceDataSet ;
2488 if (!cutString.
IsNull()) {
2490 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2491 <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2495 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2496 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2504 std::move(cfg),
true) ;
2510 ((
RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2511 ((
RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2522 TString curveName(funcAsym.GetName()) ;
2535 RooCurve *curve =
new RooCurve(funcAsym.GetName(),funcAsym.GetTitle(),scaleBind,
2543 ccoutW(Eval) << std::endl ;
2545 if (projDataSel!=o.
projData)
delete projDataSel ;
2564 TString curveName(funcAsym.GetName()) ;
2580 delete posProjCompList ;
2581 delete negProjCompList ;
2611 for(
auto * rrvFitRes : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2613 auto rrvInAbsReal =
static_cast<RooRealVar const*
>(allParamsInAbsReal.
find(*rrvFitRes));
2620 if (rrvFitRes->getError() <= std::abs(rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
continue;
2623 if(!rrvInAbsReal)
continue;
2627 if(std::abs(rrvInAbsReal->getVal() - rrvFitRes->getVal()) > 0.01 * rrvFitRes->getError()) {
2628 std::stringstream errMsg;
2629 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
2630 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
2632 throw std::runtime_error(errMsg.str());
2635 paramList.
add(*rrvInAbsReal);
2638 std::vector<double> plusVar;
2639 std::vector<double> minusVar;
2640 plusVar.reserve(paramList.
size());
2641 minusVar.reserve(paramList.
size());
2648 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2650 auto& rrv =
static_cast<RooRealVar&
>(paramList[ivar]);
2652 double cenVal = rrv.
getVal() ;
2653 double errVal = sqrt(V(ivar,ivar)) ;
2656 rrv.setVal(cenVal+errVal) ;
2657 plusVar.push_back(
getVal(nset)) ;
2660 rrv.setVal(cenVal-errVal) ;
2661 minusVar.push_back(
getVal(nset)) ;
2663 rrv.setVal(cenVal) ;
2676 std::vector<double> errVec(paramList.
getSize()) ;
2677 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2678 errVec[i] = std::sqrt(V(i,i)) ;
2679 for (
int j=i ; j<paramList.
getSize() ; j++) {
2680 C(i,j) = V(i,j) / std::sqrt(V(i,i)*V(j,j));
2687 for (
unsigned int j=0 ; j<plusVar.size() ; j++) {
2688 F[j] = (plusVar[j]-minusVar[j])/2 ;
2692 double sum =
F*(C*
F) ;
2739 for (
auto * cmd : static_range_cast<RooCmdArg*>(plotArgListTmp)) {
2740 if (std::string(
"Normalization")==cmd->GetName()) {
2743 plotArgList.
Add(cmd) ;
2746 plotArgList.
Add(cmd) ;
2753 auto plotFunc = [&](
RooAbsReal const& absReal) {
2756 absReal.plotOn(frame, tmp);
2763 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOnWithErrorBand: no curve for central value available" << std::endl;
2790 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2791 << errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << std::endl ;
2796 std::unique_ptr<RooDataSet> generatedData{paramPdf->
generate(errorParams,
n)};
2797 std::vector<RooCurve*> cvec ;
2798 for (
int i=0 ; i<generatedData->numEntries() ; i++) {
2799 cloneParams.
assign(*generatedData->get(i)) ;
2800 plotFunc(*cloneFunc);
2801 cvec.push_back(frame->
getCurve()) ;
2814 for (std::vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2832 for (
auto const* frv : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2833 if (frv->getError() > frv->getVal() * std::numeric_limits<double>::epsilon()) {
2834 fpf_stripped.
add(*frv);
2852 std::vector<int> fpf_idx ;
2856 paramList.
add(*par) ;
2857 fpf_idx.push_back(i) ;
2861 std::vector<RooCurve*> plusVar, minusVar ;
2870 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2874 double cenVal = rrv.
getVal() ;
2875 double errVal = sqrt(V(ivar,ivar)) ;
2878 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal+Z*errVal) ;
2881 plotFunc(*cloneFunc);
2882 plusVar.push_back(frame->
getCurve()) ;
2887 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal-Z*errVal) ;
2888 plotFunc(*cloneFunc);
2889 minusVar.push_back(frame->
getCurve()) ;
2896 std::vector<double> errVec(paramList.
getSize()) ;
2897 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2898 errVec[i] = sqrt(V(i,i)) ;
2899 for (
int j=i ; j<paramList.
getSize() ; j++) {
2900 C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2910 for (std::vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2913 for (std::vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2920 if (!band)
return frame ;
2925 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
2926 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
2927 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
2928 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
2929 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
2930 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
2932 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
2933 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
2935 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
2936 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
2969 }
else if (pc.
getString(
"curveNameSuffix",0,
true)) {
3002 <<
":plotOn: frame does not specify a plot variable" << std::endl;
3015 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOn: WARNING: variable is not an explicit dependent: "
3016 << var->
GetName() << std::endl;
3034 RooArgSet& projectedVars,
bool silent)
const
3036 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") plotVar = " << plotVar->
GetName()
3037 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << std::endl ;
3040 if (!allVars) return ;
3043 projectedVars.
add(*allVars) ;
3048 projectedVars.
remove(*found);
3051 std::unique_ptr<RooArgSet> plotServers{plotVar->
getObservables(&projectedVars)};
3055 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") removing " << tmp->
GetName()
3056 <<
" from projection set because it a server of " << plotVar->
GetName() << std::endl ;
3057 projectedVars.
remove(*tmp) ;
3063 <<
") WARNING: cannot project out frame variable ("
3064 << found->
GetName() <<
"), ignoring" << std::endl ;
3071 projectedVars.
remove(*arg,
true) ;
3074 <<
") function doesn't depend on projection variable "
3075 << arg->GetName() <<
", ignoring" << std::endl ;
3113 if(binding && !binding->
isValid()) {
3114 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":bindVars: cannot bind to " << vars << std::endl ;
3130 auto other =
static_cast<const RooAbsReal*
>(source);
3131 assert(
dynamic_cast<const RooAbsReal*
>(source));
3133 _value = other->_treeReadBuffer ? other->_treeReadBuffer->operator
double() : other->_value;
3174 coutE(Eval) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") ERROR: TTree branch " <<
GetName()
3175 <<
" is an array and cannot be attached to a RooAbsReal" << std::endl ;
3185 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3186 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3187 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3188 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3189 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3190 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3191 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3192 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3193 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3194 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3195 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3198 auto typeDetails = typeMap.find(typeName.
Data());
3199 if (typeDetails != typeMap.end()) {
3200 coutI(DataHandling) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") TTree " << typeDetails->first <<
" branch " <<
GetName()
3201 <<
" will be converted to double precision." << std::endl ;
3211 coutE(InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << std::endl ;
3233 coutE(Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree: " <<
cleanBranchName() << std::endl ;
3371 const TList &nameList)
const
3374 bool isMatched(
true);
3375 for(
auto *
name : static_range_cast<TObjString*>(nameList)) {
3378 matched.
add(*found);
3392 if(isMatched) matchedArgs.
add(matched);
3441 if (config)
return config ;
3454 if (config)
return config ;
3554 static bool inLogEvalError = false ;
3556 if (inLogEvalError) {
3559 inLogEvalError = true ;
3564 if (serverValueString) {
3569 oocoutE(
nullptr,Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << std::endl
3570 <<
" origin : " << origName << std::endl
3571 <<
" message : " << ee.
_msg << std::endl
3572 <<
" server values: " << ee.
_srvval << std::endl ;
3579 inLogEvalError = false ;
3609 static bool inLogEvalError = false ;
3611 if (inLogEvalError) {
3614 inLogEvalError = true ;
3619 if (serverValueString) {
3622 std::string srvval ;
3623 std::ostringstream oss ;
3634 p->print(oss,
true) ;
3639 std::ostringstream oss2 ;
3643 coutE(Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << std::endl
3644 <<
" origin : " << oss2.str() << std::endl
3645 <<
" message : " << ee.
_msg << std::endl
3646 <<
" server values: " << ee.
_srvval << std::endl ;
3655 <<
") delayed evaluation error, " << std::endl
3656 <<
" origin : " << oss2.str() << std::endl
3657 <<
" message : " << oee.
_msg << std::endl
3658 <<
" server values: " << oee.
_srvval << std::endl ;
3665 inLogEvalError = false ;
3721 if (maxPerNode<0) return ;
3724 if (maxPerNode==0) {
3727 os << iter->second.first ;
3729 os <<
" has " << iter->second.second.size() <<
" errors" << std::endl ;
3734 os << iter->second.first << std::endl ;
3738 for(
auto iter2 = iter->second.second.begin();iter2!=iter->second.second.end() ; ++iter2, i++) {
3739 os <<
" " << iter2->_msg <<
" @ " << iter2->_srvval << std::endl ;
3741 os <<
" ... (remaining " << iter->second.second.size() - maxPerNode <<
" messages suppressed)" << std::endl ;
3762 ntot += elem.second.second.size() ;
3782 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3785 pdf->selectNormalization(&addNormSet,force) ;
3787 pdf->selectNormalization(0,force) ;
3807 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3809 pdf->selectNormalizationRange(rangeName,force) ;
3827 orderedObs.
add(obs) ;
3885 pc.
defineSet(
"supNormSet",
"SupNormSet",0,0) ;
3886 pc.
defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3887 pc.
defineInt(
"intOrder",
"ScanParameters",1,2) ;
3888 pc.
defineInt(
"doScanNum",
"ScanNum",0,1) ;
3889 pc.
defineInt(
"doScanAll",
"ScanAll",0,0) ;
3890 pc.
defineInt(
"doScanNon",
"ScanNone",0,0) ;
3894 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3922 coutI(NumIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << std::endl
3923 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3924 << intOrder <<
" interpolation on integrated histogram." << std::endl
3925 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << std::endl ;
3943 ivar->
setBins(numScanBins,
"numcdf") ;
3944 auto ret = std::make_unique<RooNumRunningInt>(
name.c_str(),
name.c_str(),*
this,*ivar,
"numrunint") ;
3945 ret->setInterpolationOrder(intOrder) ;
3964 coutW(InputArguments) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << std::endl ;
3978 for(
auto * rrv : static_range_cast<RooRealVar*>(ilist)) {
3982 cloneList.
add(*cloneArg) ;
3987 cloneLo->
setVal(rrv->getMin()) ;
3988 loList.
add(*cloneLo) ;
4000 finalNset.
add(cloneList,
true) ;
4001 std::unique_ptr<RooAbsReal> cdf{tmp->
createIntegral(cloneList,finalNset,
"CDF")};
4004 cdf->addOwnedComponents(*tmp) ;
4005 cdf->addOwnedComponents(cloneList) ;
4006 cdf->addOwnedComponents(loList) ;
4020 if (realObs.
size() != obs.
size()) {
4021 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
4026 if (realPars.
size() != pars.
size()) {
4027 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4045 if (realObs.
size() != obs.
size()) {
4046 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
4051 if (realPars.
size() != pars.
size()) {
4052 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4057 for (
int i=0 ; i<obs.
getSize() ; i++) {
4059 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed observable " << obs.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
4063 for (
int i=0 ; i<pars.
getSize() ; i++) {
4065 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed parameter " << pars.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
4097 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << std::endl ;
4102 for (
int i=0 ; i<pars.
getSize() ; i++) {
4132 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
4147 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4149 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
4150 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
4166 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4168 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
4169 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
4170 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4295 return new RooChi2Var(
name.c_str(),
name.c_str(),*
this,
data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4311 for(
auto * arg : static_range_cast<RooCmdArg*>(cmdList)) {
4318 return createChi2(
data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4384 std::unique_ptr<RooAbsReal> xychi2{
createChi2(xydata,chi2CmdList)};
4427 pc.
defineInt(
"integrate",
"Integrate",0,0) ;
4437 bool integrate = pc.
getInt(
"integrate") ;
4462 pc.
defineInt(
"optConst",
"Optimize",0,1) ;
4466 pc.
defineInt(
"plevel",
"PrintLevel",0,1) ;
4468 pc.
defineInt(
"initHesse",
"InitialHesse",0,0) ;
4472 pc.
defineInt(
"numee",
"PrintEvalErrors",0,10) ;
4476 pc.
defineSet(
"minosSet",
"Minos",0,
nullptr) ;
4485 const char* minType = pc.
getString(
"mintype",
"") ;
4486 const char* minAlg = pc.
getString(
"minalg",
"minuit") ;
4500 std::unique_ptr<RooFitResult> ret;
4504 m.setMinimizerType(minType);
4510 m.setPrintEvalErrors(numee) ;
4512 m.setPrintLevel(plevel) ;
4517 m.optimizeConst(optConst);
4531 m.setStrategy(strat) ;
4540 m.minimize(minType, minAlg) ;
4550 m.minos(*minosSet) ;
4559 std::string title =
Form(
"Result of fit of %s ",
GetName()) ;
4560 ret = std::unique_ptr<RooFitResult>{
m.save(
name.c_str(),title.c_str())};
4595 for (
auto const* arg : paramVars) {
4597 coutW(InputArguments) <<
"RooAbsReal::setParameterizeIntegral(" <<
GetName()
4598 <<
") function does not depend on std::listed parameter " << arg->
GetName() <<
", ignoring" << std::endl ;
4601 if (plist.size()>0) plist +=
":" ;
4602 plist += arg->GetName() ;
4641 std::vector<ServerData> ourServers;
4642 std::size_t dataSize = 1;
4644 for (
auto absArgServer :
servers()) {
4645 if (absArgServer->IsA()->InheritsFrom(
RooAbsReal::Class()) && absArgServer->isValueServer(*
this)) {
4646 auto server =
static_cast<RooAbsReal*
>(absArgServer);
4647 ourServers.push_back({server,
4648 server->getValues(evalData, normSet),
4649 server->getVal(normSet),
4650 server->operMode()});
4653 dataSize = std::max(dataSize, ourServers.back().batch.size());
4659 struct RestoreStateRAII {
4660 RestoreStateRAII(std::vector<ServerData>& servers) :
4661 _servers{servers} { }
4663 ~RestoreStateRAII() {
4664 for (
auto& serverData : _servers) {
4665 serverData.server->setCachedValue(serverData.oldValue,
true);
4666 serverData.server->setOperMode(serverData.oldOperMode);
4670 std::vector<ServerData>& _servers;
4671 } restoreState{ourServers};
4677 coutI(FastEvaluations) <<
"The class " <<
ClassName() <<
" does not implement the faster batch evaluation interface."
4678 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4683 auto outputData = evalData.
makeBatch(
this, dataSize);
4685 for (std::size_t i=0; i < outputData.size(); ++i) {
4686 for (
auto& serv : ourServers) {
4687 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4713 std::vector<ServerData> ourServers;
4716 for (
auto server :
servers()) {
4717 auto serverValues = dataMap.
at(server);
4718 if(serverValues.empty())
continue;
4721 auto oldOperMode = server->operMode();
4726 ourServers.push_back({server,
4730 server->_valueDirty,
4731 server->_shapeDirty});
4737 struct RestoreStateRAII {
4738 RestoreStateRAII(std::vector<ServerData>& servers) :
4739 _servers{servers} { }
4741 ~RestoreStateRAII() {
4742 for (
auto& serverData : _servers) {
4743 serverData.server->setCachedValue(serverData.oldValue,
true);
4744 serverData.server->setOperMode(serverData.oldOperMode);
4745 serverData.server->_valueDirty = serverData.oldValueDirty;
4746 serverData.server->_shapeDirty = serverData.oldShapeDirty;
4750 std::vector<ServerData>& _servers;
4751 } restoreState{ourServers};
4757 coutI(FastEvaluations) <<
"The class " <<
ClassName() <<
" does not implement the faster batch evaluation interface."
4758 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4764 for (std::size_t i=0; i < nEvents; ++i) {
4765 for (
auto& serv : ourServers) {
4766 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4778 const bool tmpFast =
_fast;
4779 const double tmp =
_value;
4781 double fullEval = 0.;
4783 fullEval =
getValV(normalisationSet);
4792 if (std::isfinite(ret) && ( ret != 0. ? (ret - fullEval)/ret : ret - fullEval) > 1.E-9) {
4797 formatter <<
"--> (Scalar computation wrong here:)\n"
4798 <<
GetName() <<
" " <<
this <<
" _fast=" << tmpFast
4799 <<
"\n\tcached _value=" << std::setprecision(16) << tmp
4800 <<
"\n\treturning =" << ret
4801 <<
"\n\trecomputed =" << fullEval
4802 <<
"\n\tnew _value =" <<
_value <<
"] ";
4803 formatter <<
"\nServers:";
4829 auto realServer =
dynamic_cast<RooAbsReal*
>(server);
4838 const auto item = evalData.
spans.find(
this);
4839 if (item == evalData.
spans.end())
4842 auto batch = item->second;
4844 const double batchVal = batch.size() == 1 ? batch[0] : batch[evtNo];
4847 if (std::abs(relDiff) > relAccuracy && std::abs(
value) > 1.E-300) {
4849 formatter <<
"--> (Batch computation wrong:)\n";
4851 formatter <<
"\n batch=" << batch.data() <<
" size=" << batch.size() << std::setprecision(17)
4852 <<
"\n batch[" << std::setw(7) << evtNo-1 <<
"]= " << (evtNo > 0 && evtNo - 1 < batch.size() ? std::to_string(batch[evtNo-1]) :
"---")
4853 <<
"\n batch[" << std::setw(7) << evtNo <<
"]= " << batchVal <<
" !!!"
4854 <<
"\n expected ('value'): " <<
value
4855 <<
"\n eval(unnorm.) : " <<
evaluate()
4856 <<
"\n delta " <<
" = " <<
value - batchVal
4857 <<
"\n rel delta " <<
" = " << relDiff
4858 <<
"\n _batch[" << std::setw(7) << evtNo+1 <<
"]= " << (batch.size() > evtNo+1 ? std::to_string(batch[evtNo+1]) :
"---");
4862 formatter <<
"\nServers: ";
4864 formatter <<
"\n - ";
4866 formatter << std::setprecision(17);
4868 auto serverAsReal =
dynamic_cast<RooAbsReal*
>(server);
4871 if (serverBatch.size() > evtNo) {
4872 formatter <<
"\n _batch[" << evtNo-1 <<
"]=" << (serverBatch.size() > evtNo-1 ? std::to_string(serverBatch[evtNo-1]) :
"---")
4873 <<
"\n _batch[" << evtNo <<
"]=" << serverBatch[evtNo]
4874 <<
"\n _batch[" << evtNo+1 <<
"]=" << (serverBatch.size() > evtNo+1 ? std::to_string(serverBatch[evtNo+1]) :
"---");
4877 formatter << std::setprecision(17)
4878 <<
"\n getVal()=" << serverAsReal->getVal(normSet);