22#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
23#define protected public
28#if ROOT_VERSION_CODE < ROOT_VERSION(6, 33, 00)
61#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
63#define GETWS(a) a->_myws
64#define GETWSSETS(w) w->_namedSets
66#define GETWS(a) a->workspace()
67#define GETWSSETS(w) w->sets()
74#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
75#define protected public
104std::set<int> xRooNLLVar::xRooHypoPoint::allowedStatusCodes = {0};
115 fOldTitle =
fNll->get()->getStringAttribute(
"fitresultTitle");
140 std::unique_ptr<RooAbsCollection>
fSnap;
143 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
fOldData;
152 std::make_pair(std::shared_ptr<RooAbsData>(data.first, [](
RooAbsData *) {}),
153 std::shared_ptr<const RooAbsCollection>(data.second, [](
const RooAbsCollection *) {})),
159 const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &
data,
164#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 37, 00)
181 for (
int i = 0; i < opts.
GetSize(); i++) {
184 if (strcmp(opts.
At(i)->
GetName(),
"GlobalObservables") == 0) {
189 throw std::runtime_error(
"GlobalObservables mismatch");
197 auto _vars = std::unique_ptr<RooArgSet>(
fPdf->getVariables());
198 if (
auto extCon =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"ExternalConstraints"))) {
199 for (
auto con : *extCon->getSet(0)) {
200 _vars->add(*std::unique_ptr<RooArgSet>(con->getVariables()));
203 auto _funcGlobs = std::unique_ptr<RooArgSet>(
dynamic_cast<RooArgSet *
>(_vars->selectCommon(*
fGlobs)));
207 if (
auto flag =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"ReuseNLL"))) {
213 if (
auto range =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"RangeWithName"))) {
214 TString rangeName = range->getString(0);
221 std::vector<TString> chanPatterns;
223 bool hasRange(
false);
224 std::string noneCatRanges;
226 chanPatterns.emplace_back(pattern);
227 if (_cat.hasRange(chanPatterns.back())) {
230 if (!noneCatRanges.empty())
231 noneCatRanges +=
",";
232 noneCatRanges += chanPatterns.back();
239 if (noneCatRanges.empty()) {
240 fOpts->Remove(range);
243 range->setString(0, noneCatRanges.c_str());
247 std::make_shared<RooSimultaneous>(
TString::Format(
"%s_reduced", s->GetName()),
"Reduced model", _cat);
248 for (
auto &
c : _cat) {
249 auto _pdf = s->getPdf(
c.first.c_str());
252 _cat.setIndex(
c.second);
253 bool matchAny =
false;
254 for (
auto &p : chanPatterns) {
255 if (_cat.hasRange(p) && _cat.inRange(p)) {
261 newPdf->addPdf(*_pdf,
c.first.c_str());
296 (opts.find(
"GlobalObservables"))
297 ? dynamic_cast<
RooCmdArg *>(opts.find(
"GlobalObservables"))->getSet(0)->snapshot()
305 std::cout <<
"PDF: ";
309 std::cout <<
"<null>" << std::endl;
311 std::cout <<
"Data: ";
315 std::cout <<
"<null>" << std::endl;
317 std::cout <<
"NLL Options: " << std::endl;
318 for (
int i = 0; i <
fOpts->GetSize(); i++) {
322 std::cout <<
" " <<
c->GetName() <<
" : ";
323 if (
c->getString(0)) {
324 std::cout <<
c->getString(0);
325 }
else if (
c->getSet(0) && !
c->getSet(0)->empty()) {
326 std::cout << (
c->getSet(0)->contentsString());
328 std::cout <<
c->getInt(0);
330 std::cout << std::endl;
333 std::cout <<
"Fit Config: " << std::endl;
334 std::cout <<
" UseParabErrors: " << (
fFitConfig->ParabErrors() ?
"True" :
"False")
335 <<
" [toggles HESSE algorithm]" << std::endl;
336 std::cout <<
" MinimizerOptions: " << std::endl;
345 if (std::shared_ptr<RooAbsReal>::get())
346 oldName = std::shared_ptr<RooAbsReal>::get()->GetName();
351 fPdf->treeNodeServerList(&s,
nullptr,
true,
false);
353 bool isBinned =
false;
354 bool hasBinned =
false;
357 isBinned =
a->getInt(0);
359 std::map<RooAbsArg *, bool> origValues;
362 if (
a->InheritsFrom(
"RooRealSumPdf")) {
365 bool setBinned =
false;
367 std::unique_ptr<RooArgSet> obs(
a->getObservables(
fData->get()));
368 if (obs->size() == 1) {
369 auto *var =
static_cast<RooRealVar *
>(obs->first());
370 std::unique_ptr<std::list<double>> boundaries{
dynamic_cast<RooAbsReal *
>(
a)->binBoundaries(
371 *var, -std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity())};
373 if (!std::shared_ptr<RooAbsReal>::get()) {
374 Info(
"xRooNLLVar",
"%s will be evaluated as a Binned PDF (%d bins)",
a->GetName(),
375 int(boundaries->size() - 1));
381 origValues[
a] =
a->getAttribute(
"BinnedLikelihood");
382 a->setAttribute(
"BinnedLikelihood", setBinned);
386 std::map<RooAbsPdf *, std::string> normRanges;
387 std::set<TObject *> removedOpts;
388 if (
auto range =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"RangeWithName"))) {
389 TString rangeName = range->getString(0);
390 if (
auto sr =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"SplitRange"));
392 if (
auto special =
fOpts->find(
"RangeOptimize")) {
393 removedOpts.insert(sr);
395 removedOpts.insert(range);
396 fOpts->Remove(range);
397 removedOpts.insert(special);
398 fOpts->Remove(special);
402 for (
auto cat : simPdf->indexCat()) {
403 auto subpdf = simPdf->getPdf(cat.first.c_str());
407 srangeName.
ReplaceAll(
",",
"_" + cat.first +
",");
408 srangeName +=
"_" + cat.first;
410 subpdf->treeNodeServerList(&ss,
nullptr,
true,
false);
413 if (
a->InheritsFrom(
"RooAddPdf")) {
415 normRanges[p] = p->normRange() ? p->normRange() :
"";
416 p->setNormRange(srangeName);
425 if (
a->InheritsFrom(
"RooAddPdf")) {
427 normRanges[p] = p->normRange() ? p->normRange() :
"";
428 p->setNormRange(rangeName);
435 std::set<std::string> setNames;
438 setNames.insert(
a.first);
441 for (
auto &
a : setNames) {
445 std::set<std::string> attribs;
446 if (std::shared_ptr<RooAbsReal>::get())
447 attribs = std::shared_ptr<RooAbsReal>::get()->attributes();
448 this->reset(std::unique_ptr<RooAbsReal>{
fPdf->createNLL(*
fData, *
fOpts)}.release());
450 for (
auto o : removedOpts)
456 for (
auto &[k,
v] : normRanges)
457 k->setNormRange(
v ==
"" ?
nullptr :
v.c_str());
459 for (
auto &
a : attribs)
460 std::shared_ptr<RooAbsReal>::get()->setAttribute(
a.c_str());
466 std::shared_ptr<RooAbsReal>::get()->SetName(oldName);
467 if (!origValues.empty()) {
469 std::shared_ptr<RooAbsReal>::get()->getVal();
470 for (
auto &[o,
v] : origValues)
471 o->setAttribute(
"BinnedLikelihood",
v);
475 fFuncVars = std::unique_ptr<RooArgSet>{std::shared_ptr<RooAbsReal>::get()->getVariables()};
483std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
487 return std::pair(
nullptr,
nullptr);
488 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
492 fr->setConstParList(
l);
495 std::unique_ptr<RooAbsCollection>(fr->constPars().selectCommon(*
fGlobs))->setAttribAll(
"global",
true);
529 throw std::runtime_error(
"xRooFitResult::cfit: Cannot create cfit without nll");
533 if (
auto res =
fCfits->find(alias); res !=
fCfits->end()) {
537 if (
auto res =
fCfits->find(poiValues); res !=
fCfits->end()) {
542 *
fNll->fFuncVars =
get()->floatParsFinal();
543 fNll->fFuncVars->assignValueOnly(
get()->constPars());
544 std::unique_ptr<RooAbsCollection>(
fNll->fFuncVars->selectCommon(
get()->floatParsFinal()))
545 ->setAttribAll(
"Constant",
false);
546 std::unique_ptr<RooAbsCollection>(
fNll->fFuncVars->selectCommon(
get()->constPars()))->setAttribAll(
"Constant",
true);
551 fCfits->insert(std::pair((alias) ? alias : poiValues, out));
558 throw std::runtime_error(
"xRooFitResult::ifit: par not found");
567 throw std::runtime_error(
"xRooFitResult::impact: poi not found");
568 auto _ifit =
ifit(np, up, prefit);
570 throw std::runtime_error(
"xRooFitResult::impact: null ifit");
571 if (_ifit->status() != 0)
572 fNode->Warning(
"impact",
"ifit status code is %d", _ifit->status());
573 return _ifit->floatParsFinal().getRealValue(
poi) - poiHat->
getVal();
576 int iPoi =
get()->floatParsFinal().index(
poi);
577 int iNp =
get()->floatParsFinal().index(np);
579 throw std::runtime_error(
"xRooFitResult::impact: poi not found");
581 throw std::runtime_error(
"xRooFitResult::impact: np not found");
583 dynamic_cast<RooRealVar *
>((prefit ?
get()->floatParsInit() :
get()->floatParsFinal()).find(np));
586 return std::numeric_limits<double>::quiet_NaN();
596 for (
auto p :
get()->floatParsFinal()) {
597 if (strcmp(p->GetName(),
poi) == 0) {
603 bool matches =
false;
606 if ((p->getStringAttribute(
"group") && s == p->getStringAttribute(
"group")) ||
615 npNames += p->GetName();
624 fNode->Warning(
"conditionalError",
"No parameters selected by: %s", nps);
625 return (up) ?
static_cast<RooRealVar *
>(poiVar)->getErrorHi() :
static_cast<RooRealVar *
>(poiVar)->getErrorLo();
630 return sqrt(
get()->conditionalCovarianceMatrix(vars)(idx, idx));
633 auto _cfit =
cfit(npNames.
Data(), nps);
635 auto _poi = _cfit->floatParsFinal().find(
poi);
637 return (up) ?
static_cast<RooRealVar *
>(_poi)->getErrorHi() :
static_cast<RooRealVar *
>(_poi)->getErrorLo();
645 throw std::runtime_error(
"xRooFitResult::ranknp: poi not found");
647 std::vector<std::pair<std::string, double>> ranks;
649 for (
auto par :
get()->floatParsFinal()) {
652 ranks.emplace_back(std::pair(par->GetName(),
impact(
poi, par->GetName(), up, prefit,
true)));
655 std::sort(ranks.begin(), ranks.end(), [](
auto &left,
auto &right) {
656 if (std::isnan(left.second) && !std::isnan(right.second))
658 if (!std::isnan(left.second) && std::isnan(right.second))
660 return fabs(left.second) > fabs(right.second);
664 for (
auto &[
n,
v] : ranks) {
665 if (
v >= approxThreshold) {
669 v = std::numeric_limits<double>::quiet_NaN();
675 std::sort(ranks.begin(), ranks.end(), [](
auto &left,
auto &right) {
676 if (std::isnan(left.second) && !std::isnan(right.second))
678 if (!std::isnan(left.second) && std::isnan(right.second))
680 return fabs(left.second) > fabs(right.second);
685 for (
auto &[
n,
v] : ranks) {
690 vv->removeMin();vv->removeMax();
708 std::unique_ptr<RooAbsCollection>(out->constPars().selectCommon(*
fGlobs))->setAttribAll(
"global",
true);
711 if (
fOpts->find(
"GoF")) {
718 return xRooFitResult(std::make_shared<xRooNode>(out,
fPdf), std::make_shared<xRooNLLVar>(*
this));
740 if (
size_t(_data->numEntries()) <= entry)
743 *std::unique_ptr<RooAbsCollection>(_pdf->getObservables(_data)) = *_data->get(entry);
746 return -_data->weight() * _pdf->getLogVal(_data->get());
751 std::set<std::string> out;
753 auto binnedOpt =
dynamic_cast<RooCmdArg *
>(
fOpts->find(
"Binned"));
757 bool allChannels =
true;
758 for (
auto c : simPdf.
bins()) {
762 c->get<
RooAbsArg>()->treeNodeServerList(&nodes,
nullptr,
true,
false);
763 bool isBinned =
false;
764 for (
auto a : nodes) {
765 if (
a->InheritsFrom(
"RooRealSumPdf") &&
766 ((binnedOpt && binnedOpt->getInt(0)) || (!binnedOpt &&
a->getAttribute(
"BinnedLikelihood")))) {
768 out.insert(chanName(chanName.
Index(
"=") + 1, chanName.
Length()).
Data());
783 pdf()->treeNodeServerList(&nodes,
nullptr,
true,
false);
784 for (
auto a : nodes) {
785 if (
a->InheritsFrom(
"RooRealSumPdf") &&
786 ((binnedOpt && binnedOpt->getInt(0)) || (!binnedOpt &&
a->getAttribute(
"BinnedLikelihood")))) {
801 if (
size_t(_data->numEntries()) <= entry)
803 auto _pdf =
pdf().get();
804 std::unique_ptr<RooAbsCollection> _robs(_pdf->getObservables(_data->get()));
805 *_robs = *_data->get(entry);
807 _pdf = s->getPdf(s->indexCat().getCurrentLabel());
810 for (
auto o : *_robs) {
813 a && _pdf->dependsOn(*
a)) {
814 std::unique_ptr<std::list<double>> bins(
815 _pdf->binBoundaries(*
a, -std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity()));
817 double lowEdge = -std::numeric_limits<double>::infinity();
818 for (
auto b : *bins) {
819 if (
b >
a->getVal()) {
820 volume *= (
b - lowEdge);
846 for (
auto c : cTerm->list()) {
847 if (std::string(
c->ClassName()) ==
"RooAbsPdf" ||
848 std::string(
c->ClassName()).find(
"RooNormalizedPdf") != std::string::npos) {
858 gaus->getMean().GetName()));
863 }
else if (
auto pois =
dynamic_cast<RooPoisson *
>(
c)) {
877 std::unique_ptr<RooAbsCollection>(
pars()->selectByAttrib(
"Constant",
false))->size();
891 std::unique_ptr<RooAbsCollection> _floats(
pars()->selectByAttrib(
"Constant",
false));
893 _floats->remove(*std::unique_ptr<RooAbsCollection>(_constraintTerm->getVariables()));
907 return _constraintTerm->getVal();
934 return std::numeric_limits<double>::quiet_NaN();
948 double out = _data->sumEntries();
949 for (
int i = 0; i < _data->numEntries(); i++) {
951 double w = _data->weight();
954 out -= w * std::log(w);
955 if (_binnedChannels.count(
"*")) {
957 }
else if (_binnedChannels.empty()) {
961 if (_binnedChannels.count(_data->get()->getCatLabel(cat->
GetName()))) {
967 throw std::runtime_error(
"Cannot determine category of RooSimultaneous pdf");
978 auto out = std::shared_ptr<RooArgSet>(
get()->getVariables());
979 if (stripGlobalObs &&
fGlobs) {
980 out->remove(*
fGlobs,
true,
true);
988 return Scan(*std::unique_ptr<RooAbsCollection>(
get()->getVariables()->selectByName(scanPars)), coords, profilePars);
995 if (scanPars.
size() > 2 || scanPars.
empty())
1005 std::unique_ptr<RooAbsCollection> funcVars(
get()->getVariables());
1008 for (
auto &coord : coords) {
1009 if (coord.size() != scanPars.
size()) {
1010 throw std::runtime_error(
"Invalid coordinate");
1012 for (
size_t i = 0; i < coord.size(); i++) {
1016 if (profilePars.
empty()) {
1033 auto _pars =
pars();
1035 if (sOpt ==
"sensitivity") {
1040 if (sOpt ==
"floating") {
1042 auto floats = std::unique_ptr<RooAbsCollection>(_pars->selectByAttrib(
"Constant",
false));
1049 gr->SetName(
"multigraph");
1065 if (
auto a = _pars->find(s);
a)
1069 if (vars.
size() == 1) {
1077 bool normRange =
false;
1089 double low =
v->getVal();
1091 double step = (
v->getMax() -
v->getMin()) / 100;
1092 double init =
v->getVal();
1093 double initVal =
func()->getVal();
1095 auto currTime = std::chrono::steady_clock::now();
1096 while (out->
GetN() < 100 && (low >
v->getMin() || high < v->getMax())) {
1097 if (out->
GetN() == 0) {
1107 if (low >
v->getMin()) {
1109 auto _v =
func()->getVal();
1110 if (std::isnan(_v) || std::isinf(_v)) {
1111 if (bad->
GetN() == 0)
1119 if (high < v->getMax()) {
1121 auto _v =
func()->getVal();
1122 if (std::isnan(_v) || std::isinf(_v)) {
1123 if (bad->
GetN() == 0)
1134 if (std::chrono::steady_clock::now() - currTime > std::chrono::seconds(1)) {
1135 currTime = std::chrono::steady_clock::now();
1142 a.DrawArrow(init, 0, init, -0.1);
1144#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1145 gPad->GetCanvas()->ResetUpdated();
1150 Error(
"Draw",
"Name a parameter to scan over: Draw(<name>) , choose from: %s",
1151 _pars->empty() ?
"" : _pars->contentsString().c_str());
1165 return setData(std::dynamic_pointer_cast<RooAbsData>(
data.fComp),
1166 std::shared_ptr<const RooAbsCollection>(
data.globs().argList().snapshot()));
1169bool xRooNLLVar::setData(
const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &_data)
1172 if (
fData == _data.first &&
fGlobs == _data.second)
1177 auto _dglobs = (_data.second) ? _data.second
1178 : std::shared_ptr<const RooAbsCollection>(_data.first->getGlobalObservables(),
1181 if (
fGlobs && !(
fGlobs->empty() && !_dglobs) && _data.first &&
1185 throw std::runtime_error(
"Missing globs");
1189 std::unique_ptr<RooAbsCollection> _actualGlobs(
fPdf->getObservables(s));
1192 std::unique_ptr<RooAbsCollection> _actualGlobs2(
fPdf->getObservables(s2));
1193 if (!_actualGlobs->equals(*_actualGlobs2)) {
1195 rC.
add(*_actualGlobs2);
1199 lC.
add(*_actualGlobs);
1202 throw std::runtime_error(
TString::Format(
"globs mismatch: adding %s removing %s",
r.Data(),
l.Data()));
1207 if (!std::shared_ptr<RooAbsReal>::get()) {
1208 fData = _data.first;
1221 fFuncVars->setAttribAll(
"Constant",
false);
1223 std::shared_ptr<RooAbsData> __data =
fData;
1225 fData = _data.first;
1246 fData = _data.first;
1248 }
catch (std::runtime_error &) {
1253 fFuncVars->setAttribAll(
"Constant",
false);
1255 std::shared_ptr<RooAbsData> __data =
fData;
1257 fData = _data.first;
1261 throw std::runtime_error(
"Unable to setData");
1268 }
else if (
auto f = std::unique_ptr<RooAbsCollection>(
fConstVars->selectByAttrib(
"Constant",
false)); !
f->empty()) {
1291 if (strcmp(opt.
GetName(),
"Hesse") == 0) {
1293 }
else if (strcmp(opt.
GetName(),
"Minos") == 0) {
1295 }
else if (strcmp(opt.
GetName(),
"Strategy") == 0) {
1297 }
else if (strcmp(opt.
GetName(),
"StrategySequence") == 0) {
1299 }
else if (strcmp(opt.
GetName(),
"Tolerance") == 0) {
1301 }
else if (strcmp(opt.
GetName(),
"MaxCalls") == 0) {
1303 }
else if (strcmp(opt.
GetName(),
"MaxIterations") == 0) {
1305 }
else if (strcmp(opt.
GetName(),
"PrintLevel") == 0) {
1308 if (strcmp(opt.
GetName(),
"Optimize") == 0) {
1313 if (
auto prevObject =
fOpts->FindObject(opt.
GetName()); prevObject) {
1315 fOpts->Replace(prevObject, opt.
Clone(
nullptr));
1321 if (std::shared_ptr<RooAbsReal>::get()) {
1394 return fData->sumEntries() * log(1.0 * (s->servers().size() - 1));
1406 for (
int i = 0; i <
fData->numEntries(); i++) {
1416 auto _func =
func();
1419 for (
auto s : _func->servers()) {
1423 for (
auto s2 : s->servers()) {
1443 bool doCLs = sWhat.
Contains(
"pcls");
1444 bool doNull = sWhat.
Contains(
"pnull");
1445 bool doAlt = sWhat.
Contains(
"palt");
1446 double nSigma = (sWhat.
Contains(
"exp"))
1451 : std::numeric_limits<double>::quiet_NaN();
1453 bool toys = sWhat.
Contains(
"toys");
1457 bool readOnly = sWhat.
Contains(
"readonly");
1464 if (
getVal(sWhat +
" readonly").second != 0) {
1470 size_t nToys = toyNum.
Atoi();
1471 size_t nToysAlt = (toyNum.
Atof() - nToys) * nToys;
1472 if (nToysAlt == 0 && !toyNum.
Contains(
'.'))
1477 if (
altToys.size() < nToysAlt) {
1480 }
else if (doCLs && toys) {
1484 throw std::runtime_error(
"Auto-generating toys for anything other than CLs not yet supported, please "
1485 "specify number of toys with 'toys=N' ");
1491 RestoreNll(std::shared_ptr<xRooNLLVar> &
v,
bool r) : rr(
r), var(
v)
1493 if (rr && var && var->get()) {
1494 _readOnly = var->get()->getAttribute(
"readOnly");
1495 var->get()->setAttribute(
"readOnly", rr);
1503 var->get()->setAttribute(
"readOnly", _readOnly);
1507 bool _readOnly =
false;
1509 std::shared_ptr<xRooNLLVar> &var;
1512 RestoreNll rest(
nllVar, readOnly);
1523 throw std::runtime_error(std::string(
"Unknown: ") +
what);
1530 out.
add(*std::unique_ptr<RooAbsCollection>(
coords->selectByAttrib(
"poi",
true)));
1538 out.
addClone(*std::unique_ptr<RooAbsCollection>(
coords->selectByAttrib(
"poi",
true)));
1539 for (
auto a : out) {
1543 if (
auto s =
a->getStringAttribute(
"altVal"); s && strlen(s)) {
1546 v->setVal(std::numeric_limits<double>::quiet_NaN());
1562 if (me.asimov(
true))
1563 out += me.asimov(
true)->status() << 3;
1571 std::cout <<
"POI: " << _poi.contentsString() <<
" , null: ";
1573 for (
auto a : _poi) {
1579 std::cout <<
v->getVal();
1582 std::cout <<
" , alt: ";
1584 bool any_alt =
false;
1585 for (
auto a : _alt_poi) {
1591 std::cout <<
v->getVal();
1593 if (!std::isnan(
v->getVal()))
1596 std::cout <<
" , pllType: " <<
fPllType << std::endl;
1602 std::cout <<
" - ufit: ";
1604 std::cout <<
fUfit->GetName() <<
" " <<
fUfit->minNll() <<
" (status=" <<
fUfit->status() <<
") (";
1606 for (
auto a : _poi) {
1607 auto v =
dynamic_cast<RooRealVar *
>(
fUfit->floatParsFinal().find(
a->GetName()));
1612 std::cout <<
v->GetName() <<
"_hat: " <<
v->getVal() <<
" +/- " <<
v->getError();
1615 std::cout <<
")" << std::endl;
1617 std::cout <<
"Not calculated" << std::endl;
1619 std::cout <<
" - cfit_null: ";
1623 std::cout <<
"Not calculated";
1626 std::cout << std::endl <<
" - cfit_alt: ";
1631 std::cout <<
"Not calculated" << std::endl;
1633 std::cout <<
" sigma_mu: ";
1636 std::cout <<
"Not calculated";
1638 std::cout << const_cast<xRooHypoPoint *>(
this)->sigma_mu().first <<
" +/- "
1642 std::cout << std::endl;
1643 std::cout <<
" - asimov ufit: ";
1645 std::cout <<
fAsimov->fUfit->GetName() <<
" " <<
fAsimov->fUfit->minNll()
1646 <<
" (status=" <<
fAsimov->fUfit->status() <<
")";
1648 std::cout <<
"Not calculated";
1650 std::cout << std::endl <<
" - asimov cfit_null: ";
1652 std::cout <<
fAsimov->fNull_cfit->GetName() <<
" " <<
fAsimov->fNull_cfit->minNll()
1653 <<
" (status=" <<
fAsimov->fNull_cfit->status() <<
")";
1655 std::cout <<
"Not calculated";
1658 std::cout << std::endl;
1660 std::cout << std::endl;
1664 <<
" (status=" <<
fLbound_cfit->status() <<
")" << std::endl;
1667 std::cout <<
" - gfit: " <<
fGenFit->GetName() << std::endl;
1669 std::cout <<
" * null toys: " <<
nullToys.size();
1670 size_t firstToy = 0;
1671 while (firstToy <
nullToys.size() && std::isnan(std::get<1>(
nullToys[firstToy])))
1674 std::cout <<
" [ of which " << firstToy <<
" are bad]";
1675 std::cout <<
" , alt toys: " <<
altToys.size();
1677 while (firstToy <
altToys.size() && std::isnan(std::get<1>(
altToys[firstToy])))
1680 std::cout <<
" [ of which " << firstToy <<
" are bad]";
1681 std::cout << std::endl;
1696 throw std::runtime_error(
"Unconditional fit unavailable");
1727 if (toys->getGlobalObservables()) {
1728 coords = std::shared_ptr<RooAbsCollection>(toys->getGlobalObservables()->snapshot());
1730 for (
int i = 0; i < toys->numEntries(); i++) {
1731 auto toy = toys->get(i);
1733 std::make_tuple(
int(toy->getRealValue(
"seed")), toy->getRealValue(
"ts"), toys->weight()));
1738 for (
int i = 0; i < toys->numEntries(); i++) {
1739 auto toy = toys->get(i);
1741 std::make_tuple(
int(toy->getRealValue(
"seed")), toy->getRealValue(
"ts"), toys->weight()));
1760 fAsimov = std::make_shared<xRooHypoPoint>(*
this);
1762 fAsimov->hypoTestResult.reset();
1764 for (
auto p :
fAsimov->poi()) {
1767 v->deleteSharedProperties();
1777 std::make_pair(
nullptr,
nullptr);
1788 return std::pair<double, double>(1, 0);
1791 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1794 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1797 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1800 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1801 return std::pair(nom, std::max(std::abs(up - nom), std::abs(down - nom)));
1807 return std::pair<double, double>(1, 0);
1810 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1813 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1816 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1819 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1821 return std::pair(nom, std::max(std::abs(up - nom), std::abs(down - nom)));
1827 return std::pair<double, double>(1, 0);
1830 return std::pair<double, double>(1, 0);
1833 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1838 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1841 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1844 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1846 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1849 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1852 first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1854 auto nom = (nom1 == 0) ? 0 : nom1 / nom2;
1855 auto up = (up1 == 0) ? 0 : up1 / up2;
1856 auto down = (down1 == 0) ? 0 : down1 / down2;
1858 return std::pair(nom, std::max(std::abs(up - nom), std::abs(down - nom)));
1863 if (std::isnan(nSigma)) {
1869 if (!first_poi || (!std::isnan(nSigma) && std::isnan(_sigma_mu.first)))
1870 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1872 _sigma_mu.first, first_poi->getMin(
"physical"), first_poi->getMax(
"physical"));
1874 _sigma_mu.first + _sigma_mu.second, first_poi->getMin(
"physical"),
1875 first_poi->getMax(
"physical"));
1877 _sigma_mu.first - _sigma_mu.second, first_poi->getMin(
"physical"),
1878 first_poi->getMax(
"physical"));
1879 return std::pair<double, double>(nom, std::max(std::abs(nom - up), std::abs(nom - down)));
1884 if (std::isnan(nSigma)) {
1888 size_t firstToy = 0;
1889 while (firstToy <
altToys.size() && std::isnan(std::get<1>(
altToys[firstToy])))
1891 if (firstToy >=
altToys.size())
1892 return std::pair(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN());
1895 return std::pair(std::get<1>(
altToys[targetIdx]), (std::get<1>(
altToys[std::min(
int(
altToys.size()), targetIdx)]) -
1896 std::get<1>(
altToys[std::max(0, targetIdx)])) /
1902 auto _ufit =
ufit(readOnly);
1905 return std::pair<double, double>(
hypoTestResult->GetTestStatisticData(), 0);
1906 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1909 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1911 if (
auto _first_poi =
dynamic_cast<RooRealVar *
>(
poi().first());
1912 _first_poi && _first_poi->
getMin(
"physical") > _first_poi->getMin() &&
1917 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1924 return std::pair<double, double>(0, 0);
1927 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1929 double diff = _cfit_null->minNll() - _ufit->minNll();
1933 diff += (_ufit->edm() - _cfit_null->edm());
1935 return std::pair<double, double>(2. * cFactor * diff,
1936 2. * cFactor * sqrt(pow(
cfit_null(readOnly)->edm(), 2) + pow(_ufit->edm(), 2)));
1946 for (
int i = 0; i < fits->numEntries(); i++) {
1947 auto fit = fits->get(i);
1948 if (fit->getCatIndex(
"type") !=
type)
1952 fits->getGlobalObservables()->getStringValue(
TString::Format(
"%s.name", fit->getCatLabel(
"type")));
1955 for (
auto file : *
gROOT->GetListOfFiles()) {
1956 if (
auto k =
static_cast<TDirectory *
>(file)->FindKeyAny(_name.c_str())) {
1959 k->GetMotherDir()->GetList()
1962 if (
auto cachedFit = (storedFr) ? storedFr->
fr.get() : k->ReadObject<
RooFitResult>(); cachedFit) {
1965 k->GetMotherDir()->Add(storedFr);
1968 return storedFr->
fr;
1972 auto rfit = std::make_shared<RooFitResult>(_name.c_str(),
TUUID(_name.c_str()).
GetTime().
AsString());
1973 rfit->setStatus(fit->getRealValue(
"status"));
1974 rfit->setMinNLL(fit->getRealValue(
"minNll"));
1975 rfit->setEDM(fit->getRealValue(
"edm"));
1977 std::unique_ptr<RooAbsCollection> par_hats(
1978 hypoTestResult->GetFitInfo()->getGlobalObservables()->selectByName(
coords->contentsString().c_str()));
1979 par_hats->setName(
"floatParsFinal");
1980 rfit->setFinalParList(*par_hats);
1987 rfit->setCovarianceMatrix(cov);
1988 rfit->setCovQual(fit->getRealValue(
"covQual"));
2000 return fUfit = rfit;
2002 if (!
nllVar || (readOnly &&
nllVar->get() && !
nllVar->get()->getAttribute(
"readOnly")))
2010 bool tmp =
nllVar->get()->getAttribute(
"readOnly");
2011 nllVar->get()->setAttribute(
"readOnly");
2012 auto out =
ufit(
true);
2013 nllVar->get()->setAttribute(
"readOnly", tmp);
2021 }
else if (!
nllVar->get()->getAttribute(
"readOnly")) {
2024 nllVar->fFuncVars->setAttribAll(
"Constant",
false);
2027 nllVar->fFuncGlobs->setAttribAll(
"Constant",
true);
2028 std::unique_ptr<RooAbsCollection>(
nllVar->fFuncVars->selectCommon(
poi()))
2029 ->setAttribAll(
"Constant",
false);
2033 nllVar->fFuncVars->assignValueOnly(
fGenFit->floatParsFinal());
2040 }
else if (!std::isnan(
fAltVal())) {
2042 for (
auto _poiCoord :
poi()) {
2043 auto _poi =
dynamic_cast<RooRealVar *
>(
nllVar->fFuncVars->find(_poiCoord->GetName()));
2045 _poi->setVal(_poi->getStringAttribute(
"initVal") ?
TString(_poi->getStringAttribute(
"initVal")).
Atof()
2056 for (
auto &
c : coll) {
2059 out +=
c->GetName();
2078 if (!
nllVar || (readOnly &&
nllVar->get() && !
nllVar->get()->getAttribute(
"readOnly")))
2086 bool tmp =
nllVar->get()->getAttribute(
"readOnly");
2087 nllVar->get()->setAttribute(
"readOnly");
2089 nllVar->get()->setAttribute(
"readOnly", tmp);
2097 }
else if (!
nllVar->get()->getAttribute(
"readOnly")) {
2104 nllVar->fFuncVars->setAttribAll(
"Constant",
false);
2107 nllVar->fFuncGlobs->setAttribAll(
"Constant",
true);
2124 auto _first_poi =
dynamic_cast<RooRealVar *
>(
poi().first());
2127 if (_first_poi->getMin(
"physical") <= _first_poi->getMin())
2134 if (!
nllVar || (readOnly &&
nllVar->get() && !
nllVar->get()->getAttribute(
"readOnly")))
2142 bool tmp =
nllVar->get()->getAttribute(
"readOnly");
2143 nllVar->get()->setAttribute(
"readOnly");
2145 nllVar->get()->setAttribute(
"readOnly", tmp);
2153 }
else if (!
nllVar->get()->getAttribute(
"readOnly")) {
2160 nllVar->fFuncVars->setAttribAll(
"Constant",
false);
2162 nllVar->fFuncVars->setRealValue(_first_poi->GetName(), _first_poi->getMin(
"physical"));
2164 nllVar->fFuncGlobs->setAttribAll(
"Constant",
true);
2175 nllVar->get()->setStringAttribute(
2190 if (!
nllVar || (readOnly &&
nllVar->get() && !
nllVar->get()->getAttribute(
"readOnly")))
2198 bool tmp =
nllVar->get()->getAttribute(
"readOnly");
2199 nllVar->get()->setAttribute(
"readOnly");
2201 nllVar->get()->setAttribute(
"readOnly", tmp);
2209 }
else if (!
nllVar->get()->getAttribute(
"readOnly")) {
2216 nllVar->fFuncVars->setAttribAll(
"Constant",
false);
2219 nllVar->fFuncGlobs->setAttribAll(
"Constant",
true);
2234 auto asi =
asimov(readOnly);
2237 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
2240 auto out = asi->pll(readOnly);
2241 return std::pair<double, double>(std::abs(
fNullVal() -
fAltVal()) / sqrt(out.first),
2243 (out.first * sqrt(out.first)));
2249 if (std::isnan(_ts.first))
2252 return std::pair<double, double>(1, 0);
2258 if (_theToys.empty()) {
2259 return std::pair(0.5, std::numeric_limits<double>::infinity());
2266 double result_err_up = 0;
2267 double result_err_down = 0;
2268 for (
auto &toy : _theToys) {
2269 if (std::isnan(std::get<1>(toy))) {
2272 bool res = std::get<1>(toy) >= _ts.first;
2273 if (std::get<2>(toy) != 1) {
2279 result += std::get<2>(toy);
2280 if (std::get<1>(toy) >= _ts.first - _ts.second)
2281 result_err_up += std::get<2>(toy);
2282 if (std::get<1>(toy) >= _ts.first - _ts.second)
2283 result_err_down += std::get<2>(toy);
2288 result_err_down -=
result;
2289 double result_err = std::max(std::abs(result_err_up), std::abs(result_err_down));
2292 result_err /= _theToys.size();
2295 result /= (_theToys.size() - nans);
2299 return std::pair<double, double>(
result, result_err);
2304 return pX_toys(
false, nSigma);
2309 if (!std::isnan(nSigma)) {
2356 bool targetCLs,
double relErrThreshold,
size_t maxToys)
2359 throw std::runtime_error(
"Cannot add toys, invalid conditional fit");
2362 auto condition = [&]() {
2363 if (std::isnan(target))
2366 if (!std::isnan(obs.first)) {
2367 double diff = (target < 0) ? obs.first : std::abs(obs.first - target);
2368 double err = obs.second;
2369 if (
err > 1
e-4 && diff <= relErrThreshold * obs.second) {
2377 alt = (pAlt.second * pNull.first > pNull.second * pAlt.first);
2378 if ((alt ? pAlt.second : pNull.second) < 1
e-4)
2387 if (!std::isnan(target) && std::isnan(
ts_toys(target_nSigma).first)) {
2388 if (std::isnan(target_nSigma)) {
2389 throw std::runtime_error(
"Cannot target obs p-value because ts value unavailable");
2391 if (targetCLs &&
pCLs_toys(target_nSigma).second == 0) {
2397 Info(
"addToys",
"First generating 100 alt toys in order to determine expected ts value");
2398 addToys(
true, 100, initialSeed);
2400 if (std::isnan(
ts_toys(target_nSigma).first)) {
2401 throw std::runtime_error(
"Unable to determine expected ts value");
2411 g->SetNameTitle(
"toyTime",
"Time per toy;Toy;time [s]");
2420 size_t toysAdded(0);
2421 size_t altToysAdded(0);
2427 if (toys.size() >= maxToys) {
2432 if (!std::isnan(target) && !condition()) {
2435 auto currVal = std::isnan(target) ? std::pair(0., 0.)
2438 size_t nnToys = std::min(
size_t(nToys), (maxToys - toys.size()));
2440 for (
size_t i = 0; i < nnToys; i++) {
2445 toys.push_back(std::make_tuple(seed, toy.pll().first, 1.));
2447 (alt ? altToysAdded : toysAdded)++;
2448 if (std::isnan(std::get<1>(toys.back())))
2450 g->SetPoint(
g->GetN(),
g->GetN(), s.
RealTime() - lastTime);
2454 <<
TString::Format(
"Generated %d/%d %s hypothesis toys [%.2f toys/s]",
2455 int(alt ? altToysAdded : toysAdded),
int(nnToys), alt ?
"alt" :
"null",
2456 double(altToysAdded + toysAdded - lasti) / s.
RealTime());
2457 if (!std::isnan(target)) {
2458 std::cout <<
" [current=" << currVal.first <<
"+/-" << currVal.second <<
" target=" << target
2459 <<
" nSigma=" << target_nSigma <<
"]";
2461 std::cout <<
"..." << std::flush;
2462 lasti = altToysAdded + toysAdded;
2464 if (!
gROOT->IsBatch()) {
2468#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
2469 gPad->GetCanvas()->ResetUpdated();
2482 for (
auto &t : toys) {
2483 if (std::isnan(std::get<1>(t)))
2484 std::get<1>(t) = -std::numeric_limits<double>::infinity();
2486 std::sort(toys.begin(), toys.end(),
2487 [](
const decltype(
nullToys)::value_type &
a,
const decltype(
nullToys)::value_type &
b) ->
bool {
2488 if (std::isnan(std::get<1>(a)))
2490 if (std::isnan(std::get<1>(b)))
2492 return std::get<1>(a) < std::get<1>(b);
2494 for (
auto &t : toys) {
2495 if (std::isinf(std::get<1>(t)))
2496 std::get<1>(t) = std::numeric_limits<double>::quiet_NaN();
2498 if (std::isnan(target)) {
2505 }
while (condition());
2508 <<
"Finished Generating ";
2510 std::cout << toysAdded <<
" null ";
2513 std::cout << altToysAdded <<
" alt ";
2515 std::cout <<
"toys " <<
TString::Format(
"[%.2f toys/s overall]",
double(toysAdded + altToysAdded) / s2.
RealTime())
2517 if (!
gROOT->IsBatch()) {
2521#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
2522 gPad->GetCanvas()->ResetUpdated();
2530 std::cout <<
"Warning: " << nans <<
" toys were bad" << std::endl;
2537 addToys(
false, nToys, seed, target, target_nSigma);
2541 addToys(
true, nToys, seed, target, target_nSigma);
2546 addToys(
false, nToys, seed, target, target_nSigma,
true);
2607 out.
nllVar = std::make_shared<xRooNLLVar>(*
this);
2615 double val = std::numeric_limits<double>::quiet_NaN();
2616 auto i = s.
Index(
"=");
2621 throw std::runtime_error(
"poiValues must contain value");
2626 throw std::runtime_error(
"Cannot find poi");
2627 if (!std::isnan(val))
2630 if (poiNames !=
"") {
2635 if (poiNames ==
"") {
2636 throw std::runtime_error(
"No poi");
2638 if (!std::isnan(alt_value)) {
2639 std::unique_ptr<RooAbsCollection> thePoi(
fFuncVars->selectByName(poiNames));
2640 for (
auto b : *thePoi) {
2641 if (!
static_cast<RooRealVar *
>(
b)->hasRange(
"physical")) {
2642 static_cast<RooRealVar *
>(
b)->setRange(
"physical", 0, std::numeric_limits<double>::infinity());
2646 auto _snap = std::unique_ptr<RooAbsCollection>(
fFuncVars->selectByAttrib(
"Constant",
true))->snapshot();
2647 _snap->setAttribAll(
"poi",
false);
2648 std::unique_ptr<RooAbsCollection> _poi(_snap->selectByName(poiNames));
2649 _poi->setAttribAll(
"poi",
true);
2650 if (std::isnan(alt_value)) {
2651 for (
auto a : *_poi)
2652 a->setStringAttribute(
"altVal",
nullptr);
2654 for (
auto a : *_poi)
2658 _snap->remove(*
fGlobs,
true,
true);
2661 auto _type = pllType;
2664 if (std::isnan(alt_value)) {
2666 }
else if (
dynamic_cast<RooRealVar *
>(_poi->first())->
getVal() >= alt_value) {
2684 std::unique_ptr<RooAbsCollection> _poi(
fFuncVars->selectByAttrib(
"poi",
true));
2685 if (_poi->empty()) {
2686 throw std::runtime_error(
"No POI specified in model");
2687 }
else if (_poi->size() != 1) {
2688 throw std::runtime_error(
"Multiple POI specified in model");
2690 return hypoPoint(_poi->first()->GetName(), value, alt_value, pllType);
2707 bool hasSame = sOpt.
Contains(
"same");
2712 TH1 *hAxis =
nullptr;
2714 auto clearPad = []() {
2716 if (
gPad->GetNumber() == 0) {
2717 gPad->SetBottomMargin(
gStyle->GetPadBottomMargin());
2718 gPad->SetTopMargin(
gStyle->GetPadTopMargin());
2719 gPad->SetLeftMargin(
gStyle->GetPadLeftMargin());
2720 gPad->SetRightMargin(
gStyle->GetPadRightMargin());
2724 if (!hasSame || !pad) {
2735 if (hAxis =
dynamic_cast<TH1 *
>(o); hAxis)
2742 double _min = std::numeric_limits<double>::quiet_NaN();
2743 double _max = -std::numeric_limits<double>::quiet_NaN();
2746 if (std::get<2>(p) == 0)
2748 if (std::isnan(std::get<1>(p)))
2750 _min = std::min(std::get<1>(p), _min);
2751 _max = std::max(std::get<1>(p), _max);
2754 if (std::get<2>(p) == 0)
2756 if (std::isnan(std::get<1>(p)))
2758 _min = std::min(std::get<1>(p), _min);
2759 _max = std::max(std::get<1>(p), _max);
2763 if (!std::isnan(obs.first)) {
2764 _min = std::min(obs.first - std::abs(obs.first) * 0.1, _min);
2765 _max = std::max(obs.first + std::abs(obs.first) * 0.1, _max);
2771 ? std::pair(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN())
2774 ? std::pair(std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN())
2779 : std::numeric_limits<double>::quiet_NaN();
2780 if (!std::isnan(asi) && asi > 0) {
2782 _min = std::min(asi - std::abs(asi), _min);
2783 _max = std::max(asi + std::abs(asi), _max);
2790 auto makeHist = [&](
bool isAlt) {
2792 auto h =
new TH1D((isAlt) ?
"alt_toys" :
"null_toys",
"", 100, _min, _max + (_max - _min) * 0.01);
2793 h->SetDirectory(
nullptr);
2794 size_t nBadOrZero = 0;
2796 double w = std::isnan(std::get<1>(p)) ? 0 : std::get<2>(p);
2799 if (!std::isnan(std::get<1>(p)))
2800 h->Fill(std::get<1>(p), w);
2802 if (
h->GetEntries() > 0)
2803 h->Scale(1. /
h->Integral(0,
h->GetNbinsX() + 1));
2827 h->SetMarkerSize(0);
2832 auto nullHist = makeHist(
false);
2833 auto altHist = makeHist(
true);
2836 auto h = (nullHist->GetEntries()) ? nullHist : altHist;
2839 auto axis =
static_cast<TH1 *
>(
h->Clone(
".axis"));
2841 axis->SetStats(
false);
2842 axis->Reset(
"ICES");
2844 axis->SetLineWidth(0);
2846 axis->SetMinimum(1
e-7);
2847 axis->GetYaxis()->SetRangeUser(1
e-7, 10);
2848 axis->SetMaximum(
h->GetMaximum());
2850 l =
new TLegend(0.4, 0.7, 1. -
gPad->GetRightMargin(), 1. -
gPad->GetTopMargin());
2851 l->SetName(
"legend");
2853 l->SetBorderSize(0);
2856 l->ConvertNDCtoPad();
2858 for (
auto o : *
gPad->GetListOfPrimitives()) {
2865 if (
h->GetEntries() > 0) {
2868 h->Draw(
"axissame");
2871 if (
h->GetEntries() > 0) {
2874 h->Draw(
"axissame");
2878 l->AddEntry(nullHist);
2879 l->AddEntry(altHist);
2883 auto hh =
static_cast<TH1 *
>(nullHist->Clone(
"null_asymp"));
2885 hh->SetStats(
false);
2886 hh->SetLineStyle(2);
2888 for (
int i = 1; i <= hh->GetNbinsX(); i++) {
2891 _poi->getMin(
"physical"), _poi->getMax(
"physical")) -
2893 sigma_mu().first, _poi->getMin(
"physical"), _poi->getMax(
"physical")));
2896 hh =
static_cast<TH1 *
>(altHist->Clone(
"alt_asymp"));
2898 hh->SetStats(
false);
2899 hh->SetLineStyle(2);
2901 for (
int i = 1; i <= hh->GetNbinsX(); i++) {
2904 _poi->getMin(
"physical"), _poi->getMax(
"physical")) -
2906 sigma_mu().first, _poi->getMin(
"physical"), _poi->getMax(
"physical")));
2921 l->AddEntry(tl, label,
"l");
2923 if (nullHist->GetEntries() || altHist->GetEntries()) {
2925 label +=
" p_{toy}=(";
2926 label += (std::isnan(pNull.first)) ?
"-" :
TString::Format(
"%.4f #pm %.4f", pNull.first, pNull.second);
2927 label += (std::isnan(pAlt.first)) ?
",-" :
TString::Format(
",%.4f #pm %.4f", pAlt.first, pAlt.second);
2928 label += (std::isnan(pCLs.first)) ?
",-)" :
TString::Format(
",%.4f #pm %.4f)", pCLs.first, pCLs.second);
2930 if (label.Length() > 0)
2931 l->AddEntry(
"", label,
"");
2933 if (!std::isnan(pNullA.first) || !std::isnan(pAltA.first)) {
2935 label +=
" p_{asymp}=(";
2936 label += (std::isnan(pNullA.first)) ?
"-" :
TString::Format(
"%.4f #pm %.4f", pNullA.first, pNullA.second);
2937 label += (std::isnan(pAltA.first)) ?
",-" :
TString::Format(
",%.4f #pm %.4f", pAltA.first, pAltA.second);
2938 label += (std::isnan(pCLs.first)) ?
",-)" :
TString::Format(
",%.4f #pm %.4f)", pCLs.first, pCLs.second);
2940 if (label.Length() > 0)
2941 l->AddEntry(
"", label,
"");
2943 if (
auto ax =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(
".axis")))
2944 ax->GetYaxis()->SetRangeUser(1
e-7, 1);
2951 if (
v &&
v->hasRange(
"physical") &&
v->getMin(
"physical") != -std::numeric_limits<double>::infinity()) {
2961 if (
v &&
v->hasRange(
"physical") &&
v->getMin(
"physical") != -std::numeric_limits<double>::infinity()) {
2965 return (inWords) ?
TString::Format(
"-2log[L(%s,#hat{#hat{#theta}})/L(#hat{%s},#hat{#theta})]",
v->GetTitle(),
2971 if (
v &&
v->hasRange(
"physical") &&
v->getMin(
"physical") != -std::numeric_limits<double>::infinity()) {
2972 return (inWords) ?
TString::Format(
"Lower-Bound One-Sided Discovery PLR")
2981 if (
v &&
v->hasRange(
"physical") &&
v->getMin(
"physical") != -std::numeric_limits<double>::infinity()) {
2990 return "Test Statistic";
2996 return (
poi().empty()) ? nullptr : (
poi().first())->
GetName();
3001 return (first_poi ==
nullptr) ? std::numeric_limits<double>::quiet_NaN() : first_poi->getVal();
3006 auto first_poi =
dynamic_cast<RooAbsReal *
>(_alt_poi.first());
3007 return (first_poi ==
nullptr) ? std::numeric_limits<double>::quiet_NaN() : first_poi->getVal();
3014 throw std::runtime_error(
"HypoPoint has no POI, cannot set null value");
3020 auto first_poi =
dynamic_cast<RooAbsArg *
>(
poi().first());
3022 throw std::runtime_error(
"HypoPoint has no POI, cannot set alt value");
3031 if (nPoints < 0 || tsType < 0) {
3035 nPoints =
int(low + 0.5);
3039 if (alt_value == std::numeric_limits<double>::quiet_NaN()) {
3047 auto out =
hypoSpace(parName, pllType, alt_value);
3053 for (
auto p : out.poi()) {
3055 dynamic_cast<RooRealVar *
>(p)->setRange(
"physical", 0, std::numeric_limits<double>::infinity());
3056 Info(
"xRooNLLVar::hypoSpace",
"Setting physical range of %s to [0,inf]", p->GetName());
3057 }
else if (
auto v =
dynamic_cast<RooRealVar *
>(p);
v->hasRange(
"physical")) {
3058 v->removeMin(
"physical");
v->removeMax(
"physical");
3059 Info(
"xRooNLLVar::hypoSpace",
"Removing physical range of %s", p->GetName());
3073 out.AddPoints(parName, nPoints, low, high);
3075 if (!std::isnan(low) && !std::isnan(high) && !(std::isinf(low) && std::isinf(high))) {
3076 for (
auto p : out.poi()) {
3077 dynamic_cast<RooRealVar *
>(p)->setRange(
"scan", low, high);
3086 hs.
AddPoints(parName, nPoints, low, high);
3088 if (!std::isnan(low) && !std::isnan(high) && !(std::isinf(low) && std::isinf(high))) {
3089 for (
auto p : hs.
poi()) {
3090 dynamic_cast<RooRealVar *
>(p)->setRange(
"scan", low, high);
3100 auto _poi = std::unique_ptr<RooAbsCollection>(
3101 std::unique_ptr<RooAbsCollection>(
pdf()->getVariables())->selectByAttrib(
"poi",
true));
3103 throw std::runtime_error(
"You must specify a POI for the hypoSpace");
3104 return hypoSpace(_poi->first()->GetName(), nPoints, low, high, alt_value, pllType);
3113 if (strlen(parName)) {
3114 std::unique_ptr<RooAbsCollection> axes(s.
pars()->selectByName(parName));
3116 throw std::runtime_error(
"parameter not found");
3117 axes->setAttribAll(
"axis",
true);
3122 s.
fNlls[s.
fPdfs.begin()->second] = std::make_shared<xRooNLLVar>(*
this);
3125 for (
auto poi : s.
poi()) {
3126 poi->setStringAttribute(
"altVal", std::isnan(alt_value) ?
nullptr :
TString::Format(
"%f", alt_value));
3142 bool setReadonly =
false;
3143 if (
nllVar && !
nllVar->get()->getAttribute(
"readOnly")) {
3145 nllVar->get()->setAttribute(
"readOnly");
3156 {
"OneSidedPositive", 1},
3157 {
"OneSidedNegative", 2},
3158 {
"OneSidedAbsolute", 3},
3172 {
"asimov_cfit_null", 4},
3174 {
"cfit_lbound", 6}}));
3180 auto fitDS =
new RooDataSet(
"fits",
"fit summary data", fitDetails);
3184 for (
int i = 0; i < 7; i++) {
3185 std::shared_ptr<const RooFitResult> fit;
3187 case 0: fit =
ufit();
break;
3190 case 3: fit =
asimov() ?
asimov()->ufit(
true) :
nullptr;
break;
3191 case 4: fit =
asimov() ?
asimov()->cfit_null(
true) :
nullptr;
break;
3204 fitDS->add(fitDetails);
3207 fitDS->setGlobalObservables(fitMeta);
3218 nullToyDS->setGlobalObservables(nullMeta);
3221 std::vector<double> values;
3222 std::vector<double> weights;
3227 values.push_back(std::get<1>(t));
3228 weights.push_back(std::get<2>(t));
3231 nullToyDS->add(nullDetails, std::get<2>(t));
3234#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3244#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3255 std::vector<double> values;
3256 std::vector<double> weights;
3257 values.reserve(
altToys.size());
3258 weights.reserve(
altToys.size());
3265 altToyDS->setGlobalObservables(altMeta);
3267 values.push_back(std::get<1>(t));
3268 weights.push_back(std::get<2>(t));
3271 altToyDS->add(altDetails, std::get<2>(t));
3275#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3286#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3296 nllVar->get()->setAttribute(
"readOnly",
false);
3305 return "xValueWithError: nullptr\n";
3306 return Form(
"%f +/- %f",
v->first,
v->second);
3308std::string cling::printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m)
3312 std::string out =
"{\n";
3313 for (
auto [k,
v] : *
m) {
3314 out +=
"\"" + k +
"\" => " + printValue(&
v) +
"\n";
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
TMatrixTSym< Double_t > TMatrixDSym
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
AutoRestorer(const RooAbsCollection &s, xRooNLLVar *nll=nullptr)
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > fOldData
std::unique_ptr< RooAbsCollection > fSnap
static double k(const IncompatFunc &compatRegions, double pValue, double poiVal, double poiPrimeVal, double sigma_mu=0, double mu_low=-std::numeric_limits< double >::infinity(), double mu_high=std::numeric_limits< double >::infinity())
static double PValue(const IncompatFunc &compatRegions, double k, double mu, double mu_prime, double sigma_mu=0, double mu_low=-std::numeric_limits< double >::infinity(), double mu_high=std::numeric_limits< double >::infinity())
static int CompatFactor(const IncompatFunc &func, double mu_hat)
std::shared_ptr< RooFitResult > fr
!
static std::shared_ptr< ROOT::Fit::FitConfig > createFitConfig()
static std::shared_ptr< const RooFitResult > minimize(RooAbsReal &nll, const std::shared_ptr< ROOT::Fit::FitConfig > &fitConfig=nullptr, const std::shared_ptr< RooLinkedList > &nllOpts=nullptr)
static std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > generateFrom(RooAbsPdf &pdf, const RooFitResult &fr, bool expected=false, int seed=0)
double impact(const char *poi, const char *np, bool up=true, bool prefit=false, bool approx=false)
const RooFitResult * operator->() const
xRooFitResult cfit(const char *poiValues, const char *alias=nullptr)
std::shared_ptr< xRooNLLVar > fNll
xRooFitResult(const RooFitResult &fr)
double conditionalError(const char *poi, const char *nps, bool up=true, bool approx=false)
RooArgList ranknp(const char *poi, bool up=true, bool prefit=false, double approxThreshold=std::numeric_limits< double >::infinity())
std::shared_ptr< xRooNLLVar > nll() const
xRooFitResult ifit(const char *np, bool up, bool prefit=false)
std::shared_ptr< xRooNode > fNode
void Draw(Option_t *opt="")
std::shared_ptr< std::map< std::string, xRooFitResult > > fCfits
static std::set< int > allowedStatusCodes
std::shared_ptr< xRooHypoPoint > asimov(bool readOnly=false)
std::shared_ptr< RooStats::HypoTestResult > hypoTestResult
xValueWithError pAlt_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > fData
void addNullToys(int nToys=1, int seed=0, double target=std::numeric_limits< double >::quiet_NaN(), double target_nSigma=std::numeric_limits< double >::quiet_NaN())
std::vector< std::tuple< int, double, double > > altToys
std::shared_ptr< const RooFitResult > retrieveFit(int type)
std::shared_ptr< const RooAbsCollection > coords
xRooHypoPoint generateAlt(int seed=0)
std::shared_ptr< const RooFitResult > cfit_lbound(bool readOnly=false)
TString tsTitle(bool inWords=false) const
std::shared_ptr< const RooFitResult > fLbound_cfit
std::shared_ptr< xRooNLLVar > nllVar
xValueWithError ts_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError pNull_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > fNull_cfit
std::shared_ptr< const RooFitResult > ufit(bool readOnly=false)
std::shared_ptr< const RooFitResult > fUfit
xRooFit::Asymptotics::PLLType fPllType
std::vector< std::tuple< int, double, double > > nullToys
RooArgList alt_poi() const
xValueWithError getVal(const char *what)
std::shared_ptr< const RooFitResult > cfit_null(bool readOnly=false)
void Print(Option_t *opt="") const override
Print TNamed name and title.
void addAltToys(int nToys=1, int seed=0, double target=std::numeric_limits< double >::quiet_NaN(), double target_nSigma=std::numeric_limits< double >::quiet_NaN())
xRooHypoPoint generateNull(int seed=0)
xValueWithError ts_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
void setNullVal(double val)
xValueWithError pAlt_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
void addCLsToys(int nToys=1, int seed=0, double target=std::numeric_limits< double >::quiet_NaN(), double target_nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > fAlt_cfit
xValueWithError pNull_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
RooStats::HypoTestResult result()
xRooHypoPoint(std::shared_ptr< RooStats::HypoTestResult > htr=nullptr, const RooAbsCollection *_coords=nullptr)
size_t addToys(bool alt, int nToys, int initialSeed=0, double target=std::numeric_limits< double >::quiet_NaN(), double target_nSigma=std::numeric_limits< double >::quiet_NaN(), bool targetCLs=false, double relErrThreshold=2., size_t maxToys=10000)
void Draw(Option_t *opt="") override
Default Draw method for all objects.
std::shared_ptr< const RooFitResult > fGenFit
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > data()
void setAltVal(double val)
xValueWithError pX_toys(bool alt, double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError sigma_mu(bool readOnly=false)
std::shared_ptr< xRooHypoPoint > fAsimov
std::shared_ptr< const RooFitResult > cfit_alt(bool readOnly=false)
xValueWithError pCLs_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError pCLs_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError pll(bool readOnly=false)
bool AddModel(const xRooNode &pdf, const char *validity="")
std::shared_ptr< RooArgSet > pars() const
xRooFit::Asymptotics::PLLType fTestStatType
std::map< std::shared_ptr< xRooNode >, std::shared_ptr< xRooNLLVar > > fNlls
int AddPoints(const char *parName, size_t nPoints, double low, double high)
std::set< std::pair< std::shared_ptr< RooArgList >, std::shared_ptr< xRooNode > > > fPdfs
This xRooNLLVar object has several special methods, e.g.
std::shared_ptr< RooAbsCollection > fFuncGlobs
std::shared_ptr< const RooAbsCollection > fGlobs
double constraintTermVal() const
std::shared_ptr< RooLinkedList > fOpts
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > getData() const
void Draw(Option_t *opt="")
xRooFitResult minimize(const std::shared_ptr< ROOT::Fit::FitConfig > &=nullptr)
std::shared_ptr< RooArgSet > pars(bool stripGlobalObs=true) const
std::shared_ptr< RooAbsReal > func() const
void Print(Option_t *opt="")
xRooHypoSpace hypoSpace(const char *parName, int nPoints, double low, double high, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown, int tsType=0)
std::shared_ptr< ROOT::Fit::FitConfig > fFitConfig
bool setData(const std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > &_data)
double mainTermVal() const
double saturatedConstraintTermVal() const
std::shared_ptr< RooAbsCollection > fConstVars
RooAbsData * data() const
std::shared_ptr< RooAbsPdf > pdf() const
double mainTermPgof() const
double saturatedVal() const
void SetOption(const RooCmdArg &opt)
std::set< std::string > binnedChannels() const
double getEntryVal(size_t entry) const
ROOT::Math::IOptions * fitConfigOptions()
std::string fFuncCreationLog
xRooHypoPoint hypoPoint(const char *parName, double value, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown)
std::shared_ptr< RooAbsCollection > fFuncVars
double getEntryBinWidth(size_t entry) const
double simTermVal() const
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > generate(bool expected=false, int seed=0)
double extendedTermVal() const
TObject * Scan(const RooArgList &scanPars, const std::vector< std::vector< double > > &coords, const RooArgList &profilePars=RooArgList())
std::shared_ptr< RooAbsData > fData
std::shared_ptr< RooAbsPdf > fPdf
std::shared_ptr< ROOT::Fit::FitConfig > fitConfig()
RooConstraintSum * constraintTerm() const
xRooNLLVar(RooAbsPdf &pdf, const std::pair< RooAbsData *, const RooAbsCollection * > &data, const RooLinkedList &nllOpts=RooLinkedList())
double binnedDataTermVal() const
double saturatedMainTermVal() const
double mainTermNdof() const
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
xRooNode bins() const
bins of a channel or sample, or channels of a multi-channel pdf
Generic interface for defining configuration options of a numerical algorithm.
void SetValue(const char *name, double val)
generic methods for retrieving options
virtual void SetNamedValue(const char *, const char *)
Common abstract base class for objects that represent a value and a "shape" in RooFit.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
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.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void setAttribAll(const Text_t *name, bool value=true)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
Storage_t::size_type size() const
RooAbsArg * first() const
bool setCatIndex(const char *name, Int_t newVal=0, bool verbose=false)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
bool setRealValue(const char *name, double newVal=0.0, bool verbose=false)
Set value of a RooAbsRealLValue stored in set with given name to newVal No error messages are printed...
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
const char * getCatLabel(const char *name, const char *defVal="", bool verbose=false) const
Get state name of a RooAbsCategory stored in set with given name.
std::string contentsString() const
Return comma separated list of contained object names as STL string.
void setName(const char *name)
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 interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual bool setData(RooAbsData &, bool=true)
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Object to represent discrete states.
Named container for two doubles, two integers two object points and three string pointers that can be...
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
double getDouble(Int_t idx) const
Return double stored in slot idx.
Int_t getInt(Int_t idx) const
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
const char * getString(Int_t idx) const
Return string stored in slot idx.
Calculates the sum of the -(log) likelihoods of a set of RooAbsPfs that represent constraint function...
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
TObject * At(int index) const
Return object stored in sequential position given by index.
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
double getErrorLo() const
double getErrorHi() const
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
HypoTestResult is a base class for results from hypothesis tests.
void SetAltDetailedOutput(RooDataSet *d)
double fNullPValue
p-value for the null hypothesis (small number means disfavoured)
double fAlternatePValueError
error of p-value for the alternate hypothesis (small number means disfavoured)
void SetNullDetailedOutput(RooDataSet *d)
void SetBackgroundAsAlt(bool l=true)
void SetAltPValue(double pvalue)
void SetNullDistribution(SamplingDistribution *null)
void SetTestStatisticData(const double tsd)
void SetAltPValueError(double err)
void SetFitInfo(RooDataSet *d)
double fNullPValueError
error of p-value for the null hypothesis (small number means disfavoured)
void SetAltDistribution(SamplingDistribution *alt)
double fAlternatePValue
p-value for the alternate hypothesis (small number means disfavoured)
void SetNullPValue(double pvalue)
void SetNullPValueError(double err)
This class simply holds a sampling distribution of some test statistic.
A RooAbsArg implementing string values.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
const char * AsString() const
Return the date & time as a string (ctime() format).
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
void FillWeighted(Bool_t bPassed, Double_t weight, Double_t x, Double_t y=0, Double_t z=0)
Double_t GetEfficiencyErrorUp(Int_t bin) const
void Fill(Bool_t bPassed, Double_t x, Double_t y=0, Double_t z=0)
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
Set the name of the TNamed.
virtual Double_t GetPointY(Int_t i) const
virtual void Sort(Bool_t(*greater)(const TGraph *, Int_t, Int_t)=&TGraph::CompareX, Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111)
1-D histogram with a double per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Return minimum value larger than minval of bins in the range, unless the value has been overridden by...
Use the TLine constructor to create a simple line.
virtual TLine * DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Draw this line with new coordinates.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
@ kCanDelete
if object in a list can be deleted
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
Regular expression class.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Continue()
Resume a stopped stopwatch.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
TDatime GetTime() const
Get time from UUID.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
virtual TList * GetListOfPrimitives() const =0
virtual TObject * GetPrimitive(const char *name) const =0
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg GlobalObservablesSource(const char *sourceName)
double gaussian_pdf(double x, double sigma=1, double x0=0)
Probability density function of the normal (Gaussian) distribution with mean x0 and standard deviatio...
std::string collectionContents(const RooAbsCollection &coll)
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.
double gaussian_cdf_c(double x, double sigma=1, double x0=0)
Alternative name for same function.
static constexpr auto NumIntegration
Alias of MsgLevel::NumericIntegration for backwards compatibility.
Double_t Prob(Double_t chi2, Int_t ndf)
Double_t Poisson(Double_t x, Double_t par)
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE
void removeTopic(RooFit::MsgTopic oldTopic)