231 RooAbsReal(
name,title,plotMin,plotMax), _normMgr(this,10), _selectComp(
kTRUE), _specGeneratorConfig(0)
244 _normMgr(other._normMgr,this), _selectComp(other._selectComp), _normRange(other._normRange)
246 resetErrorCounters() ;
252 _specGeneratorConfig = 0 ;
308 if (normVal < 0. || (normVal == 0. && rawVal != 0)) {
310 const std::string msg =
"p.d.f normalization integral is zero or negative: " + std::to_string(normVal);
317 logEvalError(
Form(
"p.d.f value is less than zero (%f), trying to recover", rawVal));
328 _value = (rawVal == 0. && normVal == 0.) ? 0. : rawVal / normVal;
352 auto item = evalData.
spans.find(
this);
353 if (item != evalData.
spans.end()) {
358 assert(evalData.
spans.count(
this) > 0);
360 if (normSet !=
nullptr) {
371 if(normVals.size() > 1) {
372 for(std::size_t i = 0; i < outputs.size(); ++i) {
373 if (normVals[i] < 0. || (normVals[i] == 0. && outputs[i] != 0)) {
375 "\n\tInt(%s) = %f",
GetName(), normVals[i]));
377 if(normVals[i] != 1. && normVals[i] > 0.) {
378 outputs[i] /= normVals[i];
383 const double normVal = normVals[0];
385 || (normVal == 0. && std::any_of(outputs.begin(), outputs.end(), [](
double val){return val != 0;}))) {
387 "\n\tInt(%s) = %f",
GetName(), normVal));
390 if (normVal != 1. && normVal > 0.) {
391 const double invNorm = 1./normVal;
392 for (
double& val : outputs) {
411 cxcoutD(
Eval) <<
"RooAbsPdf::analyticalIntegralWN(" <<
GetName() <<
") code = " << code <<
" normset = " << (normSet?*normSet:
RooArgSet()) << endl ;
414 if (code==0)
return getVal(normSet) ;
434 logEvalError(
Form(
"p.d.f value is Not-a-Number (%f), forcing value to zero",value)) ;
438 logEvalError(
Form(
"p.d.f value is less than zero (%f), forcing value to zero",value)) ;
443 if(!error)
return error ;
466 if (!nset)
return 1 ;
474 coutW(
Eval) <<
"RooAbsPdf::getNorm(" <<
GetName() <<
":: WARNING normalization is zero, nset = " ; nset->
Print(
"1") ;
494 return cache->
_norm ;
537 if (nsetChanged && adjustProxies) {
547 ((
RooAbsPdf*)
this)->setProxyNormSet(nset) ;
556 <<
") recreating normalization integral " << endl ;
559 cxcoutD(
Tracing) << IsA()->GetName() <<
"::syncNormalization(" <<
GetName() <<
") selfNormalized, creating unit norm" << endl;
565 auto ntitle = std::string(
GetTitle()) +
" Unit Normalization";
566 auto nname = std::string(
GetName()) +
"_UnitNorm";
577 if (cacheParamsStr && strlen(cacheParamsStr)) {
579 std::unique_ptr<RooArgSet> intParams{normInt->
getVariables()} ;
583 std::unique_ptr<RooArgSet> cacheParams{cacheParamNames.
select(*intParams)} ;
585 if (cacheParams->getSize()>0) {
586 cxcoutD(
Caching) <<
"RooAbsReal::createIntObj(" <<
GetName() <<
") INFO: constructing " << cacheParams->getSize()
587 <<
"-dim value cache for integral over " << depList <<
" as a function of " << *cacheParams <<
" in range " << (nr?nr:
"<default>") << endl ;
588 string name =
Form(
"%s_CACHE_[%s]",normInt->
GetName(),cacheParams->contentsString().c_str()) ;
596 normInt= cachedIntegral ;
660 if (
fabs(prob)>1e6) {
661 coutW(
Eval) <<
"RooAbsPdf::getLogVal(" <<
GetName() <<
") WARNING: large likelihood value: " << prob << endl ;
665 logEvalError(
"getLogVal() top-level p.d.f evaluates to a negative number") ;
670 logEvalError(
"getLogVal() top-level p.d.f evaluates to zero") ;
672 return -std::numeric_limits<double>::infinity();
676 logEvalError(
"getLogVal() top-level p.d.f evaluates to NaN") ;
691bool checkInfNaNNeg(
const T& inputs) {
697 for (
double val : inputs) {
698 inf |= !std::isfinite(val);
703 return inf || nan || neg;
714 for (
unsigned int i=0; i<outputs.
size(); ++i) {
715 const double value = outputs[i];
719 }
else if (!std::isfinite(outputs[i])){
722 }
else if (outputs[i] < 0.) {
723 logEvalError(
Form(
"p.d.f value of (%s) is less than zero (%f) for entry %zu",
738 auto pdfValues =
getValues(evalData, normSet);
743 if (checkInfNaNNeg(pdfValues)) {
746 for (std::size_t i = 0; i < pdfValues.size(); ++i) {
747 const double prob = pdfValues[i];
763 for (std::size_t i = 0; i < pdfValues.size(); ++i) {
764 const double prob = pdfValues[i];
792 logEvalError(
"extendedTerm #expected events is <0 return a NaN");
798 if (
fabs(expected)<1
e-10 &&
fabs(observed)<1
e-10) {
804 logEvalError(
"extendedTerm #expected events is a NaN") ;
835 << observed <<
" events. extendedTerm = " << extra << endl;
935 pc.defineString(
"rangeName",
"RangeWithName",0,
"",
kTRUE) ;
936 pc.defineString(
"addCoefRange",
"SumCoefRange",0,
"") ;
937 pc.defineString(
"globstag",
"GlobalObservablesTag",0,
"") ;
938 pc.defineDouble(
"rangeLo",
"Range",0,-999.) ;
939 pc.defineDouble(
"rangeHi",
"Range",1,-999.) ;
940 pc.defineInt(
"splitRange",
"SplitRange",0,0) ;
941 pc.defineInt(
"ext",
"Extended",0,2) ;
942 pc.defineInt(
"numcpu",
"NumCPU",0,1) ;
943 pc.defineInt(
"interleave",
"NumCPU",1,0) ;
944 pc.defineInt(
"verbose",
"Verbose",0,0) ;
945 pc.defineInt(
"optConst",
"Optimize",0,0) ;
946 pc.defineInt(
"cloneData",
"CloneData", 0, 2);
947 pc.defineSet(
"projDepSet",
"ProjectedObservables",0,0) ;
948 pc.defineSet(
"cPars",
"Constrain",0,0) ;
949 pc.defineSet(
"glObs",
"GlobalObservables",0,0) ;
951 pc.defineInt(
"doOffset",
"OffsetLikelihood",0,0) ;
952 pc.defineSet(
"extCons",
"ExternalConstraints",0,0) ;
953 pc.defineInt(
"BatchMode",
"BatchMode", 0, 0);
954 pc.defineDouble(
"IntegrateBins",
"IntegrateBins", 0, -1.);
955 pc.defineMutex(
"Range",
"RangeWithName") ;
957 pc.defineMutex(
"GlobalObservables",
"GlobalObservablesTag") ;
960 pc.process(cmdList) ;
966 const char* rangeName =
pc.getString(
"rangeName",0,
kTRUE) ;
967 const char* addCoefRangeName =
pc.getString(
"addCoefRange",0,
kTRUE) ;
968 const char* globsTag =
pc.getString(
"globstag",0,
kTRUE) ;
970 Int_t numcpu =
pc.getInt(
"numcpu") ;
971 Int_t numcpu_strategy =
pc.getInt(
"interleave");
973 if (numcpu_strategy==3 && !this->
InheritsFrom(
"RooSimultaneous") ) {
974 coutW(
Minimization) <<
"Cannot use a NumCpu Strategy = 3 when the pdf is not a RooSimultaneus, "
975 "falling back to default strategy = 0" << endl;
980 Int_t splitr =
pc.getInt(
"splitRange") ;
982 Int_t optConst =
pc.getInt(
"optConst") ;
983 Int_t cloneData =
pc.getInt(
"cloneData") ;
984 Int_t doOffset =
pc.getInt(
"doOffset") ;
988 cloneData = optConst ;
994 if (
pc.hasProcessed(
"GlobalObservablesTag")) {
995 if (glObs)
delete glObs ;
998 coutI(
Minimization) <<
"User-defined specification of global observables definition with tag named '" << globsTag <<
"'" << endl ;
1000 }
else if (!
pc.hasProcessed(
"GlobalObservables")) {
1005 if (defGlobObsTag) {
1006 coutI(
Minimization) <<
"p.d.f. provides built-in specification of global observables definition with tag named '" << defGlobObsTag <<
"'" << endl ;
1007 if (glObs)
delete glObs ;
1021 doStripDisconnected=
kTRUE ;
1029 coutI(
Minimization) <<
"p.d.f. provides expected number of events, including extended term in likelihood." << endl ;
1036 if (
pc.hasProcessed(
"Range")) {
1043 for (
auto arg : obs) {
1045 if (rrv) rrv->
setRange(
"fit",rangeLo,rangeHi) ;
1055 projDeps.
add(*tmp) ;
1062 if (!rangeName || strchr(rangeName,
',')==0) {
1066 auto theNLL =
new RooNLLVar(baseName.c_str(),
"-log(likelihood)",
1067 *
this,data,projDeps,ext,rangeName,addCoefRangeName,numcpu,interl,
1068 verbose,splitr,cloneData,
false,
pc.getDouble(
"IntegrateBins"));
1069 theNLL->batchMode(
pc.getInt(
"BatchMode"));
1075 for (
const auto& token : tokens) {
1076 auto nllComp =
new RooNLLVar(
Form(
"%s_%s",baseName.c_str(),token.c_str()),
"-log(likelihood)",
1077 *
this,data,projDeps,ext,token.c_str(),addCoefRangeName,numcpu,interl,
1078 verbose,splitr,cloneData,
false,
pc.getDouble(
"IntegrateBins"));
1079 nllComp->batchMode(
pc.getInt(
"BatchMode"));
1080 nllList.
add(*nllComp) ;
1095 <<
" entries" << endl;
1096 allConstraints.
add(*constr);
1100 if (cPars && cPars->
getSize() > 0) {
1102 allConstraints.
add(*constraints);
1106 allConstraints.
add(*extCons);
1114 <<
" with " << allConstraints.
getSize() <<
" entries" << endl;
1122 if (allConstraints.
getSize()>0 && cPars) {
1124 coutI(
Minimization) <<
" Including the following constraint terms in minimization: " << allConstraints << endl ;
1126 coutI(
Minimization) <<
"The following global observables have been defined: " << *glObs << endl ;
1128 nllCons =
new RooConstraintSum(
Form(
"%s_constr",baseName.c_str()),
"nllCons",allConstraints,glObs ? *glObs : *cPars) ;
1141 if (doStripDisconnected) {
1153template <
class Minimizer>
1157 std::unique_ptr<RooFitResult> rw(minimizer.save());
1161 <<
"RooAbsPdf::fitTo(" << this->
GetName()
1162 <<
") Calculating covariance matrix according to the asymptotically correct approach. If you find this "
1163 "method useful please consider citing https://arxiv.org/abs/1911.01303."
1167 auto nFloatPars = rw->floatParsFinal().getSize();
1169 for (
int k = 0; k < nFloatPars; k++) {
1170 for (
int l = 0;
l < nFloatPars;
l++) {
1177 std::vector<std::unique_ptr<RooDerivative>> derivatives;
1178 const RooArgList &floated = rw->floatParsFinal();
1179 std::unique_ptr<RooArgSet> floatingparams{
1181 for (
const auto paramresult : floated) {
1182 auto paraminternal =
static_cast<RooRealVar *
>(floatingparams->find(*paramresult));
1184 derivatives.emplace_back(this->
derivative(*paraminternal, obs, 1));
1188 for (
int j = 0; j < data.
numEntries(); j++) {
1192 std::vector<double> diffs(floated.
getSize(), 0.0);
1193 for (
int k = 0; k < floated.
getSize(); k++) {
1194 const auto paramresult =
static_cast<RooRealVar *
>(floated.
at(k));
1195 auto paraminternal =
static_cast<RooRealVar *
>(floatingparams->find(*paramresult));
1197 double diff = derivatives[k]->
getVal();
1199 *paraminternal = paramresult->getVal();
1203 double prob =
getVal(&obs);
1204 for (
int k = 0; k < floated.
getSize(); k++) {
1205 for (
int l = 0;
l < floated.
getSize();
l++) {
1206 num(k,
l) += data.
weight() * data.
weight() * diffs[k] * diffs[
l] / (prob * prob);
1213 minimizer.applyCovarianceMatrix(num);
1218 return rw->covQual();
1221template <
class Minimizer>
1226 std::vector<RooNLLVar *> nllComponents;
1228 for (
auto const &arg : *comps) {
1230 nllComponents.push_back(nllComp);
1235 std::unique_ptr<RooFitResult> rw{minimizer.save()};
1236 for (
auto &comp : nllComponents) {
1237 comp->applyWeightSquared(
true);
1240 <<
") Calculating sum-of-weights-squared correction matrix for covariance matrix"
1243 std::unique_ptr<RooFitResult> rw2{minimizer.save()};
1244 for (
auto &comp : nllComponents) {
1245 comp->applyWeightSquared(
false);
1254 <<
") ERROR: Cannot apply sum-of-weights correction to covariance matrix: correction "
1255 "matrix calculated with weight-squared is singular"
1264 for (
int i = 0; i < matC.
GetNrows(); ++i) {
1265 for (
int j = 0; j < i; ++j) {
1266 matC(j, i) = matC(i, j);
1272 minimizer.applyCovarianceMatrix(matC);
1274 return std::min(rw->covQual(), rw2->covQual());
1438 RooLinkedList nllCmdList =
pc.filterCmdList(fitCmdList,
"ProjectedObservables,Extended,Range,"
1439 "RangeWithName,SumCoefRange,NumCPU,SplitRange,Constrained,Constrain,ExternalConstraints,"
1440 "CloneData,GlobalObservables,GlobalObservablesTag,OffsetLikelihood,BatchMode,IntegrateBins");
1442 pc.defineDouble(
"prefit",
"Prefit",0,0);
1443 pc.defineDouble(
"RecoverFromUndefinedRegions",
"RecoverFromUndefinedRegions",0,10.);
1444 pc.defineString(
"fitOpt",
"FitOptions",0,
"") ;
1445 pc.defineInt(
"optConst",
"Optimize",0,2) ;
1446 pc.defineInt(
"verbose",
"Verbose",0,0) ;
1447 pc.defineInt(
"doSave",
"Save",0,0) ;
1448 pc.defineInt(
"doTimer",
"Timer",0,0) ;
1449 pc.defineInt(
"plevel",
"PrintLevel",0,1) ;
1450 pc.defineInt(
"strat",
"Strategy",0,1) ;
1451 pc.defineInt(
"initHesse",
"InitialHesse",0,0) ;
1452 pc.defineInt(
"hesse",
"Hesse",0,1) ;
1453 pc.defineInt(
"minos",
"Minos",0,0) ;
1454 pc.defineInt(
"ext",
"Extended",0,2) ;
1455 pc.defineInt(
"numcpu",
"NumCPU",0,1) ;
1456 pc.defineInt(
"numee",
"PrintEvalErrors",0,10) ;
1457 pc.defineInt(
"doEEWall",
"EvalErrorWall",0,1) ;
1458 pc.defineInt(
"doWarn",
"Warnings",0,1) ;
1459 pc.defineInt(
"doSumW2",
"SumW2Error",0,-1) ;
1460 pc.defineInt(
"doAsymptoticError",
"AsymptoticError",0,-1) ;
1461 pc.defineInt(
"doOffset",
"OffsetLikelihood",0,0) ;
1462 pc.defineString(
"mintype",
"Minimizer",0,
"Minuit") ;
1463 pc.defineString(
"minalg",
"Minimizer",1,
"minuit") ;
1464 pc.defineObject(
"minosSet",
"Minos",0,0) ;
1465 pc.defineSet(
"cPars",
"Constrain",0,0) ;
1466 pc.defineSet(
"extCons",
"ExternalConstraints",0,0) ;
1467 pc.defineMutex(
"FitOptions",
"Verbose") ;
1468 pc.defineMutex(
"FitOptions",
"Save") ;
1469 pc.defineMutex(
"FitOptions",
"Timer") ;
1470 pc.defineMutex(
"FitOptions",
"Strategy") ;
1471 pc.defineMutex(
"FitOptions",
"InitialHesse") ;
1472 pc.defineMutex(
"FitOptions",
"Hesse") ;
1473 pc.defineMutex(
"FitOptions",
"Minos") ;
1474 pc.defineMutex(
"Range",
"RangeWithName") ;
1475 pc.defineMutex(
"InitialHesse",
"Minimizer") ;
1478 pc.process(fitCmdList) ;
1485 const double recoverFromNaN =
pc.getDouble(
"RecoverFromUndefinedRegions");
1486 const char* fitOpt =
pc.getString(
"fitOpt",0,
kTRUE) ;
1487 Int_t optConst =
pc.getInt(
"optConst") ;
1489 Int_t doSave =
pc.getInt(
"doSave") ;
1490 Int_t doTimer =
pc.getInt(
"doTimer") ;
1491 Int_t plevel =
pc.getInt(
"plevel") ;
1492 Int_t strat =
pc.getInt(
"strat") ;
1493 Int_t initHesse=
pc.getInt(
"initHesse") ;
1494 Int_t hesse =
pc.getInt(
"hesse") ;
1495 Int_t minos =
pc.getInt(
"minos") ;
1496 Int_t numee =
pc.getInt(
"numee") ;
1497 Int_t doEEWall =
pc.getInt(
"doEEWall") ;
1498 Int_t doWarn =
pc.getInt(
"doWarn") ;
1499 Int_t doSumW2 =
pc.getInt(
"doSumW2") ;
1500 Int_t doAsymptotic =
pc.getInt(
"doAsymptoticError");
1502#ifdef __ROOFIT_NOROOMINIMIZER
1503 const char* minType =0 ;
1505 const char* minType =
pc.getString(
"mintype",
"Minuit") ;
1506 const char* minAlg =
pc.getString(
"minalg",
"minuit") ;
1514 conf.
defineInt(
"BatchMode",
"BatchMode",0,0);
1517 if (conf.
getInt(
"BatchMode") != 0) {
1527 if (weightedData && doSumW2==-1 && doAsymptotic==-1) {
1528 coutW(
InputArguments) <<
"RooAbsPdf::fitTo(" <<
GetName() <<
") WARNING: a likelihood fit is requested of what appears to be weighted data.\n"
1529 <<
" While the estimated values of the parameters will always be calculated taking the weights into account,\n"
1530 <<
" there are multiple ways to estimate the errors of the parameters. You are advised to make an \n"
1531 <<
" explicit choice for the error calculation:\n"
1532 <<
" - Either provide SumW2Error(true), to calculate a sum-of-weights-corrected HESSE error matrix\n"
1533 <<
" (error will be proportional to the number of events in MC).\n"
1534 <<
" - Or provide SumW2Error(false), to return errors from original HESSE error matrix\n"
1535 <<
" (which will be proportional to the sum of the weights, i.e., a dataset with <sum of weights> events).\n"
1536 <<
" - Or provide AsymptoticError(true), to use the asymptotically correct expression\n"
1537 <<
" (for details see https://arxiv.org/abs/1911.01303)."
1543 if (doSumW2==1 && minos) {
1544 coutW(
InputArguments) <<
"RooAbsPdf::fitTo(" <<
GetName() <<
") WARNING: sum-of-weights correction does not apply to MINOS errors" << endl ;
1546 if (doAsymptotic==1 && minos) {
1547 coutW(
InputArguments) <<
"RooAbsPdf::fitTo(" <<
GetName() <<
") WARNING: asymptotic correction does not apply to MINOS errors" << endl ;
1551 size_t nEvents =
static_cast<size_t>(prefit*data.
numEntries());
1552 if (prefit > 0.5 || nEvents < 100) {
1554 <<
"With the current PrefitDataFraction=" << prefit
1555 <<
", the number of events would be " << nEvents<<
" out of "
1556 << data.
numEntries() <<
". Skipping prefit..." << endl;
1574 pc.filterCmdList(tinyCmdList,
"Prefit,Hesse,Minos,Verbose,Save,Timer");
1578 tinyCmdList.
Add(&hesse_option);
1579 tinyCmdList.
Add(&print_option);
1581 fitTo(tiny,tinyCmdList);
1589 if (doSumW2==1 && doAsymptotic==1) {
1590 coutE(
InputArguments) <<
"RooAbsPdf::fitTo(" <<
GetName() <<
") ERROR: Cannot compute both asymptotically correct and SumW2 errors." << endl ;
1596 if (
string(minType)!=
"OldMinuit") {
1598#ifndef __ROOFIT_NOROOMINIMIZER
1601 m.setMinimizerType(minType) ;
1603 m.setEvalErrorWall(doEEWall) ;
1604 m.setRecoverFromNaNStrength(recoverFromNaN);
1609 m.setPrintEvalErrors(numee) ;
1611 m.setPrintLevel(plevel) ;
1616 m.optimizeConst(optConst) ;
1622 ret =
m.fit(fitOpt) ;
1637 m.setStrategy(strat) ;
1646 m.minimize(minType,minAlg) ;
1653 int corrCovQual = -1;
1656 if (doAsymptotic==1 &&
m.getNPar()>0) {
1660 if (doSumW2==1 &&
m.getNPar()>0) {
1667 m.minos(*minosSet) ;
1676 string title =
Form(
"Result of fit of p.d.f. %s to dataset %s",
GetName(),data.
GetName()) ;
1677 ret =
m.save(
name.c_str(),title.c_str()) ;
1678 if((doSumW2==1 || doAsymptotic==1) &&
m.getNPar()>0) {
1686 m.optimizeConst(0) ;
1695 m.setEvalErrorWall(doEEWall) ;
1700 m.setPrintEvalErrors(numee) ;
1702 m.setPrintLevel(plevel) ;
1707 m.optimizeConst(optConst) ;
1713 ret =
m.fit(fitOpt) ;
1728 m.setStrategy(strat) ;
1744 int corrCovQual = -1;
1747 if (doAsymptotic==1 &&
m.getNPar()>0) {
1751 if (doSumW2==1 &&
m.getNPar()>0) {
1758 m.minos(*minosSet) ;
1767 string title =
Form(
"Result of fit of p.d.f. %s to dataset %s",
GetName(),data.
GetName()) ;
1768 ret =
m.save(
name.c_str(),title.c_str()) ;
1769 if((doSumW2==1 || doAsymptotic==1) &&
m.getNPar()>0) {
1777 m.optimizeConst(0) ;
1801 RooLinkedList chi2CmdList =
pc.filterCmdList(fitCmdList,
"Range,RangeWithName,NumCPU,Optimize,ProjectedObservables,AddCoefRange,SplitRange,DataError,Extended,IntegrateBins") ;
1850 pc.defineString(
"rangeName",
"RangeWithName",0,
"",
kTRUE) ;
1852 pc.process(cmdList) ;
1856 const char* rangeName =
pc.getString(
"rangeName",0,
kTRUE) ;
1866 if (!rangeName || strchr(rangeName,
',')==0) {
1869 chi2 =
new RooChi2Var(baseName.c_str(),baseName.c_str(),*
this,data,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
1875 string rcmd =
"RangeWithName" ;
1876 if (arg1.
GetName()==rcmd) rarg = &arg1 ;
1877 if (arg2.
GetName()==rcmd) rarg = &arg2 ;
1878 if (arg3.
GetName()==rcmd) rarg = &arg3 ;
1879 if (arg4.
GetName()==rcmd) rarg = &arg4 ;
1880 if (arg5.
GetName()==rcmd) rarg = &arg5 ;
1881 if (arg6.
GetName()==rcmd) rarg = &arg6 ;
1882 if (arg7.
GetName()==rcmd) rarg = &arg7 ;
1883 if (arg8.
GetName()==rcmd) rarg = &arg8 ;
1891 &arg1==rarg?subRangeCmd:arg1,&arg2==rarg?subRangeCmd:arg2,
1892 &arg3==rarg?subRangeCmd:arg3,&arg4==rarg?subRangeCmd:arg4,
1893 &arg5==rarg?subRangeCmd:arg5,&arg6==rarg?subRangeCmd:arg6,
1894 &arg7==rarg?subRangeCmd:arg7,&arg8==rarg?subRangeCmd:arg8) ;
1895 chi2List.
add(*chi2Comp) ;
1916 pc.defineInt(
"integrate",
"Integrate",0,0) ;
1917 pc.defineObject(
"yvar",
"YVar",0,0) ;
1920 pc.process(cmdList) ;
1926 Bool_t integrate =
pc.getInt(
"integrate") ;
1966 os <<
indent <<
"--- RooAbsPdf ---" << endl;
1969 os <<
indent <<
" Normalization integral: " << endl ;
1970 auto moreIndent = std::string(
indent.Data()) +
" " ;
2002 if (prototype || (auxProto && auxProto->
getSize()>0)) {
2078 pc.defineObject(
"proto",
"PrototypeData",0,0) ;
2079 pc.defineString(
"dsetName",
"Name",0,
"") ;
2080 pc.defineInt(
"randProto",
"PrototypeData",0,0) ;
2081 pc.defineInt(
"resampleProto",
"PrototypeData",1,0) ;
2082 pc.defineInt(
"verbose",
"Verbose",0,0) ;
2083 pc.defineInt(
"extended",
"Extended",0,0) ;
2084 pc.defineInt(
"nEvents",
"NumEvents",0,0) ;
2085 pc.defineInt(
"autoBinned",
"AutoBinned",0,1) ;
2086 pc.defineInt(
"expectedData",
"ExpectedData",0,0) ;
2087 pc.defineDouble(
"nEventsD",
"NumEventsD",0,-1.) ;
2088 pc.defineString(
"binnedTag",
"GenBinned",0,
"") ;
2089 pc.defineMutex(
"GenBinned",
"ProtoData") ;
2090 pc.defineMutex(
"Extended",
"NumEvents");
2093 pc.process(arg1,arg2,arg3,arg4,arg5,arg6) ;
2100 const char* dsetName =
pc.getString(
"dsetName") ;
2102 Bool_t randProto =
pc.getInt(
"randProto") ;
2103 Bool_t resampleProto =
pc.getInt(
"resampleProto") ;
2104 Bool_t extended =
pc.getInt(
"extended") ;
2105 Bool_t autoBinned =
pc.getInt(
"autoBinned") ;
2106 const char* binnedTag =
pc.getString(
"binnedTag") ;
2107 Int_t nEventsI =
pc.getInt(
"nEvents") ;
2110 Bool_t expectedData =
pc.getInt(
"expectedData") ;
2121 }
else if (nEvents==0) {
2122 cxcoutI(
Generation) <<
"No number of events specified , number of events generated is "
2126 if (extended && protoData && !randProto) {
2127 cxcoutI(
Generation) <<
"WARNING Using generator option Extended() (Poisson distribution of #events) together "
2128 <<
"with a prototype dataset implies incomplete sampling or oversampling of proto data. "
2129 <<
"Set randomize flag in ProtoData() option to randomize prototype dataset order and thus "
2130 <<
"to randomize the set of over/undersampled prototype events for each generation cycle." << endl ;
2139 data =
generate(whatVars,nEvents,
verbose,autoBinned,binnedTag,expectedData, extended) ;
2143 if (dsetName && strlen(dsetName)>0) {
2170 pc.defineObject(
"proto",
"PrototypeData",0,0) ;
2171 pc.defineString(
"dsetName",
"Name",0,
"") ;
2172 pc.defineInt(
"randProto",
"PrototypeData",0,0) ;
2173 pc.defineInt(
"resampleProto",
"PrototypeData",1,0) ;
2174 pc.defineInt(
"verbose",
"Verbose",0,0) ;
2175 pc.defineInt(
"extended",
"Extended",0,0) ;
2176 pc.defineInt(
"nEvents",
"NumEvents",0,0) ;
2177 pc.defineInt(
"autoBinned",
"AutoBinned",0,1) ;
2178 pc.defineString(
"binnedTag",
"GenBinned",0,
"") ;
2179 pc.defineMutex(
"GenBinned",
"ProtoData") ;
2183 pc.process(arg1,arg2,arg3,arg4,arg5,arg6) ;
2190 const char* dsetName =
pc.getString(
"dsetName") ;
2191 Int_t nEvents =
pc.getInt(
"nEvents") ;
2193 Bool_t randProto =
pc.getInt(
"randProto") ;
2194 Bool_t resampleProto =
pc.getInt(
"resampleProto") ;
2195 Bool_t extended =
pc.getInt(
"extended") ;
2196 Bool_t autoBinned =
pc.getInt(
"autoBinned") ;
2197 const char* binnedTag =
pc.getString(
"binnedTag") ;
2201 return new GenSpec(cx,whatVars,protoData,nEvents,extended,randProto,resampleProto,dsetName) ;
2251 return new RooDataSet(
"emptyData",
"emptyData",whatVars) ;
2261 if(0 != context && context->
isValid()) {
2267 if(0 != context)
delete context;
2281 if (nEvents==0 && (prototype==0 || prototype->
numEntries()==0)) {
2282 return new RooDataSet(
"emptyData",
"emptyData",whatVars) ;
2288 if (resampleProto) {
2289 randProtoOrder=
kTRUE ;
2292 if (randProtoOrder && prototype && prototype->
numEntries()!=nEvents) {
2293 coutI(
Generation) <<
"RooAbsPdf::generate (Re)randomizing event order in prototype dataset (Nevt=" << nEvents <<
")" << endl ;
2300 generated= context.
generate(nEvents,skipInit,extended);
2303 coutE(
Generation) <<
"RooAbsPdf::generate(" <<
GetName() <<
") do not have a valid generator context" << endl;
2342 coutE(
Generation) <<
"RooAbsPdf::generate(" <<
GetName() <<
") ERROR creating generator context" << endl ;
2359 for (i=0 ; i<nProto ; i++) {
2367 if (!resampleProto) {
2369 for (i=0 ; i<nProto ; i++) {
2378 for (i=0 ; i<nProto ; i++) {
2440 if(server == &arg)
continue;
2441 if(server->dependsOn(arg)) {
2481 pc.defineString(
"dsetName",
"Name",0,
"") ;
2482 pc.defineInt(
"verbose",
"Verbose",0,0) ;
2483 pc.defineInt(
"extended",
"Extended",0,0) ;
2484 pc.defineInt(
"nEvents",
"NumEvents",0,0) ;
2485 pc.defineDouble(
"nEventsD",
"NumEventsD",0,-1.) ;
2486 pc.defineInt(
"expectedData",
"ExpectedData",0,0) ;
2489 pc.process(arg1,arg2,arg3,arg4,arg5,arg6) ;
2495 Double_t nEvents =
pc.getDouble(
"nEventsD") ;
2497 nEvents =
pc.getInt(
"nEvents") ;
2500 Bool_t extended =
pc.getInt(
"extended") ;
2501 Bool_t expectedData =
pc.getInt(
"expectedData") ;
2502 const char* dsetName =
pc.getString(
"dsetName") ;
2507 cxcoutI(
Generation) <<
" Extended mode active, number of events generated (" << nEvents <<
") is Poisson fluctuation on "
2508 <<
GetName() <<
"::expectedEvents() = " << nEvents << endl ;
2513 }
else if (nEvents==0) {
2514 cxcoutI(
Generation) <<
"No number of events specified , number of events generated is "
2522 if (dsetName && strlen(dsetName)>0) {
2565 coutE(
InputArguments) <<
"RooAbsPdf::generateBinned(" <<
GetName() <<
") ERROR: No event count provided and p.d.f does not provide expected number of events" << endl ;
2571 if (expectedData || extended) {
2584 Int_t histOutSum(0) ;
2593 }
else if (extended) {
2603 if (hist->
weight()>histMax) {
2604 histMax = hist->
weight() ;
2607 histOutSum += histOut[i] ;
2612 if (!expectedData && !extended) {
2617 Int_t nEvtExtra = abs(
Int_t(nEvents)-histOutSum) ;
2618 Int_t wgt = (histOutSum>nEvents) ? -1 : 1 ;
2621 std::size_t counter = 0;
2622 bool havePrintedInfo =
false;
2623 while(nEvtExtra>0) {
2626 hist->
get(ibinRand) ;
2629 if (ranY<hist->weight()) {
2631 histOut[ibinRand]++ ;
2634 if (histOut[ibinRand]>0) {
2635 histOut[ibinRand]-- ;
2643 if ((counter++ > 10*nEvents || nEvents > 1.E7) && !havePrintedInfo) {
2644 havePrintedInfo =
true;
2645 coutP(
Generation) <<
"RooAbsPdf::generateBinned(" <<
GetName() <<
") Performing costly accept/reject sampling. If this takes too long, use "
2646 <<
"extended mode to speed up the process." << std::endl;
2653 hist->
set(histOut[i],
sqrt(1.0*histOut[i])) ;
2656 }
else if (expectedData) {
2679 return generate(whatVars,nEvents) ;
2683void removeRangeOverlap(std::vector<std::pair<double, double>>& ranges) {
2685 std::sort(ranges.begin(), ranges.end());
2687 for (
auto it = ranges.begin(); it != ranges.end(); ++it) {
2688 double& startL = it->first;
2689 double& endL = it->second;
2691 for (
auto innerIt = it+1; innerIt != ranges.end(); ++innerIt) {
2692 const double startR = innerIt->first;
2693 const double endR = innerIt->second;
2695 if (startL <= startR && startR <= endL) {
2697 endL = std::max(endL, endR);
2698 *innerIt = make_pair(0., 0.);
2703 auto newEnd = std::remove_if(ranges.begin(), ranges.end(),
2704 [](
const std::pair<double,double>& input){
2705 return input.first == input.second;
2707 ranges.erase(newEnd, ranges.end());
2818 cmdList.
Add(plotRange) ;
2823 cmdList.
Add(normRange2) ;
2826 if (plotRange || normRange2) {
2827 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") p.d.f was fitted in a subrange and no explicit "
2828 << (plotRange?
"Range()":
"") << ((plotRange&&normRange2)?
" and ":
"")
2829 << (normRange2?
"NormRange()":
"") <<
" was specified. Plotting / normalising in fit range. To override, do one of the following"
2830 <<
"\n\t- Clear the automatic fit range attribute: <pdf>.setStringAttribute(\"fitrange\", nullptr);"
2831 <<
"\n\t- Explicitly specify the plotting range: Range(\"<rangeName>\")."
2832 <<
"\n\t- Explicitly specify where to compute the normalisation: NormRange(\"<rangeName>\")."
2833 <<
"\n\tThe default (full) range can be denoted with Range(\"\") / NormRange(\"\")."<< endl ;
2841 pc.defineDouble(
"scaleFactor",
"Normalization",0,1.0) ;
2842 pc.defineInt(
"scaleType",
"Normalization",0,
Relative) ;
2843 pc.defineObject(
"compSet",
"SelectCompSet",0) ;
2844 pc.defineString(
"compSpec",
"SelectCompSpec",0) ;
2845 pc.defineObject(
"asymCat",
"Asymmetry",0) ;
2846 pc.defineDouble(
"rangeLo",
"Range",0,-999.) ;
2847 pc.defineDouble(
"rangeHi",
"Range",1,-999.) ;
2848 pc.defineString(
"rangeName",
"RangeWithName",0,
"") ;
2849 pc.defineString(
"normRangeName",
"NormRange",0,
"") ;
2850 pc.defineInt(
"rangeAdjustNorm",
"Range",0,0) ;
2851 pc.defineInt(
"rangeWNAdjustNorm",
"RangeWithName",0,0) ;
2852 pc.defineMutex(
"SelectCompSet",
"SelectCompSpec") ;
2853 pc.defineMutex(
"Range",
"RangeWithName") ;
2854 pc.allowUndefined() ;
2857 pc.process(cmdList) ;
2864 Double_t scaleFactor =
pc.getDouble(
"scaleFactor") ;
2866 const char* compSpec =
pc.getString(
"compSpec") ;
2868 Bool_t haveCompSel = ( (compSpec && strlen(compSpec)>0) || compSet) ;
2871 std::string nameSuffix ;
2872 if (compSpec && strlen(compSpec)>0) {
2873 nameSuffix.append(
"_Comp[") ;
2874 nameSuffix.append(compSpec) ;
2875 nameSuffix.append(
"]") ;
2876 }
else if (compSet) {
2877 nameSuffix.append(
"_Comp[") ;
2879 nameSuffix.append(
"]") ;
2883 pc.stripCmdList(cmdList,
"SelectCompSet,SelectCompSpec") ;
2887 RooCmdArg cnsuffix(
"CurveNameSuffix",0,0,0,0,nameSuffix.c_str(),0,0,0) ;
2888 cmdList.
Add(&cnsuffix);
2897 <<
"): ERROR the 'Expected' scale option can only be used on extendable PDFs" << endl ;
2909 std::vector<pair<Double_t,Double_t> > rangeLim;
2912 if (
pc.hasProcessed(
"Range")) {
2916 rangeLim.push_back(make_pair(rangeLo,rangeHi)) ;
2917 adjustNorm =
pc.getInt(
"rangeAdjustNorm") ;
2918 hasCustomRange =
kTRUE ;
2921 << rangeLo <<
"," << rangeHi <<
"]" ;
2922 if (!
pc.hasProcessed(
"NormRange")) {
2923 ccoutI(
Plotting) <<
", curve is normalized to data in " << (adjustNorm?
"given":
"full") <<
" range" << endl ;
2928 nameSuffix.append(
Form(
"_Range[%f_%f]",rangeLo,rangeHi)) ;
2930 }
else if (
pc.hasProcessed(
"RangeWithName")) {
2932 for (
const std::string& rangeNameToken :
RooHelpers::tokenise(
pc.getString(
"rangeName",
"",
false),
",",
true)) {
2933 const char* thisRangeName = rangeNameToken.empty() ? nullptr : rangeNameToken.c_str();
2935 coutE(
Plotting) <<
"Range '" << rangeNameToken <<
"' not defined for variable '"
2941 adjustNorm =
pc.getInt(
"rangeWNAdjustNorm") ;
2942 hasCustomRange =
kTRUE ;
2944 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") only plotting range '" <<
pc.getString(
"rangeName",
"",
false) <<
"'" ;
2945 if (!
pc.hasProcessed(
"NormRange")) {
2946 ccoutI(
Plotting) <<
", curve is normalized to data in " << (adjustNorm?
"given":
"full") <<
" range" << endl ;
2951 nameSuffix.append(
Form(
"_Range[%s]",
pc.getString(
"rangeName"))) ;
2954 if (
pc.hasProcessed(
"NormRange")) {
2956 for (
const auto& rangeNameToken :
RooHelpers::tokenise(
pc.getString(
"normRangeName",
"",
false),
",",
true)) {
2957 const char* thisRangeName = rangeNameToken.empty() ? nullptr : rangeNameToken.c_str();
2959 coutE(
Plotting) <<
"Range '" << rangeNameToken <<
"' not defined for variable '"
2965 adjustNorm =
kTRUE ;
2966 hasCustomRange =
kTRUE ;
2967 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") p.d.f. curve is normalized using explicit choice of ranges '" <<
pc.getString(
"normRangeName",
"",
false) <<
"'" << endl ;
2969 nameSuffix.append(
Form(
"_NormRange[%s]",
pc.getString(
"rangeName"))) ;
2973 if (hasCustomRange && adjustNorm) {
2975 const std::size_t oldSize = rangeLim.size();
2976 removeRangeOverlap(rangeLim);
2978 if (oldSize != rangeLim.size() && !
pc.hasProcessed(
"NormRange")) {
2982 coutE(
Plotting) <<
"Requested plot/integration ranges overlap. For correct plotting, new ranges "
2983 "will be defined." << std::endl;
2986 std::string rangesNoOverlap;
2987 for (
auto it = rangeLim.begin(); it != rangeLim.end(); ++it) {
2988 std::stringstream rangeName;
2989 rangeName <<
"Remove_overlap_range_" << it - rangeLim.begin();
2990 plotVar->setRange(rangeName.str().c_str(), it->first, it->second);
2991 if (!rangesNoOverlap.empty())
2992 rangesNoOverlap +=
",";
2993 rangesNoOverlap += rangeName.str();
2998 rangeArg->
setString(0, rangesNoOverlap.c_str());
3001 cmdList.
Add(plotRange);
3006 for (
const auto& riter : rangeLim) {
3011 scaleFactor *= rangeNevt/nExpected ;
3017 scaleFactor *= nExpected ;
3019 scaleFactor /= nExpected ;
3038 for (
const auto arg : branchNodeSet) {
3040 branchNodeSet.
remove(*arg) ;
3051 if (dirSelNodes->
getSize()>0) {
3052 coutI(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") directly selected PDF components: " << *dirSelNodes << endl ;
3058 coutE(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") ERROR: component selection set " << *compSet <<
" does not match any components of p.d.f." << endl ;
3060 coutE(
Plotting) <<
"RooAbsPdf::plotOn(" <<
GetName() <<
") ERROR: component selection expression '" << compSpec <<
"' does not select any components of p.d.f." << endl ;
3065 delete dirSelNodes ;
3069 RooCmdArg cnsuffix(
"CurveNameSuffix",0,0,0,0,nameSuffix.c_str(),0,0,0) ;
3070 cmdList.
Add(&cnsuffix);
3112 <<
"): ERROR the 'Expected' scale option can only be used on extendable PDFs" << endl ;
3179 pc.defineString(
"label",
"Label",0,
"") ;
3180 pc.defineDouble(
"xmin",
"Layout",0,0.50) ;
3181 pc.defineDouble(
"xmax",
"Layout",1,0.99) ;
3182 pc.defineInt(
"ymaxi",
"Layout",0,
Int_t(0.95*10000)) ;
3183 pc.defineInt(
"showc",
"ShowConstants",0,0) ;
3184 pc.defineObject(
"params",
"Parameters",0,0) ;
3185 pc.defineString(
"formatStr",
"Format",0,
"NELU") ;
3186 pc.defineInt(
"sigDigit",
"Format",0,2) ;
3187 pc.defineInt(
"dummy",
"FormatArgs",0,0) ;
3188 pc.defineMutex(
"Format",
"FormatArgs") ;
3191 pc.process(cmdList) ;
3196 const char* label =
pc.getString(
"label") ;
3200 Int_t showc =
pc.getInt(
"showc") ;
3203 const char* formatStr =
pc.getString(
"formatStr") ;
3204 Int_t sigDigit =
pc.getInt(
"sigDigit") ;
3210 if (
pc.hasProcessed(
"FormatArgs")) {
3218 std::unique_ptr<RooArgSet> selParams{
static_cast<RooArgSet*
>(pdfParams->selectCommon(*params))} ;
3219 if (
pc.hasProcessed(
"FormatArgs")) {
3265 Bool_t showLabel= (label != 0 && strlen(label) > 0);
3270 for (
const auto param : params) {
3272 if(showConstants || !var->isConstant())
ymin-= dy;
3275 std::string labelString = label;
3276 unsigned int numLines = std::count(labelString.begin(), labelString.end(),
'\n') + 1;
3277 if (showLabel)
ymin -= numLines * dy;
3283 box->SetFillColor(0);
3284 box->SetBorderSize(1);
3285 box->SetTextAlign(12);
3286 box->SetTextSize(0.04F);
3287 box->SetFillStyle(1001);
3288 box->SetFillColor(0);
3290 for (
const auto param : params) {
3291 auto var =
static_cast<const RooRealVar*
>(param);
3292 if(var->isConstant() && !showConstants)
continue;
3294 TString *formatted= options ? var->format(sigDigits, options) : var->format(*formatCmd) ;
3295 box->AddText(formatted->
Data());
3366 pdfOwner->
_norm = 0 ;
3382 name.append(
"_Proj[") ;
3385 for(
auto const& arg : iset) {
3391 name.append(arg->GetName()) ;
3441 pc.defineObject(
"supNormSet",
"SupNormSet",0,0) ;
3442 pc.defineInt(
"numScanBins",
"ScanParameters",0,1000) ;
3443 pc.defineInt(
"intOrder",
"ScanParameters",1,2) ;
3444 pc.defineInt(
"doScanNum",
"ScanNumCdf",0,1) ;
3445 pc.defineInt(
"doScanAll",
"ScanAllCdf",0,0) ;
3446 pc.defineInt(
"doScanNon",
"ScanNoCdf",0,0) ;
3447 pc.defineMutex(
"ScanNumCdf",
"ScanAllCdf",
"ScanNoCdf") ;
3450 pc.process(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) ;
3461 Int_t numScanBins =
pc.getInt(
"numScanBins") ;
3462 Int_t intOrder =
pc.getInt(
"intOrder") ;
3463 Int_t doScanNum =
pc.getInt(
"doScanNum") ;
3464 Int_t doScanAll =
pc.getInt(
"doScanAll") ;
3465 Int_t doScanNon =
pc.getInt(
"doScanNon") ;
3476 Int_t isNum= (tmp->numIntRealVars().getSize()>0) ;
3479 coutI(
NumIntegration) <<
"RooAbsPdf::createCdf(" <<
GetName() <<
") integration over observable(s) " << iset <<
" involves numeric integration," << endl
3480 <<
" constructing cdf though numeric integration of sampled pdf in " << numScanBins <<
" bins and applying order "
3481 << intOrder <<
" interpolation on integrated histogram." << endl
3482 <<
" To override this choice of technique use argument ScanNone(), to change scan parameters use ScanParameters(nbins,order) argument" << endl ;
3494 ivar->
setBins(numScanBins,
"numcdf") ;
3512 for (
const auto arg : *comps) {
3513 auto pdf =
dynamic_cast<const RooAbsPdf*
>(arg) ;
3514 if (pdf && !ret->
find(pdf->GetName())) {
3515 std::unique_ptr<RooArgSet> compRet(pdf->getConstraints(observables,constrainedParams,stripDisconnected));
3570 if (config)
return config ;
3608 delete _genContext ;
3616 _genContext(context), _whatVars(whatVars), _protoData(protoData), _nGen(nGen), _extended(extended),
3617 _randProto(randProto), _resampleProto(resampleProto), _dsetName(dsetName), _init(init)
header file containing the templated implementation of matrix inversion routines for use with ROOT's ...
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
class to compute the Cholesky decomposition of a matrix
bool Invert(M &m) const
place the inverse into m
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
void clearValueAndShapeDirty() const
RooWorkspace * _myws
Prevent 'AlwaysDirty' mode for this node.
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
Bool_t isValueDirty() const
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Interface function signaling a request to perform constant term optimization.
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE)
Set the operation mode of this node.
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void setProxyNormSet(const RooArgSet *nset)
Forward a change in the cached normalization argset to all the registered proxies.
friend class RooProjectedPdf
RefCountList_t _serverList
RooArgSet * getComponents() const
Create a RooArgSet with all components (branch nodes) of the expression tree headed by this object.
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...
void branchNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
Fill supplied list with all branch nodes of the arg tree starting with ourself as top node.
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.
void setInterpolationOrder(Int_t order)
Set interpolation order of RooHistFunct representing cache histogram.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsArg * first() const
RooAbsCollection * selectByName(const char *nameList, Bool_t verbose=kFALSE) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
std::string contentsString() const
Return comma separated list of contained object names as STL string.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Bool_t isNonPoissonWeighted() const
virtual Double_t weight() const =0
virtual Bool_t isWeighted() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooAbsGenContext is the abstract base class for generator contexts of RooAbsPdf objects.
virtual RooDataSet * generate(Double_t nEvents=0, Bool_t skipInit=kFALSE, Bool_t extendedMode=kFALSE)
Generate the specified number of events with nEvents>0 and and return a dataset containing the genera...
virtual void setExpectedData(Bool_t)
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.
virtual ~CacheElem()
Destructor of normalization cache element.
void operModeHook(RooAbsArg::OperMode)
Dummy implementation.
GenSpec * prepareMultiGen(const RooArgSet &whatVars, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none())
Prepare GenSpec configuration object for efficient generation of multiple datasets from identical spe...
RooObjCacheManager _normMgr
Double_t getNorm(const RooArgSet &nset) const
Get normalisation term needed to normalise the raw values returned by getVal().
virtual void generateEvent(Int_t code)
Interface for generation of an event using the algorithm corresponding to the specified code.
virtual ~RooAbsPdf()
Destructor.
void logBatchComputationErrors(RooSpan< const double > &outputs, std::size_t begin) const
Scan through outputs and fix+log all nans and negative values.
RooSpan< const double > getLogProbabilities(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet=nullptr) const
Compute the log-likelihoods for all events in the requested batch.
RooSpan< const double > getValues(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet) const
Compute batch of values for given input data, and normalise by integrating over the observables in no...
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...
virtual RooAbsReal * createChi2(RooDataHist &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Create a from a histogram and this function.
virtual RooFitResult * chi2FitTo(RooDataHist &data, const RooLinkedList &cmdList)
Calls RooAbsPdf::createChi2(RooDataSet& data, const RooLinkedList& cmdList) and returns fit result.
static int verboseEval()
Return global level of verbosity for p.d.f. evaluations.
Bool_t traceEvalPdf(Double_t value) const
Check that passed value is positive and not 'not-a-number'.
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
virtual RooAbsGenContext * genContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE) const
Interface function to create a generator context from a p.d.f.
RooAbsReal * createScanCdf(const RooArgSet &iset, const RooArgSet &nset, Int_t numScanBins, Int_t intOrder)
TString _normRange
MC generator configuration specific for this object.
void setNormRange(const char *rangeName)
virtual RooDataHist * generateBinned(const RooArgSet &whatVars, Double_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none()) const
As RooAbsPdf::generateBinned(const RooArgSet&, const RooCmdArg&,const RooCmdArg&, const RooCmdArg&,...
RooArgSet const * _normSet
Normalization integral (owned by _normMgr)
virtual Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
RooNumGenConfig * specialGeneratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
Bool_t canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual Bool_t selfNormalized() const
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print multi line detailed information of this RooAbsPdf.
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Analytical integral with normalization (see RooAbsReal::analyticalIntegralWN() for further informatio...
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
virtual RooAbsGenContext * autoGenContext(const RooArgSet &vars, const RooDataSet *prototype=0, const RooArgSet *auxProto=0, Bool_t verbose=kFALSE, Bool_t autoBinned=kTRUE, const char *binnedTag="") const
virtual Double_t extendedTerm(Double_t observedEvents, const RooArgSet *nset=0) const
Return the extended likelihood term ( ) of this PDF for the given number of observed events.
virtual void printValue(std::ostream &os) const
Print value of p.d.f, also print normalization integral that was last used, if any.
virtual RooArgSet * getAllConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, Bool_t stripDisconnected=kTRUE) const
This helper function finds and collects all constraints terms of all component p.d....
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
virtual Bool_t syncNormalization(const RooArgSet *dset, Bool_t adjustProxies=kTRUE) const
Verify that the normalization integral cached with this PDF is valid for given set of normalization o...
int calculateAsymptoticCorrectedCovMatrix(Minimizer &minimizer, RooAbsData const &data)
virtual Double_t getValV(const RooArgSet *set=0) const
Return current value, normalized by integrating over the observables in nset.
virtual RooPlot * paramOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Add a box with parameter values (and errors) to the specified frame.
void setTraceCounter(Int_t value, Bool_t allNodes=kFALSE)
Reset trace counter to given value, limiting the number of future trace messages for this pdf to 'val...
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.
virtual const RooAbsReal * getNormObj(const RooArgSet *set, const RooArgSet *iset, const TNamed *rangeName=0) const
Return pointer to RooAbsReal object that implements calculation of integral over observables iset in ...
virtual Double_t getLogVal(const RooArgSet *set=0) const
Return the log of the current value with given normalization An error message is printed if the argum...
Int_t * randomizeProtoOrder(Int_t nProto, Int_t nGen, Bool_t resample=kFALSE) const
Return lookup table with randomized access order for prototype events, given nProto prototype data ev...
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
void setNormRangeOverride(const char *rangeName)
virtual RooDataSet * generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
virtual Bool_t isDirectGenSafe(const RooAbsArg &arg) const
Check if given observable can be safely generated using the pdfs internal generator mechanism (if tha...
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.
int calculateSumW2CorrectedCovMatrix(Minimizer &minimizer, RooAbsReal const &nll) const
RooAbsPdf()
Default constructor.
virtual RooAbsGenContext * binnedGenContext(const RooArgSet &vars, Bool_t verbose=kFALSE) const
Return a binned generator context.
static RooNumGenConfig * defaultGeneratorConfig()
Returns the default numeric MC generator configuration for all RooAbsReals.
RooNumGenConfig * _specGeneratorConfig
static TString _normRangeOverride
static Int_t _verboseEval
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 RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none(), const RooCmdArg &arg9=RooCmdArg::none(), const RooCmdArg &arg10=RooCmdArg::none()) const
Helper calling plotOn(RooPlot*, RooLinkedList&) const.
std::pair< double, double > getRange(const char *name=0) const
Get low and high bound of the variable.
virtual Bool_t hasRange(const char *name) const
Check if variable has a binning with given name.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
void plotOnCompSelect(RooArgSet *selNodes) const
Helper function for plotting of composite p.d.fs.
virtual RooSpan< double > evaluateSpan(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet) const
Evaluate this object for a batch/span of data points.
RooDerivative * derivative(RooRealVar &obs, Int_t order=1, Double_t eps=0.001)
Return function representing first, second or third order derivative of this function.
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
virtual Double_t evaluate() const =0
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
TString integralNameSuffix(const RooArgSet &iset, const RooArgSet *nset=0, const char *rangeName=0, Bool_t omitEmpty=kFALSE) const
Construct string with unique suffix name to give to integral object that encodes integrated observabl...
RooAbsReal * createIntRI(const RooArgSet &iset, const RooArgSet &nset=RooArgSet())
Utility function for createRunningIntegral.
RooFitResult * chi2FitDriver(RooAbsReal &fcn, RooLinkedList &cmdList)
Internal driver function for chi2 fits.
virtual RooSpan< const double > getValues(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet=nullptr) const
by this change, please consult the release notes for ROOT 6.24 for guidance on how to make this trans...
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void enableOffsetting(Bool_t)
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
Bool_t plotSanityChecks(RooPlot *frame) const
Utility function for plotOn(), perform general sanity check on frame to ensure safe plotting operatio...
static void setEvalErrorLoggingMode(ErrorLoggingMode m)
Set evaluation error logging mode.
virtual Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
const RooNumIntConfig * getIntegratorConfig() const
Return the numeric integration configuration used for this object.
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
RooDataHist * fillDataHist(RooDataHist *hist, const RooArgSet *nset, Double_t scaleFactor, Bool_t correctForBinVolume=kFALSE, Bool_t showProgress=kFALSE) const
Fill a RooDataHist with values sampled from this function at the bin centers.
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add element to non-owning set.
RooBinnedGenContext is an efficient implementation of the generator context specific for binned pdfs.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
RooCachedReal is an implementation of RooAbsCachedReal that can cache any external RooAbsReal input f...
void setCacheSource(Bool_t flag)
RooChi2Var implements a simple calculation from a binned dataset and a PDF.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
void setInt(Int_t idx, Int_t value)
void setString(Int_t idx, const char *value)
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
void allowUndefined(Bool_t flag=kTRUE)
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
RooConstraintSum calculates the sum of the -(log) likelihoods of a set of RooAbsPfs that represent co...
The RooDataHist is a container class to hold N-dimensional binned data.
double weight(std::size_t i) const
Return weight of i-th bin.
void set(std::size_t binNumber, double weight, double wgtErr)
Set bin content of bin that was last loaded with get(std::size_t).
Double_t sumEntries() const override
Sum the weights of all bins.
Int_t numEntries() const override
Return the number of bins.
void SetName(const char *name) override
Change the name of the RooDataHist.
const RooArgSet * get() const override
Get bin centre of current bin.
RooDataSet is a container class to hold unbinned data.
void SetName(const char *name) override
Change the name of this dataset into the given name.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
void setCovQual(Int_t val)
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.
RooInt is a minimal implementation of a TObject holding a Int_t value.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
virtual void Add(TObject *arg)
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
RooMinuit is a wrapper class around TFitter/TMinuit that provides a seamless interface between the MI...
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
static const char * str(const TNamed *ptr)
Return C++ string corresponding to given TNamed pointer.
RooNameSet is a utility class that stores the names the objects in a RooArget.
RooArgSet * select(const RooArgSet &list) const
Construct a RooArgSet of objects in input 'list' whose names match to those in the internal name list...
void setNameList(const char *givenList)
const char * content() const
Class RooNumCdf is an implementation of RooNumRunningInt specialized to calculate cumulative distribu...
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.
void sterilize()
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_t invisible=kFALSE)
Add a generic object to this plot.
Double_t getFitRangeNEvt() const
Return the number of events in the fit range.
Double_t getFitRangeBinW() const
Return the bin width that is being used to normalise the PDF.
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.
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,...
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.
RooRealIntegral performs hybrid numerical/analytical integrals of RooAbsReal objects.
RooRealVar represents a variable that can be changed from the outside.
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
A simple container to hold a batch of data values.
constexpr std::span< T >::index_type size() const noexcept
Bool_t defineSetInternal(const char *name, const RooArgSet &aset)
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
RooXYChi2Var implements a simple chi^2 calculation from an unbinned dataset with values x,...
Iterator abstract base class.
virtual TObject * Next()=0
TMatrixTSym< Element > & Similarity(const TMatrixT< Element > &n)
Calculate B * (*this) * B^T , final matrix will be (nrowsb x nrowsb) This is a similarity transform w...
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
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 ToLower()
Change string to lower-case.
void Clear()
Clear string without changing its capacity.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) 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, Bool_t reinterpretAsWeight=kFALSE)
RooCmdArg Hesse(Bool_t flag=kTRUE)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg Minimizer(const char *type, const char *alg=0)
RooCmdArg NormRange(const char *rangeNameList)
RooCmdArg Range(const char *rangeName, Bool_t adjustNorm=kTRUE)
RooCmdArg Normalization(Double_t scaleFactor)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
double fast_log(double x)
std::vector< std::string > tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken=true)
Tokenise the string by splitting at the characters in delims.
static constexpr double pc
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754
This struct enables passing computation data around between elements of a computation graph.
std::vector< double > logProbabilities
If evaluation should only occur in a range, the range name can be passed here.
std::unordered_map< const RooAbsReal *, RooSpan< const double > > spans
Once an object has computed its value(s), the span pointing to the results is registered here.
static double packFloatIntoNaN(float payload)
Pack float into mantissa of a NaN.
static void output(int code)