108#include <sys/types.h>
145 double inMaxVal,
const char *unit) :
146 RooAbsArg(
name,title), _plotMin(inMinVal), _plotMax(inMaxVal), _unit(unit)
156 RooAbsArg(other,
name), _plotMin(other._plotMin), _plotMax(other._plotMax),
157 _plotBins(other._plotBins), _value(other._value), _unit(other._unit), _label(other._label),
158 _forceNumInt(other._forceNumInt), _selectComp(other._selectComp)
197 if (!assumeSameType) {
213 if(appendUnit && 0 != strlen(
getUnit())) {
262 auto item = evalData.
spans.find(
this);
263 if (item != evalData.
spans.end()) {
267 std::map<RooFit::Detail::DataKey, RooSpan<const double>> dataSpans;
268 for (
auto const &evalDataItem : evalData.
spans) {
269 dataSpans[evalDataItem.first] = evalDataItem.second;
272 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, normSet ? *normSet :
RooArgSet{});
274 driver.setData(dataSpans);
276 results = driver.getValues();
277 evalData.
spans[
this] = results;
284 std::unique_ptr<RooAbsReal>
clone = RooFit::Detail::compileForNormSet<RooAbsReal>(*
this, *
data.get());
322 <<
"): validation failed: " <<
value << std::endl ;
342 const RooArgSet* ,
const char* rangeName)
const
373 if (code==0)
return getVal(normSet) ;
387 coutF(Eval) <<
"RooAbsReal::analyticalIntegral(" <<
GetName() <<
") code " << code <<
" not implemented" << std::endl ;
448 os <<
indent <<
"--- RooAbsReal ---" << std::endl;
466 for (
auto const& arg : paramsOfInterest) {
472 name.append(arg->GetName()) ;
511 pc.
defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
516 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
522 const char* rangeName = pc.
getString(
"rangeName",0,
true) ;
547 if (!rangeName || strchr(rangeName,
',')==0) {
555 std::vector<std::string> tokens =
ROOT::Split(rangeName,
",");
558 std::stringstream errMsg;
559 errMsg <<
GetName() <<
" : integrating with respect to the variables " << iset <<
" on the ranges \"" << rangeName
560 <<
"\" is not possible because the ranges are overlapping";
561 const std::string errMsgString = errMsg.str();
562 coutE(Integration) << errMsgString << std::endl;
563 throw std::invalid_argument(errMsgString);
566 for (
const std::string& token : tokens) {
568 components.
add(*compIntegral);
571 const std::string title = std::string(
"Integral of ") +
GetTitle();
574 return new RooAddition(fullName.c_str(), title.c_str(), components,
true);
592 std::unique_ptr<RooAbsReal> integral;
597 const std::string title = std::string(
"Integral of ") +
GetTitle();
600 return new RooRealIntegral(
name.c_str(), title.c_str(), *
this, iset, nset, cfg, rangeName);
604 while(!iset.
empty()) {
613 if (innerSet.
empty()) {
619 const std::string title = std::string(
"Integral of ") + integrand->
GetTitle();
622 std::unique_ptr<RooAbsReal> innerIntegral = std::move(integral);
625 integral = std::make_unique<RooRealIntegral>(
name.c_str(),title.c_str(),*integrand,innerSet,nset,cfg,rangeName);
629 integral->addOwnedComponents(std::move(innerIntegral));
636 if (integrand ==
this && !iset.
empty()) {
637 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 ;
641 integrand = integral.get();
649 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;
656 if (cacheParamsStr && strlen(cacheParamsStr)) {
658 std::unique_ptr<RooArgSet> intParams{integral->getVariables()};
662 if (!cacheParams.
empty()) {
663 cxcoutD(Caching) <<
"RooAbsReal::createIntObj(" <<
GetName() <<
") INFO: constructing " << cacheParams.
size()
664 <<
"-dim value cache for integral over " << iset2 <<
" as a function of " << cacheParams <<
" in range " << (rangeName?rangeName:
"<none>") << std::endl ;
670 if (integral->operMode()==
ADirty) {
674 return cachedIntegral;
678 return integral.release();
702 for (
const auto aarg : allObs) {
707 RooAbsBinning& binning = arglv->getBinning(rangeName,
false,
true) ;
716 obsWithParamRange.
add(*aarg) ;
717 obsWithFixedRange.
remove(*aarg) ;
718 obsServingAsRangeParams.
add(loBoundObs,
false) ;
719 obsServingAsRangeParams.
add(hiBoundObs,
false) ;
726 RooArgSet obsWithFixedRangeNP(obsWithFixedRange) ;
727 obsWithFixedRangeNP.
remove(obsServingAsRangeParams) ;
730 RooArgSet obsWithParamRangeNP(obsWithParamRange) ;
731 obsWithParamRangeNP.
remove(obsServingAsRangeParams) ;
735 innerObs.
add(obsWithFixedRangeNP) ;
736 innerObs.
add(obsWithParamRangeNP) ;
753 name.Append(
"_Int[") ;
761 name.Append(arg->GetName()) ;
765 name.Append(rangeName) ;
768 }
else if (!omitEmpty) {
769 name.Append(
"_Int[]") ;
772 if (nset && !nset->
empty()) {
777 name.Append(
"_Norm[") ;
785 name.Append(arg->GetName()) ;
847 for (
const auto arg : dependentVars) {
848 if(!arg->isFundamental() && !
dynamic_cast<const RooAbsLValue*
>(arg)) {
849 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":createPlotProjection: variable \"" << arg->GetName()
850 <<
"\" of wrong type: " << arg->ClassName() << std::endl;
857 <<
"\" is not a dependent and will be ignored." << std::endl;
862 leafNodes.
replace(*found,*arg);
864 leafNodes.
add(*arg) ;
868 arg->getObservables(&leafNodes, lvDep);
869 for (
const auto lvs : lvDep) {
873 leafNodes.
add(*lvs) ;
880 if(0 != projectedVars && projectedVars->
find(arg->GetName())) {
882 <<
"\" cannot be both a dependent and a projected variable." << std::endl;
888 if(0 != projectedVars) leafNodes.
remove(*projectedVars,
true);
893 coutE(Plotting) <<
"RooAbsPdf::createPlotProjection(" <<
GetName() <<
") Couldn't deep-clone PDF, abort," << std::endl ;
904 std::unique_ptr<RooArgSet> plotLeafNodes{
static_cast<RooArgSet*
>(leafNodes.
selectCommon(dependentVars))};
909 if(0 != projectedVars) normSet.
add(*projectedVars);
911 normSet.
remove(*condObs,
true,
true) ;
918 if(0 == projectedVars) projectedVars= ∅
924 title.
Prepend(
"Projection of ");
929 if(0 == projected || !projected->
isValid()) {
930 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":createPlotProjection: cannot integrate out ";
933 if(0 != projected)
delete projected;
938 static_cast<RooRealIntegral*
>(projected)->setAllowComponentSelection(
true);
970 double scaleFactor,
const RooArgSet *projectedVars,
bool scaleForDensity,
971 const RooArgSet* condObs,
bool setError)
const
975 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: no valid histogram to fill" << std::endl;
981 if(hdim != plotVars.
getSize()) {
982 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: plotVars has the wrong dimension" << std::endl;
995 <<
"\" of type " << var->
ClassName() << std::endl;
1000 <<
":fillHistogram: WARNING: variable is not an explicit dependent: " << realVar->
GetName() << std::endl;
1002 plotClones.
addClone(*realVar,
true);
1012 if (projectedVars) {
1013 allDeps.
add(*projectedVars) ;
1016 coutE(InputArguments) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1024 cxcoutD(Plotting) <<
"RooAbsReal::fillHistogram(" <<
GetName() <<
") plot projection object is " << projected->
GetName() << std::endl ;
1027 Int_t xbins(0),ybins(1),zbins(1);
1039 assert(0 != zvar && 0 != zaxis);
1040 if (scaleForDensity) {
1048 assert(0 != yvar && 0 != yaxis);
1049 if (scaleForDensity) {
1057 assert(0 != xvar && 0 != xaxis);
1058 if (scaleForDensity) {
1063 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillHistogram: cannot fill histogram with "
1064 << hdim <<
" dimensions" << std::endl;
1071 Int_t xbin(0),ybin(0),zbin(0);
1072 Int_t bins= xbins*ybins*zbins;
1073 for(
Int_t bin= 0; bin < bins; bin++) {
1076 if(bin % (xbins*ybins) == 0) {
1082 if(bin % xbins == 0) {
1083 ybin= (ybin%ybins) + 1;
1088 xbin= (xbin%xbins) + 1;
1092 coutE(InputArguments) <<
"RooAbsReal::fillHistogram: Internal Error!" << std::endl;
1098 coutW(Plotting) <<
"WARNING: Function evaluation error(s) at coordinates [x]=" << xvar->
getVal() ;
1099 if (hdim==2)
ccoutW(Plotting) <<
" [y]=" << yvar->
getVal() ;
1100 if (hdim==3)
ccoutW(Plotting) <<
" [z]=" << zvar->
getVal() ;
1101 ccoutW(Plotting) << std::endl ;
1143 bool correctForBinSize,
bool showProgress)
const
1147 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":fillDataHist: no valid RooDataHist to fill" << std::endl;
1154 coutE(InputArguments) <<
"RooAbsReal::fillDataHist(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
1172 if (showProgress && (i%onePct==0)) {
1173 ccoutP(Eval) <<
"." << std::flush ;
1176 double binVal = theClone->
getVal(normSet?normSet:obs)*scaleFactor ;
1177 if (correctForBinSize) {
1180 hist->
set(i, binVal, 0.);
1206 std::vector<RooRealVar*> histVars(3,
nullptr);
1208 for(std::size_t iVar = 0; iVar < varNames.size(); ++iVar) {
1209 if(varNames[iVar].empty())
continue;
1211 std::stringstream errMsg;
1212 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR more than three variable names passed, but maxumum number of supported variables is three";
1213 coutE(Plotting) << errMsg.str() << std::endl;
1214 throw std::invalid_argument(errMsg.str());
1216 auto var =
static_cast<RooRealVar*
>(vars->find(varNames[iVar].c_str()));
1218 std::stringstream errMsg;
1219 errMsg <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR variable " << varNames[iVar] <<
" does not exist in argset: " << *vars;
1220 coutE(Plotting) << errMsg.str() << std::endl;
1221 throw std::runtime_error(errMsg.str());
1223 histVars[iVar] = var;
1305 pc.
defineInt(
"intBinning",
"IntrinsicBinning",0,2) ;
1306 pc.
defineInt(
"extended",
"Extended",0,2) ;
1308 pc.
defineSet(
"compSet",
"SelectCompSet",0);
1310 pc.
defineSet(
"projObs",
"ProjectedObservables",0,0) ;
1313 pc.
defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
1315 pc.
defineMutex(
"IntrinsicBinning",
"BinningName") ;
1316 pc.
defineMutex(
"IntrinsicBinning",
"BinningSpec") ;
1335 auto projObs = pc.
getSet(
"projObs");
1338 bool doScaling = pc.
getInt(
"scaling") ;
1344 if (!pdfSelf && doExtended == 1) {
1345 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-pdf object, ignored" << std::endl ;
1349 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName() <<
") WARNING extended mode requested for a non-extendable pdf, ignored" << std::endl ;
1352 if (pdfSelf && doExtended==2) {
1354 }
else if(!pdfSelf) {
1358 const char* compSpec = pc.
getString(
"compSpec") ;
1360 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
1362 std::unique_ptr<RooBinning> intBinning;
1363 if (doIntBinning>0) {
1368 if (doIntBinning==1) {
1369 coutW(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1370 <<
") WARNING, intrinsic model binning requested for histogram, but model does not define bin boundaries, reverting to default binning"<< std::endl ;
1373 if (doIntBinning==2) {
1374 coutI(InputArguments) <<
"RooAbsReal::createHistogram(" <<
GetName()
1375 <<
") INFO: Model has intrinsic binning definition, selecting that binning for the histogram"<< std::endl ;
1377 std::vector<double> ba(bl->size());
1379 for (
auto const& elem : *bl) { ba[i++] = elem ; }
1380 intBinning = std::make_unique<RooBinning>(bl->size()-1,ba.data()) ;
1385 RooCmdConfig::stripCmdList(argListCreate,
"Scaling,ProjectedObservables,IntrinsicBinning,SelectCompSet,SelectCompSpec,Extended") ;
1390 argListCreate.
Add(&tmp) ;
1406 branchNodeSet.
remove(*arg) ;
1410 std::unique_ptr<RooArgSet> dirSelNodes;
1416 if (!dirSelNodes->empty()) {
1417 coutI(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << std::endl ;
1423 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << std::endl ;
1425 coutE(Plotting) <<
"RooAbsPdf::createHistogram(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << std::endl ;
1431 double scaleFactor(1.0) ;
1437 fillHistogram(histo,vars,scaleFactor,intObs,doScaling,projObs,
false) ;
1464 for (
unsigned int i = 0; i < branchNodeSet.
size(); ++i) {
1465 const auto arg = branchNodeSet[i];
1467 branchNodeSet.
remove(*arg) ;
1474 for (
const auto arg : branchNodeSet) {
1483 for (
const auto arg : branchNodeSet) {
1484 for (
const auto selNode : *selNodes) {
1485 if (selNode->dependsOn(*arg)) {
1492 for (
const auto arg : branchNodeSet) {
1493 if (arg->dependsOn(*selNodes)) {
1498 tmp.
remove(*selNodes,
true);
1501 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") indirectly selected PDF components: " << tmp << std::endl ;
1504 for (
const auto arg : branchNodeSet) {
1505 bool select = selNodes->
find(arg->GetName()) !=
nullptr;
1659 argList.
Add(&rnorm) ;
1661 std::vector<std::string> rlist;
1665 rlist.emplace_back(rangeNameToken);
1668 for (
const auto& rangeString : rlist) {
1670 rcmd->
setString(0, rangeString.c_str());
1680 pc.
defineString(
"projectionRangeName",
"ProjectionRange",0,
"",
true) ;
1681 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
1682 pc.
defineString(
"sliceCatState",
"SliceCat",0,
"",
true) ;
1685 pc.
defineSet(
"sliceSet",
"SliceVars",0) ;
1695 pc.
defineInt(
"doEvalError",
"EvalErrorValue",0,0) ;
1696 pc.
defineInt(
"shiftToZero",
"ShiftToZero",0,0) ;
1697 pc.
defineSet(
"projDataSet",
"ProjData",0) ;
1701 pc.
defineSet(
"errorPars",
"VisualizeError",0) ;
1702 pc.
defineInt(
"linearMethod",
"VisualizeError",0,0) ;
1703 pc.
defineInt(
"binProjData",
"ProjData",0,0) ;
1706 pc.
defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1707 pc.
defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
1708 pc.
defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
1712 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
1713 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
1715 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
1716 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
1717 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
1718 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
1719 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
1721 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
1722 pc.
defineInt(
"showProg",
"ShowProgress",0,0) ;
1724 pc.
defineInt(
"interleave",
"NumCPU",1,0) ;
1728 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
1732 pc.
defineMutex(
"VisualizeError",
"VisualizeErrorData") ;
1746 bool linMethod = pc.
getInt(
"linearMethod") ;
1747 if (!drawOpt.
Contains(
"P") && errFR) {
1768 std::unique_ptr<RooArgSet> sliceSet{sliceSetTmp ?
static_cast<RooArgSet*
>(sliceSetTmp->
Clone()) :
nullptr};
1774 const char* sliceCatState = pc.
getString(
"sliceCatState",0,
true) ;
1776 if (sliceCatState) {
1780 sliceSet = std::make_unique<RooArgSet>();
1785 auto iter = sliceCatList.
begin();
1786 for (
unsigned int i=0; i < catTokens.size(); ++i) {
1787 if (
auto scat =
static_cast<RooCategory*
>(*iter)) {
1789 scat->setLabel(catTokens[i]) ;
1791 sliceSet->add(*scat,
false) ;
1804 if (vlines==2) vlines=0 ;
1810 if (vlines==2) vlines=0 ;
1830 coutE(InputArguments) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") cannot find existing curve " << o.
addToCurveName <<
" to add to in RooPlot" << std::endl ;
1836 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have slice " << *sliceSet << std::endl ;
1841 for (
const auto sliceArg : *sliceSet) {
1844 projectedVars.
remove(*arg) ;
1846 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") slice variable "
1847 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
1850 }
else if (projSet) {
1851 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have projSet " << *projSet << std::endl ;
1854 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: have neither sliceSet nor projSet " << std::endl ;
1859 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") Preprocessing: projectedVars = " << projectedVars << std::endl ;
1889 if ((fillColor != -999 || fillStyle != -999) && !drawOpt.
Contains(
"F")) {
1890 coutW(Plotting) <<
"Fill color or style was set for plotting \"" <<
GetName()
1891 <<
"\", but these only have an effect when 'DrawOption(\"F\")' for fill is used at the same time." << std::endl;
1931 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjData with observables = " << *o.
projData->
get() << std::endl ;
1934 projDataVars.
add(*tmp) ;
1935 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have ProjDataSet = " << *o.
projDataSet <<
" will only use this subset of projData" << std::endl ;
1937 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") using full ProjData" << std::endl ;
1942 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") ProjDataVars = " << projDataVars << std::endl ;
1948 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") have input projSet = " << *o.
projSet << std::endl ;
1950 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") calculated projectedVars = " << *o.
projSet << std::endl ;
1957 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") frame->getNormVars() that are also observables = " << sliceSetTmp << std::endl ;
1959 sliceSetTmp.
remove(projectedVars,
true,
true) ;
1964 sliceSetTmp.
remove(*tmp,
true,
true) ;
1967 if (!sliceSetTmp.
empty()) {
1968 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on "
1969 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
1971 sliceSet.
add(sliceSetTmp) ;
1977 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") projectedVars = " << projectedVars <<
" sliceSet = " << sliceSet << std::endl ;
1984 projectedVars.
remove(projDataVars,
true,
true) ;
1989 double oldPlotVarVal = plotVar->
getVal();
1992 if (!projectedVars.
empty()) {
1993 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->GetName()
1994 <<
" integrates over variables " << projectedVars
1997 if (projDataNeededVars && !projDataNeededVars->
empty()) {
1998 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->GetName()
1999 <<
" averages using data variables " << *projDataNeededVars << std::endl ;
2007 deps.
remove(projectedVars,
true,
true) ;
2008 if (projDataNeededVars) {
2009 deps.
remove(*projDataNeededVars,
true,
true) ;
2011 deps.
remove(*plotVar,
true,
true) ;
2012 deps.
add(*plotVar) ;
2018 coutE(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") error in checkObservables, abort" << std::endl ;
2019 if (projDataNeededVars)
delete projDataNeededVars ;
2024 cxcoutD(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot projection object is " << projection->
GetName() << std::endl ;
2031 fullNormSet.
add(projectedVars) ;
2032 if (projDataNeededVars && !projDataNeededVars->
empty()) {
2033 fullNormSet.
add(*projDataNeededVars) ;
2036 std::unique_ptr<RooArgSet> projectionComponents(projection->
getComponents());
2037 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*projectionComponents)) {
2039 pdf->selectNormalization(&fullNormSet) ;
2044 if (o.
projData && projDataNeededVars && !projDataNeededVars->
empty()) {
2054 if (!sliceDataSet->empty()) {
2056 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2073 if (!cutString.
IsNull()) {
2075 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2080 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2089 if (!
dynamic_cast<RooCategory*
>(arg2)) allCat =
false ;
2093 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") unbinned projection dataset consist only of discrete variables,"
2094 <<
" performing projection with binned copy for optimization." << std::endl ;
2102 if (projDataSel!=o.
projData)
delete projDataSel ;
2109 projection->
getVal(projDataSel->
get()) ;
2117 std::move(cfg),
true) ;
2136 if (!sliceSet.
empty()) {
2171 if (projDataSel!=o.
projData)
delete projDataSel ;
2205 if (!sliceSet.
empty()) {
2252 if (projDataNeededVars)
delete projDataNeededVars ;
2253 delete projectionCompList ;
2254 plotVar->setVal(oldPlotVarVal);
2274 projectedVars.
remove(*arg) ;
2276 coutI(Plotting) <<
"RooAbsReal::plotSliceOn(" <<
GetName() <<
") slice variable "
2277 << sliceArg->GetName() <<
" was not projected anyway" << std::endl ;
2319 projDataVars.
add(*tmp) ;
2327 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2328 <<
") function doesn't depend on asymmetry category " << asymCat.
GetName() << std::endl ;
2334 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2335 <<
") asymmetry category must have 2 or 3 states with index values -1,0,1" << std::endl ;
2349 sliceSetTmp.
remove(projectedVars,
true,
true) ;
2354 sliceSetTmp.
remove(*tmp,
true,
true) ;
2357 if (!sliceSetTmp.
empty()) {
2358 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on "
2359 << frame->
getPlotVar()->
GetName() <<
" represents a slice in " << sliceSetTmp << std::endl ;
2361 sliceSet.
add(sliceSetTmp) ;
2372 projectedVars.
remove(projDataVars,
true,
true) ;
2385 if (!projectedVars.
empty()) {
2386 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2387 <<
" projects variables " << projectedVars << std::endl ;
2389 if (projDataNeededVars && !projDataNeededVars->
empty()) {
2390 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") plot on " << plotVar->
GetName()
2391 <<
" averages using data variables "<< *projDataNeededVars << std::endl ;
2399 asymNeg->setIndex(-1) ;
2405 custNeg.replaceArg(asymCat,*asymNeg) ;
2406 std::unique_ptr<RooAbsReal> funcPos{
static_cast<RooAbsReal*
>(custPos.build())};
2407 std::unique_ptr<RooAbsReal> funcNeg{
static_cast<RooAbsReal*
>(custNeg.build())};
2410 RooArgSet *posProjCompList, *negProjCompList ;
2416 depPos.
add(projDataVars) ;
2417 depNeg.
add(projDataVars) ;
2421 if (!posProj || !negProj) {
2422 coutE(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName() <<
") Unable to create projections, abort" << std::endl ;
2428 asymName.
Append(
"_Asym[") ;
2432 asymTitle.
Append(
" Asymmetry of ") ;
2445 if (!sliceDataSet->
empty()) {
2447 for(
RooAbsArg * sliceVar : *sliceDataSet) {
2463 delete sliceDataSet ;
2465 if (!cutString.
IsNull()) {
2467 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2468 <<
") reducing given projection dataset to entries with " << cutString << std::endl ;
2472 coutI(Plotting) <<
"RooAbsReal::plotAsymOn(" <<
GetName()
2473 <<
") only the following components of the projection data will be used: " << *projDataNeededVars << std::endl ;
2481 std::move(cfg),
true) ;
2485 ((
RooAbsReal*)posProj)->attachDataSet(*projDataSel) ;
2486 ((
RooAbsReal*)negProj)->attachDataSet(*projDataSel) ;
2498 TString curveName(funcAsym.GetName()) ;
2501 if (!sliceSet.
empty()) {
2511 RooCurve *curve =
new RooCurve(funcAsym.GetName(),funcAsym.GetTitle(),scaleBind,
2519 ccoutW(Eval) << std::endl ;
2521 if (projDataSel!=o.
projData)
delete projDataSel ;
2540 TString curveName(funcAsym.GetName()) ;
2541 if (!sliceSet.
empty()) {
2556 delete posProjCompList ;
2557 delete negProjCompList ;
2587 for(
auto * rrvFitRes : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2589 auto rrvInAbsReal =
static_cast<RooRealVar const*
>(allParamsInAbsReal.
find(*rrvFitRes));
2596 if (rrvFitRes->getError() <= rrvFitRes->getVal() * std::numeric_limits<double>::epsilon())
continue;
2599 if(!rrvInAbsReal)
continue;
2603 if(std::abs(rrvInAbsReal->getVal() - rrvFitRes->getVal()) > 0.01 * rrvFitRes->getError()) {
2604 std::stringstream errMsg;
2605 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
2606 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
2608 throw std::runtime_error(errMsg.str());
2611 paramList.
add(*rrvInAbsReal);
2614 std::vector<double> plusVar;
2615 std::vector<double> minusVar;
2616 plusVar.reserve(paramList.
size());
2617 minusVar.reserve(paramList.
size());
2624 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2626 auto& rrv =
static_cast<RooRealVar&
>(paramList[ivar]);
2628 double cenVal = rrv.
getVal() ;
2629 double errVal = sqrt(V(ivar,ivar)) ;
2632 rrv.setVal(cenVal+errVal) ;
2633 plusVar.push_back(
getVal(nset)) ;
2636 rrv.setVal(cenVal-errVal) ;
2637 minusVar.push_back(
getVal(nset)) ;
2639 rrv.setVal(cenVal) ;
2652 std::vector<double> errVec(paramList.
size()) ;
2653 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2654 errVec[i] = std::sqrt(V(i,i)) ;
2655 for (
int j=i ; j<paramList.
getSize() ; j++) {
2656 C(i,j) = V(i,j) / std::sqrt(V(i,i)*V(j,j));
2663 for (
unsigned int j=0 ; j<plusVar.size() ; j++) {
2664 F[j] = (plusVar[j]-minusVar[j])/2 ;
2668 double sum =
F*(C*
F) ;
2715 for (
auto * cmd : static_range_cast<RooCmdArg*>(plotArgListTmp)) {
2716 if (std::string(
"Normalization")==cmd->GetName()) {
2719 plotArgList.
Add(cmd) ;
2722 plotArgList.
Add(cmd) ;
2729 auto plotFunc = [&](
RooAbsReal const& absReal) {
2732 absReal.plotOn(frame, tmp);
2739 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOnWithErrorBand: no curve for central value available" << std::endl;
2766 coutI(Plotting) <<
"RooAbsReal::plotOn(" <<
GetName() <<
") INFO: visualizing " << Z <<
"-sigma uncertainties in parameters "
2767 << errorParams <<
" from fit result " << fr.
GetName() <<
" using " <<
n <<
" samplings." << std::endl ;
2773 std::vector<RooCurve*> cvec ;
2774 for (
int i=0 ; i<
d->numEntries() ; i++) {
2775 cloneParams.
assign(*
d->get(i)) ;
2776 plotFunc(*cloneFunc);
2777 cvec.push_back(frame->
getCurve()) ;
2790 for (std::vector<RooCurve*>::iterator i=cvec.begin() ; i!=cvec.end() ; ++i) {
2808 for (
auto const* frv : static_range_cast<RooRealVar*>(fr.
floatParsFinal())) {
2809 if (frv->getError() > frv->getVal() * std::numeric_limits<double>::epsilon()) {
2810 fpf_stripped.
add(*frv);
2828 std::vector<int> fpf_idx ;
2832 paramList.
add(*par) ;
2833 fpf_idx.push_back(i) ;
2837 std::vector<RooCurve*> plusVar, minusVar ;
2846 for (
Int_t ivar=0 ; ivar<paramList.
getSize() ; ivar++) {
2850 double cenVal = rrv.
getVal() ;
2851 double errVal = sqrt(V(ivar,ivar)) ;
2854 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal+Z*errVal) ;
2857 plotFunc(*cloneFunc);
2858 plusVar.push_back(frame->
getCurve()) ;
2863 ((
RooRealVar*)paramList.
at(ivar))->setVal(cenVal-Z*errVal) ;
2864 plotFunc(*cloneFunc);
2865 minusVar.push_back(frame->
getCurve()) ;
2872 std::vector<double> errVec(paramList.
size()) ;
2873 for (
int i=0 ; i<paramList.
getSize() ; i++) {
2874 errVec[i] = sqrt(V(i,i)) ;
2875 for (
int j=i ; j<paramList.
getSize() ; j++) {
2876 C(i,j) = V(i,j)/sqrt(V(i,i)*V(j,j)) ;
2886 for (std::vector<RooCurve*>::iterator i=plusVar.begin() ; i!=plusVar.end() ; ++i) {
2889 for (std::vector<RooCurve*>::iterator i=minusVar.begin() ; i!=minusVar.end() ; ++i) {
2896 if (!band)
return frame ;
2901 pc.
defineString(
"curveNameSuffix",
"CurveNameSuffix",0,
"") ;
2902 pc.
defineInt(
"lineColor",
"LineColor",0,-999) ;
2903 pc.
defineInt(
"lineStyle",
"LineStyle",0,-999) ;
2904 pc.
defineInt(
"lineWidth",
"LineWidth",0,-999) ;
2905 pc.
defineInt(
"markerColor",
"MarkerColor",0,-999) ;
2906 pc.
defineInt(
"markerStyle",
"MarkerStyle",0,-999) ;
2908 pc.
defineInt(
"fillColor",
"FillColor",0,-999) ;
2909 pc.
defineInt(
"fillStyle",
"FillStyle",0,-999) ;
2911 pc.
defineInt(
"curveInvisible",
"Invisible",0,0) ;
2912 pc.
defineInt(
"moveToBack",
"MoveToBack",0,0) ;
2945 }
else if (pc.
getString(
"curveNameSuffix",0,
true)) {
2978 <<
":plotOn: frame does not specify a plot variable" << std::endl;
2991 coutE(Plotting) <<
ClassName() <<
"::" <<
GetName() <<
":plotOn: WARNING: variable is not an explicit dependent: "
2992 << var->
GetName() << std::endl;
3010 RooArgSet& projectedVars,
bool silent)
const
3012 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") plotVar = " << plotVar->
GetName()
3013 <<
" allVars = " << (allVars?(*allVars):
RooArgSet()) << std::endl ;
3016 if (!allVars) return ;
3019 projectedVars.
add(*allVars) ;
3024 projectedVars.
remove(*found);
3027 std::unique_ptr<RooArgSet> plotServers{plotVar->
getObservables(&projectedVars)};
3031 cxcoutD(Plotting) <<
"RooAbsReal::makeProjectionSet(" <<
GetName() <<
") removing " << tmp->
GetName()
3032 <<
" from projection set because it a server of " << plotVar->
GetName() << std::endl ;
3033 projectedVars.
remove(*tmp) ;
3039 <<
") WARNING: cannot project out frame variable ("
3040 << found->
GetName() <<
"), ignoring" << std::endl ;
3047 projectedVars.
remove(*arg,
true) ;
3050 <<
") function doesn't depend on projection variable "
3051 << arg->GetName() <<
", ignoring" << std::endl ;
3088 auto binding = std::make_unique<RooRealBinding>(*
this,vars,nset,clipInvalid);
3089 if(!binding->isValid()) {
3090 coutE(InputArguments) <<
ClassName() <<
"::" <<
GetName() <<
":bindVars: cannot bind to " << vars << std::endl ;
3093 return binding.release();
3105 auto other =
static_cast<const RooAbsReal*
>(source);
3106 assert(
dynamic_cast<const RooAbsReal*
>(source));
3108 _value = other->_treeReadBuffer ? other->_treeReadBuffer->operator
double() : other->_value;
3148 coutE(Eval) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") ERROR: TTree branch " <<
GetName()
3149 <<
" is an array and cannot be attached to a RooAbsReal" << std::endl ;
3159 std::map<std::string, std::pair<std::string, std::function<std::unique_ptr<TreeReadBuffer>()>>> typeMap {
3160 {
"Float_t", {
"FLOAT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Float_t >(cleanName, t); }}},
3161 {
"Int_t", {
"INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<Int_t >(cleanName, t); }}},
3162 {
"UChar_t", {
"BYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<UChar_t >(cleanName, t); }}},
3163 {
"Bool_t", {
"BOOL_TREE_BRANCH", [&](){
return createTreeReadBuffer<Bool_t >(cleanName, t); }}},
3164 {
"Char_t", {
"SIGNEDBYTE_TREE_BRANCH", [&](){
return createTreeReadBuffer<Char_t >(cleanName, t); }}},
3165 {
"UInt_t", {
"UNSIGNED_INTEGER_TREE_BRANCH", [&](){
return createTreeReadBuffer<UInt_t >(cleanName, t); }}},
3166 {
"Long64_t", {
"LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<Long64_t >(cleanName, t); }}},
3167 {
"ULong64_t", {
"UNSIGNED_LONG_TREE_BRANCH", [&](){
return createTreeReadBuffer<ULong64_t>(cleanName, t); }}},
3168 {
"Short_t", {
"SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<Short_t >(cleanName, t); }}},
3169 {
"UShort_t", {
"UNSIGNED_SHORT_TREE_BRANCH", [&](){
return createTreeReadBuffer<UShort_t >(cleanName, t); }}},
3172 auto typeDetails = typeMap.find(typeName.
Data());
3173 if (typeDetails != typeMap.end()) {
3174 coutI(DataHandling) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") TTree " << typeDetails->first <<
" branch " <<
GetName()
3175 <<
" will be converted to double precision." << std::endl ;
3185 coutE(InputArguments) <<
"RooAbsReal::attachToTree(" <<
GetName() <<
") data type " << typeName <<
" is not supported." << std::endl ;
3207 coutE(Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree: " <<
cleanBranchName() << std::endl ;
3345 const TList &nameList)
const
3348 bool isMatched(
true);
3349 for(
auto *
name : static_range_cast<TObjString*>(nameList)) {
3352 matched.
add(*found);
3366 if(isMatched) matchedArgs.
add(matched);
3415 if (config)
return config ;
3428 if (config)
return config ;
3522 static bool inLogEvalError = false ;
3524 if (inLogEvalError) {
3527 inLogEvalError = true ;
3532 if (serverValueString) {
3537 oocoutE(
nullptr,Eval) <<
"RooAbsReal::logEvalError(" <<
"<STATIC>" <<
") evaluation error, " << std::endl
3538 <<
" origin : " << origName << std::endl
3539 <<
" message : " << ee.
_msg << std::endl
3540 <<
" server values: " << ee.
_srvval << std::endl ;
3547 inLogEvalError = false ;
3577 static bool inLogEvalError = false ;
3579 if (inLogEvalError) {
3582 inLogEvalError = true ;
3587 if (serverValueString) {
3590 std::string srvval ;
3591 std::ostringstream oss ;
3602 p->print(oss,
true) ;
3607 std::ostringstream oss2 ;
3611 coutE(Eval) <<
"RooAbsReal::logEvalError(" <<
GetName() <<
") evaluation error, " << std::endl
3612 <<
" origin : " << oss2.str() << std::endl
3613 <<
" message : " << ee.
_msg << std::endl
3614 <<
" server values: " << ee.
_srvval << std::endl ;
3623 <<
") delayed evaluation error, " << std::endl
3624 <<
" origin : " << oss2.str() << std::endl
3625 <<
" message : " << oee.
_msg << std::endl
3626 <<
" server values: " << oee.
_srvval << std::endl ;
3633 inLogEvalError = false ;
3689 if (maxPerNode<0) return ;
3692 if (maxPerNode==0) {
3695 os << iter->second.first ;
3697 os <<
" has " << iter->second.second.size() <<
" errors" << std::endl ;
3702 os << iter->second.first << std::endl ;
3706 for(
auto iter2 = iter->second.second.begin();iter2!=iter->second.second.end() ; ++iter2, i++) {
3707 os <<
" " << iter2->_msg <<
" @ " << iter2->_srvval << std::endl ;
3709 os <<
" ... (remaining " << iter->second.second.size() - maxPerNode <<
" messages suppressed)" << std::endl ;
3730 ntot += elem.second.second.size() ;
3750 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3752 if (!addNormSet.
empty()) {
3753 pdf->selectNormalization(&addNormSet,force) ;
3755 pdf->selectNormalization(0,force) ;
3775 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(*compSet)) {
3777 pdf->selectNormalizationRange(rangeName,force) ;
3795 orderedObs.
add(obs) ;
3853 pc.
defineSet(
"supNormSet",
"SupNormSet",0,0) ;
3854 pc.
defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3855 pc.
defineInt(
"intOrder",
"ScanParameters",1,2) ;
3856 pc.
defineInt(
"doScanNum",
"ScanNum",0,1) ;
3857 pc.
defineInt(
"doScanAll",
"ScanAll",0,0) ;
3858 pc.
defineInt(
"doScanNon",
"ScanNone",0,0) ;
3862 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3887 Int_t isNum= (tmp->numIntRealVars().size()==1) ;
3890 coutI(NumIntegration) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << std::endl
3891 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3892 << intOrder <<
" interpolation on integrated histogram." << std::endl
3893 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << std::endl ;
3911 ivar->
setBins(numScanBins,
"numcdf") ;
3912 auto ret = std::make_unique<RooNumRunningInt>(
name.c_str(),
name.c_str(),*
this,*ivar,
"numrunint") ;
3913 ret->setInterpolationOrder(intOrder) ;
3932 coutW(InputArguments) <<
"RooAbsPdf::createRunningIntegral(" <<
GetName() <<
") WARNING ignoring non-RooRealVar input argument " << arg->GetName() << std::endl ;
3946 for(
auto * rrv : static_range_cast<RooRealVar*>(ilist)) {
3950 cloneList.
add(*cloneArg) ;
3955 cloneLo->
setVal(rrv->getMin()) ;
3956 loList.
add(*cloneLo) ;
3968 finalNset.
add(cloneList,
true) ;
3969 std::unique_ptr<RooAbsReal> cdf{tmp->
createIntegral(cloneList,finalNset,
"CDF")};
3973 cdf->addOwnedComponents(cloneList) ;
3974 cdf->addOwnedComponents(loList) ;
3988 if (realObs.
size() != obs.
size()) {
3989 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
3994 if (realPars.
size() != pars.
size()) {
3995 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4013 if (realObs.
size() != obs.
size()) {
4014 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified observables are not variables of this p.d.f" << std::endl ;
4019 if (realPars.
size() != pars.
size()) {
4020 coutE(InputArguments) <<
"RooAbsReal::functor(" <<
GetName() <<
") ERROR: one or more specified parameters are not variables of this p.d.f" << std::endl ;
4025 for (
int i=0 ; i<obs.
getSize() ; i++) {
4027 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed observable " << obs.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
4031 for (
int i=0 ; i<pars.
getSize() ; i++) {
4033 coutE(ObjectHandling) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: proposed parameter " << pars.
at(0)->
GetName() <<
" is not of type RooRealVar" << std::endl ;
4064 coutE(InputArguments) <<
"RooAbsReal::asTF(" <<
GetName() <<
") ERROR: " << obs.
size()
4065 <<
" observables specified, but a ROOT TFx can only have 1,2 or 3 observables" << std::endl ;
4070 for (
int i=0 ; i<pars.
getSize() ; i++) {
4100 return new RooDerivative(
name.c_str(),title.c_str(),*
this,obs,normSet,order,eps) ;
4115 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4117 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,central,takeRoot) ;
4118 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,order,central,takeRoot) ;
4134 std::string title=
Form(
"%sMoment of order %d of %s w.r.t %s ",(central?
"Central ":
""),order,
GetName(),obs.
GetName()) ;
4136 if (order==1)
return new RooFirstMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,intNormObs) ;
4137 if (order==2)
return new RooSecondMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,central,takeRoot,intNormObs) ;
4138 return new RooMoment(
name.c_str(),title.c_str(),*
this,obs,normObs,order,central,takeRoot,intNormObs) ;
4245 return new RooChi2Var(
name.c_str(),
name.c_str(),*
this,
data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
4261 for(
auto * arg : static_range_cast<RooCmdArg*>(cmdList)) {
4268 return createChi2(
data,*cmds[0],*cmds[1],*cmds[2],*cmds[3],*cmds[4],*cmds[5],*cmds[6],*cmds[7]) ;
4334 std::unique_ptr<RooAbsReal> xychi2{
createChi2(xydata,chi2CmdList)};
4379 pc.
defineInt(
"integrate",
"Integrate",0,0) ;
4389 bool integrate = pc.
getInt(
"integrate") ;
4414 pc.
defineInt(
"optConst",
"Optimize",0,1) ;
4418 pc.
defineInt(
"plevel",
"PrintLevel",0,1) ;
4420 pc.
defineInt(
"initHesse",
"InitialHesse",0,0) ;
4424 pc.
defineInt(
"numee",
"PrintEvalErrors",0,10) ;
4428 pc.
defineSet(
"minosSet",
"Minos",0,
nullptr) ;
4437 const char* minType = pc.
getString(
"mintype",
"") ;
4438 const char* minAlg = pc.
getString(
"minalg",
"minuit") ;
4456 m.setMinimizerType(minType);
4462 m.setPrintEvalErrors(numee) ;
4464 m.setPrintLevel(plevel) ;
4469 m.optimizeConst(optConst);
4483 m.setStrategy(strat) ;
4492 m.minimize(minType, minAlg) ;
4502 m.minos(*minosSet) ;
4511 std::string title =
Form(
"Result of fit of %s ",
GetName()) ;
4512 ret =
m.save(
name.c_str(),title.c_str()) ;
4549 for (
auto const* arg : paramVars) {
4551 coutW(InputArguments) <<
"RooAbsReal::setParameterizeIntegral(" <<
GetName()
4552 <<
") function does not depend on std::listed parameter " << arg->GetName() <<
", ignoring" << std::endl ;
4555 if (plist.size()>0) plist +=
":" ;
4556 plist += arg->GetName() ;
4578 std::vector<ServerData> ourServers;
4581 for (
auto server :
servers()) {
4582 auto serverValues = dataMap.
at(server);
4583 if(serverValues.empty())
continue;
4586 auto oldOperMode = server->operMode();
4591 ourServers.push_back({server,
4595 server->_valueDirty,
4596 server->_shapeDirty});
4602 struct RestoreStateRAII {
4603 RestoreStateRAII(std::vector<ServerData>& servers) :
4604 _servers{servers} { }
4606 ~RestoreStateRAII() {
4607 for (
auto& serverData : _servers) {
4608 serverData.server->setCachedValue(serverData.oldValue,
true);
4609 serverData.server->setOperMode(serverData.oldOperMode);
4610 serverData.server->_valueDirty = serverData.oldValueDirty;
4611 serverData.server->_shapeDirty = serverData.oldShapeDirty;
4615 std::vector<ServerData>& _servers;
4616 } restoreState{ourServers};
4622 coutI(FastEvaluations) <<
"The class " <<
ClassName() <<
" does not implement the faster batch evaluation interface."
4623 <<
" Consider requesting or implementing it to benefit from a speed up." << std::endl;
4629 for (std::size_t i=0; i < nEvents; ++i) {
4630 for (
auto& serv : ourServers) {
4631 serv.server->setCachedValue(serv.batch[std::min(i, serv.batch.size()-1)],
false);
4649 std::stringstream errorMsg;
4650 errorMsg <<
"An analytical integral function for class \"" <<
ClassName() <<
"\" has not yet been implemented.";
4651 coutE(Minimization) << errorMsg.str() << std::endl;
4652 throw std::runtime_error(errorMsg.str().c_str());
4657 const bool tmpFast =
_fast;
4658 const double tmp =
_value;
4660 double fullEval = 0.;
4662 fullEval =
getValV(normalisationSet);
4671 if (std::isfinite(ret) && ( ret != 0. ? (ret - fullEval)/ret : ret - fullEval) > 1.E-9) {
4676 formatter <<
"--> (Scalar computation wrong here:)\n"
4677 <<
GetName() <<
" " <<
this <<
" _fast=" << tmpFast
4678 <<
"\n\tcached _value=" << std::setprecision(16) << tmp
4679 <<
"\n\treturning =" << ret
4680 <<
"\n\trecomputed =" << fullEval
4681 <<
"\n\tnew _value =" <<
_value <<
"] ";
4682 formatter <<
"\nServers:";
4708 auto realServer =
dynamic_cast<RooAbsReal*
>(server);
4717 const auto item = evalData.
spans.find(
this);
4718 if (item == evalData.
spans.end())
4721 auto batch = item->second;
4723 const double batchVal = batch.size() == 1 ? batch[0] : batch[evtNo];
4726 if (std::abs(relDiff) > relAccuracy && std::abs(
value) > 1.E-300) {
4728 formatter <<
"--> (Batch computation wrong:)\n";
4730 formatter <<
"\n batch=" << batch.data() <<
" size=" << batch.size() << std::setprecision(17)
4731 <<
"\n batch[" << std::setw(7) << evtNo-1 <<
"]= " << (evtNo > 0 && evtNo - 1 < batch.size() ? std::to_string(batch[evtNo-1]) :
"---")
4732 <<
"\n batch[" << std::setw(7) << evtNo <<
"]= " << batchVal <<
" !!!"
4733 <<
"\n expected ('value'): " <<
value
4734 <<
"\n eval(unnorm.) : " <<
evaluate()
4735 <<
"\n delta " <<
" = " <<
value - batchVal
4736 <<
"\n rel delta " <<
" = " << relDiff
4737 <<
"\n _batch[" << std::setw(7) << evtNo+1 <<
"]= " << (batch.size() > evtNo+1 ? std::to_string(batch[evtNo+1]) :
"---");
4741 formatter <<
"\nServers: ";
4743 formatter <<
"\n - ";
4745 formatter << std::setprecision(17);
4747 auto serverAsReal =
dynamic_cast<RooAbsReal*
>(server);
4750 if (serverBatch.size() > evtNo) {
4751 formatter <<
"\n _batch[" << evtNo-1 <<
"]=" << (serverBatch.size() > evtNo-1 ? std::to_string(serverBatch[evtNo-1]) :
"---")
4752 <<
"\n _batch[" << evtNo <<
"]=" << serverBatch[evtNo]
4753 <<
"\n _batch[" << evtNo+1 <<
"]=" << (serverBatch.size() > evtNo+1 ? std::to_string(serverBatch[evtNo+1]) :
"---");
4756 formatter << std::setprecision(17)
4757 <<
"\n getVal()=" << serverAsReal->getVal(normSet);
4768 bool nameChange,
bool isRecursiveStep)
4780 if(
auto realArg =
dynamic_cast<RooAbsReal*
>(arg)) {
4781 realArg->enableOffsetting(flag) ;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static void indent(ostringstream &buf, int indent_level)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result