47#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
49#define protected public
70#define GETWS(a) a->_myws
71#define GETWSSETS(w) w->_namedSets
72#define GETWSSNAPSHOTS(w) w->_snapshots
73#define GETACTBROWSER(b) b->fActBrowser
74#define GETROOTDIR(b) b->fRootDir
75#define GETLISTTREE(b) b->fListTree
76#define GETDMP(o, m) o->m
101 return a->workspace();
109 return w->getSnapshots();
113 return b->GetActBrowser();
117 return b->GetRootDir();
121 return b->GetListTree();
123#define GETDMP(o, m) \
124 *reinterpret_cast<void **>(reinterpret_cast<unsigned char *>(o) + o->Class()->GetDataMemberOffset(#m))
175#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
179#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
208#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
214xRooNode::InteractiveObject *xRooNode::gIntObj =
nullptr;
215std::map<std::string, std::tuple<std::function<
double(
double,
double,
double)>,
bool>> xRooNode::auxFunctions;
216void xRooNode::SetAuxFunction(
const char *title,
const std::function<
double(
double,
double,
double)> &func,
219 auxFunctions[title] = std::make_tuple(func,
symmetrize);
238xRooNode::xRooNode(
const char *classname,
const char *
name,
const char *title)
244#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
245 w->_embeddedDataList.Delete();
247 xRooNode(*
w, std::make_shared<xRooNode>()).sterilize();
258xRooNode::xRooNode(
const char *
name,
const std::shared_ptr<TObject> &
comp,
const std::shared_ptr<xRooNode> &parent)
269#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
270 fComp = std::make_shared<RooWorkspace>(
"workspace",
name);
275 Error(
"xRooNode",
"Error reading json workspace %s",
name);
280 Error(
"xRooNode",
"json format workspaces available only in ROOT 6.26 onwards");
286 auto _file = std::make_shared<TFile>(
291 auto keys =
_file->GetListOfKeys();
293 for (
auto &&k : *keys) {
299#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
300 dynamic_cast<RooWorkspace *>(ws)->_embeddedDataList.Delete();
302 xRooNode(*ws, std::make_shared<xRooNode>()).sterilize();
308 fParent = std::make_shared<xRooNode>(
328 for (
auto f : *
gROOT->GetListOfFiles()) {
329 if ((
dynamic_cast<TFile *
>(
f)->GetVersion() / 100) > (
gROOT->GetVersionInt() / 100)) {
330 Warning(
"xRooNode",
"There is file open with version %d > current version %d ... results may be wrong",
331 dynamic_cast<TFile *
>(
f)->GetVersion(),
gROOT->GetVersionInt());
337 gROOT->GetListOfColors()->Clear();
338 for (
auto col : *
colors) {
339 gROOT->GetListOfColors()->Add(col);
345 for (
auto &
d : _ws->allData()) {
346 for (
auto &
a : *
d->get()) {
347 if (
auto v = _ws->var(
a->GetName());
v) {
348 v->setAttribute(
"obs");
349 }
else if (
auto c = _ws->cat(
a->GetName());
c) {
350 c->setAttribute(
"obs");
357 if (
checkCount == 0 && !_ws->allData().empty())
358 _ws->allData().back()->SetBit(1 << 20,
true);
361 for (
auto s : *_set) {
363 _ws->var(s->GetName())->setStringAttribute(
"nominal",
TString::Format(
"%f",
v->getVal()));
371 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
374 s->setAttribute(
"obs");
375 s->setAttribute(
"global");
378 const_cast<RooArgSet &
>(
v).setAttribAll(
"obs");
381 s->setAttribute(
"poi");
393 const_cast<RooArgSet &
>(
v).setAttribAll(
"np");
397 _ws->defineSet(
"globalObservables",
_allGlobs);
402 if (!_ws->allPdfs().empty()) {
405 for (
auto &
p :
np()) {
409 if (!
v->hasError()) {
418 "Inferring initial errors of %d parameters (%s%s) (give all nuisance parameters an error to avoid "
423 for (
auto &
a : *
this) {
427 if (
a->fFolder ==
"!pdfs") {
429 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
433 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
434 arg && arg->hasError()) {
435 v->setError(arg->getError());
451 if (
strlen(GetTitle()) == 0) {
478 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
479 return a->getStringAttribute(
"alias");
481 return comp->GetName();
500 if (o->isSelectedComp() && !val) {
503 o->setAttribute(
"hidden");
504 }
else if (!o->isSelectedComp() && !val) {
509 o->setAttribute(
"hidden",
false);
512 item->CheckItem(!o->getAttribute(
"hidden"));
513 if (o->isSelectedComp()) {
516 item->SetColor(
kGray);
521 if (
auto o =
get(); o) {
523 o->SetBit(1 << 20, val);
525 if (
auto _ws =
ws(); _ws) {
528 if (!_ws->genobj(fr->GetName())) {
530 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
535 _allVars = fr->floatParsFinal();
536 _allVars = fr->constPars();
537 for (
auto &i : fr->floatParsInit()) {
543 for (
auto oo : _ws->allGenericObjects()) {
545 ffr->ResetBit(1 << 20);
549 _ws->allVars() = fr->floatParsInit();
553 if (
auto first = item->GetParent()->GetFirstChild()) {
555 if (first->HasCheckBox()) {
556 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
557 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
559 }
while ((first = first->GetNextSibling()));
572 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
573 if (!b2 || !b2->GetBrowserImp()) {
580 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
582 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
584 b2->BrowseObject(
this);
589 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
596 _b->GotoDir(
nullptr);
607 if (
auto first = item->GetFirstChild()) {
609 if (first->HasCheckBox()) {
610 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
611 first->CheckItem(
_obj->get() &&
612 (
_obj->get()->TestBit(1 << 20) ||
615 }
while ((first = first->GetNextSibling()));
628 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
629 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corrcolztext\")",
nullptr, *
this));
630 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
631 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
638 s->SetFillAttributes();
645 Draw(
b->GetDrawOption());
647 }
catch (
const std::exception &
e) {
650 (
gROOT->GetListOfBrowsers()->At(0))
653 "Exception",
e.what(),
660 for (
auto &
c : *
this) {
661 if (!
c->fFolder.empty()) {
672 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
675 for (
auto &
v : *
this) {
676 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
677 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
684 _name = _name(1, _name.
Length());
685 b->Add(
v.get(), _name);
689 for (
auto &
v : *
this) {
692 if (
strcmp(
v->GetName(),
".folders") == 0)
696 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
704 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
712 :
v->get()->GetName());
714 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
716 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
724 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
730 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
739 if (
auto o =
v->get(); o)
740 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
742 if (
auto o =
v->get(); o)
745 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
746 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
749 if (
_fr->status() ||
_fr->covQual() != 3) {
750 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() ||
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
751 }
else if (
_fr->numStatusHistory() == 0) {
752 v->GetTreeItem(
b)->SetColor(
kGray);
755 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
757 v->GetTreeItem(
b)->SetColor(
kGray);
759 v->GetTreeItem(
b)->ClearColor();
763 if (
auto fits =
_htr->GetFitInfo()) {
764 for (
int i = 0; i <
fits->numEntries(); i++) {
766 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
767 v->GetTreeItem(
b)->SetColor(
kRed);
772 v->GetTreeItem(
b)->SetColor(
kBlue);
799 if (_name ==
".memory")
803 if (
auto o =
v->get(); o)
804 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
805 b->Add(
v.get(), _name, -1);
806 if (
auto o =
v->get(); o)
810 b->SetSelected(
this);
823 auto v = std::make_shared<xRooNode>(
vars());
834 if (
strcmp(
b->GetName(),
".vars") == 0)
857 if (
auto v = var();
v)
858 return v->getBinWidth(bin - 1, GetName());
863 if (
auto v = rvar();
v) {
864 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
865 :
v->getBinning(GetName()).binLow(bin - 1);
871 if (
auto v = rvar();
v)
872 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
878 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
885 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
897 std::vector<double> bins(nbins + 1);
898 for (
int i = 0; i <= nbins; i++)
899 bins.at(i) =
xbins[i];
900 return Set(nbins, &bins[0]);
912 Int_t FindFixBin(
double x)
const override {
return (binning()) ? (binning()->binNumber(
x) + 1) :
x; }
925 if (
name == o->GetName()) {
926 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
937 _parent = _parent->fParent;
943 std::shared_ptr<TObject> out;
944 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
945 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
946 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
951 if (
auto arg =
ws()->
data(
name.c_str()); arg) {
952 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
953 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
958 if (
auto arg =
ws()->genobj(
name.c_str()); arg) {
959 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
960 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
965 if (
auto arg =
ws()->embeddedData(
name.c_str()); arg) {
966 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
967 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
973 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
974 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
984 arg->treeNodeServerList(&nodes);
997 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1013 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1025 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1026 for (
auto &
v : _obs) {
1052 if (o !=
dynamic_cast<TObject *
>(
x)) {
1057 TString binningName = o->getStringAttribute(
"binning");
1058 auto _bnames =
x->getBinningNames();
1059 bool hasBinning =
false;
1061 if (
b == binningName) {
1069 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1071 o->setStringAttribute(
"binning",
nullptr);
1075 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1081 if (
b == o->GetName()) {
1082 binningName = o->GetName();
1086 if (binningName ==
"") {
1092 (std::list<double> *)(
nullptr),
1093 o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1094 std::numeric_limits<double>::infinity()));
1096 std::vector<double>
_bins;
1097 for (
auto &
b : *
bins) {
1105 _v->getBinning(o->GetName())
1110 binningName = o->GetName();
1121 if (
r->getBinning(binningName).isUniform()) {
1122 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1124 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1126 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1127 std::vector<double>
bins = {};
1128 for (
int i = 0; i <=
x->numBins(binningName); i++)
1130 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1133 std::map<int, std::string> cats;
1134 for (
auto &
c : *cat) {
1135 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1136 cats[
c.second] =
c.first;
1139 for (
auto &[
_,
label] : cats) {
1145 fXAxis->SetName(binningName);
1152 if (
auto o =
get(); o) {
1153 if (o->InheritsFrom(
"RooWorkspace"))
1155 if (o->InheritsFrom(
"RooAbsData"))
1157 if (o->InheritsFrom(
"RooSimultaneous"))
1160 if (o->InheritsFrom(
"RooProdPdf"))
1162 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1165 if (o->InheritsFrom(
"RooFitResult")) {
1166 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1167 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1168 "package.xpm",
"->Browse()");
1170 return "xRooFitRooFitResult";
1172 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1174 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1175 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1177 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1178 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1181 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1185 if (o->InheritsFrom(
"TStyle")) {
1186 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1187 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1188 "bld_colorselect.xpm",
"->Browse()");
1190 return "xRooFitTStyle";
1192 if (o->InheritsFrom(
"RooConstVar")) {
1198 return "TMethodBrowsable-leaf";
1200 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1201 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1202 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1205 return "xRooFitScanStyle";
1207 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1208 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1209 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1212 return "xRooFitTestStyle";
1214 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1215 return "TBranchElement-folder";
1216 if (o->InheritsFrom(
"RooAbsPdf")) {
1217 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1218 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1221 return "xRooFitPDFStyle";
1223 if (o->InheritsFrom(
"RooStats::ModelConfig")) {
1224 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitMCStyle",
true)) {
1225 gClient->GetMimeTypeList()->AddType(
"xRooFitMCStyle",
"xRooFitMCStyle",
"app_t.xpm",
"app_t.xpm",
1228 return "xRooFitMCStyle";
1232 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1234 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1235 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1236 std::numeric_limits<double>::infinity()))))) {
1241 return o->ClassName();
1252 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1254 if (o->InheritsFrom(
"PiecewiseInterpolation"))
1256 if (o->InheritsFrom(
"RooHistFunc"))
1257 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"ConstDensityHisto" :
"ConstHisto";
1258 if (o->InheritsFrom(
"RooBinWidthFunction"))
1260 if (o->InheritsFrom(
"ParamHistFunc"))
1262 if (o->InheritsFrom(
"RooRealVar"))
1264 if (o->InheritsFrom(
"RooConstVar"))
1272 xRooNode out(
".coords",
nullptr, *
this);
1274 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1304 if (
auto pos =
pName.Index(
'='); pos != -1) {
1305 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1313 _obs->setVal((high + low) / 2.);
1314 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1316 "coordRange",
"coordRange");
1318 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1323 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1326 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1327 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1331 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1333 throw std::runtime_error(
"Unknown observable, could not find");
1345 }
catch (
const std::exception &
e) {
1354 }
catch (
const std::exception &
e) {
1381 pdf =
p->pdfList().find(
child.GetName());
1384 auto i =
p->pdfList().index(*pdf);
1386#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1387 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1388#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1389 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1391 auto nset =
p->_pdfNSetList.At(i);
1392 p->_pdfNSetList.Remove(nset);
1395 if (
p->_extendedIndex == i)
1396 p->_extendedIndex = -1;
1397 else if (
p->_extendedIndex > i)
1398 p->_extendedIndex--;
1410 arg =
p2->components().find(
child.GetName());
1414#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1415 p2->_compRSet.remove(*arg);
1417 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1419 p2->removeServer(*arg,
true);
1429 }
catch (std::runtime_error &) {
1439 arg =
p4->funcList().find(
child.GetName());
1443 auto idx =
p4->funcList().index(arg);
1448 p4->removeServer(*arg,
true);
1450 std::vector<RooAbsArg *>
_coefs;
1452 if (
ii !=
size_t(idx))
1467 arg =
p5->pdfList().find(
child.GetName());
1471 auto idx =
p5->pdfList().index(arg);
1476 p5->removeServer(*arg,
true);
1478 std::vector<RooAbsArg *>
_coefs;
1480 if (
ii !=
size_t(idx))
1495 arg =
p6->list().find(
child.GetName());
1500 p6->removeServer(*arg,
true);
1508 auto arg =
w->components().find(
child.GetName());
1515 if (arg->hasClients()) {
1516 throw std::runtime_error(
1517 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1520 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1529 throw std::runtime_error(
"Removal not implemented for object type " +
1579 out->setAttribute(
"obs");
1580 out->setAttribute(
"global");
1583 throw std::runtime_error(
"Failed to add global observable");
1587 out->setAttribute(
"poi");
1595 throw std::runtime_error(
"Failed to add parameter of interest");
1599 if (!
fac.Contains(
"["))
1607 throw std::runtime_error(
1608 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1611 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1629 }
else if (!_ws->obj(
_fr->GetName())) {
1638 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1646 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1649 if (
auto _d = _ws->data(
child.GetName()); _d) {
1652 l.remove(*_d->get(),
true,
true);
1656 throw std::runtime_error(
"Cannot extend dataset with new columns");
1667 if (
auto __d = _ws->data(
child.GetName()))
1668 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1676 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1685 throw std::runtime_error(
"Cannot create dataset");
1690 throw std::runtime_error(
"Cannot add to null object with no parentage");
1692 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1697 std::rethrow_exception(std::current_exception());
1702 throw std::runtime_error(
"No object");
1712 throw std::runtime_error(
"Can only add datasets to a dataset");
1721 }
else if (
g->GetContent() !=
glob->GetContent()) {
1722 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1727 if (
auto _dglobs =
p->getGlobalObservables()) {
1737 for (
auto col : *_data->get()) {
1738 if (!
p->get()->contains(*col)) {
1739 ds->addColumn(*col);
1743 ds->SetTitle(
TString(
ds->GetTitle()) +
" + " + _data->GetTitle());
1749 throw std::runtime_error(
"Can only add histogram or dataset to data");
1753 throw std::runtime_error(
"Could not find pdf");
1754 auto _ax = _pdf->GetXaxis();
1756 throw std::runtime_error(
"Cannot determine binning to add data");
1765 l.remove(*
p->get(),
true,
true);
1769 throw std::runtime_error(
"Cannot extend dataset with new columns");
1776 for (
auto &o :
obs) {
1778 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1779 if (
v->getMin() <
dv->getMin())
1780 dv->setMin(
v->getMin());
1781 if (
v->getMax() >
dv->getMax())
1782 dv->setMax(
v->getMax());
1786 if (!
dc->hasLabel(
c->getCurrentLabel())) {
1787 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
1793 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1795 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1796 throw std::runtime_error(
1797 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1798 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1799 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1800 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1802 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1807 p->add(
obs,
_h->GetBinContent(i));
1817 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
1819 throw std::runtime_error(
"Something went wrong with pdf acquisition");
1826 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
1827 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1828 std::numeric_limits<double>::infinity()));
1829 !_boundaries && _ax->GetNbins() > 0) {
1830#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1831 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
1835 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1836 if (!_p->getStringAttribute(
"alias"))
1837 _p->setStringAttribute(
"alias", out->GetName());
1839 throw std::runtime_error(
1840 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
1846 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
1850 if (_pdf->canBeExtended()) {
1861 for (
auto i =
p->coefList().size(); i <
p->pdfList().size(); i++) {
1866 *
static_cast<RooAbsPdf *
>(
p->pdfList().at(i))));
1872 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
1873 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
1874 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
1875 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
1877 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
1909 std::shared_ptr<TObject> out;
1914 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
1919 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
1923 if (!out && !
child.fComp) {
1924 std::shared_ptr<RooAbsArg> _func;
1935 std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(), _ax->binning()->array());
1937 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
1939 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1940 }
else if (_obs.size() == 1) {
1943 auto _bnames = _x->getBinningNames();
1944 TString binningName =
p->getStringAttribute(
"binning");
1946 if (
b ==
p->GetName()) {
1947 binningName =
p->GetName();
1953 auto h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
1954 _x->getBinningPtr(binningName)->array());
1956 h->GetXaxis()->SetName(
1959 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1960 Info(
"Add",
"Created densityhisto factor %s (xaxis=%s) for %s", _func->GetName(), _obs.at(0)->GetName(),
1963 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
1969 _func->setStringAttribute(
"alias",
child.GetName());
1973 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
1977 _f->setAttribute(
"density");
1978 if (
_f->getAttribute(
"autodensity")) {
1980 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
1984 _f->setAttribute(
"autodensity",
false);
1985 _f->setValueDirty();
1994 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
1995 _f->getAttribute(
"density") ?
"densityhisto" :
"histo",
_f->GetName(),
p->GetName());
1999 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
2004 newName.ReplaceAll(
"_samples",
"");
2006 Warning(
"Add",
"converting samples to components");
2011 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2012 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2013 std::numeric_limits<double>::infinity()));
2014 !_boundaries && _ax->GetNbins() > 0) {
2015#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2016 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2020 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2021 if (!_p->getStringAttribute(
"alias"))
2022 _p->setStringAttribute(
"alias", out->GetName());
2024 throw std::runtime_error(
2025 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2032 if (!_p->canBeExtended()) {
2041 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2048 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
2050 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
2051 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2052 std::numeric_limits<double>::infinity()));
2053 !_boundaries && _ax->GetNbins() > 0) {
2054#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2057 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
2061 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
2062 if (!sumPdf->getStringAttribute(
"alias"))
2063 sumPdf->setStringAttribute(
"alias", out->GetName());
2066 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2067 if (!
_f->getStringAttribute(
"alias"))
2068 _f->setStringAttribute(
"alias", out->GetName());
2070 throw std::runtime_error(
2071 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2079 if (!
p->getStringAttribute(
"binning"))
2080 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2083 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2088 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2097 p->setStringAttribute(
"xvar",
nullptr);
2122 auto out = this->
operator[](
"components")->Add(child);
2141 for (
auto &
_pdfa :
pp->components()) {
2159 auto out = this->
operator[](
"samples")->Add(child);
2162 p2->setStringAttribute(
"xvar",
nullptr);
2175 child.convertForAcquisition(
2176 *
this,
child.get() ?
"" :
"func" );
2180 if (!
w->import(*_d)) {
2183 std::unique_ptr<RooAbsCollection>(
w->allVars().selectCommon(*_d->get()))->setAttribAll(
"obs");
2185 if (_d->getGlobalObservables()) {
2186 std::unique_ptr<RooAbsCollection>
globs(
w->allVars().selectCommon(*_d->get()));
2187 globs->setAttribAll(
"obs");
2188 globs->setAttribAll(
"global");
2192 throw std::runtime_error(
2203 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2206 std::string
catName =
"channelCat";
2207 if (!
child.empty()) {
2213 _cat->setAttribute(
"obs");
2215 Info(
"Add",
"Created pdf RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2220 if (
sOpt ==
"pdf") {
2226 }
else if (
sOpt ==
"channel") {
2231 std::shared_ptr<TObject> out;
2232 child.convertForAcquisition(*
this);
2235 }
else if (!
child.fComp) {
2238 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2242 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2248 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2251 }
else if (
sOpt ==
"dataset") {
2254 return (*this).datasets().Add(
child);
2312 a->setAttribute(
"hidden", set);
2323 return a->getAttribute(
"hidden");
2330 if (
get() ==
rhs.get()) {
2338 for (
auto &
c :
rhs.components()) {
2346 for (
auto &
f :
rhs.factors()) {
2354 for (
auto &
v :
rhs.variations()) {
2382 if (!
chans.empty()) {
2393 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2399 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2401 std::shared_ptr<RooProdPdf> pdf =
2402 std::dynamic_pointer_cast<RooProdPdf>(out.
acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2407 std::dynamic_pointer_cast<RooAbsArg>(out.
acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2423 static std::unique_ptr<cout_redirect>
capture;
2433 if (
sOpt.Contains(
"depth=")) {
2438 if (
sOpt.Contains(
"indent=")) {
2444 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2450 if (
get() &&
get() !=
this) {
2455 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2459 std::cout <<
"Minimization Logs:" << std::endl;
2460 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2474 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2480 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2488 }
else if (!
get()) {
2489 std::cout << std::endl;
2493 std::vector<std::string> folderNames;
2494 for (
auto &k : *
this) {
2495 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2496 folderNames.push_back(k->fFolder);
2499 for (
auto &
f : folderNames) {
2505 std::cout <<
f << std::endl;
2508 for (
auto &k : *
this) {
2509 if (k->fFolder !=
f) {
2515 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2519 auto _deps = k->coords(
false).argList();
2520 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2522 k->get()->Print(
sOpt);
2526 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2534 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2540 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2545 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2551 std::cout <<
" NULL " << std::endl;
2559 for (
size_t i = 0; i <
captureStr.size(); i++) {
2570 (
gROOT->GetListOfBrowsers()->At(0))
2585 double mean = std::numeric_limits<double>::quiet_NaN();
2586 double sigma = mean;
2595 mean = std::numeric_limits<double>::quiet_NaN();
2606 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2607 sigma =
v->getError();
2612 throw std::runtime_error(
"No error on parameter for poisson constraint");
2614 sigma = pow(
v->getVal() /
v->getError(), 2);
2622 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2623 globs->setConstant();
2624 globs->setAttribute(
"obs");
2625 globs->setAttribute(
"global");
2638 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
2644 mean - 10 * sigma, mean + 10 * sigma);
2645 globs->setAttribute(
"obs");
2646 globs->setAttribute(
"global");
2647 globs->setConstant();
2656 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
2665 throw std::runtime_error(
"Cannot constrain non arg");
2668 if (!
p->dependsOn(*
_me)) {
2669 throw std::runtime_error(
"Constraint does not depend on constrainee");
2678 throw std::runtime_error(
"Nowhere to put constraint");
2683 for (
auto d :
x->datasets()) {
2693 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
2702 for (
auto &
c : *
x) {
2708 return x->Multiply(
child);
2710 return x->Add(
child,
"+");
2733 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
2756 ?
fParent->mainChild()->GetName()
2763 throw std::runtime_error(
2783#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
2790 for (std::size_t i = 0; i <
pSet.size(); i++) {
2800 _bin->fBinNumber = -1;
2829 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
2834 std::rethrow_exception(std::current_exception());
2846 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
2850 }
else if (
sOpt ==
"norm") {
2857 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2862 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
2866 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2870 }
else if (
sOpt ==
"shape" ||
sOpt ==
"histo" ||
sOpt ==
"blankshape") {
2875 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
2876 h->SetBinContent(i, 1);
2881 h->SetTitle(
child.GetTitle());
2882 if (
sOpt.Contains(
"shape"))
2886 Info(
"Multiply",
"Scaled %s by new %s factor %s",
2891 }
else if (
sOpt ==
"overall") {
2893 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
2895 Info(
"Multiply",
"Scaled %s by new overall factor %s",
2899 }
else if (
sOpt ==
"func" &&
ws()) {
2904 Info(
"Multiply",
"Scaled %s by new func factor %s",
2917 std::shared_ptr<TObject> out;
2918 child.convertForAcquisition(*
this);
2929 if (
p->coefList().empty() && !
p->pdfList().empty()) {
2930 for (
auto _pdf :
p->pdfList()) {
2936 Info(
"Multiply",
"Created RooExtendedBinding coefficients for all pdfs of %s so that can multiply coef",
2938 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2939 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
2940 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2941 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
2943 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
2945 auto coefs =
p->coefList().at(i);
2954 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
2961 const_cast<RooArgList &
>(
p->coefList()).removeAll();
2969 throw std::runtime_error(
"this coefs case is not supported");
2973 std::shared_ptr<TObject> out;
2980 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
2982 _f &&
_f->getAttribute(
"autodensity")) {
2992 if (
_f->getAttribute(
"density")) {
2995 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
2999 _f->setValueDirty();
3006 _f->setAttribute(
"autodensity",
false);
3010 Info(
"Multiply",
"Created %s factor %s in %s",
3014 Info(
"Multiply",
"Created shape factor %s in %s",
child->GetName(),
p->GetName());
3017 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
3018#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3019 p->_compRSet.add(*
_f);
3027 for (
auto &_par :
_out.pars()) {
3030 for (
auto &
_constr : _par->constraints()) {
3038 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
3041 throw std::runtime_error(
"Couldn't find boundConstraint");
3043 _par->Constrain(_pdf);
3052 std::shared_ptr<TObject> out;
3053 child.convertForAcquisition(*
this);
3062 std::shared_ptr<RooAbsPdf> _pdf;
3079 _pdf->setStringAttribute(
"alias",
child.GetName());
3081 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
3082 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
3084 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
3089 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3090#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3092#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
3093 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
3097 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
3098 p2->_extendedIndex =
p2->_pdfList.size() - 1;
3109 std::shared_ptr<TObject> out;
3110 child.convertForAcquisition(*
this);
3116 TString s =
p3->getStringAttribute(
"global_factors");
3119 s += out->GetName();
3120 p3->setStringAttribute(
"global_factors", s);
3123 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3124 out->GetName(),
p3->GetName());
3135 std::set<RooAbsArg *> cl;
3136 for (
auto &arg :
p5->clients()) {
3142 if (cl.size() > 1) {
3147 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3153 for (
auto &
a :
p5->attributes())
3154 new_p->setAttribute(
a.c_str());
3155 for (
auto &
a :
p5->stringAttributes())
3156 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3157 if (!
new_p->getStringAttribute(
"alias"))
3158 new_p->setStringAttribute(
"alias",
p5->GetName());
3161 for (
auto arg : cl) {
3173 throw std::runtime_error(
3175 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3183 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3192 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3194 std::set<RooAbsArg *> cl;
3195 for (
auto &arg :
p5->clients()) {
3203 if (cl.size() > 1) {
3211 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3215 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3216 for (
auto arg : cl) {
3240 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3245 std::rethrow_exception(std::current_exception());
3258 if (
auto pos =
label.find(
'='); pos != std::string::npos)
3260 if (!s->indexCat().hasLabel(
label)) {
3263 std::shared_ptr<TObject> out;
3264 child.convertForAcquisition(*
this);
3267 }
else if (!
child.fComp) {
3270 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3273 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3274 s->addPdf(*_pdf,
label.c_str());
3286 child.convertForAcquisition(*
this);
3288 if (!_c &&
child.get()) {
3289 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3291#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3292 double value = (_c ? _c->getVal() :
p->_nominal);
3295 double value = (_c ? _c->getVal() :
p->nominal());
3300 if (
cName ==
"nominal") {
3304 if (
cName.CountChar(
'=') != 1) {
3305 throw std::runtime_error(
"unsupported variation form");
3310 throw std::runtime_error(
"unsupported variation magnitude");
3323 if (!
p->findServer(*
v)) {
3324#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3325 p->_paramList.add(*
v);
3326 p->_low.push_back(0);
3327 p->_high.push_back(0);
3328 p->_interpCode.push_back(4);
3331 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3332 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3333 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3335 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3340 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3343 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3346 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3349 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3359 if (
cName.CountChar(
'=') != 1) {
3360 throw std::runtime_error(
"unsupported variation form");
3365 throw std::runtime_error(
"unsupported variation magnitude");
3367#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3370 throw std::runtime_error(
3371 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3376 throw std::runtime_error(
3377 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3383 for (
auto par :
p2->paramList()) {
3384 if (
parName == par->GetName()) {
3398 std::shared_ptr<RooHistFunc>
up(
3400 std::shared_ptr<RooHistFunc>
down(
3403#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3404 std::unique_ptr<RooDataHist>
h1(
3406 std::unique_ptr<RooDataHist>
h2(
3408 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3414 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3415 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3416#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3417 p2->_highSet.add(*
ups.get());
3418 p2->_lowSet.add(*
downs.get());
3419 p2->_interpCode.push_back(4);
3420 p2->_paramSet.add(*
v);
3424 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3427 p2->setValueDirty();
3431 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3432 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3433 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3454 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3455 throw std::runtime_error(
"Cannot vary pure constants");
3461 std::set<RooAbsArg *> cl;
3462 for (
auto &arg :
p3->clients()) {
3467 if (cl.size() > 1) {
3472 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3475 p3->setStringAttribute(
"origName",
p3->GetName());
3477 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3480 std::vector<double>(), std::vector<double>());
3483 for (
auto &
a :
p3->attributes())
3484 new_p->setAttribute(
a.c_str());
3485 for (
auto &
a :
p3->stringAttributes())
3486 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3490 for (
auto arg : cl) {
3501 std::set<RooAbsArg *> cl;
3502 for (
auto &arg :
p4->clients()) {
3507 if (cl.size() > 1) {
3512 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
3515 p4->setStringAttribute(
"origName",
p4->GetName());
3517 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
3522 for (
auto &
a :
p4->attributes())
3523 new_p->setAttribute(
a.c_str());
3524 for (
auto &
a :
p4->stringAttributes())
3525 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3529 for (
auto arg : cl) {
3572 a->setStringAttribute(
"alias",
GetName());
3575 throw std::runtime_error(
"Cannot determine type");
3580 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
3597 throw std::runtime_error(
"no xaxis");
3602 if (
h->GetXaxis()->IsVariableBinSize()) {
3603 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
3611 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
3620 throw std::runtime_error(
"Failed setting stat error");
3624 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
3636 throw std::runtime_error(
"Assignment failed");
3666 std::map<RooAbsRealLValue *, double>
valsToSet;
3668 auto idx = pattern.
Index(
'=');
3671 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3672 for (
auto p :
_pars.argList()) {
3674 p->setAttribute(
"Constant",
true);
3675 if (!std::isnan(val)) {
3687 if (
d->get()->TestBit(1 << 20)) {
3697 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
3698 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
3699 auto fr = _nll.minimize();
3702 throw std::runtime_error(
"Fit Failed");
3705 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
3709 (
gROOT->GetListOfBrowsers()->At(0))
3712 if (fr->status() != 0) {
3714 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3717 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
3718 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
3719 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3724 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3727 }
catch (
const std::exception &
e) {
3730 (
gROOT->GetListOfBrowsers()->At(0))
3741 }
catch (
const std::exception &
e) {
3744 (
gROOT->GetListOfBrowsers()->At(0))
3747 "Exception",
e.what(),
3763 if (
d->get()->TestBit(1 << 20)) {
3769 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
3772 auto idx = pattern.
Index(
'=');
3775 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3776 for (
auto par :
_pars.argList()) {
3778 par->setAttribute(
"Constant",
true);
3779 if (!std::isnan(val)) {
3797 (
gROOT->GetListOfBrowsers()->At(0))
3800 "Scan Finished with Bad Status Code",
3806 if (
auto res =
hs.result())
3812 }
catch (
const std::exception &
e) {
3815 (
gROOT->GetListOfBrowsers()->At(0))
3826 }
catch (
const std::exception &
e) {
3835#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
3840 for (
auto a : *
this) {
3847 for (
auto c : args) {
3853 f.SetParName(i,
c->GetName());
3855 f.SetParLimits(i,
v->getMin(),
v->getMax());
3856 if (
v->isConstant())
3857 f.FixParameter(i,
v->getVal());
3859 f.SetParameter(i,
v->getVal());
3860 f.SetParError(i,
v->getError());
3871 (
gROOT->GetListOfBrowsers()->At(0))
3877 for (i = 0; i <
f.GetNpar(); i++) {
3878 auto c = args.
find(
f.GetParName(i));
3883 f.GetParLimits(i, low, high);
3885 v->setConstant(low);
3887 v->setRange(low, high);
3897 throw std::runtime_error(
"Failed to SetContent");
3898 }
catch (
const std::exception &
e) {
3912 std::shared_ptr<TH1D>
h;
3913 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
3916 if (
_b->isUniform()) {
3921 h->SetOption(
"nostyle");
3922 h->SetDirectory(
nullptr);
3938 auto _ax = (bin) ?
GetXaxis() :
nullptr;
3940 throw std::runtime_error(
"Cannot determine binning to fill data");
3942 if (_ax && _ax->GetNbins() < bin) {
3943 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
3944 _ax->GetName(), _ax->GetNbins()));
3950 for (
auto _c :
coords()) {
3954 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
3962 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
3965 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
3974 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
3975 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
4007 l.remove(*_data->get(),
true,
true);
4012 _data->addColumn(*
x);
4022 for (
auto &o :
obs) {
4024 if (
auto dv =
dynamic_cast<RooRealVar *
>(_data->get()->find(
v->GetName()));
dv) {
4025 if (
v->getMin() <
dv->getMin())
4026 dv->setMin(
v->getMin());
4027 if (
v->getMax() >
dv->getMax())
4028 dv->setMax(
v->getMax());
4031 if (
auto dc =
dynamic_cast<RooCategory *
>(_data->get()->find(
c->GetName()));
dc) {
4032 if (!
dc->hasLabel(
c->getCurrentLabel())) {
4033 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
4042 if (
auto _nentries = std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula))->numEntries();
4047 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
4050 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4052 _data->add(*_obs,
_reduced->weight());
4055 for (
int i = 1; i <= _ax->GetNbins(); i++) {
4059 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
4065 if (std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula2))->numEntries() > 0) {
4068 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4070 _data->add(*_obs,
_reduced->weight());
4074 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
4081 throw std::runtime_error(
"RooDataHist not supported yet");
4086 if (!par ||
strlen(par) == 0) {
4089 return it->SetBinContent(bin,
value);
4101 if (!par ||
strlen(par) == 0) {
4114 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
4117#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4130 auto bin_pars =
f->dataHist().get(bin - 1);
4131 if (
f->getAttribute(
"density")) {
4139 f->setStringAttribute(
"symmetrized_by",
nullptr);
4141 x->setStringAttribute(
"symmetrizes",
nullptr);
4142 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4156 f2->setNominal(
value);
4165 push_back(std::make_shared<xRooNode>(
data));
4172 return node->SetBinContent(bin,
value);
4179 push_back(std::make_shared<xRooNode>(
data));
4186 return node->SetContents(obj);
4224 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4233 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4238 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4245 h->SetName(
"statFactor");
4247 h->SetOption(
"blankshape");
4256 throw std::runtime_error(
"Failed creating stat shapeFactor");
4262 TString prefix =
f->getStringAttribute(
"statPrefix");
4263 if (
value && prefix ==
"") {
4267 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4268 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4275 Form(
"%s_bin%d", prefix.
Data(), bin), 1);
4276#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4283 if (
newVar.get() != var) {
4287 for (std::size_t i = 0; i <
pSet.size(); i++) {
4288 if (
int(i) != bin - 1) {
4303 auto bin_pars =
f->dataHist().get(bin - 1);
4305 if (
f->getAttribute(
"density")) {
4311 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4312 if (s.find(
"sumw_") == 0) {
4314 }
else if (s.find(
"sumw2_") == 0) {
4318 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4320 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4321 rrv->setConstant(
false);
4326 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4331 double _min = tau * (1. - 5. * sqrt(1. / tau));
4332 double _max = tau * (1. + 5. * sqrt(1. / tau));
4335 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4336 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
4338 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
4342 v.constraints().Remove(*
_constr.at(0));
4361 throw std::out_of_range(
name +
" does not exist");
4383 xRooNode out(
".constraints",
nullptr, *
this);
4396 for (
auto &
c :
n.bins()) {
4407 for (
auto p : _ws->allPdfs()) {
4410 if (
p->dependsOn(par)) {
4411 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4419 for (
auto p : o->pdfList()) {
4422 if (
p->dependsOn(par)) {
4423 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4429 for (
auto &
p :
vars()) {
4435 if (
v->getAttribute(
"obs"))
4445 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
4446 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
4448 for (
auto &
c : out) {
4449 if (
c.get() == it->get())
4454 std::string
_cName =
c->GetName();
4458 }
while (
_cName.find(
';') != std::string::npos);
4460 _cName = it->get()->GetName();
4464 }
while (
_cName.find(
';') != std::string::npos);
4472 c->TNamed::SetName(
_cName.c_str());
4486 for (
auto &o : out) {
4487 o->TNamed::SetName(o->get()->GetName());
4508 while (
sOpt2.Contains(
"=")) {
4509 auto pos =
sOpt2.Index(
"=");
4510 auto start =
sOpt2.Index(
";") + 1;
4534 if (
auto pos =
varName.Index(
';'); pos != -1) {
4544 binningName =
ax->GetName();
4545 }
else if (
acquirer.obs().size() == 1)
4549 h->GetXaxis()->GetXmax());
4550 if (
x->getMin() >
h->GetXaxis()->GetXmin())
4551 x->setMin(
h->GetXaxis()->GetXmin());
4552 if (
x->getMax() <
h->GetXaxis()->GetXmax())
4553 x->setMax(
h->GetXaxis()->GetXmax());
4554 if (!
x->hasBinning(binningName.c_str())) {
4555 if (
h->GetXaxis()->IsVariableBinSize()) {
4556 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
4559 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
4560 binningName.c_str());
4562 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
4563 if (
x->getBinningNames().size() == 2) {
4565 x->setBinning(
x->getBinning(binningName.c_str()));
4569 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
4570 throw std::runtime_error(
4571 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
4575 std::shared_ptr<RooAbsArg>
_f;
4582 _f->setStringAttribute(k.c_str(),
v.c_str());
4584 x->setAttribute(
"obs",
true);
4585 }
else if (
sOpt2.Contains(
"shape")) {
4587 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
4588 std::shared_ptr<RooAbsArg> arg;
4589 if (
sOpt2.Contains(
"blankshape")) {
4595 if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
4597 h->GetBinContent(i + 1),
h->GetMinimumStored(),
4598 h->GetMaximumStored());
4601 h->GetBinContent(i + 1));
4609 x->setBinning(
x->getBinning(binningName.c_str()));
4611#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4612 dynamic_cast<ParamHistFunc *
>(
_f.get())->_paramSet.setName(
"paramSet");
4615 .setName(
"paramSet");
4617 x->setBinning(*
tmp);
4620 _f->setStringAttribute(k.c_str(),
v.c_str());
4624 binningName.c_str() );
4626 throw std::runtime_error(
"Couldn't make data hist");
4631 f->setAttribute(
"autodensity");
4635 _f->setStringAttribute(k.c_str(),
v.c_str());
4639 _f->setStringAttribute(
"xvar",
x->GetName());
4640 _f->setStringAttribute(
"binning", binningName.c_str());
4647 _f = std::dynamic_pointer_cast<RooAbsArg>(
tmp.fComp);
4650 _f->setStringAttribute(
"xvar",
x->GetName());
4651 _f->setStringAttribute(
"binning", binningName.c_str());
4691 if (arg->getStringAttribute(
"style")) {
4692 t = arg->getStringAttribute(
"style");
4702 std::shared_ptr<TStyle>
style;
4704 if (!
gROOT->GetStyle(t)) {
4727 if (arg && !arg->getStringAttribute(
"style")) {
4728 arg->setStringAttribute(
"style",
style->GetName());
4746 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
4747 auto out_arg = _ws->arg(
a->GetName());
4754 if (
aName !=
a->GetName())
4755 Warning(
"acquire",
"Renaming to %s",
a->GetName());
4759 if (
auto res = _ws->factory(arg->GetName()); res) {
4766 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
4787 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
4793 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
4794 }
else if (arg->InheritsFrom(
"RooFitResult") || arg->InheritsFrom(
"TTree") || arg->IsA() ==
TStyle::Class() ||
4795 arg->InheritsFrom(
"RooStats::HypoTestInverterResult") ||
4796 arg->InheritsFrom(
"RooStats::HypoTestResult")) {
4807 if (
aName != arg->GetName()) {
4808 Warning(
"acquire",
"Renaming to %s", arg->GetName());
4810 if (_ws->import(*arg,
false )) {
4814 out_arg = _ws->genobj(arg->GetName());
4839 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
4845 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
4851 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
4857 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
4859 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
4901 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
4904 _x->setBinning(binning,
a->
GetName());
4905 _x->getBinning(
a->GetName()).SetTitle(title);
4906 if (_x->getBinningNames().size() == 2) {
4908 _x->setBinning(_x->getBinning(
a->GetName()));
4913 if (_x->getMax() < high)
4915 if (_x->getMin() > low)
4921 _x->setAttribute(
"obs");
4924 a->setStringAttribute(
"xvar", _x->GetName());
4925 a->setStringAttribute(
"binning",
a->GetName());
4935 if (
ax->IsVariableBinSize()) {
4936 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
4938 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
4944 return find(
name,
false) !=
nullptr;
4952 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
4953 for (
auto &
child : *
this) {
4956 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
4969 for (
auto &
child2 :
x.browse()) {
4995 auto out = std::make_shared<xRooNode>(obj, *
this);
5010 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5012 for (
auto &
child : *
this) {
5024 for (
auto &
child2 :
x.browse()) {
5036 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
5054 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
5057 out->SetName(
"!pdfs");
5060 return out->operator[](
name.substr(
partname.length() + 1));
5068 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5070 if (!
b || !
b->GetBrowserImp())
5077 if (!
b->GetBrowserImp())
5093 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5095 if (!
b || !
b->GetBrowserImp())
5102 if (
b->GetBrowserImp()) {
5120 a->setStringAttribute(
"alias",
name);
5121 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5122 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
5124 item->SetText(
name);
5147 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5148 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5149 for (
auto &
c :
nn) {
5150 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5153 return std::shared_ptr<xRooNode>(
nullptr);
5158 const std::vector<std::shared_ptr<xRooNode>> &
nn(
n);
5159 for (
auto &
c :
nn) {
5172 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5173 for (
auto &
c :
nn2) {
5174 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5178 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5217 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5230 emplace_back(std::make_shared<xRooNode>(
_coefs));
5242 for (
int i = 0; i < arg->numProxies(); i++) {
5243 auto _proxy = arg->getProxy(i);
5253 for (
auto &
child : *
this) {
5261 for (
auto a2 : *s) {
5262 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5263 if (arg->numProxies() != 1) {
5264 c->fFolder = std::string(
"!.") +
5297 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5310 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5312 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5318 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5319 for (
auto &
c :
nn) {
5342 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
5343 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
5349 if (
auto fit =
hp->ufit()) {
5350 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
5352 if (
auto fit =
hp->cfit_null()) {
5353 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
5355 if (
auto fit =
hp->cfit_alt()) {
5356 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
5358 if (
auto fit =
hp->gfit()) {
5359 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
5361 if (
auto asi =
hp->asimov()) {
5362 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
5363 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
5365 asiP->TNamed::SetName(
"asimov");
5366 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
5372 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
5373 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
5374 if (it->get()->fTimes == 0) {
5375 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5377 if (
b &&
b->GetBrowserImp()) {
5424 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
5426 for (
auto o :
vars()) {
5429 out.emplace_back(o);
5440 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
5442 for (
auto o :
obs()) {
5445 out.emplace_back(o);
5456 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
5458 for (
auto o :
obs()) {
5461 out.emplace_back(o);
5476 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
5478 for (
auto o :
vars()) {
5481 out.emplace_back(o);
5492 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
5494 for (
auto o :
pars()) {
5497 out.emplace_back(o);
5509 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
5511 for (
auto o :
pars()) {
5514 out.emplace_back(o);
5526 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
5528 for (
auto o :
pars()) {
5531 out.emplace_back(o);
5543 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
5545 for (
auto o :
pars()) {
5547 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
5550 out.emplace_back(o);
5561 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
5563 for (
auto o :
pars()) {
5567 out.emplace_back(o);
5578 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
5581 for (
auto &
x : *
this) {
5582 for (
auto &
y :
x->vars()) {
5597 if (!
c->getAttribute(
"global")) {
5599 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5601 if (
c->getAttribute(
"global")) {
5602 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5603 _globs.back()->fFolder =
"!globs";
5604 }
else if (
c->getAttribute(
"obs")) {
5605 out.back()->fFolder =
"!robs";
5606 }
else if (
c->getAttribute(
"poi")) {
5607 out.back()->fFolder =
"!poi";
5608 }
else if (
c->getAttribute(
"np") ||
5610 out.back()->fFolder =
"!np";
5612 out.back()->fFolder =
"!floats";
5614 out.back()->fFolder =
"!pp";
5620 out.emplace_back(
g);
5623 for (
auto a : *
p2->get()) {
5624 a->setAttribute(
"obs");
5625 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5628 if (
auto _dglobs =
p2->getGlobalObservables()) {
5630 a->setAttribute(
"obs");
5631 a->setAttribute(
"global");
5632 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5637 a->setAttribute(
"obs");
5638 a->setAttribute(
"global");
5639 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5642 }
else if (
auto _ws =
ws(); _ws) {
5645 a->setAttribute(
"obs");
5646 a->setAttribute(
"global");
5647 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5651 for (
auto &
_g :
_gl->second) {
5652 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5653 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5655 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5664 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5665 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5667 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5673 for (
auto a :
w->allVars()) {
5674 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5678 for (
auto a :
w->allCats()) {
5679 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5688 xRooNode out(
".components",
nullptr, *
this);
5693 for (
auto &o :
p->pdfList()) {
5696 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5714 for (
auto &o :
p2->funcList()) {
5717 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5721 for (
auto &o :
p3->list()) {
5722 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5725 for (
auto &
a : *
p4) {
5726 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5729 for (
auto &o :
p5->components()) {
5732 bool hasClients =
false;
5733 for (
auto &
c : o->clients()) {
5734 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
5741 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5742 if (o->InheritsFrom(
"RooAbsPdf")) {
5743 out.back()->fFolder =
"!pdfs";
5745 out.back()->fFolder =
"!scratch";
5748 for (
auto &o :
p5->allGenericObjects()) {
5752 s = s(0, s.
Index(
';'));
5753 if (
auto _pdf = out.
find(s.
Data()); _pdf) {
5755 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
5762 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
5764 out.back()->fFolder =
"!fits";
5766 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5768 out.back()->fFolder =
"!styles";
5769 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
5770 out.back()->fFolder =
"!scans";
5771 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::ModelConfig") == 0) {
5772 out.back()->fFolder =
"!models";
5774 out.back()->fFolder =
"!objects";
5781 if (k.find(
"CACHE_") == 0)
5783 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
5784 out.back()->fFolder =
"!sets";
5788 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
5790 while ((
snap = iter->Next())) {
5791 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
5792 out.back()->fFolder =
"!snapshots";
5797 out.emplace_back(std::make_shared<xRooNode>(
".pdf", *
mc->GetPdf(), *
this));
5799 if (
mc->GetExternalConstraints()) {
5800 out.emplace_back(std::make_shared<xRooNode>(
".extCons", *
mc->GetExternalConstraints(), *
this));
5806 out.emplace_back(
c);
5813 out.emplace_back(
c);
5827 xRooNode out(
".bins",
nullptr, *
this);
5830 std::map<int, std::shared_ptr<xRooNode>> cats;
5831 for (
auto &
c :
p->indexCat()) {
5832 auto pp =
p->getPdf(
c.first.c_str());
5836 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
5838 for (
auto &[
_,
n] : cats)
5839 out.emplace_back(
n);
5842#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5845 auto &
pSet =
phf->paramList();
5847 for (
auto par :
pSet) {
5848 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
5849 out.back()->fBinNumber = i;
5853 for (
int i = 1; i <=
ax->GetNbins(); i++) {
5859 for (
auto &
ss :
f->bins()[i - 1]->factors())
5866 out.emplace_back(std::make_shared<xRooNode>(
5867 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
5873#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5879 out.back()->fBinNumber = i;
5904 std::make_shared<RooProduct>(
".recursiveCoefs",
5909 auto mem = out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
5910 mem->emplace_back(std::make_shared<xRooNode>(
ourCoefs));
5923 if (!parent->fComp) {
5924 while (!parent->fComp && parent->fParent) {
5925 parent = parent->fParent;
5928 parent = parent->fParent;
5934 for (
auto &o :
p->funcList()) {
5936 if (i >=
p->coefList().size()) {
5938 coefs.add(
p->coefList());
5940 coefs.add(*
p->coefList().at(i));
5947 if (
p2->coefList().empty()) {
5952 for (
auto &o :
p2->pdfList()) {
5954 if (i >=
p2->coefList().size()) {
5958 coefs.add(*
p2->coefList().at(i));
5972 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
5973 "Coefficients of",
coefs));
5974 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
5975 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
5978 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
5980 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
5982 if (!
coefs.empty()) {
5986 }
else if (
coefs.size() == 1) {
5988 if (!
coefs.empty()) {
6007 xRooNode out(
".factors",
nullptr, *
this);
6012 a->setStringAttribute(
"alias",
"samples");
6014 a2->setStringAttribute(
"alias",
"components");
6016 int _npdfs =
p->pdfList().size();
6017 for (
auto &o :
p->pdfList()) {
6018 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6020 out.back()->fFolder =
"!constraints";
6023 for (
auto &o :
p2->components()) {
6024 if (o->InheritsFrom(
"RooProduct")) {
6026 auto x =
xRooNode(
"tmp", *o, *
this).factors();
6028 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
6031 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6040 for (
auto a :
w->allFunctions()) {
6041 if (_obs.contains(*
a))
6044 for (
auto c :
a->clients()) {
6046 if (
c->InheritsFrom(
"RooProduct")) {
6052 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6096 xRooNode out(
".variations",
nullptr, *
this);
6109#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6110 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
6112 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
6114 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
6116 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
6117 *
p2->highList().at(i), *
this));
6118 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
6119 *
p2->lowList().at(i), *
this));
6122#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6123 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
6124 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
6125 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
6127 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
6131 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
6132 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
6133 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
6135 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
6159 for (
auto &k : *
this) {
6168 xRooNode out(
".datasets()",
nullptr, *
this);
6174 for (
auto &
d : _ws->allData()) {
6175 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
6176 out.back()->fFolder =
"!datasets";
6189 for (
auto _c :
coords()) {
6193 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6202 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6207 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6214 for (
auto cat : s->indexCat()) {
6215 if (!s->getPdf(cat.first.c_str())) {
6227 cutobs.add(s->indexCat());
6236 for (
auto &
child : *
this) {
6242 for (
auto &
d :
_wsNode.datasets()) {
6248 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6255 out.emplace_back(std::make_shared<xRooNode>(
6260 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6262 if (
d->get()->TestBit(1 << 20))
6263 out.back()->get()->
SetBit(1 << 20);
6265 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6267 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6309 for (
auto o : *
fromPad->GetListOfPrimitives()) {
6329 cat->numTypes(), 0, cat->numTypes());
6331 std::map<int, std::string> cats;
6332 for (
auto &
c : *cat) {
6333 cats[
c.second] =
c.first;
6335 for (
auto &[
_,
label] : cats) {
6339 auto _binning =
v->getBinningPtr(
nullptr);
6340 if (_binning->isUniform()) {
6344 v->numBins(), _binning->lowBound(), _binning->highBound());
6349 v->numBins(), _binning->array());
6353 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
6366 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
6387 : (
theHist->GetXaxis()->IsAlphanumeric() ?
theHist->GetXaxis()->GetTimeFormatOnly()
6388 :
theHist->GetXaxis()->GetName()));
6408 for (
int i = 0; i <
nevent; i++) {
6413 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
6419 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
6452 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
6454 double val =
theHist->GetBinContent(i + 1);
6457 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
6460 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
6473 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
6477 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
6478 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
6512 throw std::runtime_error(
"Cannot build graph");
6518 if (
auto _w =
ws();
_w) {
6520 for (
auto o :
_w->allGenericObjects()) {
6522 _fr->ResetBit(1 << 20);
6525 res->SetBit(1 << 20);
6527 auto allVars =
_w->allVars();
6532 throw std::runtime_error(
"Not supported yet");
6546 throw std::runtime_error(
"Not a RooFitResult");
6557#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
6569 if (
sOpt ==
"prefit") {
6583 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
6584 fr->setFinalParList(*
_pars);
6585 for (
auto &
p : fr->floatParsFinal()) {
6589 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
6592 std::shared_ptr<xRooNode>
pConstr;
6599 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
6600 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
6617 for (
auto &_d :
pConstr->vars()) {
6618 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
6642 if (!
_v->getStringAttribute(
"nominal"))
6654 _args.add(
_globs.argList());
6655 fr->setConstParList(_args);
6658 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6661 fr->setInitParList(*
_snap);
6666 if (
auto _w =
ws();
_w) {
6671 for (
auto p :
pars()) {
6675 _fr->floatParsFinal().getCatIndex(cat->GetName(), std::numeric_limits<int>().max())) {
6680 if (
_fr->floatParsFinal().find(
p->GetName()) ||
6681 std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6687 if (
_fr->constPars().find(
p->GetName()) ||
6689 _fr->floatParsFinal().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6698 std::unique_ptr<RooArgList>
_pars(
6700 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
6702 fr->setFinalParList(*
_pars);
6707 for (
size_t i = 0; i <
_pars->size(); i++) {
6709 cov(i, i) = pow(
v->getError(), 2);
6714 fr->setCovarianceMatrix(
cov);
6721 _args.add(
_globs.argList());
6722 fr->setConstParList(_args);
6725 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6728 fr->setInitParList(*
_snap);
6731 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
6735 for (
auto o :
_w->allGenericObjects()) {
6761 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
6763 fr->setFinalParList(*
_pars);
6769 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
6770 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
6771 cov(i,
j) = (*prevCov)(i,
j);
6776 for (
auto &
p : fr->floatParsFinal()) {
6779 cov(i, i) = pow(
v->getError(), 2);
6787 fr->setCovarianceMatrix(
cov);
6794 _args.add(
_globs.argList());
6795 fr->setConstParList(_args);
6798 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6801 fr->setInitParList(*
_snap);
6831 o->setStringAttribute(
"range",
range);
6838 std::string &out =
fRange;
6839 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
6840 out = o->getStringAttribute(
"range");
6842 while (out.empty() && _parent) {
6843 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
6844 out = o->getStringAttribute(
"range");
6845 _parent = _parent->fParent;
6870 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
6876 return nll(_data,
l);
6894 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
6895 "generate with (found at least %s and %s)",
6913 for (
auto c :
bins()) {
6935 if (
d->get()->TestBit(1 << 20)) {
6941 throw std::runtime_error(
6942 "Need at least one dataset selected (SetChecked) to use for deselected regions");
6963 if (
mc->GetExternalConstraints()) {
6965 for (
auto o :
opts) {
6990 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
6991 "build nll with (found at least %s and %s)",
7000 throw std::runtime_error(
TString::Format(
"Workspace has multiple pdfs, you must specify which to "
7001 "build nll with (found at least %s and %s)",
7014 for (
auto c :
bins()) {
7035 _d = std::make_shared<xRooNode>(
asi.first, *
this);
7038 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
7048 me.push_back(std::make_shared<xRooNode>(_data));
7065 for (
int i = 0; i <
opts.GetSize(); i++) {
7068 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
7079 std::dynamic_pointer_cast<RooAbsData>(_data.
fComp), *
_opts);
7177 auto rangeName = (_range.empty()) ?
GetRange() : _range;
7178 if (!rangeName.empty()) {
7189 for (
auto &
c :
bins()) {
7192 _cat.setLabel(
cName);
7199 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
7213 std::vector<TObject *>
funcs;
7223 funcs.push_back(
c->get());
7227 if (!
funcs.empty()) {
7229 _pdf->setFloor(
false);
7255 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
7257 fr->setCovarianceMatrix(
_tmp);
7259 const_cast<RooArgList &
>(fr->floatParsFinal())
7270 for (
auto c : *
this) {
7271 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
7275 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
7379 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
7388 return getProjection(&intobs, _normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
7404 return rrv->getErrorHi();
7406 return rrv->getErrorLo();
7408 return rrv->getError();
7425 if (
rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
7435 std::stringstream
errMsg;
7436 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
7437 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
7439 throw std::runtime_error(
errMsg.str());
7451 : fr.reducedCovarianceMatrix(*
_pars));
7455 double nomVal =
f.getVal(nset);
7505 for (std::size_t i = 0; i <
_pars->size(); i++) {
7506 errVec[i] = std::sqrt(V(i, i));
7507 for (std::size_t
j = i;
j <
_pars->size();
j++) {
7508 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
7514 double sum = F * (
C *
F);
7530 fFunc(
"func",
"func",
this,
f),
7531 fCoef(
"coef",
"coef",
this),
7532 fExpPdf(
"expPdf",
"expPdf",
this)
7537 fCoef.setArg(*coef);
7541 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
7553 fExpectedEventsMode(
other.fExpectedEventsMode)
7560 return fFunc->binBoundaries(obs, xlo, xhi);
7565 return (fExpectedEventsMode ? 1. : fFunc) *
7566 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(_normSet) : 1.) *
7567 (fCoef.absArg() ? fCoef : 1.);
7578#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
7579 double oo = getPropagatedError(fr,
nset_in);
7580 if (std::isnan(
oo)) {
7599 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
7609 std::stringstream
errMsg;
7611 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
7612 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
7614 throw std::runtime_error(
errMsg.str());
7619 if (paramList.
empty())
7654#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7678 std::vector<double>
errVec(paramList.
size());
7679 for (std::size_t i = 0; i < paramList.
size(); i++) {
7680 errVec[i] = std::sqrt(V(i, i));
7681 for (std::size_t
j = i;
j < paramList.
size();
j++) {
7682 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
7689 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7694 double sum = F * (C *
F);
7704 if (
frv->getError() > 1
e-20) {
7721 for (
Int_t i = 0; i <
fpf.size(); i++) {
7724 paramList.
add(*par);
7760 std::vector<double>
errVec(paramList.
size());
7761 for (
int i = 0; i < paramList.
size(); i++) {
7762 errVec[i] = sqrt(V(i, i));
7763 for (
int j = i;
j < paramList.
size();
j++) {
7764 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
7771 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7776 double sum = F * (C *
F);
7790 bool fExpectedEventsMode =
false;
7798 std::cout <<
"Got signal " <<
signum << std::endl;
7800 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
7813 for (
int i = 0; i < obj->numCaches(); i++) {
7819 p->setNormRange(
p->normRange());
7821#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7826 p->setProxyNormSet(
nullptr);
7827 p->_lastNSet =
nullptr;
7830 obj->setValueDirty();
7834 for (
auto &
c :
w->components()) {
7854 for (
auto obj :
a->clients()) {
7861 }
while (
a->clients().size() !=
nClients);
7880 out.
fComp = std::shared_ptr<TH1>(
7881 BuildHistogram(
nullptr, !
content,
errors, -1, -1, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
false));
7882 }
else if (
vars.size() == 1) {
7884 out.
fComp = std::shared_ptr<TH1>(
7885 BuildHistogram(
v, !
content,
errors, 1, 0, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
true));
7887 throw std::runtime_error(
"multi-dim histo not yet supported");
7923 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
7924 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
7925 h->GetXaxis()->SetTimeFormat(
rar->GetName());
7934 if (
h->GetListOfFunctions())
7937 h->SetTitle(
rar->GetTitle());
7942 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
7944 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
7945 h->SetBinContent(1,
rar->getVal());
7946 if (
x->getError()) {
7947 h->SetBinError(1,
x->getError());
7948 h->SetFillStyle(3005);
7949 h->SetFillColor(
h->GetLineColor());
7951 h->SetMaximum(
x->hasMax() ?
x->getMax()
7952 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
7953 h->SetMinimum(
x->hasMin() ?
x->getMin()
7954 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
7957 h->SetMarkerSize(0);
7958 h->SetMarkerStyle(0);
7963 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
7964 if (binningName ==
"")
7965 binningName =
rar->GetName();
7966 if (
x->hasBinning(binningName)) {
7967 if (
x->getBinning(binningName).isUniform()) {
7968 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
7969 x->getMin(binningName),
x->getMax(binningName));
7971 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
7973 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
7975 }
else if (
auto _boundaries =
7976 _or_func( (std::list<double> *)(
nullptr),
7977 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
7978 std::numeric_limits<double>::infinity()));
7980 std::vector<double>
_bins;
7981 for (
auto &
b : *_boundaries) {
7987 }
else if (!
x->hasMax() || !
x->hasMin()) {
7989 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
7991 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
7995 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
7998 std::map<int, std::string> cats;
7999 for (
auto &
c : *cat) {
8000 cats[
c.second] =
c.first;
8002 for (
auto &[
_,
label] : cats) {
8003 h->GetXaxis()->SetBinLabel(i++,
label.c_str());
8009 h->GetXaxis()->SetTitle(o->GetTitle());
8013 if (
h->GetXaxis()->IsAlphanumeric()) {
8022 if (
auto s =
styles(
nullptr,
false); s) {
8028 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
8029 h->GetXaxis()->SetTitle(
vv->GetTitle());
8058 if (!
GETDMP(fr, _finalPars)) {
8086 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
8087 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
8088 cov(i,
j) = (*prevCov)(i,
j);
8108 _pars.remove(*_p,
true);
8141 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
8159 for (
auto o : _obs) {
8161 rr->removeRange(
"coordRange");
8162 rr->setStringAttribute(
"coordRange",
nullptr);
8166 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8167 rr->removeRange(
"coordRange");
8168 rr->setStringAttribute(
"coordRange",
nullptr);
8178 bool hasRange =
false;
8181 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
8191 for (
auto pdf :
bins()) {
8198 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
8200 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
8204 rar =
p->createProjection(
8208 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
8212 p->setNormRange(
"coordRange");
8217 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
8223 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
8241 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
8263 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
8266 -std::numeric_limits<double>::infinity(),
8267 std::numeric_limits<double>::infinity()))))
8280 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
8298 auto l =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
8301 h->GetListOfFunctions()->Add(
l, (
setInterp) ?
"lsame" :
"histsame");
8305 h->SetMarkerSize(0);
8306 h->SetFillStyle(3005);
8307 h->SetFillColor(
h->GetLineColor());
8323 auto l =
static_cast<TH1 *
>(
h->Clone(
"toys"));
8326 h->GetListOfFunctions()->Add(
8340 static_cast<TH1 *
>(
main_h->GetListOfFunctions()->FindObject(
"toys"))->GetListOfFunctions()->
Add(
h);
8345 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
8348 x->setVal(
h->GetBinCenter(i));
8350 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
8354 if (
x && !
x->inRange(
"coordRange"))
8358 if (!empty ||
toy > 0) {
8360#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8369 r *=
h->GetBinWidth(i);
8377 h->SetBinContent(i,
r);
8394#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8396 p->_normSet =
nullptr;
8414 res *=
h->GetBinWidth(i);
8416 h->SetBinError(i, res);
8432 res *=
h->GetBinWidth(i);
8437 h->SetBinContent(i,
h->GetBinContent(i) + (res -
h->GetBinError(i)) * 0.5);
8438 h->SetBinError(i, (res +
h->GetBinError(i)) * 0.5);
8450 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
8460 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
8486 auto nomHist =
static_cast<TH1 *
>(
h->FindObject(
"nominal"));
8489 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
8490 std::vector<double> vals;
8498 std::sort(vals.begin(), vals.end());
8507 upVal =
h->GetBinContent(i) + err;
8508 downVal =
h->GetBinContent(i) - err;
8516 std::vector<RooAbsArg *> extra;
8519 for (
auto _pdf : s->servers()) {
8521 extra.push_back(_pdf);
8524 extra.push_back(
rar);
8527 for (
auto a : extra)
8534 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
8536 h->GetYaxis()->SetTitle(
"Events");
8538 h->GetYaxis()->SetTitle(
"Probability Mass");
8540 h->GetYaxis()->SetMaxDigits(3);
8549 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"copy"));
8553 hCopy->SetStats(
false);
8554 h->GetListOfFunctions()->Add(
hCopy,
TString(
h->GetOption()) +
"same");
8555 h->GetListOfFunctions()->Add(
hCopy,
"axissame");
8573 std::vector<TH1 *>
hhs;
8580 if (!
rarNode->components().empty()) {
8583 if (
c->fFolder ==
"!.coeffs")
8589 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
8594 std::unique_ptr<RooAbsReal>
f(
8596 zero.setAttribute(
Form(
"ORIGNAME:%s",
c->GetName()));
8601 hh->SetName(
c->GetName());
8603 hh->Scale(
sf->getVal());
8605 hh->SetTitle(
c->GetName());
8607 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8612 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
8629 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
8631 hh->SetTitle(
samp->GetTitle());
8633 hh->SetTitle(
samp->GetName());
8635 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8639 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
8643 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
8649 auto hh =
samp->BuildHistogram(
8650 v, empty,
false ,
binStart,
binEnd,
_fr,
false,
false, 0,
h,
true,
8652 hh->SetName(
samp->GetName());
8654 hh->Scale(
sf->getVal());
8657 hh->SetTitle(
samp->GetName());
8659 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8668 for (
auto &
hh :
hhs) {
8719 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
8734 (*ritr)->SetTitle(
_title.c_str());
8738 for (
auto &
hh :
hhs) {
8749 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
8770 h->GetListOfFunctions()->AddFirst(stack,
"noclear same");
8782 for (
auto ho : *ll) {
8790 hh->SetFillStyle(1001);
8793 hh->SetFillColor((count++));
8796 for (
auto ho2 : *ll) {
8817 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
8820 hh->SetFillColor(10);
8833 push_back(std::make_shared<xRooNode>(
data));
8841 return std::numeric_limits<double>::quiet_NaN();
8842 return node->GetBinContent(bin);
8853 std::vector<double> out;
8865 for (
int i = 0; i <
g->GetN(); i++)
8866 integral +=
g->GetPointY(i);
8867 out.push_back(integral);
8872 out.push_back(
g->GetPointY(i));
8893 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
8894 tot +=
h->GetBinContent(i);
8899 out.push_back(
h->GetBinContent(i));
8910 for (
auto &
l :
a->servers()) {
8930 if (
auto o =
get(); o) {
8939#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8943 for (
int i = 0; i <
p->fCGnx; i++) {
8944 for (
int j = 0;
j <
p->fCGny;
j++) {
8945 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
8948 p->FillCollideGrid(o);
8957 if (
p->Collide(i,
j,
iw,
ih)) {
8968 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
8976 gPad->PaintModified();
8982 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
8983 1. -
gPad->GetTopMargin() - 0.08);
8984 l->SetBorderSize(0);
8985 if (
l->GetTextSize() == 0)
8993 l->ConvertNDCtoPad();
8999 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
9002 double w =
p->GetX2NDC() -
p->GetX1NDC();
9003 double h =
p->GetY2NDC() -
p->GetY1NDC();
9005 gPad->PaintModified();
9009 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
9010 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
9011 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
9012 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
9013 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
9014 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
9026 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
9027 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
9035 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
9036 if (
l =
dynamic_cast<TLegend *
>(
p->GetPrimitive(
"legend"));
l || !create)
9040 gPad->GetBottomMargin());
9041 l->SetBorderSize(1);
9045 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
9046 l->SetBorderSize(0);
9048 if (
l->GetTextSize() == 0) {
9056 l->SetName(
"legend");
9058 l->ConvertNDCtoPad();
9065 auto i = s.find(
"\n");
9066 if (i == std::string::npos) {
9069 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
9078 for (
auto a : *
l->GetListOfPrimitives()) {
9082 if (
l->GetListOfPrimitives()->GetEntries() > 20)
9086 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
9088 int nn =
l->GetNColumns();
9091 l->SetNColumns(
l->GetNColumns() + 1);
9092 if (
l->GetBorderSize() == 0) {
9093 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
9096 if (
l->GetBorderSize() == 0) {
9097 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
9113 fPad->GetCanvas()->Paint();
9114 fPad->GetCanvas()->Update();
9115#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
9116 fPad->GetCanvas()->ResetUpdated();
9131 if (
gROOT->FromPopUp()) {
9132 gROOT->SetFromPopUp(
false);
9135 }
catch (
const std::exception &
e) {
9138 (
gROOT->GetListOfBrowsers()->At(0))
9141 "Exception",
e.what(),
9144 gROOT->SetFromPopUp(
true);
9176 if (
d->get()->TestBit(1 << 20)) {
9182 hs.limits(
"cls visualize");
9194 [](
double a,
double b,
double) {
9197 if (
b == 0 &&
a == 0)
9204 [](
double n,
double b,
double sigma) {
9208 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
9210 double sigma2 = sigma * sigma;
9218 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
9227 if (
sOpt2.Contains(
"x=")) {
9229 int _idx =
sOpt2.Index(
"x=");
9245 }
else if (
ii == 1) {
9247 }
else if (
ii == 2) {
9255 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
9258 }
else if (nBins == 1)
9259 xPoints.push_back((min + max) / 2.);
9268 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
9278 if (
sOpt2.Contains(
"force")) {
9292 Error(
"Draw",
"Can only compute forces with PDFs");
9304 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
9306 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
9307 sOpt +=
"auxSignif";
9318 sOpt.ReplaceAll(
"ratio",
"");
9319 sOpt.ReplaceAll(
"significance",
"");
9321 sOpt.ReplaceAll(
"nostack",
"");
9323 sOpt.ReplaceAll(
"same",
"");
9325 sOpt.ReplaceAll(
"goff",
"");
9327 sOpt.ReplaceAll(
"pull",
"");
9331 sOpt.ReplaceAll(
"e",
"");
9333 sOpt.ReplaceAll(
"txt",
"texte");
9335 sOpt.ReplaceAll(
"txt",
"text");
9348 if (
gPad->GetNumber() == 0) {
9368 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
9370 for (
auto o : *
pad->GetListOfPrimitives()) {
9377 :
hAxis->GetXaxis()->GetName())
9399 double ymin =
hh->GetMinimum();
9400 double ymax =
hh->GetMaximum();
9401 if (
hh->GetMaximumStored() == -1111)
9403 if (
hh->GetMinimumStored() == -1111) {
9406 }
else if (
ymin < 0) {
9414 if (
hh->GetSumw2()) {
9417 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
9437 double up =
ymax -
hh->GetBinContent(1);
9462 double ymax = -std::numeric_limits<double>::infinity();
9463 double ymin = std::numeric_limits<double>::infinity();
9464 for (
int i = 0; i <
gr->
GetN(); i++) {
9498 pad->Divide(1, 2, 1
e-9, 1
e-9);
9499 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
9500 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
9502 optNoFR.ReplaceAll(
"pull",
"");
9512 gPad->GetFrame()->SetFillStyle(1001);
9513 gPad->SetTopMargin(0);
9514 gPad->SetBottomMargin(0);
9515 gPad->SetName(
"pull");
9519 Error(
"Draw",
"Couldn't find pull graph");
9528 throw std::runtime_error(
"Could not find scales in fit result");
9530 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
9535 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
9539 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
9540 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
9544 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
9545 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
9546 g->SetEditable(
true);
9547 g->SetHighlight(
true);
9548 g->SetMarkerStyle(20);
9549 g->SetMarkerSize(0.5);
9575 if (!
_v->IsHidden())
9584 pad->SetBorderSize(0);
9606 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
9608 auto _pad =
pad->GetPad(_size);
9609 _pad->SetName(
"legend");
9611 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
9614 while (
pad->GetPad(
x + 1)) {
9615 pad->GetPad(
x + 1)->SetFillStyle(0);
9625 if (_range &&
strlen(_range)) {
9649 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9664 for (
auto &
_v : *
this) {
9671 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9674 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9684 pad->SetBorderSize(0);
9685 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
9688 for (
auto &
_v : *
this) {
9695 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9698 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9707 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9729 if (
sOpt.Contains(
"corr")) {
9736 hist->SetStats(
false);
9737 hist->SetDirectory(
nullptr);
9740 hist->GetXaxis()->SetTickSize(0);
9741 hist->GetYaxis()->SetTickSize(0);
9742 hist->SetMinimum(-100);
9745 gPad->SetGrid(1, 1);
9751 if (
sOpt.Contains(
"brakdown")) {
9757 if (
sOpt.Contains(
"brakdown:")) {
9762 if (_poi->empty()) {
9763 throw std::runtime_error(
"No floating poi in the fit");
9764 }
else if (_poi->size() != 1) {
9765 throw std::runtime_error(
"Multiple poi in the fit");
9767 poiName = _poi->first()->GetName();
9773 std::set<std::string>
groups;
9777 }
else if (
p->getStringAttribute(
"group")) {
9778 groups.insert(
p->getStringAttribute(
"group"));
9805 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
9806 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
9814 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
9815 pie->SetEntryVal(i, 0);
9824 pie->SetEntryLabel(i,
group.c_str());
9839 pie->SetRadius(0.17);
9852 ugraph->SetTitle(
"Fit Result Pulls");
9854 std::map<std::string, double>
scale;
9855 std::map<std::string, double>
offset;
9861 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
9862 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
9876 std::shared_ptr<xRooNode>
pConstr;
9879 if (
_vv->hasRange(
"pullScale")) {
9889 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
9890 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
9912 std::string
xName =
pConstr->find(
".x")->get()->GetName();
9914 for (
auto &_d :
pConstr->vars()) {
9915 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
9917 if (
xName == _d->get()->GetName())
9941 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
9956 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
9975 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
9988 for (
int i = 0; i <
ugraph->GetN(); i++)
9989 ugraph->SetPointX(i, i + graph->GetN());
10002 graph->SetMarkerStyle(20);
10003 graph->SetMarkerSize(0.5);
10005 graph->SetMaximum(4);
10006 graph->SetMinimum(-4);
10009 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
10011 std::vector<std::pair<double, std::string>>
covariances;
10014 if (
sOpt.Contains(
"impact")) {
10015 if (
sOpt.Contains(
"impact:")) {
10020 if (_poi->empty()) {
10021 throw std::runtime_error(
"No floating poi in the fit");
10022 }
else if (_poi->size() != 1) {
10023 throw std::runtime_error(
"Multiple poi in the fit");
10025 poiName = _poi->first()->GetName();
10046 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
10047 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
10048 : (std::abs(i.first) > std::abs(j.first));
10069 sortedGraph.SetPointError(
sortedGraph.GetN() - 1, 0, 0, graph->GetErrorYlow(i), graph->GetErrorYhigh(i));
10078 graph->SetTitle(
"Fit Result Impact");
10085 std::max(graph->GetN(), 1) - 0.5);
10094 hist =
new TH2D(
GetName(), fr->
GetTitle(), std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5,
10121 graph->GetHistogram()->GetXaxis()->Set(std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5);
10122 for (
int ii = 1;
ii <=
_axis->GetNbins();
ii++) {
10123 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
10138 gPad->Divide(1, 1, 1
e-9, 1
e-9);
10142 gPad->SetLeftMargin(0.4);
10144 gPad->SetBottomMargin(0.4);
10147 auto pNamesHist =
dynamic_cast<TH1F *
>(graph->GetHistogram()->Clone(
"scales"));
10151 for (
int ii = 1;
ii <= graph->GetN();
ii++) {
10155 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
10160 if (!
sOpt.Contains(
"impact")) {
10161 for (
int ii = 2;
ii >= 1;
ii--) {
10196 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
10197 pave->SetFillStyle(0);
10198 pave->SetBorderSize(0);
10199 pave->SetMargin(0.);
10200 pave->SetName(
"status");
10201 pave->SetTextAlign(31);
10206 case 0:
covQualTxt =
"Not calculated";
break;
10208 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
10223 gPad->SetTicks(0, 0);
10227 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
10228 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
10232 double factor = 475. /
gPad->GetCanvas()->GetWh();
10261 for (
int tt = 0;
tt < 2;
tt++) {
10262 auto impact =
static_cast<TH1 *
>(
10263 graph->GetHistogram()->Clone(
TString::Format(
"%s_impact+",
tt == 0 ?
"prefit" :
"postfit")));
10266 impact->SetBarWidth(0.9);
10267 impact->SetBarOffset(0.05);
10268 impact->SetLineColor(
kBlack);
10269 impact->SetFillColor(
kAzure - 4);
10270 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
10272 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
10273 impact2->SetDirectory(
nullptr);
10281 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
10283 :
c.first *
vv->getError() /
vv->getErrorHi() *
10284 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
10287 :
c.first *
vv->getError() /
vv->getErrorLo() *
10288 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
10295 for (
int ii = -1;
ii <= 1;
ii++) {
10308 leg1->SetFillStyle(0);
10309 leg1->SetBorderSize(0);
10310 leg1->SetMargin(0.25);
10311 leg1->SetNColumns(2);
10313 leg1->SetTextSize(
_axis->GetLabelSize());
10314 leg1->SetTextFont(
_axis->GetLabelFont());
10315 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
10316 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
10317 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
10318 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
10319 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
10320 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
10321 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
10322 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
10328 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
10335 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
10343 graph->SetEditable(
false);
10347 graph->GetListOfFunctions()->Add(
pNamesHist,
"same");
10351 for (
int p = 0;
p < graph->GetN();
p++) {
10352 graph->SetPoint(
p, graph->GetPointY(
p), graph->GetPointX(
p));
10353 graph->SetPointError(
p, graph->GetErrorYlow(
p), graph->GetErrorYhigh(
p), graph->GetErrorXlow(
p),
10354 graph->GetErrorXhigh(
p));
10357 if (
f->InheritsFrom(
"TH1")) {
10366 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
10367 for (
int p = 0;
p <
g->GetN();
p++) {
10368 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
10371 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
10381 graph->SetName(
"pulls");
10390 hist->
Draw(
"same");
10402 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
10403 hh->SetDirectory(
nullptr);
10421 for (
auto c : s->bins()) {
10422 auto _pad =
dynamic_cast<TPad *
>(
gPad->GetPrimitive(
c->GetName()));
10427 c->push_back(std::make_shared<xRooNode>(*
this));
10429 c->resize(
c->size() - 1);
10431 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
10450 for (
auto o : *
gPad->GetListOfPrimitives()) {
10475 for (
int i = 0; i <
dataGraph->GetN(); i++)
10492 for (
auto o : *
gPad->GetListOfPrimitives()) {
10493 if (
auto h =
dynamic_cast<TH1 *
>(o);
10503 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
10506 histName = histName(0, histName.
Index(
'|'));
10507 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
10513 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
10525 if (!std::isnan(
yval)) {
10527 if (!std::isnan(yup))
10529 if (!std::isnan(
ydown))
10596 if (!
d->get()->TestBit(1 << 20))
10600 auto _obs =
d->obs();
10602 auto _nll =
nll(
d);
10605 for (
int i = 0; i <
nevent; i++) {
10607 bool _skip =
false;
10608 for (
const auto &_c :
_coords) {
10610 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
10620 auto val = _nll.pars()->getRealValue(
initPar->GetName());
10623 auto nllVal = _nll.getEntryVal(i);
10624 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
10625 auto nllVal2 = _nll.getEntryVal(i);
10626 _nll.pars()->setRealValue(
initPar->GetName(), val);
10632 auto val = _nll.pars()->getRealValue(
initPar->GetName());
10635 auto _extTerm = _nll.extendedTermVal();
10636 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
10637 auto _extTerm2 = _nll.extendedTermVal();
10638 _nll.pars()->setRealValue(
initPar->GetName(), val);
10639 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
10644 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
10650 }
else if (
ii == 3) {
10676 (
rarNode->get()->InheritsFrom(
"RooRealSumPdf") ||
rarNode->get()->InheritsFrom(
"RooAddPdf") ||
10677 (
v &&
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
10685 auto h =
BuildHistogram(
v,
false,
hasErrorOpt, 1, 0,
"",
false,
false, 0,
nullptr,
nostack,
true );
10697 :
h->GetXaxis()->GetName())
10700 if (
h->GetXaxis()->IsAlphanumeric()) {
10708 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
10709 rar->InheritsFrom(
"RooSimultaneous"))) {
10712 rar->leafNodeServerList(&s);
10719 for (
auto _p : s) {
10727 if (
_v->hasError()) {
10738 gPad->SetGrid(0, 0);
10740 gPad->SetGrid(1, 1);
10745 h->SetFillStyle(0);
10794 gROOT->SetEditHistograms(
true);
10796 gROOT->SetEditHistograms(
false);
10805 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
10810 bool hasError(
false);
10811 for (
int i = 0; i <
h->GetSumw2N(); i++) {
10812 if (
h->GetSumw2()->At(i)) {
10823 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
10824 h->GetYaxis()->SetTitleOffset(1.);
10842 hCopy->SetDirectory(
nullptr);
10844 _hist->GetListOfFunctions()->Add(node);
10845 _hist->GetListOfFunctions()->Add(
new TExec(
10848 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
10849 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
10850 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
10851 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
10852 "h->SetBinContent(1, "
10853 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
10854 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
10855 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
10856 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
10857 _hist->GetName(), node->GetName())));
10859 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
10860 errHist->SetFillColor(
h->GetLineColor());
10863 hCopy->SetFillStyle(0);
10864 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
10867 _hist->SetStats(
false);
10924 errHist->SetFillColor(
h->GetLineColor());
10941 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
10943 if (
auto stack =
dynamic_cast<THStack *
>(
h->FindObject(
"stack"))) {
10949 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
10950 if (
lnk == stack->GetHists()->FirstLink() &&
h->GetMinimum() >
hhMin) {
11236 dOpt.ReplaceAll(
"TEXT",
"");
11238 double ymax = -std::numeric_limits<double>::infinity();
11239 double ymin = std::numeric_limits<double>::infinity();
11240 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
11269 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
11278 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
11279 double val =
ratioHist->GetBinContent(i);
11280 double err =
ratioHist->GetBinError(i);
11287 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
11294#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
11303 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
11304 _h->SetDirectory(
nullptr);
11305 _h->SetFillColor(0);
11306 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
11311 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
11312 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
11313 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
11314 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
11324 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
11328 histName = histName(0, histName.
Index(
'|'));
11330 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
11331 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
11334 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
11335 double val =
h->GetBinContent(i);
11336 double err =
h->GetBinError(i);
11337 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
11338 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
11339 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
11340 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
11341 h->GetBinContent(i));
11358 double ymax = -std::numeric_limits<double>::infinity();
11359 double ymin = std::numeric_limits<double>::infinity();
11360 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
11361 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
11362 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
11396 if (
d->get()->TestBit(1 << 20)) {
11417 w->import(*
gROOT->GetListOfColors(),
true);
11420#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
11429 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
11434#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11438 for (
auto &
c :
w->components()) {
11439 c->_eocache =
nullptr;
11447 if (
auto fitDb =
dynamic_cast<TFile *
>(
gROOT->GetListOfFiles()->FindObject(
"fitDatabase"))) {
11452 auto dir =
dest->GetDirectory(
source->GetName());
11456 for (
auto k : *
source->GetListOfKeys()) {
11457 auto key =
dynamic_cast<TKey *
>(k);
11458 const char *classname = key->GetClassName();
11467 if (dir->FindKey(key->GetName()))
11470 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
11472 dir->WriteObject(
fc, key->GetName());
11475 TObject *obj = key->ReadObj();
11477 dir->WriteTObject(obj, key->
GetName());
11491#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11493 for (
auto &
c :
w->components()) {
11494 c->setExpensiveObjectCache(
w->expensiveObjectCache());
11504 return std::numeric_limits<double>::quiet_NaN();
11510 std::vector<double> out;
11511 out.reserve(
size());
11512 for (
auto child : *
this) {
11513 out.push_back(
child->GetContent());
11527 auto rho =
_fr->correlationMatrix();
11536 for (
int m = 0;
m < rho.GetNrows();
m++) {
11543 auto tmp = _p->getVal();
11544 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
11546 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
11549 for (
int n = 0;
n < rho.GetNrows();
n++) {
11557 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
11559 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
11562 for (
int i = 0; i < out.
GetNrows(); i++) {
11575 double err = std::numeric_limits<double>::quiet_NaN();
11577 std::unique_ptr<RooAbsCollection>
_snap;
11595 p->setNormRange(rangeName);
11596#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
11599 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
11600#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11602 p->_normSet =
nullptr;
11606 p->setNormRange(
nullptr);
11609 auto f = std::shared_ptr<RooAbsReal>(
11610 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
11614 out *=
f->getVal();
11615 err =
xRooNode(
pr, *
this).GetBinError(-1, fr);
11620 auto ax = (rangeName) ?
GetXaxis() :
nullptr;
11624 for (
auto &
v : vals) {
11627 if (
rv && !
rv->inRange(
ax->GetBinCenter(i), rangeName))
11629 if (
cv && !
cv->isStateInRange(rangeName,
ax->GetBinLabel(i)))
11636 out = std::numeric_limits<double>::quiet_NaN();
11639 _pars.RooAbsCollection::operator=(*_snap);
11641 return std::make_pair(out, err);
11660 std::vector<double> out;
11666 binEnd = _hist->GetNbinsX();
11673 _hist->GetBinError(bin));
11798std::string cling::printValue(
const xRooNode *
v)
11801 return "nullptr\n";
11804 size_t left =
v->size();
11805 for (
auto n : *
v) {
11811 out +=
n->GetName();
11812 if (out.length() > 100 && left > 0) {
11818 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName())) + out;
11823 return "<nullptr>";
11825 return Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName());
#define ROOT_VERSION(a, b, c)
#define ROOT_VERSION_CODE
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
double GetBinLowEdge(Int_t bin) const override
Return low edge of bin.
double GetBinUpEdge(Int_t bin) const override
Return up edge of bin.
Int_t FindFixBin(double x) const override
Find bin number corresponding to abscissa x.
void Set(Int_t nbins, const double *xbins) override
Initialize axis with variable bins.
RooAbsRealLValue * rvar() const
void SetTitle(const char *title) override
Set the title of the TNamed.
void Set(Int_t nbins, double xmin, double xmax) override
Initialize axis with fix bins.
Int_t FindFixBin(const char *label) const override
Find bin number with label.
RooAbsLValue * var() const
const RooAbsBinning * binning() const
void Set(Int_t nbins, const float *xbins) override
Initialize axis with variable bins.
const char * GetTitle() const override
Returns title of object.
double GetBinWidth(Int_t bin) const override
Return bin width.
PadRefresher(TVirtualPad *p)
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
double getSimplePropagatedError(const RooFitResult &fr, const RooArgSet &nset_in) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
TObject * clone(const char *newname) const override
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Retrieve bin boundaries if this distribution is binned in obs.
PdfWrapper(const PdfWrapper &other, const char *name=nullptr)
PdfWrapper(RooAbsReal &f, RooAbsReal *coef, bool expEvMode=false, RooAbsPdf *expPdf=nullptr)
The PiecewiseInterpolation is a class that can morph distributions into each other,...
static std::shared_ptr< RooLinkedList > createNLLOptions()
static std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > generateFrom(RooAbsPdf &pdf, const RooFitResult &fr, bool expected=false, int seed=0)
static xRooNLLVar createNLL(const std::shared_ptr< RooAbsPdf > pdf, const std::shared_ptr< RooAbsData > data, const RooLinkedList &nllOpts)
static std::pair< double, double > matchPrecision(const std::pair< double, double > &in)
void Draw(Option_t *opt="") override
Default Draw method for all objects.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
This xRooNLLVar object has several special methods, e.g.
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)
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
void _Add_(const char *name, const char *opt)
TH1 * BuildHistogram(RooAbsLValue *v=nullptr, bool empty=false, bool errors=false, int binStart=1, int binEnd=0, const xRooNode &fr="", bool errorsHi=false, bool errorsLo=false, int nErrorToys=0, TH1 *templateHist=nullptr, bool nostack=true, bool setInterp=false) const
xRooNode filter(const xRooNode &range) const
void _scan_(const char *what="plr", double nToys=0, const char *xvar="", int nPointsX=0, double lowX=0, double highX=0, const char *constParValues="")
std::vector< std::shared_ptr< xRooNode > > fBrowsables
xRooNLLVar nll(const xRooNode &_data, std::initializer_list< RooCmdArg > nllOpts) const
xRooNode poi() const
List of parameters of interest: parameters marked as "of interest" These parameters have the "poi" at...
void SetName(const char *name) override
Set the name of the TNamed.
TGListTreeItem * GetTreeItem(TBrowser *b) const
void SetTitle(const char *title) override
Set the title of the TNamed.
xRooNode Multiply(const xRooNode &child, Option_t *opt="")
xRooNode Replace(const xRooNode &node)
bool SetData(const TObject &obj, const xRooNode &data="obsData")
xRooNode datasets() const
xRooNode Remove(const xRooNode &child)
xRooNode globs() const
List of global observables of this node.
xRooNode Combine(const xRooNode &rhs)
xRooNode Add(const xRooNode &child, Option_t *opt="")
xRooNode(const char *type, const char *name, const char *title="")
const char * GetIconName() const override
Returns mime type name of object.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
bool _IsShowVars_() const
TGraph * BuildGraph(RooAbsLValue *v=nullptr, bool includeZeros=false, TVirtualPad *fromPad=nullptr) const
const std::shared_ptr< xRooNode > & at(size_t idx, bool browseResult=true) const
const char * GetNodeType() const
bool SetBinContent(int bin, double value, const char *par=nullptr, double parVal=1)
std::shared_ptr< xRooNode > operator[](size_t idx)
void Checked(TObject *obj, bool val)
void Print(Option_t *opt="") const override
Print TNamed name and title.
double GetContent() const
std::shared_ptr< T > acquireNew(Args &&...args)
xRooNode components() const
void SaveAs(const char *filename="", Option_t *option="") const override
Save this object in the file specified by filename.
xRooNode bins() const
bins of a channel or sample, or channels of a multi-channel pdf
std::shared_ptr< xRooNode > find(const std::string &name, bool browseResult=true) const
TGListTree * GetListTree(TBrowser *b) const
xRooNode styles(TObject *initObject=nullptr, bool autoCreate=true) const
bool fInterrupted
appears that if was fXaxis then dialog box for SetXaxis will take as current value
xRooNode generate(const xRooNode &fr="", bool expected=false, int seed=0)
void Inspect() const override
Dump contents of this object in a graphics canvas.
std::shared_ptr< xRooNode > getBrowsable(const char *name) const
bool SetXaxis(const RooAbsBinning &binning)
double GetBinError(int bin, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
RooArgList argList() const
bool SetBinData(int bin, double value, const xRooNode &data="obsData")
void SetHidden(bool set=true)
std::vector< double > GetBinContents(int binStart=1, int binEnd=0) const
xRooNode pp() const
List of prespecified parameters: non-floatable parameters.
xRooNode constraints() const
std::shared_ptr< xRooNode > fProvider
std::shared_ptr< TStyle > style(TObject *initObject=nullptr, bool autoCreate=true) const
xRooNode mainChild() const
xRooNode fitResult(const char *opt="") const
std::shared_ptr< TAxis > fXAxis
only here so can have char* GetRange return so can return nullptr for no range set (required for RooC...
xRooNode coords(bool setVals=true) const
xRooNode Vary(const xRooNode &child)
xRooNode Constrain(const xRooNode &child)
static std::map< std::string, std::tuple< std::function< double(double, double, double)>, bool > > auxFunctions
xRooNode pars() const
List of parameters (non-observables) of this node.
void _SetContent_(double value)
void SetFitResult(const RooFitResult *fr=nullptr)
void _ShowVars_(bool set=true)
xRooNode coefs(bool recurse=false) const
bool IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
double GetBinData(int bin, const xRooNode &data="obsData")
bool SetBinError(int bin, double value)
void _Vary_(const char *what)
bool SetContents(const TObject &obj)
std::shared_ptr< TObject > fComp
std::vector< double > contents() const
RooWorkspace * ws() const
The RooWorkspace this node belong to, if any.
xRooNode shallowCopy(const std::string &name, std::shared_ptr< xRooNode > parent=nullptr)
void _generate_(const char *name="", bool expected=false)
void _fit_(const char *constParValues="")
std::shared_ptr< TObject > getObject(const std::string &name, const std::string &type="") const
xRooNode np() const
List of nuisance parameters: non-constant parameters that are not marked of interest,...
xRooNode floats() const
List of parameters that are currently non-constant These parameters do not have the "Constant" attrib...
bool contains(const std::string &name) const
double GetBinContent(int bin) const
xRooNode reduced(const std::string &range="", bool invert=false) const
xRooNode variations() const
std::string GetPath() const
std::vector< double > GetBinErrors(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
auto begin() const -> xRooNodeIterator
std::shared_ptr< xRooNode > parentPdf() const
like a parent but only for use by getObject
bool SetContent(double value)
std::shared_ptr< xRooNode > fParent
std::pair< double, double > IntegralAndError(const xRooNode &fr="", const char *rangeName=nullptr) const
xRooNode robs() const
List of regular observables of this node.
TClass * IsA() const override
xRooNode & operator=(const TObject &o)
auto end() const -> xRooNodeIterator
xRooNode consts() const
List of parameters that are currently constant.
void _SetBinContent_(int bin, double value, const char *par="", double parVal=1)
std::shared_ptr< TObject > acquire(const std::shared_ptr< TObject > &arg, bool checkFactory=false, bool mustBeNew=false)
std::function< xRooNode(xRooNode *) fBrowseOperation)
xRooNode histo(const xRooNode &vars="x", const xRooNode &fr="", bool content=true, bool errors=true, bool stack=true, bool errorsHi=false, bool errorsLo=false, int nErrorToys=0) const
void Browse(TBrowser *b=nullptr) override
Browse object. May be overridden for another default action.
xRooNode obs() const
List of observables (global and regular) of this node.
void SetRange(const char *range, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN())
static void SetAuxFunction(const char *title, const std::function< double(double, double, double)> &func, bool symmetrize=false)
std::shared_ptr< TObject > convertForAcquisition(xRooNode &acquirer, const char *opt="") const
double GetError(const xRooNode &fr="") const
xRooNode vars() const
List of variables (observables and parameters) of this node.
const char * GetRange() const
TMatrixDSym covariances(const xRooNode &fr="") const
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
void SetName(const char *name) override
Set the name of the TNamed.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Abstract base class for RooRealVar binning definitions.
virtual double highBound() const =0
virtual double lowBound() const =0
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
virtual value_type getCurrentIndex() const
Return index number of current state.
const char * getLabel() const
Retrieve current label. Use getCurrentLabel() for more clarity.
Abstract container object that can hold multiple RooAbsArg objects.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
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
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
void setName(const char *name)
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for binned and unbinned datasets.
RooFit::OwningPtr< RooAbsData > reduce(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a reduced copy of this dataset.
RooArgSet const * getGlobalObservables() const
Returns snapshot of global observables stored in this data.
Abstract base class for objects that are lvalues, i.e.
Abstract interface for all probability density functions.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
Context to temporarily change the error logging mode as long as the context is alive.
Abstract base class for objects that represent a real value and implements functionality common to al...
bool isSelectedComp() const
If true, the current pdf is a selected component (for use in plotting)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void forceNumInt(bool flag=true)
Efficient implementation of a sum of PDFs of the form.
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.
Abstract interface for RooAbsArg proxy classes.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
Named container for two doubles, two integers two object points and three string pointers that can be...
static const RooCmdArg & none()
Return reference to null argument.
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Represents a constant real-valued object.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
TMatrixDSym conditionalCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix, which is calculated as.
void setCovQual(Int_t val)
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
Int_t statusCodeHistory(UInt_t icycle) const
const RooArgList & floatParsInit() const
Return list of floating parameters before fit.
TMatrixDSym reducedCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
const RooArgList & randomizePars() const
Generate random perturbations of the final parameters using the covariance matrix.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
double edm() const
Return estimated distance to minimum.
const RooArgList & constPars() const
Return list of constant parameters.
const char * statusLabelHistory(UInt_t icycle) const
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
TH2 * correlationHist(const char *name="correlation_matrix") const
Return TH2D of correlation matrix.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Int_t status() const
Return MINUIT status code.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
UInt_t numStatusHistory() const
double minNll() const
Return minimized -log(L) value.
Implementation of a probability density function that takes a RooArgList of servers and a C++ express...
A real-valued function sampled from a multidimensional histogram.
bool isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
static RooMsgService & instance()
Return reference to singleton instance.
Implementation of a RooCacheManager<RooAbsCacheElement> that specializes in the storage of cache elem...
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
A RooAbsPdf implementation that represent a projection of a given input p.d.f and the object returned...
RooProjectedPdf()
Default constructor.
Implements a PDF constructed from a sum of functions:
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setError(double value)
bool hasError(bool allowZero=true) 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.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
A RooAbsArg implementing string values.
Persistable container for RooFit projects.
bool removeSet(const char *name)
Remove a named set from the workspace.
RooFactoryWSTool & factory()
Return instance to factory tool.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
virtual void SetNdivisions(Int_t n=510, Bool_t optim=kTRUE)
Set the number of divisions for this axis.
Fill Area Attributes class.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual Color_t GetLineColor() const
Return the line color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual Font_t GetTextFont() const
Return the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Class to manage histogram axis.
virtual void LabelsOption(Option_t *option="h")
Set option(s) to draw axis with labels option can be:
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
TAxis()
Default constructor.
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
Using a TBrowser one can browse all ROOT objects.
TBrowserImp * GetBrowserImp() const
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
virtual Int_t GetEntries() const
static Int_t GetColorPalette(Int_t i)
Static function returning the color number i in current palette.
static Int_t GetNumberOfColors()
Static function returning number of colors in the color palette.
Describe directory structure in memory.
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=nullptr)
Set the value of a resource or create a new resource.
TExec is a utility class that can be used to execute a C++ command when some event happens in a pad.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Create a dialog for fit function parameter settings.
System file browser, used as TRootBrowser plug-in.
A list tree is a widget that can contain a number of items arranged in a tree structure.
ROOT GUI Window base class.
virtual void SetTitle(const char *title="")
Change the title of the axis.
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
TGraph with asymmetric error bars.
virtual void SetPointEYlow(Int_t i, Double_t eyl)
Set EYlow for point i.
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
Set ex and ey values for point pointed by the mouse.
virtual void SetPointEYhigh(Int_t i, Double_t eyh)
Set EYhigh for point i.
Double_t GetErrorYlow(Int_t i) const override
Get low error on Y.
A TGraphErrors is a TGraph with error bars.
Double_t GetErrorYlow(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const override
It returns the error along Y at point i.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void AddPoint(Double_t x, Double_t y)
Append a new point to the graph.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
void SetName(const char *name="") override
Set graph name.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
virtual TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
virtual Double_t GetPointY(Int_t i) const
Get y value for point i.
void SetTitle(const char *title="") override
Change (i.e.
1-D histogram with a double per channel (see TH1 documentation)
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
void SetTitle(const char *title) override
Change/set the title.
virtual Int_t GetNbinsY() const
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
@ kNoTitle
Don't draw the histogram title.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
void Draw(Option_t *option="") override
Draw this histogram with options.
TList * GetListOfFunctions() const
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a double per channel (see TH1 documentation)
The Histogram stack class.
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Storage class for one entry of a TLegend.
This class displays a legend box (TPaveText) containing several legend entries.
Use the TLine constructor to create a simple line.
virtual void SetY2(Double_t y2)
virtual void SetX2(Double_t x2)
virtual void SetX1(Double_t x1)
virtual void SetY1(Double_t y1)
void Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
The TNamed class is the base class for all named ROOT classes.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
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.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Wrapper around a TObject so it can be stored in a TList.
Mother of all ROOT objects.
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void Delete(Option_t *option="")
Delete this object.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
@ kCanDelete
if object in a list can be deleted
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
The most important graphics class in the ROOT system.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void SetY1NDC(Double_t y1)
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
virtual void SetY2NDC(Double_t y2)
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Regular expression class.
This class creates a ROOT object browser, constituted by three main tabs.
Sequenceable collection abstract base class.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t Atof() const
Return floating-point value contained in string.
const char * Data() const
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
TStyle objects may be created to define special styles.
void SetPaintTextFormat(const char *format="g")
Int_t GetOptTitle() const
Float_t GetLabelSize(Option_t *axis="X") const
Return label size.
Float_t GetPadRightMargin() const
Style_t GetTitleFont(Option_t *axis="X") const
Return title font.
Bool_t GetHistMinimumZero() const
Float_t GetPadLeftMargin() const
Float_t GetTitleYSize() const
Double_t GetHistTopMargin() const
Float_t GetPadBottomMargin() const
const char * GetPaintTextFormat() const
Float_t GetPadTopMargin() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
double evaluate() const override
Evaluate projected p.d.f.
TObject * clone(const char *newname) const override
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events to be used in calculation of extended likelihood.
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
RooCmdArg RecycleConflictNodes(bool flag=true)
RooConstVar & RooConst(double val)
RooCmdArg Embedded(bool flag=true)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg ExternalConstraints(const RooArgSet &constraintPdfs)
RooCmdArg Range(const char *rangeName, bool adjustNorm=true)
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
constexpr Double_t C()
Velocity of light in .
Double_t Prob(Double_t chi2, Int_t ndf)
Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf...
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
Double_t StdDev(Long64_t n, const T *a, const Double_t *w=nullptr)
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE
bool isNaNWithPayload() const
Test if this struct has a float packed into its mantissa.
static float unpackNaN(double val)
If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the manti...
static uint64_t sum(uint64_t i)
void(* gOldHandlerr)(int)
void addLegendEntry(TObject *o, const char *title, const char *opt)
void buildHistogramInterrupt(int signum)
auto GETACTBROWSER(TRootBrowser *b)
auto & GETWSSNAPSHOTS(RooWorkspace *w)
bool TopRightPlaceBox(TPad *p, TObject *o, double w, double h, double &xl, double &yb)
TPaveText * getPave(const char *name="labels", bool create=true, bool doPaint=false)
std::string formatLegendString(const std::string &s)
auto GETROOTDIR(TGFileBrowser *b)
const xRooNode * runningNode
auto GETLISTTREE(TGFileBrowser *b)
const T & _or_func(const T &a, const T &b)
double new_getPropagatedError(const RooAbsReal &f, const RooFitResult &fr, const RooArgSet &nset={}, RooArgList **pars=nullptr, bool asymHi=false, bool asymLo=false)
TLegend * getLegend(bool create=true, bool doPaint=false)