151#ifdef ROOFIT_LEGACY_EVAL_BACKEND
201 coutI(Minimization) <<
"p.d.f. provides expected number of events, including extended term in likelihood."
211 if (extendedCmdArg == 0) {
213 std::string errMsg =
"You used the Extended(false) option on a pdf where the fit MUST be extended! "
214 "The parameters are not well defined and you're getting nonsensical results.";
215 coutE(InputArguments) << errMsg << std::endl;
218 return extendedCmdArg;
223inline double getLog(
double prob,
RooAbsReal const *caller)
226 if (std::abs(prob) > 1e6) {
227 oocoutW(caller, Eval) <<
"RooAbsPdf::getLogVal(" << caller->
GetName()
228 <<
") WARNING: top-level pdf has a large value: " << prob << std::endl;
232 caller->
logEvalError(
"getLogVal() top-level p.d.f evaluates to a negative number");
237 caller->
logEvalError(
"getLogVal() top-level p.d.f evaluates to zero");
239 return -std::numeric_limits<double>::infinity();
243 caller->
logEvalError(
"getLogVal() top-level p.d.f evaluates to NaN");
248 return std::log(prob);
254 const char* rangeName,
bool splitRange)
262 if(!rangeName || splitRange)
return;
267 std::string fitrangeValue;
269 for (
auto const &subrange : subranges) {
270 if (subrange.empty())
272 std::string fitrangeValueSubrange = std::string(
"fit_") + baseName;
273 if (subranges.size() > 1) {
274 fitrangeValueSubrange +=
"_" + subrange;
276 fitrangeValue += fitrangeValueSubrange +
",";
279 if(arg->isCategory())
continue;
280 auto& observable =
static_cast<RooRealVar&
>(*arg);
282 observable.
setRange(fitrangeValueSubrange.c_str(), observable.getMin(subrange.c_str()),
283 observable.getMax(subrange.c_str()));
286 pdf.
setStringAttribute(
"fitrange", fitrangeValue.substr(0, fitrangeValue.size() - 1).c_str());
334 double plotMin,
double plotMax) :
335 RooAbsReal(
name,title,plotMin,plotMax), _normMgr(this,10), _selectComp(true)
348 _normMgr(other._normMgr,this), _selectComp(other._selectComp), _normRange(other._normRange)
370 if (normVal < 0. || (normVal == 0. && rawVal != 0)) {
372 const std::string msg =
"p.d.f normalization integral is zero or negative: " + std::to_string(normVal);
379 logEvalError(
Form(
"p.d.f value is less than zero (%f), trying to recover", rawVal));
390 return (rawVal == 0. && normVal == 0.) ? 0. : rawVal / normVal;
420 bool nintChanged(
false) ;
452 cxcoutD(Eval) <<
"RooAbsPdf::analyticalIntegralWN(" <<
GetName() <<
") code = " << code <<
" normset = " << (normSet?*normSet:
RooArgSet()) << endl ;
455 if (code==0)
return getVal(normSet) ;
484 if(!error)
return error ;
507 if (!nset)
return 1 ;
515 coutW(Eval) <<
"RooAbsPdf::getNorm(" <<
GetName() <<
":: WARNING normalization is zero, nset = " ; nset->
Print(
"1") ;
516 if(
_errorCount == 10)
coutW(Eval) <<
"RooAbsPdf::getNorm(" <<
GetName() <<
") INFO: no more messages will be printed " << endl ;
534 return cache->
_norm ;
596 ((
RooAbsPdf*)
this)->setProxyNormSet(nset) ;
605 <<
") recreating normalization integral " << endl ;
608 cxcoutD(Tracing) <<
ClassName() <<
"::syncNormalization(" <<
GetName() <<
") selfNormalized, creating unit norm" << endl;
614 auto ntitle = std::string(
GetTitle()) +
" Unit Normalization";
615 auto nname = std::string(
GetName()) +
"_UnitNorm";
629 static_cast<RooRealIntegral*
>(normInt)->setAllowComponentSelection(
false);
634 if (cacheParamsStr && strlen(cacheParamsStr)) {
636 std::unique_ptr<RooArgSet> intParams{normInt->
getVariables()} ;
640 if (!cacheParams.
empty()) {
641 cxcoutD(Caching) <<
"RooAbsReal::createIntObj(" <<
GetName() <<
") INFO: constructing " << cacheParams.
getSize()
642 <<
"-dim value cache for integral over " << depList <<
" as a function of " << cacheParams <<
" in range " << (nr?nr:
"<default>") << endl ;
651 normInt= cachedIntegral ;
693 for(
auto * pdf : dynamic_range_cast<RooAbsPdf*>(branchList)) {
694 if (pdf) pdf->setTraceCounter(
value,
false) ;
709 return getLog(
getVal(nset),
this);
719bool checkInfNaNNeg(
const T& inputs) {
725 for (
double val : inputs) {
726 inf |= !std::isfinite(val);
731 return inf || nan || neg;
742 for (
unsigned int i=0; i<outputs.size(); ++i) {
743 const double value = outputs[i];
747 }
else if (!std::isfinite(outputs[i])){
750 }
else if (outputs[i] < 0.) {
751 logEvalError(
Form(
"p.d.f value of (%s) is less than zero (%f) for entry %zu",
759 for (std::size_t i = 0; i < pdfValues.size(); ++i) {
760 output[i] = getLog(pdfValues[i],
this);
821 coutE(InputArguments) <<
GetName() <<
": this PDF does not support extended maximum likelihood"
827 coutE(InputArguments) <<
GetName() <<
": calculated negative expected events: " << expected
829 logEvalError(
"extendedTerm #expected events is <0 return a NaN");
835 if (std::abs(expected)<1
e-10 && std::abs(sumEntries)<1
e-10) {
841 logEvalError(
"extendedTerm #expected events is a NaN") ;
845 double extra = doOffset
846 ? (expected - sumEntries) - sumEntries * (std::log(expected) - std::log(sumEntries))
847 : expected - sumEntries * std::log(expected);
849 if(sumEntriesW2 != 0.0) {
850 extra *= sumEntriesW2 / sumEntries;
881 double sumW =
data.sumEntries();
884 sumW2 =
data.sumEntriesW2();
1028 auto baseName = std::string(
"nll_") +
GetName() +
"_" +
data.GetName();
1033 pc.
defineString(
"rangeName",
"RangeWithName",0,
"",
true) ;
1035 pc.
defineString(
"globstag",
"GlobalObservablesTag",0,
"") ;
1036 pc.
defineString(
"globssource",
"GlobalObservablesSource",0,
"data") ;
1039 pc.
defineInt(
"splitRange",
"SplitRange",0,0) ;
1042 pc.
defineInt(
"interleave",
"NumCPU",1,0) ;
1044 pc.
defineInt(
"optConst",
"Optimize",0,0) ;
1045 pc.
defineInt(
"cloneData",
"CloneData", 0, 2);
1046 pc.
defineSet(
"projDepSet",
"ProjectedObservables",0,0) ;
1048 pc.
defineSet(
"glObs",
"GlobalObservables",0,0) ;
1049 pc.
defineInt(
"doOffset",
"OffsetLikelihood",0,0) ;
1050 pc.
defineSet(
"extCons",
"ExternalConstraints",0,0) ;
1052 pc.
defineDouble(
"IntegrateBins",
"IntegrateBins", 0, -1.);
1054 pc.
defineMutex(
"GlobalObservables",
"GlobalObservablesTag") ;
1055 pc.
defineInt(
"ModularL",
"ModularL", 0, 0);
1069 if (pc.
getInt(
"ModularL")) {
1070 int lut[3] = {2, 1, 0};
1078 if (
auto tmp = pc.
getSet(
"cPars"))
1081 if (
auto tmp = pc.
getSet(
"extCons"))
1082 extConsSet.
add(*tmp);
1084 if (
auto tmp = pc.
getSet(
"glObs"))
1087 const std::string rangeName = pc.
getString(
"globstag",
"",
false);
1090 builder.Extended(ext)
1091 .ConstrainedParameters(cParsSet)
1092 .ExternalConstraints(extConsSet)
1093 .GlobalObservables(glObsSet)
1094 .GlobalObservablesTag(rangeName.c_str());
1096 return std::make_unique<RooFit::TestStatistics::RooRealL>(
"likelihood",
"", builder.build());
1100 const char* rangeName = pc.
getString(
"rangeName",0,
true) ;
1101 const char* addCoefRangeName = pc.
getString(
"addCoefRange",0,
true) ;
1111 cloneData = optConst ;
1115 double rangeLo = pc.
getDouble(
"rangeLo") ;
1116 double rangeHi = pc.
getDouble(
"rangeHi") ;
1121 for (
auto arg : obs) {
1123 if (rrv) rrv->
setRange(
"fit",rangeLo,rangeHi) ;
1131 resetFitrangeAttributes(*
this,
data, baseName, rangeName, splitRange);
1134 auto tmp = pc.
getSet(
"projDepSet");
1136 projDeps.
add(*tmp) ;
1139 const std::string globalObservablesSource = pc.
getString(
"globssource",
"data",
false);
1140 if(globalObservablesSource !=
"data" && globalObservablesSource !=
"model") {
1141 std::string errMsg =
"RooAbsPdf::fitTo: GlobalObservablesSource can only be \"data\" or \"model\"!";
1142 coutE(InputArguments) << errMsg << std::endl;
1143 throw std::invalid_argument(errMsg);
1145 const bool takeGlobalObservablesFromData = globalObservablesSource ==
"data";
1150 auto createConstr = [&](
RooAbsPdf const& pdf,
bool removeConstraintsFromPdf=
false) -> std::unique_ptr<RooAbsReal> {
1152 baseName +
"_constr",
1159 takeGlobalObservablesFromData,
1160 removeConstraintsFromPdf
1176 normSet.
remove(projDeps,
true,
true);
1182 ctx.setLikelihoodMode(
true);
1184 std::unique_ptr<RooAbsPdf> pdfClone = std::unique_ptr<RooAbsPdf>{
static_cast<RooAbsPdf *
>(head.release())};
1193 if (addCoefRangeName) {
1195 <<
") fixing interpretation of coefficients of any component to range "
1196 << addCoefRangeName <<
"\n";
1197 pdfClone->fixAddCoefRange(addCoefRangeName,
false);
1200 std::unique_ptr<RooAbsReal> compiledConstr;
1201 if(std::unique_ptr<RooAbsReal> constr = createConstr(*
this)) {
1203 compiledConstr->addOwnedComponents(std::move(constr));
1206 auto nll = RooFit::BatchModeHelpers::createNLL(
1209 std::move(compiledConstr),
1210 rangeName ? rangeName :
"",
1216 std::unique_ptr<RooAbsReal> nllWrapper;
1221 nllWrapper = std::make_unique<RooFuncWrapper>(
"nll_func_wrapper",
"nll_func_wrapper", *nll, normSet, &
data,
1222 simPdf, createGradient);
1225 nllWrapper = std::make_unique<RooEvaluatorWrapper>(*nll,
1226 std::move(evaluator), rangeName ? rangeName :
"",
dynamic_cast<RooSimultaneous *
>(pdfClone.get()), takeGlobalObservablesFromData);
1227 nllWrapper->setData(
data,
false);
1230 nllWrapper->addOwnedComponents(std::move(nll));
1231 nllWrapper->addOwnedComponents(std::move(pdfClone));
1235 std::unique_ptr<RooAbsReal> nll ;
1237#ifdef ROOFIT_LEGACY_EVAL_BACKEND
1238 bool verbose = pc.
getInt(
"verbose") ;
1243 if (numcpu_strategy==3 && !this->
InheritsFrom(
"RooSimultaneous") ) {
1244 coutW(Minimization) <<
"Cannot use a NumCpu Strategy = 3 when the pdf is not a RooSimultaneous, "
1245 "falling back to default strategy = 0" << endl;
1246 numcpu_strategy = 0;
1251 RooAbsPdf &actualPdf = binnedLInfo.binnedPdf ? *binnedLInfo.binnedPdf : *
this;
1263 cfg.
binnedL = binnedLInfo.isBinnedL;
1265 cfg.
rangeName = rangeName ? rangeName :
"";
1266 auto nllVar = std::make_unique<RooNLLVar>(baseName.c_str(),
"-log(likelihood)",actualPdf,
data,projDeps, ext, cfg);
1268 nll = std::move(nllVar);
1272 if (std::unique_ptr<RooAbsReal> constraintTerm = createConstr(*
this)) {
1284 constraintTerm->setData(
data,
false);
1290 auto orignll = std::move(nll) ;
1291 nll = std::make_unique<RooAddition>((baseName +
"_with_constr").c_str(),
"nllWithCons",
RooArgSet(*orignll,*constraintTerm)) ;
1292 nll->addOwnedComponents(std::move(orignll),std::move(constraintTerm)) ;
1300 nll->enableOffsetting(
true) ;
1303 throw std::runtime_error(
"RooFit was not built with the legacy evaluation backend");
1440 std::string nllCmdListString =
"ProjectedObservables,Extended,Range,"
1441 "RangeWithName,SumCoefRange,NumCPU,SplitRange,Constrained,Constrain,ExternalConstraints,"
1442 "CloneData,GlobalObservables,GlobalObservablesSource,GlobalObservablesTag,"
1443 "EvalBackend,IntegrateBins,ModularL";
1446 nllCmdListString +=
",OffsetLikelihood";
1460 if (pc.
getInt(
"timingAnalysis") && !this->InheritsFrom(
"RooSimultaneous") ) {
1461 coutW(Minimization) <<
"The timingAnalysis feature was built for minimization with RooSimultaneous "
1462 "and is not implemented for other PDF's. Please create a RooSimultaneous to "
1463 "enable this feature." << endl;
1470 size_t nEvents =
static_cast<size_t>(prefit*
data.numEntries());
1471 if (prefit > 0.5 || nEvents < 100) {
1472 coutW(InputArguments) <<
"PrefitDataFraction should be in suitable range."
1473 <<
"With the current PrefitDataFraction=" << prefit
1474 <<
", the number of events would be " << nEvents<<
" out of "
1475 <<
data.numEntries() <<
". Skipping prefit..." << endl;
1478 size_t step =
data.numEntries()/nEvents;
1483 for (
int i=0; i<
data.numEntries(); i+=step)
1489 pc.
filterCmdList(tinyCmdList,
"Prefit,Hesse,Minos,Verbose,Save,Timer");
1493 tinyCmdList.
Add(&hesse_option);
1494 tinyCmdList.
Add(&print_option);
1496 fitTo(tiny,tinyCmdList);
1501 if (pc.
getInt(
"parallelize") != 0 || pc.
getInt(
"enableParallelGradient") || pc.
getInt(
"enableParallelDescent")) {
1504 nllCmdList.
Add(&modularL_option);
1507 std::unique_ptr<RooAbsReal> nll{
createNLL(
data,nllCmdList)};
1538 os <<
indent <<
"--- RooAbsPdf ---" << endl;
1541 os <<
indent <<
" Normalization integral: " << endl ;
1542 auto moreIndent = std::string(
indent.Data()) +
" " ;
1563 const RooArgSet* auxProto,
bool verbose)
const
1565 return new RooGenContext(*
this,vars,prototype,auxProto,verbose) ;
1572 bool verbose,
bool autoBinned,
const char* binnedTag)
const
1574 if (prototype || (auxProto && auxProto->
getSize()>0)) {
1575 return genContext(vars,prototype,auxProto,verbose);
1652 pc.
defineInt(
"randProto",
"PrototypeData",0,0) ;
1653 pc.
defineInt(
"resampleProto",
"PrototypeData",1,0) ;
1655 pc.
defineInt(
"extended",
"Extended",0,0) ;
1656 pc.
defineInt(
"nEvents",
"NumEvents",0,0) ;
1657 pc.
defineInt(
"autoBinned",
"AutoBinned",0,1) ;
1658 pc.
defineInt(
"expectedData",
"ExpectedData",0,0) ;
1665 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6) ;
1672 const char* dsetName = pc.
getString(
"dsetName") ;
1673 bool verbose = pc.
getInt(
"verbose") ;
1674 bool randProto = pc.
getInt(
"randProto") ;
1675 bool resampleProto = pc.
getInt(
"resampleProto") ;
1676 bool extended = pc.
getInt(
"extended") ;
1677 bool autoBinned = pc.
getInt(
"autoBinned") ;
1678 const char* binnedTag = pc.
getString(
"binnedTag") ;
1680 double nEventsD = pc.
getInt(
"nEventsD") ;
1682 bool expectedData = pc.
getInt(
"expectedData") ;
1684 double nEvents = (nEventsD>0) ? nEventsD :
double(nEventsI);
1693 }
else if (nEvents==0) {
1694 cxcoutI(Generation) <<
"No number of events specified , number of events generated is "
1698 if (extended && protoData && !randProto) {
1699 cxcoutI(Generation) <<
"WARNING Using generator option Extended() (Poisson distribution of #events) together "
1700 <<
"with a prototype dataset implies incomplete sampling or oversampling of proto data. "
1701 <<
"Set randomize flag in ProtoData() option to randomize prototype dataset order and thus "
1702 <<
"to randomize the set of over/undersampled prototype events for each generation cycle." << endl ;
1707 std::unique_ptr<RooDataSet>
data;
1709 data = std::unique_ptr<RooDataSet>{
generate(whatVars,*protoData,
Int_t(nEvents),verbose,randProto,resampleProto)};
1711 data = std::unique_ptr<RooDataSet>{
generate(whatVars,nEvents,verbose,autoBinned,binnedTag,expectedData, extended)};
1715 if (dsetName && strlen(dsetName)>0) {
1716 data->SetName(dsetName) ;
1744 pc.
defineInt(
"randProto",
"PrototypeData",0,0) ;
1745 pc.
defineInt(
"resampleProto",
"PrototypeData",1,0) ;
1747 pc.
defineInt(
"extended",
"Extended",0,0) ;
1748 pc.
defineInt(
"nEvents",
"NumEvents",0,0) ;
1749 pc.
defineInt(
"autoBinned",
"AutoBinned",0,1) ;
1755 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6) ;
1762 const char* dsetName = pc.
getString(
"dsetName") ;
1764 bool verbose = pc.
getInt(
"verbose") ;
1765 bool randProto = pc.
getInt(
"randProto") ;
1766 bool resampleProto = pc.
getInt(
"resampleProto") ;
1767 bool extended = pc.
getInt(
"extended") ;
1768 bool autoBinned = pc.
getInt(
"autoBinned") ;
1769 const char* binnedTag = pc.
getString(
"binnedTag") ;
1773 return new GenSpec(cx,whatVars,protoData,nEvents,extended,randProto,resampleProto,dsetName) ;
1827 std::unique_ptr<RooAbsGenContext> context{
autoGenContext(whatVars,0,0,verbose,autoBinned,binnedTag)};
1832 std::unique_ptr<RooDataSet> generated;
1833 if(0 != context && context->isValid()) {
1834 generated = std::unique_ptr<RooDataSet>{context->generate(nEvents,
false, extended)};
1837 coutE(Generation) <<
"RooAbsPdf::generate(" <<
GetName() <<
") cannot create a valid context" << endl;
1849 double nEvents,
bool ,
bool randProtoOrder,
bool resampleProto,
1850 bool skipInit,
bool extended)
const
1852 if (nEvents==0 && (prototype==0 || prototype->
numEntries()==0)) {
1853 return std::make_unique<RooDataSet>(
"emptyData",
"emptyData",whatVars);
1856 std::unique_ptr<RooDataSet> generated;
1859 if (resampleProto) {
1860 randProtoOrder=true ;
1863 if (randProtoOrder && prototype && prototype->
numEntries()!=nEvents) {
1864 coutI(Generation) <<
"RooAbsPdf::generate (Re)randomizing event order in prototype dataset (Nevt=" << nEvents <<
")" << endl ;
1871 generated = std::unique_ptr<RooDataSet>{context.
generate(nEvents,skipInit,extended)};
1874 coutE(Generation) <<
"RooAbsPdf::generate(" <<
GetName() <<
") do not have a valid generator context" << endl;
1905 Int_t nEvents,
bool verbose,
bool randProtoOrder,
bool resampleProto)
const
1907 std::unique_ptr<RooAbsGenContext> context{
genContext(whatVars,&prototype,0,verbose)};
1911 coutE(Generation) <<
"RooAbsPdf::generate(" <<
GetName() <<
") ERROR creating generator context" << endl ;
1926 if (!resampleProto) {
1928 std::iota(lut, lut + nProto, 0);
1934 for (
int i = nProto-1; i > 0; --i) {
1999 if(server == &arg)
continue;
2000 if(server->dependsOn(arg)) {
2041 pc.
defineInt(
"extended",
"Extended",0,0) ;
2042 pc.
defineInt(
"nEvents",
"NumEvents",0,0) ;
2044 pc.
defineInt(
"expectedData",
"ExpectedData",0,0) ;
2047 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6) ;
2053 double nEvents = pc.
getDouble(
"nEventsD") ;
2055 nEvents = pc.
getInt(
"nEvents") ;
2058 bool extended = pc.
getInt(
"extended") ;
2059 bool expectedData = pc.
getInt(
"expectedData") ;
2060 const char* dsetName = pc.
getString(
"dsetName") ;
2065 cxcoutI(Generation) <<
" Extended mode active, number of events generated (" << nEvents <<
") is Poisson fluctuation on "
2066 <<
GetName() <<
"::expectedEvents() = " << nEvents << endl ;
2071 }
else if (nEvents==0) {
2072 cxcoutI(Generation) <<
"No number of events specified , number of events generated is "
2080 if (dsetName && strlen(dsetName)>0) {
2081 data->SetName(dsetName) ;
2118 auto hist = std::make_unique<RooDataHist>(
"genData",
"genData",whatVars);
2123 coutE(InputArguments) <<
"RooAbsPdf::generateBinned(" <<
GetName() <<
") ERROR: No event count provided and p.d.f does not provide expected number of events" << endl ;
2128 if (expectedData || extended) {
2139 vector<int> histOut(hist->numEntries()) ;
2140 double histMax(-1) ;
2141 Int_t histOutSum(0) ;
2142 for (
int i=0 ; i<hist->numEntries() ; i++) {
2147 double w=hist->weight()*nEvents ;
2148 hist->set(i,
w, sqrt(
w));
2150 }
else if (extended) {
2154 hist->set(
w,sqrt(
w)) ;
2160 if (hist->weight()>histMax) {
2161 histMax = hist->weight() ;
2164 histOutSum += histOut[i] ;
2169 if (!expectedData && !extended) {
2174 Int_t nEvtExtra = std::abs(
Int_t(nEvents)-histOutSum) ;
2175 Int_t wgt = (histOutSum>nEvents) ? -1 : 1 ;
2178 std::size_t counter = 0;
2179 bool havePrintedInfo =
false;
2180 while(nEvtExtra>0) {
2183 hist->get(ibinRand) ;
2186 if (ranY<hist->weight()) {
2188 histOut[ibinRand]++ ;
2191 if (histOut[ibinRand]>0) {
2192 histOut[ibinRand]-- ;
2200 if ((counter++ > 10*nEvents || nEvents > 1.E7) && !havePrintedInfo) {
2201 havePrintedInfo =
true;
2202 coutP(Generation) <<
"RooAbsPdf::generateBinned(" <<
GetName() <<
") Performing costly accept/reject sampling. If this takes too long, use "
2203 <<
"extended mode to speed up the process." << std::endl;
2208 for (
int i=0 ; i<hist->numEntries() ; i++) {
2210 hist->set(histOut[i],sqrt(1.0*histOut[i])) ;
2213 }
else if (expectedData) {
2218 double corr = nEvents/hist->sumEntries() ;
2219 for (
int i=0 ; i<hist->numEntries() ; i++) {
2221 hist->set(hist->weight()*corr,sqrt(hist->weight()*corr)) ;
2236 return generate(whatVars,nEvents) ;
2240void removeRangeOverlap(std::vector<std::pair<double, double>>& ranges) {
2242 std::sort(ranges.begin(), ranges.end());
2244 for (
auto it = ranges.begin(); it != ranges.end(); ++it) {
2245 double& startL = it->first;
2246 double& endL = it->second;
2248 for (
auto innerIt = it+1; innerIt != ranges.end(); ++innerIt) {
2249 const double startR = innerIt->first;
2250 const double endR = innerIt->second;
2252 if (startL <= startR && startR <= endL) {
2254 endL = std::max(endL, endR);
2255 *innerIt = make_pair(0., 0.);
2260 auto newEnd = std::remove_if(ranges.begin(), ranges.end(),
2261 [](
const std::pair<double,double>&
input){
2262 return input.first == input.second;
2264 ranges.erase(newEnd, ranges.end());
2377 std::unique_ptr<RooCmdArg> plotRange;
2378 std::unique_ptr<RooCmdArg> normRange2;
2382 cmdList.
Add(plotRange.get());
2387 cmdList.
Add(normRange2.get());
2390 if (plotRange || normRange2) {
2391 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") p.d.f was fitted in a subrange and no explicit "
2392 << (plotRange?
"Range()":
"") << ((plotRange&&normRange2)?
" and ":
"")
2393 << (normRange2?
"NormRange()":
"") <<
" was specified. Plotting / normalising in fit range. To override, do one of the following"
2394 <<
"\n\t- Clear the automatic fit range attribute: <pdf>.removeStringAttribute(\"fitrange\");"
2395 <<
"\n\t- Explicitly specify the plotting range: Range(\"<rangeName>\")."
2396 <<
"\n\t- Explicitly specify where to compute the normalisation: NormRange(\"<rangeName>\")."
2397 <<
"\n\tThe default (full) range can be denoted with Range(\"\") / NormRange(\"\")."<< endl ;
2407 pc.
defineSet(
"compSet",
"SelectCompSet",0) ;
2414 pc.
defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
2415 pc.
defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
2416 pc.
defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
2428 double scaleFactor = pc.
getDouble(
"scaleFactor") ;
2430 const char* compSpec = pc.
getString(
"compSpec") ;
2432 bool haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
2435 std::string nameSuffix ;
2436 if (compSpec && strlen(compSpec)>0) {
2437 nameSuffix.append(
"_Comp[") ;
2438 nameSuffix.append(compSpec) ;
2439 nameSuffix.append(
"]") ;
2440 }
else if (compSet) {
2449 RooCmdArg cnsuffix(
"CurveNameSuffix",0,0,0,0,nameSuffix.c_str(),0,0,0) ;
2450 cmdList.
Add(&cnsuffix);
2455 double nExpected(1) ;
2459 <<
"): ERROR the 'Expected' scale option can only be used on extendable PDFs" << endl ;
2470 bool hasCustomRange(
false), adjustNorm(
false) ;
2472 std::vector<pair<double,double> > rangeLim;
2477 double rangeLo = pc.
getDouble(
"rangeLo") ;
2478 double rangeHi = pc.
getDouble(
"rangeHi") ;
2479 rangeLim.push_back(make_pair(rangeLo,rangeHi)) ;
2480 adjustNorm = pc.
getInt(
"rangeAdjustNorm") ;
2481 hasCustomRange = true ;
2483 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") only plotting range ["
2484 << rangeLo <<
"," << rangeHi <<
"]" ;
2486 ccoutI(Plotting) <<
", curve is normalized to data in " << (adjustNorm?
"given":
"full") <<
" range" << endl ;
2488 ccoutI(Plotting) << endl ;
2491 nameSuffix.append(
Form(
"_Range[%f_%f]",rangeLo,rangeHi)) ;
2495 for (
const std::string& rangeNameToken :
ROOT::Split(pc.
getString(
"rangeName",
"",
false),
",")) {
2496 const char* thisRangeName = rangeNameToken.empty() ? nullptr : rangeNameToken.c_str();
2498 coutE(Plotting) <<
"Range '" << rangeNameToken <<
"' not defined for variable '"
2504 adjustNorm = pc.
getInt(
"rangeWNAdjustNorm") ;
2505 hasCustomRange = true ;
2507 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") only plotting range '" << pc.
getString(
"rangeName",
"",
false) <<
"'" ;
2509 ccoutI(Plotting) <<
", curve is normalized to data in " << (adjustNorm?
"given":
"full") <<
" range" << endl ;
2511 ccoutI(Plotting) << endl ;
2514 nameSuffix.append(
"_Range[" + std::string(pc.
getString(
"rangeName")) +
"]");
2519 for (
const auto& rangeNameToken :
ROOT::Split(pc.
getString(
"normRangeName",
"",
false),
",")) {
2520 const char* thisRangeName = rangeNameToken.empty() ? nullptr : rangeNameToken.c_str();
2522 coutE(Plotting) <<
"Range '" << rangeNameToken <<
"' not defined for variable '"
2529 hasCustomRange = true ;
2530 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") p.d.f. curve is normalized using explicit choice of ranges '" << pc.
getString(
"normRangeName",
"",
false) <<
"'" << endl ;
2532 nameSuffix.append(
"_NormRange[" + std::string(pc.
getString(
"rangeName")) +
"]");
2536 if (hasCustomRange && adjustNorm) {
2538 const std::size_t oldSize = rangeLim.size();
2539 removeRangeOverlap(rangeLim);
2541 if (oldSize != rangeLim.size() && !pc.
hasProcessed(
"NormRange")) {
2545 coutE(Plotting) <<
"Requested plot/integration ranges overlap. For correct plotting, new ranges "
2546 "will be defined." << std::endl;
2549 std::string rangesNoOverlap;
2550 for (
auto it = rangeLim.begin(); it != rangeLim.end(); ++it) {
2551 std::stringstream rangeName;
2552 rangeName <<
"Remove_overlap_range_" << it - rangeLim.begin();
2553 plotVar->setRange(rangeName.str().c_str(), it->first, it->second);
2554 if (!rangesNoOverlap.empty())
2555 rangesNoOverlap +=
",";
2556 rangesNoOverlap += rangeName.str();
2561 rangeArg->
setString(0, rangesNoOverlap.c_str());
2563 plotRange = std::make_unique<RooCmdArg>(
RooFit::Range(rangesNoOverlap.c_str()));
2564 cmdList.
Add(plotRange.get());
2568 double rangeNevt(0) ;
2569 for (
const auto& riter : rangeLim) {
2574 scaleFactor *= rangeNevt/nExpected ;
2580 scaleFactor *= nExpected ;
2582 scaleFactor /= nExpected ;
2601 for (
const auto arg : branchNodeSet) {
2603 branchNodeSet.
remove(*arg) ;
2608 std::unique_ptr<RooArgSet> dirSelNodes;
2614 if (dirSelNodes->getSize()>0) {
2615 coutI(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << endl ;
2621 coutE(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << endl ;
2623 coutE(Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << endl ;
2630 RooCmdArg cnsuffix(
"CurveNameSuffix",0,0,0,0,nameSuffix.c_str(),0,0,0) ;
2631 cmdList.
Add(&cnsuffix);
2662 double nExpected(1) ;
2666 <<
"): ERROR the 'Expected' scale option can only be used on extendable PDFs" << endl ;
2736 pc.
defineInt(
"showc",
"ShowConstants",0,0) ;
2737 pc.
defineSet(
"params",
"Parameters",0,0) ;
2738 pc.
defineInt(
"dummy",
"FormatArgs",0,0) ;
2748 const char* label = pc.
getString(
"label") ;
2752 int showc = pc.
getInt(
"showc") ;
2757 params = std::unique_ptr<RooArgSet>{
static_cast<RooArgSet*
>(params->selectCommon(*requestedParams))};
2779 bool showLabel= (label != 0 && strlen(label) > 0);
2784 for (
const auto param : params) {
2786 if(showConstants || !var->isConstant())
ymin-= dy;
2789 std::string labelString = label;
2790 unsigned int numLines = std::count(labelString.begin(), labelString.end(),
'\n') + 1;
2791 if (showLabel)
ymin -= numLines * dy;
2796 box->SetName((std::string(
GetName()) +
"_paramBox").c_str());
2797 box->SetFillColor(0);
2798 box->SetBorderSize(0);
2799 box->SetTextAlign(12);
2800 box->SetTextSize(0.04F);
2801 box->SetFillStyle(0);
2803 for (
const auto param : params) {
2804 auto var =
static_cast<const RooRealVar*
>(param);
2805 if(var->isConstant() && !showConstants)
continue;
2807 std::unique_ptr<TString> formatted{formatCmd ? var->format(*formatCmd) : var->format(2,
"NELU")};
2808 box->AddText(formatted->Data());
2869 pdfOwner->
_norm = 0 ;
2885 name.append(
"_Proj[") ;
2888 for(
auto const& arg : iset) {
2894 name.append(arg->GetName()) ;
2944 pc.
defineSet(
"supNormSet",
"SupNormSet",0,0) ;
2945 pc.
defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
2946 pc.
defineInt(
"intOrder",
"ScanParameters",1,2) ;
2947 pc.
defineInt(
"doScanNum",
"ScanNumCdf",0,1) ;
2948 pc.
defineInt(
"doScanAll",
"ScanAllCdf",0,0) ;
2949 pc.
defineInt(
"doScanNon",
"ScanNoCdf",0,0) ;
2950 pc.
defineMutex(
"ScanNumCdf",
"ScanAllCdf",
"ScanNoCdf") ;
2953 pc.
process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
2982 coutI(NumIntegration) <<
"RooAbsPdf::createCdf(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << endl
2983 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
2984 << intOrder <<
" interpolation on integrated histogram." << endl
2985 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
2997 ivar->
setBins(numScanBins,
"numcdf") ;
2998 auto ret = std::make_unique<RooNumCdf>(
name.c_str(),
name.c_str(),*
this,*ivar,
"numcdf");
2999 ret->setInterpolationOrder(intOrder) ;
3011 bool stripDisconnected,
bool removeConstraintsFromPdf)
const
3016 for (
const auto arg : *comps) {
3017 auto pdf =
dynamic_cast<const RooAbsPdf*
>(arg) ;
3019 std::unique_ptr<RooArgSet> compRet(
3020 pdf->getConstraints(observables,constrainedParams,stripDisconnected,removeConstraintsFromPdf));
3022 ret->
add(*compRet,
false) ;
3075 if (config)
return config ;
3107 delete _genContext ;
3114 bool extended,
bool randProto,
bool resampleProto,
TString dsetName,
bool init) :
3115 _genContext(context), _whatVars(whatVars), _protoData(protoData), _nGen(nGen), _extended(extended),
3116 _randProto(randProto), _resampleProto(resampleProto), _dsetName(dsetName), _init(init)
3123void sterilizeClientCaches(
RooAbsArg & arg) {
3125 for(std::size_t iClient = 0; iClient <
clients.size(); ++iClient) {
3127 const std::size_t oldClientsSize =
clients.size();
3130 for(
int iCache = 0; iCache < client->
numCaches(); ++iCache) {
3132 cacheMgr->sterilize();
3139 if(
clients.size() != oldClientsSize) {
3140 auto clientIter = std::find(
clients.begin(),
clients.end(), client);
3141 if(clientIter ==
clients.end()) {
3142 throw std::runtime_error(
"After a clients caches were cleared, the client was gone! This should not happen.");
3144 iClient = std::distance(
clients.begin(), clientIter);
3163 sterilizeClientCaches(*
this);
3183 sterilizeClientCaches(*
this);
3197 bool nameChange,
bool isRecursiveStep)
3215std::unique_ptr<RooAbsArg>
3221 std::unique_ptr<RooAbsPdf> pdfClone(
static_cast<RooAbsPdf *
>(this->
Clone()));
3224 auto newArg = std::make_unique<RooNormalizedPdf>(*pdfClone, normSet);
3228 for (
RooAbsArg *server : newArg->servers()) {
3232 newArg->addOwnedComponents(std::move(pdfClone));
3242 std::stringstream errMsg;
3244 <<
" did not overload RooAbsPdf::createExpectedEventsFunc()!";
3245 coutE(InputArguments) << errMsg.str() << std::endl;
std::unique_ptr< RooAbsReal > createConstraintTerm(std::string const &name, RooAbsPdf const &pdf, RooAbsData const &data, RooArgSet const *constrainedParameters, RooArgSet const *externalConstraints, RooArgSet const *globalObservables, const char *globalObservablesTag, bool takeGlobalObservablesFromData, bool removeConstraintsFromPdf)
Create the parameter constraint sum to add to the negative log-likelihood.
static void indent(ostringstream &buf, int indent_level)
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 input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void clearValueAndShapeDirty() const
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
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.
void setOperMode(OperMode mode, bool recurseADirty=true)
Set the operation mode of this node.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
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.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
virtual std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const
RooFit::OwningPtr< RooArgSet > getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
void removeStringAttribute(const Text_t *key)
Delete a string attribute with a given key.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
RooAbsCache * getCache(Int_t index) const
Return registered cache object by index.
const RefCountList_t & clients() const
List of all clients of this object.
bool isValueDirty() const
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.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
RefCountList_t _serverList
Int_t numCaches() const
Return number of registered caches.
RooAbsArg * findServer(const char *name) const
Return server of this with name name. Returns nullptr if not found.
OperMode operMode() const
Query the operation mode of this node.
RooAbsArg * _owner
! Pointer to owning RooAbsArg
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsArg * first() const
RooAbsCollection * selectByName(const char *nameList, bool verbose=false) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
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.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Abstract base class for binned and unbinned datasets.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Abstract base class for generator contexts of RooAbsPdf objects.
virtual void setExpectedData(bool)
virtual RooDataSet * generate(double nEvents=0, bool skipInit=false, bool extendedMode=false)
Generate the specified number of events with nEvents>0 and and return a dataset containing the genera...
virtual void setProtoDataOrder(Int_t *lut)
Set the traversal order of prototype data to that in the lookup tables passed as argument.
Normalization set with for above integral.
~CacheElem() override
Destructor of normalization cache element.
RooAbsGenContext * _genContext
Abstract interface for all probability density functions.
virtual bool syncNormalization(const RooArgSet *dset, bool adjustProxies=true) const
Verify that the normalization integral cached with this PDF is valid for given set of normalization o...
double getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
std::unique_ptr< RooAbsArg > compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext &ctx) const override
RooObjCacheManager _normMgr
std::unique_ptr< RooNumGenConfig > _specGeneratorConfig
! MC generator configuration specific for this object
bool interpretExtendedCmdArg(int extendedCmdArg) const
RooFit::OwningPtr< RooAbsReal > createNLL(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Construct representation of -log(L) of PDF with given dataset.
double getValV(const RooArgSet *set=nullptr) const override
Return current value, normalized by integrating over the observables in nset.
virtual std::unique_ptr< RooFitResult > fitToImpl(RooAbsData &data, const RooLinkedList &cmdList)
Protected implementation of the likelihood fitting routine.
bool _selectComp
Component selection flag for RooAbsPdf::plotCompOn.
virtual void generateEvent(Int_t code)
Interface for generation of an event using the algorithm corresponding to the specified code.
RooFit::OwningPtr< RooAbsReal > createScanCdf(const RooArgSet &iset, const RooArgSet &nset, Int_t numScanBins, Int_t intOrder)
void setGeneratorConfig()
Remove the specialized numeric MC generator configuration associated with this object.
virtual void resetErrorCounters(Int_t resetValue=10)
Reset error counter to given value, limiting the number of future error messages for this pdf to 'res...
static int verboseEval()
Return global level of verbosity for p.d.f. evaluations.
RooFit::OwningPtr< RooAbsReal > createCdf(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Create a cumulative distribution function of this p.d.f in terms of the observables listed in iset.
bool isActiveNormSet(RooArgSet const *normSet) const
Checks if normSet is the currently active normalization set of this PDF, meaning is exactly the same ...
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
virtual RooAbsGenContext * binnedGenContext(const RooArgSet &vars, bool verbose=false) const
Return a binned generator context.
TString _normRange
Normalization range.
virtual bool isDirectGenSafe(const RooAbsArg &arg) const
Check if given observable can be safely generated using the pdfs internal generator mechanism (if tha...
Int_t * randomizeProtoOrder(Int_t nProto, Int_t nGen, bool resample=false) const
Return lookup table with randomized order for nProto prototype events.
void setNormRange(const char *rangeName)
~RooAbsPdf() override
Destructor.
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
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 override
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
RooNumGenConfig * specialGeneratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
virtual bool selfNormalized() const
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print multi line detailed information of this RooAbsPdf.
Int_t _traceCount
Number of traces remaining to print.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
void setTraceCounter(Int_t value, bool allNodes=false)
Reset trace counter to given value, limiting the number of future trace messages for this pdf to 'val...
GenSpec * prepareMultiGen(const RooArgSet &whatVars, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={})
Prepare GenSpec configuration object for efficient generation of multiple datasets from identical spe...
Int_t _errorCount
Number of errors remaining to print.
virtual std::unique_ptr< RooAbsReal > createExpectedEventsFunc(const RooArgSet *nset) const
Returns an object that represents the expected number of events for a given normalization set,...
virtual RooPlot * paramOn(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={})
Add a box with parameter values (and errors) to the specified frame.
RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Fit PDF to given dataset.
Int_t _negCount
Number of negative probabilities remaining to print.
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 const RooAbsReal * getNormObj(const RooArgSet *set, const RooArgSet *iset, const TNamed *rangeName=nullptr) const
Return pointer to RooAbsReal object that implements calculation of integral over observables iset in ...
void setActiveNormSet(RooArgSet const *normSet) const
Setter for the _normSet member, which should never be set directly.
double analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=nullptr) const override
Analytical integral with normalization (see RooAbsReal::analyticalIntegralWN() for further informatio...
void setNormRangeOverride(const char *rangeName)
virtual RooFit::OwningPtr< RooDataSet > generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
double normalizeWithNaNPacking(double rawVal, double normVal) const
virtual RooAbsGenContext * autoGenContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false, bool autoBinned=true, const char *binnedTag="") const
RooArgSet * getAllConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, bool stripDisconnected=true, bool removeConstraintsFromPdf=false) const
This helper function finds and collects all constraints terms of all component p.d....
const RooNumGenConfig * getGeneratorConfig() const
Return the numeric MC generator configuration used for this object.
virtual void initGenerator(Int_t code)
Interface for one-time initialization to setup the generator for the specified code.
virtual ExtendMode extendMode() const
Returns ability of PDF to provide extended likelihood terms.
RooAbsPdf()
Default constructor.
virtual RooFit::OwningPtr< RooDataHist > generateBinned(const RooArgSet &whatVars, double nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}) const
As RooAbsPdf::generateBinned(const RooArgSet&, const RooCmdArg&,const RooCmdArg&, const RooCmdArg&,...
bool traceEvalPdf(double value) const
Check that passed value is positive and not 'not-a-number'.
static RooNumGenConfig * defaultGeneratorConfig()
Returns the default numeric MC generator configuration for all RooAbsReals.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
The cache manager.
void printValue(std::ostream &os) const override
Print value of p.d.f, also print normalization integral that was last used, if any.
virtual std::unique_ptr< RooAbsReal > createNLLImpl(RooAbsData &data, const RooLinkedList &cmdList)
Protected implementation of the NLL creation routine.
void logBatchComputationErrors(std::span< const double > &outputs, std::size_t begin) const
Scan through outputs and fix+log all nans and negative values.
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr, const RooArgSet *auxProto=nullptr, bool verbose=false) const
Interface function to create a generator context from a p.d.f.
void getLogProbabilities(std::span< const double > pdfValues, double *output) const
static TString _normRangeOverride
static Int_t _verboseEval
double extendedTerm(double sumEntries, double expected, double sumEntriesW2=0.0, bool doOffset=false) const
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
virtual RooAbsPdf * createProjection(const RooArgSet &iset)
Return a p.d.f that represent a projection of this p.d.f integrated over given observables.
virtual double getLogVal(const RooArgSet *set=nullptr) const
Return the log of the current value with given normalization An error message is printed if the argum...
bool hasRange(const char *name) const override
Check if variable has a binning with given name.
std::pair< double, double > getRange(const char *name=nullptr) const
Get low and high bound of the variable.
Abstract base class for objects that represent a real value and implements functionality common to al...
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.
void plotOnCompSelect(RooArgSet *selNodes) const
Helper function for plotting of composite p.d.fs.
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 ...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
bool plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
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.
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
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.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
virtual bool isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooFit::OwningPtr< RooAbsReal > createIntRI(const RooArgSet &iset, const RooArgSet &nset={})
Utility function for createRunningIntegral.
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.
virtual double offset() const
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Efficient implementation of the generator context specific for binned pdfs.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=nullptr)
Setter function without integration set.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=nullptr, const TNamed *isetRangeName=nullptr)
Getter function without integration set.
RooCachedReal is an implementation of RooAbsCachedReal that can cache any external RooAbsReal input f...
void setCacheSource(bool flag)
Named container for two doubles, two integers two object points and three string pointers that can be...
void setInt(Int_t idx, Int_t value)
Int_t getInt(Int_t idx) const
void setString(Int_t idx, const char *value)
Class RooCmdConfig is a 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...
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'.
RooLinkedList filterCmdList(RooLinkedList &cmdInList, const char *cmdNameList, bool removeFromInList=true) const
Utility function to filter commands listed in cmdNameList from cmdInList.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
RooDataSet is a container class to hold unbinned data.
void markAsCompiled(RooAbsArg &arg) const
void compileServers(RooAbsArg &arg, RooArgSet const &normSet)
static Value & defaultValue()
Class RooGenContext implement a universal generator context for all RooAbsPdf classes that do not hav...
Switches the message service to a different level while the instance is alive.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
virtual void Add(TObject *arg)
TObject * FindObject(const char *name) const override
Return pointer to object with given name.
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
RooNumGenConfig holds the configuration parameters of the various numeric integrators used by RooReal...
static RooNumGenConfig & defaultConfig()
Return reference to instance of default numeric integrator configuration object.
Class RooObjCacheManager is an implementation of class RooCacheManager<RooAbsCacheElement> and specia...
void sterilize() override
Clear the cache payload but retain slot mapping w.r.t to normalization and integration sets.
A RooPlot is a plot frame and a container for graphics objects within that frame.
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
double getFitRangeNEvt() const
Return the number of events in the fit range.
const RooArgSet * getNormVars() const
RooAbsRealLValue * getPlotVar() const
void updateNormVars(const RooArgSet &vars)
Install the given set of observables are reference normalization variables for this frame.
double getFitRangeBinW() const
Return the bin width that is being used to normalise the PDF.
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,...
Class RooProjectedPdf is a RooAbsPdf implementation that represent a projection of a given input p....
static UInt_t integer(UInt_t max, TRandom *generator=randomGenerator())
Return an integer uniformly distributed from [0,n-1].
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Performs hybrid numerical/analytical integrals of RooAbsReal objects.
const RooArgSet & numIntRealVars() const
RooRealVar represents a variable that can be changed from the outside.
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
A Pave (see TPave) with text, lines or/and boxes inside.
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
void Clear()
Clear string without changing its capacity.
const char * Data() const
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
RooCmdArg SupNormSet(const RooArgSet &nset)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Hesse(bool flag=true)
RooCmdArg ModularL(bool flag=false)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg NormRange(const char *rangeNameList)
RooCmdArg Range(const char *rangeName, bool adjustNorm=true)
RooCmdArg Normalization(double scaleFactor)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
OwningPtr< T > owningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
std::unique_ptr< T > compileForNormSet(T const &arg, RooArgSet const &normSet)
void defineMinimizationOptions(RooCmdConfig &pc)
std::unique_ptr< RooFitResult > minimize(RooAbsReal &model, RooAbsReal &nll, RooAbsData const &data, RooCmdConfig const &pc)
constexpr int extendedFitDefault
OffsetMode
For setting the offset mode with the Offset() command argument to RooAbsPdf::fitTo()
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
std::unique_ptr< T > cloneTreeWithSameParameters(T const &arg, RooArgSet const *observables=nullptr)
Clone RooAbsArg object and reattach to original parameters.
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
std::string addCoefRangeName
bool takeGlobalObservablesFromData
double integrateOverBinsPrecision
RooFit::MPSplit interleave
__roodevice__ static __roohost__ double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.