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 for (
auto &
d : _ws->allData()) {
338 for (
auto &
a : *
d->get()) {
339 if (
auto v = _ws->var(
a->GetName());
v) {
340 v->setAttribute(
"obs");
341 }
else if (
auto c = _ws->cat(
a->GetName());
c) {
342 c->setAttribute(
"obs");
349 if (
checkCount == 0 && !_ws->allData().empty())
350 _ws->allData().back()->SetBit(1 << 20,
true);
353 for (
auto s : *_set) {
355 _ws->var(s->GetName())->setStringAttribute(
"nominal",
TString::Format(
"%f",
v->getVal()));
363 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
366 s->setAttribute(
"obs");
367 s->setAttribute(
"global");
370 const_cast<RooArgSet &
>(
v).setAttribAll(
"obs");
373 s->setAttribute(
"poi");
385 const_cast<RooArgSet &
>(
v).setAttribAll(
"np");
389 _ws->defineSet(
"globalObservables",
_allGlobs);
394 if (!_ws->allPdfs().empty()) {
397 for (
auto &
p :
np()) {
401 if (!
v->hasError()) {
410 "Inferring initial errors of %d parameters (%s%s) (give all nuisance parameters an error to avoid "
415 for (
auto &
a : *
this) {
419 if (
a->fFolder ==
"!pdfs") {
421 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
425 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
426 arg && arg->hasError()) {
427 v->setError(arg->getError());
443 if (
strlen(GetTitle()) == 0) {
470 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
471 return a->getStringAttribute(
"alias");
473 return comp->GetName();
492 if (o->isSelectedComp() && !val) {
495 o->setAttribute(
"hidden");
496 }
else if (!o->isSelectedComp() && !val) {
501 o->setAttribute(
"hidden",
false);
504 item->CheckItem(!o->getAttribute(
"hidden"));
505 if (o->isSelectedComp()) {
508 item->SetColor(
kGray);
513 if (
auto o =
get(); o) {
515 o->SetBit(1 << 20, val);
517 if (
auto _ws =
ws(); _ws) {
520 if (!_ws->genobj(fr->GetName())) {
522 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
527 _allVars = fr->floatParsFinal();
528 _allVars = fr->constPars();
529 for (
auto &i : fr->floatParsInit()) {
535 for (
auto oo : _ws->allGenericObjects()) {
537 ffr->ResetBit(1 << 20);
541 _ws->allVars() = fr->floatParsInit();
545 if (
auto first = item->GetParent()->GetFirstChild()) {
547 if (first->HasCheckBox()) {
548 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
549 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
551 }
while ((first = first->GetNextSibling()));
564 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
565 if (!b2 || !b2->GetBrowserImp()) {
572 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
574 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
576 b2->BrowseObject(
this);
581 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
588 _b->GotoDir(
nullptr);
599 if (
auto first = item->GetFirstChild()) {
601 if (first->HasCheckBox()) {
602 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
603 first->CheckItem(
_obj->get() &&
604 (
_obj->get()->TestBit(1 << 20) ||
607 }
while ((first = first->GetNextSibling()));
620 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
621 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corrcolztext\")",
nullptr, *
this));
622 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
623 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
630 s->SetFillAttributes();
637 Draw(
b->GetDrawOption());
639 }
catch (
const std::exception &
e) {
642 (
gROOT->GetListOfBrowsers()->At(0))
645 "Exception",
e.what(),
652 for (
auto &
c : *
this) {
653 if (!
c->fFolder.empty()) {
664 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
667 for (
auto &
v : *
this) {
668 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
669 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
676 _name = _name(1, _name.
Length());
677 b->Add(
v.get(), _name);
681 for (
auto &
v : *
this) {
684 if (
strcmp(
v->GetName(),
".folders") == 0)
688 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
696 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
704 :
v->get()->GetName());
706 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
708 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
716 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
722 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
731 if (
auto o =
v->get(); o)
732 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
734 if (
auto o =
v->get(); o)
737 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
738 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
741 if (
_fr->status() ||
_fr->covQual() != 3) {
742 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() ||
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
743 }
else if (
_fr->numStatusHistory() == 0) {
744 v->GetTreeItem(
b)->SetColor(
kGray);
747 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
749 v->GetTreeItem(
b)->SetColor(
kGray);
751 v->GetTreeItem(
b)->ClearColor();
755 if (
auto fits =
_htr->GetFitInfo()) {
756 for (
int i = 0; i <
fits->numEntries(); i++) {
758 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
759 v->GetTreeItem(
b)->SetColor(
kRed);
764 v->GetTreeItem(
b)->SetColor(
kBlue);
791 if (_name ==
".memory")
795 if (
auto o =
v->get(); o)
796 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
797 b->Add(
v.get(), _name, -1);
798 if (
auto o =
v->get(); o)
802 b->SetSelected(
this);
815 auto v = std::make_shared<xRooNode>(
vars());
826 if (
strcmp(
b->GetName(),
".vars") == 0)
849 if (
auto v = var();
v)
850 return v->getBinWidth(bin - 1, GetName());
855 if (
auto v = rvar();
v) {
856 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
857 :
v->getBinning(GetName()).binLow(bin - 1);
863 if (
auto v = rvar();
v)
864 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
870 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
877 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
881 void Set(
Int_t nbins,
const double *xbins)
override
884 v->setBinning(
RooBinning(nbins, xbins), GetName());
889 std::vector<double> bins(nbins + 1);
890 for (
int i = 0; i <= nbins; i++)
891 bins.at(i) = xbins[i];
892 return Set(nbins, &bins[0]);
904 Int_t FindFixBin(
double x)
const override {
return (binning()) ? (binning()->binNumber(
x) + 1) :
x; }
917 if (
name == o->GetName()) {
918 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
929 _parent = _parent->fParent;
935 std::shared_ptr<TObject> out;
936 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
937 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
938 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
943 if (
auto arg =
ws()->
data(
name.c_str()); arg) {
944 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
945 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
950 if (
auto arg =
ws()->genobj(
name.c_str()); arg) {
951 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
952 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
957 if (
auto arg =
ws()->embeddedData(
name.c_str()); arg) {
958 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
959 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
965 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
966 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
976 arg->treeNodeServerList(&nodes);
989 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1005 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1017 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1018 for (
auto &
v : _obs) {
1044 if (o !=
dynamic_cast<TObject *
>(
x)) {
1049 TString binningName = o->getStringAttribute(
"binning");
1050 auto _bnames =
x->getBinningNames();
1051 bool hasBinning =
false;
1053 if (
b == binningName) {
1061 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1063 o->setStringAttribute(
"binning",
nullptr);
1067 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1073 if (
b == o->GetName()) {
1074 binningName = o->GetName();
1078 if (binningName ==
"") {
1084 (std::list<double> *)(
nullptr),
1085 o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1086 std::numeric_limits<double>::infinity()));
1088 std::vector<double>
_bins;
1089 for (
auto &
b : *
bins) {
1097 _v->getBinning(o->GetName())
1102 binningName = o->GetName();
1113 if (
r->getBinning(binningName).isUniform()) {
1114 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1116 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1118 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1119 std::vector<double>
bins = {};
1120 for (
int i = 0; i <=
x->numBins(binningName); i++)
1122 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1125 std::map<int, std::string> cats;
1126 for (
auto &
c : *cat) {
1127 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1128 cats[
c.second] =
c.first;
1131 for (
auto &[
_, label] : cats) {
1132 fXAxis->SetBinLabel(i++, label.c_str());
1137 fXAxis->SetName(binningName);
1144 if (
auto o =
get(); o) {
1145 if (o->InheritsFrom(
"RooWorkspace"))
1147 if (o->InheritsFrom(
"RooAbsData"))
1149 if (o->InheritsFrom(
"RooSimultaneous"))
1152 if (o->InheritsFrom(
"RooProdPdf"))
1154 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1157 if (o->InheritsFrom(
"RooFitResult")) {
1158 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1159 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1160 "package.xpm",
"->Browse()");
1162 return "xRooFitRooFitResult";
1164 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1166 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1167 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1169 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1170 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1173 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1177 if (o->InheritsFrom(
"TStyle")) {
1178 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1179 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1180 "bld_colorselect.xpm",
"->Browse()");
1182 return "xRooFitTStyle";
1184 if (o->InheritsFrom(
"RooConstVar")) {
1190 return "TMethodBrowsable-leaf";
1192 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1193 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1194 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1197 return "xRooFitScanStyle";
1199 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1200 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1201 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1204 return "xRooFitTestStyle";
1206 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1207 return "TBranchElement-folder";
1208 if (o->InheritsFrom(
"RooAbsPdf")) {
1209 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1210 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1213 return "xRooFitPDFStyle";
1217 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1219 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1220 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1221 std::numeric_limits<double>::infinity()))))) {
1226 return o->ClassName();
1237 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1239 if (o->InheritsFrom(
"PiecewiseInterpolation"))
1241 if (o->InheritsFrom(
"RooHistFunc"))
1242 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"ConstDensityHisto" :
"ConstHisto";
1243 if (o->InheritsFrom(
"RooBinWidthFunction"))
1245 if (o->InheritsFrom(
"ParamHistFunc"))
1247 if (o->InheritsFrom(
"RooRealVar"))
1249 if (o->InheritsFrom(
"RooConstVar"))
1257 xRooNode out(
".coords",
nullptr, *
this);
1259 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1289 if (
auto pos =
pName.Index(
'='); pos != -1) {
1290 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1298 _obs->setVal((high + low) / 2.);
1299 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1301 "coordRange",
"coordRange");
1303 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1308 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1311 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1312 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1316 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1318 throw std::runtime_error(
"Unknown observable, could not find");
1330 }
catch (
const std::exception &
e) {
1339 }
catch (
const std::exception &
e) {
1366 pdf =
p->pdfList().find(
child.GetName());
1369 auto i =
p->pdfList().index(*pdf);
1371#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1372 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1373#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1374 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1376 auto nset =
p->_pdfNSetList.At(i);
1377 p->_pdfNSetList.Remove(nset);
1380 if (
p->_extendedIndex == i)
1381 p->_extendedIndex = -1;
1382 else if (
p->_extendedIndex > i)
1383 p->_extendedIndex--;
1395 arg =
p2->components().find(
child.GetName());
1399#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1400 p2->_compRSet.remove(*arg);
1402 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1404 p2->removeServer(*arg,
true);
1414 }
catch (std::runtime_error &) {
1424 arg =
p4->funcList().find(
child.GetName());
1428 auto idx =
p4->funcList().index(arg);
1433 p4->removeServer(*arg,
true);
1435 std::vector<RooAbsArg *>
_coefs;
1437 if (
ii !=
size_t(idx))
1454 auto arg =
w->components().find(
child.GetName());
1461 if (arg->hasClients()) {
1462 throw std::runtime_error(
1463 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1466 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1467 Info(
"Remove",
"Deleted %s from workspace %s", out.GetName(),
GetName());
1475 throw std::runtime_error(
"Removal not implemented for this type of object");
1524 out->setAttribute(
"obs");
1525 out->setAttribute(
"global");
1528 throw std::runtime_error(
"Failed to add global observable");
1532 out->setAttribute(
"poi");
1535 throw std::runtime_error(
"Failed to add parameter of interest");
1539 if (!
fac.Contains(
"["))
1547 throw std::runtime_error(
1548 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1551 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1569 }
else if (!_ws->obj(
_fr->GetName())) {
1578 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1586 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1589 if (
auto _d = _ws->data(
child.GetName()); _d) {
1592 l.remove(*_d->get(),
true,
true);
1596 throw std::runtime_error(
"Cannot extend dataset with new columns");
1607 if (
auto __d = _ws->data(
child.GetName()))
1608 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1616 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1625 throw std::runtime_error(
"Cannot create dataset");
1630 throw std::runtime_error(
"Cannot add to null object with no parentage");
1632 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1637 std::rethrow_exception(std::current_exception());
1642 throw std::runtime_error(
"No object");
1652 throw std::runtime_error(
"Can only add datasets to a dataset");
1661 }
else if (
g->GetContent() !=
glob->GetContent()) {
1662 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1667 if (
auto _dglobs =
p->getGlobalObservables()) {
1678 if (!
p->get()->contains(*col)) {
1679 ds->addColumn(*col);
1689 throw std::runtime_error(
"Can only add histogram or dataset to data");
1693 throw std::runtime_error(
"Could not find pdf");
1694 auto _ax = _pdf->GetXaxis();
1696 throw std::runtime_error(
"Cannot determine binning to add data");
1705 l.remove(*
p->get(),
true,
true);
1709 throw std::runtime_error(
"Cannot extend dataset with new columns");
1716 for (
auto &o :
obs) {
1718 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1719 if (
v->getMin() <
dv->getMin())
1720 dv->setMin(
v->getMin());
1721 if (
v->getMax() >
dv->getMax())
1722 dv->setMax(
v->getMax());
1726 if (!
dc->hasLabel(
c->getCurrentLabel())) {
1727 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
1733 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1735 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1736 throw std::runtime_error(
1737 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1738 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1739 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1740 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1742 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1747 p->add(
obs,
_h->GetBinContent(i));
1757 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
1759 throw std::runtime_error(
"Something went wrong with pdf acquisition");
1766 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
1767 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1768 std::numeric_limits<double>::infinity()));
1769 !_boundaries && _ax->GetNbins() > 0) {
1770#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1771 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
1775 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1776 if (!_p->getStringAttribute(
"alias"))
1777 _p->setStringAttribute(
"alias", out->GetName());
1779 throw std::runtime_error(
1780 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
1786 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
1790 if (_pdf->canBeExtended()) {
1802 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
1834 std::shared_ptr<TObject> out;
1839 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
1844 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
1848 if (!out && !
child.fComp) {
1849 std::shared_ptr<RooAbsArg>
_func;
1860 std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(), _ax->binning()->array());
1862 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
1864 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1865 }
else if (_obs.size() == 1) {
1868 auto _bnames = _x->getBinningNames();
1869 TString binningName =
p->getStringAttribute(
"binning");
1871 if (
b ==
p->GetName()) {
1872 binningName =
p->GetName();
1878 auto h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
1879 _x->getBinningPtr(binningName)->array());
1881 h->GetXaxis()->SetName(
1884 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1885 Info(
"Add",
"Created densityhisto factor %s (xaxis=%s) for %s",
_func->
GetName(), _obs.at(0)->GetName(),
1888 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
1898 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
1902 _f->setAttribute(
"density");
1903 if (
_f->getAttribute(
"autodensity")) {
1905 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
1909 _f->setAttribute(
"autodensity",
false);
1910 _f->setValueDirty();
1919 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
1920 _f->getAttribute(
"density") ?
"densityhisto" :
"histo",
_f->GetName(),
p->GetName());
1924 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
1929 newName.ReplaceAll(
"_samples",
"");
1931 Warning(
"Add",
"converting samples to components");
1936 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
1937 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1938 std::numeric_limits<double>::infinity()));
1939 !_boundaries && _ax->GetNbins() > 0) {
1940#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1941 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
1945 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1946 if (!_p->getStringAttribute(
"alias"))
1947 _p->setStringAttribute(
"alias", out->GetName());
1949 throw std::runtime_error(
1950 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
1957 if (!_p->canBeExtended()) {
1966 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
1973 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
1975 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
1976 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1977 std::numeric_limits<double>::infinity()));
1978 !_boundaries && _ax->GetNbins() > 0) {
1979#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1982 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
1986 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
1987 if (!sumPdf->getStringAttribute(
"alias"))
1988 sumPdf->setStringAttribute(
"alias", out->GetName());
1991 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1992 if (!
_f->getStringAttribute(
"alias"))
1993 _f->setStringAttribute(
"alias", out->GetName());
1995 throw std::runtime_error(
1996 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2004 if (!
p->getStringAttribute(
"binning"))
2005 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2008 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2013 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2022 p->setStringAttribute(
"xvar",
nullptr);
2047 auto out = this->
operator[](
"components")->Add(child);
2066 for (
auto &
_pdfa :
pp->components()) {
2084 auto out = this->
operator[](
"samples")->Add(child);
2087 p2->setStringAttribute(
"xvar",
nullptr);
2100 child.convertForAcquisition(*
this);
2104 if (!
w->import(*_d)) {
2107 throw std::runtime_error(
2118 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2121 std::string
catName =
"channelCat";
2122 if (!
child.empty()) {
2128 _cat->setAttribute(
"obs");
2130 Info(
"Add",
"Created model RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2135 if (
sOpt ==
"pdf") {
2141 }
else if (
sOpt ==
"channel") {
2146 std::shared_ptr<TObject> out;
2147 child.convertForAcquisition(*
this);
2150 }
else if (!
child.fComp) {
2153 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2157 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2163 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2166 }
else if (
sOpt ==
"dataset") {
2169 return (*this).datasets().Add(
child);
2227 a->setAttribute(
"hidden", set);
2238 return a->getAttribute(
"hidden");
2245 if (
get() ==
rhs.get()) {
2253 for (
auto &
c :
rhs.components()) {
2261 for (
auto &
f :
rhs.factors()) {
2269 for (
auto &
v :
rhs.variations()) {
2297 if (!
chans.empty()) {
2308 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2314 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2316 std::shared_ptr<RooProdPdf> pdf =
2317 std::dynamic_pointer_cast<RooProdPdf>(out.acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2322 std::dynamic_pointer_cast<RooAbsArg>(out.acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2338 static std::unique_ptr<cout_redirect>
capture;
2348 if (
sOpt.Contains(
"depth=")) {
2353 if (
sOpt.Contains(
"indent=")) {
2359 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2365 if (
get() &&
get() !=
this) {
2370 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2374 std::cout <<
"Minimization Logs:" << std::endl;
2375 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2389 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2395 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2403 }
else if (!
get()) {
2404 std::cout << std::endl;
2408 std::vector<std::string> folderNames;
2409 for (
auto &k : *
this) {
2410 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2411 folderNames.push_back(k->fFolder);
2414 for (
auto &
f : folderNames) {
2420 std::cout <<
f << std::endl;
2423 for (
auto &k : *
this) {
2424 if (k->fFolder !=
f) {
2430 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2434 auto _deps = k->coords(
false).argList();
2435 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2437 k->get()->Print(
sOpt);
2441 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2449 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2455 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2460 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2466 std::cout <<
" NULL " << std::endl;
2474 for (
size_t i = 0; i <
captureStr.size(); i++) {
2485 (
gROOT->GetListOfBrowsers()->At(0))
2500 double mean = std::numeric_limits<double>::quiet_NaN();
2501 double sigma = mean;
2510 mean = std::numeric_limits<double>::quiet_NaN();
2521 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2527 throw std::runtime_error(
"No error on parameter for poisson constraint");
2529 sigma = pow(
v->getVal() /
v->getError(), 2);
2537 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2538 globs->setConstant();
2539 globs->setAttribute(
"obs");
2540 globs->setAttribute(
"global");
2553 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
2560 globs->setAttribute(
"obs");
2561 globs->setAttribute(
"global");
2562 globs->setConstant();
2571 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
2580 throw std::runtime_error(
"Cannot constrain non arg");
2583 if (!
p->dependsOn(*
_me)) {
2584 throw std::runtime_error(
"Constraint does not depend on constrainee");
2593 throw std::runtime_error(
"Nowhere to put constraint");
2599 for (
auto &
c : *
x) {
2605 return x->Multiply(
child);
2607 return x->Add(
child,
"+");
2630 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
2653 ?
fParent->mainChild()->GetName()
2660 throw std::runtime_error(
2680#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
2687 for (std::size_t i = 0; i <
pSet.size(); i++) {
2697 _bin->fBinNumber = -1;
2726 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
2731 std::rethrow_exception(std::current_exception());
2743 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
2747 }
else if (
sOpt ==
"norm") {
2754 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2759 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
2763 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2767 }
else if (
sOpt ==
"shape" ||
sOpt ==
"histo" ||
sOpt ==
"blankshape") {
2772 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
2773 h->SetBinContent(i, 1);
2778 h->SetTitle(
child.GetTitle());
2779 if (
sOpt.Contains(
"shape"))
2783 Info(
"Multiply",
"Scaled %s by new %s factor %s",
2788 }
else if (
sOpt ==
"overall") {
2790 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
2792 Info(
"Multiply",
"Scaled %s by new overall factor %s",
2796 }
else if (
sOpt ==
"func" &&
ws()) {
2801 Info(
"Multiply",
"Scaled %s by new func factor %s",
2814 std::shared_ptr<TObject> out;
2815 child.convertForAcquisition(*
this);
2824 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
2826 auto coefs =
p->coefList().at(i);
2835 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
2842 const_cast<RooArgList &
>(
p->coefList()).removeAll();
2850 throw std::runtime_error(
"this coefs case is not supported");
2854 std::shared_ptr<TObject> out;
2861 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
2863 _f &&
_f->getAttribute(
"autodensity")) {
2873 if (
_f->getAttribute(
"density")) {
2876 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
2880 _f->setValueDirty();
2887 _f->setAttribute(
"autodensity",
false);
2891 Info(
"Multiply",
"Created %s factor %s in %s",
2895 Info(
"Multiply",
"Created shape factor %s in %s",
child->GetName(),
p->GetName());
2898 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2899#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
2900 p->_compRSet.add(*
_f);
2908 for (
auto &_par :
_out.pars()) {
2911 for (
auto &
_constr : _par->constraints()) {
2919 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
2922 throw std::runtime_error(
"Couldn't find boundConstraint");
2924 _par->Constrain(_pdf);
2933 std::shared_ptr<TObject> out;
2934 child.convertForAcquisition(*
this);
2943 std::shared_ptr<RooAbsPdf> _pdf;
2960 _pdf->setStringAttribute(
"alias",
child.GetName());
2962 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
2963 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
2965 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
2970 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
2971#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
2973#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
2974 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
2978 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
2979 p2->_extendedIndex =
p2->_pdfList.size() - 1;
2990 std::shared_ptr<TObject> out;
2991 child.convertForAcquisition(*
this);
2997 TString s =
p3->getStringAttribute(
"global_factors");
3000 s += out->GetName();
3001 p3->setStringAttribute(
"global_factors", s);
3004 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3005 out->GetName(),
p3->GetName());
3016 std::set<RooAbsArg *> cl;
3017 for (
auto &arg :
p5->clients()) {
3023 if (cl.size() > 1) {
3028 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3034 for (
auto &
a :
p5->attributes())
3035 new_p->setAttribute(
a.c_str());
3036 for (
auto &
a :
p5->stringAttributes())
3037 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3038 if (!
new_p->getStringAttribute(
"alias"))
3039 new_p->setStringAttribute(
"alias",
p5->GetName());
3042 for (
auto arg : cl) {
3054 throw std::runtime_error(
3056 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3064 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3073 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3075 std::set<RooAbsArg *> cl;
3076 for (
auto &arg :
p5->clients()) {
3084 if (cl.size() > 1) {
3092 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3096 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3097 for (
auto arg : cl) {
3121 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3126 std::rethrow_exception(std::current_exception());
3138 std::string label =
child.GetName();
3139 if (
auto pos = label.find(
'='); pos != std::string::npos)
3140 label = label.substr(pos + 1);
3141 if (!s->indexCat().hasLabel(label)) {
3144 std::shared_ptr<TObject> out;
3145 child.convertForAcquisition(*
this);
3148 }
else if (!
child.fComp) {
3151 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3154 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3155 s->addPdf(*_pdf, label.c_str());
3167 child.convertForAcquisition(*
this);
3169 if (!_c &&
child.get()) {
3170 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3172#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3173 double value = (_c ? _c->getVal() :
p->_nominal);
3176 double value = (_c ? _c->getVal() :
p->nominal());
3181 if (
cName ==
"nominal") {
3185 if (
cName.CountChar(
'=') != 1) {
3186 throw std::runtime_error(
"unsupported variation form");
3191 throw std::runtime_error(
"unsupported variation magnitude");
3204 if (!
p->findServer(*
v)) {
3205#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3206 p->_paramList.add(*
v);
3207 p->_low.push_back(0);
3208 p->_high.push_back(0);
3209 p->_interpCode.push_back(4);
3212 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3213 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3214 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3216 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3221 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3224 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3227 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3230 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3240 if (
cName.CountChar(
'=') != 1) {
3241 throw std::runtime_error(
"unsupported variation form");
3246 throw std::runtime_error(
"unsupported variation magnitude");
3248#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3251 throw std::runtime_error(
3252 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3257 throw std::runtime_error(
3258 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3264 for (
auto par :
p2->paramList()) {
3265 if (
parName == par->GetName()) {
3279 std::shared_ptr<RooHistFunc>
up(
3281 std::shared_ptr<RooHistFunc>
down(
3284#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3285 std::unique_ptr<RooDataHist>
h1(
3287 std::unique_ptr<RooDataHist> h2(
3289 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3295 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3296 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3297#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3298 p2->_highSet.add(*
ups.get());
3299 p2->_lowSet.add(*
downs.get());
3300 p2->_interpCode.push_back(4);
3301 p2->_paramSet.add(*
v);
3305 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3308 p2->setValueDirty();
3312 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3313 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3314 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3335 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3336 throw std::runtime_error(
"Cannot vary pure constants");
3342 std::set<RooAbsArg *> cl;
3343 for (
auto &arg :
p3->clients()) {
3348 if (cl.size() > 1) {
3353 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3356 p3->setStringAttribute(
"origName",
p3->GetName());
3358 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3361 std::vector<double>(), std::vector<double>());
3364 for (
auto &
a :
p3->attributes())
3365 new_p->setAttribute(
a.c_str());
3366 for (
auto &
a :
p3->stringAttributes())
3367 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3371 for (
auto arg : cl) {
3382 std::set<RooAbsArg *> cl;
3383 for (
auto &arg :
p4->clients()) {
3388 if (cl.size() > 1) {
3393 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
3396 p4->setStringAttribute(
"origName",
p4->GetName());
3398 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
3403 for (
auto &
a :
p4->attributes())
3404 new_p->setAttribute(
a.c_str());
3405 for (
auto &
a :
p4->stringAttributes())
3406 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3410 for (
auto arg : cl) {
3453 a->setStringAttribute(
"alias",
GetName());
3456 throw std::runtime_error(
"Cannot determine type");
3461 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
3478 throw std::runtime_error(
"no xaxis");
3483 if (
h->GetXaxis()->IsVariableBinSize()) {
3484 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
3492 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
3501 throw std::runtime_error(
"Failed setting stat error");
3505 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
3517 throw std::runtime_error(
"Assignment failed");
3547 std::map<RooAbsRealLValue *, double>
valsToSet;
3549 auto idx = pattern.
Index(
'=');
3552 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3553 for (
auto p :
_pars.argList()) {
3555 p->setAttribute(
"Constant",
true);
3556 if (!std::isnan(val)) {
3568 if (
d->get()->TestBit(1 << 20)) {
3578 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
3579 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
3580 auto fr = _nll.minimize();
3583 throw std::runtime_error(
"Fit Failed");
3586 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
3590 (
gROOT->GetListOfBrowsers()->At(0))
3593 if (fr->status() != 0) {
3595 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3598 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
3599 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
3600 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3605 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3608 }
catch (
const std::exception &
e) {
3611 (
gROOT->GetListOfBrowsers()->At(0))
3622 }
catch (
const std::exception &
e) {
3625 (
gROOT->GetListOfBrowsers()->At(0))
3628 "Exception",
e.what(),
3644 if (
d->get()->TestBit(1 << 20)) {
3650 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
3653 auto idx = pattern.
Index(
'=');
3656 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3657 for (
auto par :
_pars.argList()) {
3659 par->setAttribute(
"Constant",
true);
3660 if (!std::isnan(val)) {
3678 (
gROOT->GetListOfBrowsers()->At(0))
3681 "Scan Finished with Bad Status Code",
3687 if (
auto res =
hs.result())
3693 }
catch (
const std::exception &
e) {
3696 (
gROOT->GetListOfBrowsers()->At(0))
3707 }
catch (
const std::exception &
e) {
3716#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
3721 for (
auto a : *
this) {
3728 for (
auto c : args) {
3734 f.SetParName(i,
c->GetName());
3736 f.SetParLimits(i,
v->getMin(),
v->getMax());
3737 if (
v->isConstant())
3738 f.FixParameter(i,
v->getVal());
3740 f.SetParameter(i,
v->getVal());
3741 f.SetParError(i,
v->getError());
3752 (
gROOT->GetListOfBrowsers()->At(0))
3758 for (i = 0; i <
f.GetNpar(); i++) {
3759 auto c = args.
find(
f.GetParName(i));
3764 f.GetParLimits(i, low, high);
3766 v->setConstant(low);
3768 v->setRange(low, high);
3778 throw std::runtime_error(
"Failed to SetContent");
3779 }
catch (
const std::exception &
e) {
3793 std::shared_ptr<TH1D>
h;
3794 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
3797 if (
_b->isUniform()) {
3802 h->SetOption(
"nostyle");
3803 h->SetDirectory(
nullptr);
3819 auto _ax = (bin) ?
GetXaxis() :
nullptr;
3821 throw std::runtime_error(
"Cannot determine binning to fill data");
3823 if (_ax && _ax->GetNbins() < bin) {
3824 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
3825 _ax->GetName(), _ax->GetNbins()));
3831 for (
auto _c :
coords()) {
3835 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
3843 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
3846 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
3855 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
3856 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
3903 for (
auto &o :
obs) {
3906 if (
v->getMin() <
dv->getMin())
3907 dv->setMin(
v->getMin());
3908 if (
v->getMax() >
dv->getMax())
3909 dv->setMax(
v->getMax());
3913 if (!
dc->hasLabel(
c->getCurrentLabel())) {
3914 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
3928 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
3931 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
3936 for (
int i = 1; i <= _ax->GetNbins(); i++) {
3940 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
3949 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
3955 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
3962 throw std::runtime_error(
"RooDataHist not supported yet");
3967 if (!par ||
strlen(par) == 0) {
3970 return it->SetBinContent(bin,
value);
3982 if (!par ||
strlen(par) == 0) {
3995 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
3998#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4011 auto bin_pars =
f->dataHist().get(bin - 1);
4012 if (
f->getAttribute(
"density")) {
4020 f->setStringAttribute(
"symmetrized_by",
nullptr);
4022 x->setStringAttribute(
"symmetrizes",
nullptr);
4023 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4037 f2->setNominal(
value);
4046 push_back(std::make_shared<xRooNode>(
data));
4053 return node->SetBinContent(bin,
value);
4060 push_back(std::make_shared<xRooNode>(
data));
4067 return node->SetContents(obj);
4105 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4114 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4119 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4126 h->SetName(
"statFactor");
4128 h->SetOption(
"blankshape");
4137 throw std::runtime_error(
"Failed creating stat shapeFactor");
4143 TString prefix =
f->getStringAttribute(
"statPrefix");
4144 if (
value && prefix ==
"") {
4148 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4149 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4156 Form(
"%s_bin%d", prefix.
Data(), bin), 1);
4157#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4164 if (
newVar.get() != var) {
4168 for (std::size_t i = 0; i <
pSet.size(); i++) {
4169 if (
int(i) != bin - 1) {
4184 auto bin_pars =
f->dataHist().get(bin - 1);
4186 if (
f->getAttribute(
"density")) {
4192 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4193 if (s.find(
"sumw_") == 0) {
4195 }
else if (s.find(
"sumw2_") == 0) {
4199 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4201 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4202 rrv->setConstant(
false);
4207 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4212 double _min = tau * (1. - 5. * sqrt(1. / tau));
4213 double _max = tau * (1. + 5. * sqrt(1. / tau));
4216 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4217 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
4219 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
4223 v.constraints().Remove(*
_constr.at(0));
4242 throw std::out_of_range(
name +
" does not exist");
4264 xRooNode out(
".constraints",
nullptr, *
this);
4277 for (
auto &
c :
n.bins()) {
4288 for (
auto p : _ws->allPdfs()) {
4291 if (
p->dependsOn(par)) {
4292 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4300 for (
auto p : o->pdfList()) {
4303 if (
p->dependsOn(par)) {
4304 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4310 for (
auto &
p :
vars()) {
4316 if (
v->getAttribute(
"obs"))
4326 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
4327 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
4329 for (
auto &
c : out) {
4330 if (
c.get() == it->get())
4335 std::string
_cName =
c->GetName();
4339 }
while (
_cName.find(
';') != std::string::npos);
4341 _cName = it->get()->GetName();
4345 }
while (
_cName.find(
';') != std::string::npos);
4353 c->TNamed::SetName(
_cName.c_str());
4367 for (
auto &o : out) {
4368 o->TNamed::SetName(o->get()->GetName());
4389 while (
sOpt2.Contains(
"=")) {
4390 auto pos =
sOpt2.Index(
"=");
4391 auto start =
sOpt2.Index(
";") + 1;
4415 if (
auto pos =
varName.Index(
';'); pos != -1) {
4425 binningName =
ax->GetName();
4426 }
else if (
acquirer.obs().size() == 1)
4430 h->GetXaxis()->GetXmax());
4431 if (
x->getMin() >
h->GetXaxis()->GetXmin())
4432 x->setMin(
h->GetXaxis()->GetXmin());
4433 if (
x->getMax() <
h->GetXaxis()->GetXmax())
4434 x->setMax(
h->GetXaxis()->GetXmax());
4435 if (!
x->hasBinning(binningName.c_str())) {
4436 if (
h->GetXaxis()->IsVariableBinSize()) {
4437 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
4440 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
4441 binningName.c_str());
4443 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
4444 if (
x->getBinningNames().size() == 2) {
4446 x->setBinning(
x->getBinning(binningName.c_str()));
4450 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
4451 throw std::runtime_error(
4452 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
4456 std::shared_ptr<RooAbsArg>
_f;
4463 _f->setStringAttribute(k.c_str(),
v.c_str());
4465 x->setAttribute(
"obs",
true);
4466 }
else if (
sOpt2.Contains(
"shape")) {
4468 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
4469 std::shared_ptr<RooAbsArg> arg;
4470 if (
sOpt2.Contains(
"blankshape")) {
4476 if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
4478 h->GetBinContent(i + 1),
h->GetMinimumStored(),
4479 h->GetMaximumStored());
4482 h->GetBinContent(i + 1));
4489 auto tmp =
dynamic_cast<RooAbsBinning *
>(
x->getBinningPtr(
nullptr)->Clone());
4490 x->setBinning(
x->getBinning(binningName.c_str()));
4492#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4496 .setName(
"paramSet");
4498 x->setBinning(*tmp);
4501 _f->setStringAttribute(k.c_str(),
v.c_str());
4505 binningName.c_str() );
4507 throw std::runtime_error(
"Couldn't make data hist");
4512 f->setAttribute(
"autodensity");
4516 _f->setStringAttribute(k.c_str(),
v.c_str());
4520 _f->setStringAttribute(
"xvar",
x->GetName());
4521 _f->setStringAttribute(
"binning", binningName.c_str());
4528 _f = std::dynamic_pointer_cast<RooAbsArg>(tmp.fComp);
4531 _f->setStringAttribute(
"xvar",
x->GetName());
4532 _f->setStringAttribute(
"binning", binningName.c_str());
4564 if (arg->getStringAttribute(
"style")) {
4565 t = arg->getStringAttribute(
"style");
4575 std::shared_ptr<TStyle>
style;
4577 if (!
gROOT->GetStyle(t)) {
4600 if (arg && !arg->getStringAttribute(
"style")) {
4601 arg->setStringAttribute(
"style",
style->GetName());
4619 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
4620 auto out_arg = _ws->arg(
a->GetName());
4627 if (
aName !=
a->GetName())
4628 Warning(
"acquire",
"Renaming to %s",
a->GetName());
4632 if (
auto res = _ws->factory(arg->GetName()); res) {
4639 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
4660 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
4666 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
4667 }
else if (arg->InheritsFrom(
"RooFitResult") || arg->InheritsFrom(
"TTree") || arg->IsA() ==
TStyle::Class() ||
4668 arg->InheritsFrom(
"RooStats::HypoTestInverterResult") ||
4669 arg->InheritsFrom(
"RooStats::HypoTestResult")) {
4680 if (
aName != arg->GetName()) {
4681 Warning(
"acquire",
"Renaming to %s", arg->GetName());
4683 if (_ws->import(*arg,
false )) {
4687 out_arg = _ws->genobj(arg->GetName());
4712 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
4718 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
4724 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
4730 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
4732 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
4774 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
4777 _x->setBinning(binning,
a->
GetName());
4778 _x->getBinning(
a->GetName()).SetTitle(title);
4779 if (_x->getBinningNames().size() == 2) {
4781 _x->setBinning(_x->getBinning(
a->GetName()));
4786 if (_x->getMax() < high)
4788 if (_x->getMin() > low)
4794 _x->setAttribute(
"obs");
4797 a->setStringAttribute(
"xvar", _x->GetName());
4798 a->setStringAttribute(
"binning",
a->GetName());
4808 if (
ax->IsVariableBinSize()) {
4809 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
4811 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
4817 return find(
name,
false) !=
nullptr;
4825 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
4826 for (
auto &
child : *
this) {
4829 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
4840 for (
auto &
child2 :
x.browse()) {
4870 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
4872 for (
auto &
child : *
this) {
4884 for (
auto &
child2 :
x.browse()) {
4896 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
4914 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
4916 return out->operator[](
name.substr(
partname.length() + 1));
4924 for (
auto o : *
gROOT->GetListOfBrowsers()) {
4926 if (!
b || !
b->GetBrowserImp())
4933 if (!
b->GetBrowserImp())
4949 for (
auto o : *
gROOT->GetListOfBrowsers()) {
4951 if (!
b || !
b->GetBrowserImp())
4958 if (
b->GetBrowserImp()) {
4976 a->setStringAttribute(
"alias",
name);
4977 for (
auto o : *
gROOT->GetListOfBrowsers()) {
4978 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
4980 item->SetText(
name);
5003 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5004 std::vector<std::shared_ptr<xRooNode>> &nn = *
this;
5005 for (
auto &
c : nn) {
5006 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5009 return std::shared_ptr<xRooNode>(
nullptr);
5014 const std::vector<std::shared_ptr<xRooNode>> &nn(
n);
5015 for (
auto &
c : nn) {
5028 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5029 for (
auto &
c :
nn2) {
5030 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5034 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5073 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5086 emplace_back(std::make_shared<xRooNode>(
_coefs));
5098 for (
int i = 0; i < arg->numProxies(); i++) {
5099 auto _proxy = arg->getProxy(i);
5109 for (
auto a2 : *s) {
5110 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5111 if (arg->numProxies() != 1) {
5112 c->fFolder = std::string(
"!.") +
5145 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5158 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5160 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5166 std::vector<std::shared_ptr<xRooNode>> &nn = *
this;
5167 for (
auto &
c : nn) {
5190 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
5191 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
5197 if (
auto fit =
hp->ufit()) {
5198 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
5200 if (
auto fit =
hp->cfit_null()) {
5201 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
5203 if (
auto fit =
hp->cfit_alt()) {
5204 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
5206 if (
auto fit =
hp->gfit()) {
5207 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
5209 if (
auto asi =
hp->asimov()) {
5210 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
5211 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
5213 asiP->TNamed::SetName(
"asimov");
5214 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
5220 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
5221 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
5222 if (it->get()->fTimes == 0) {
5223 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5225 if (
b &&
b->GetBrowserImp()) {
5272 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
5274 for (
auto o :
vars()) {
5277 out.emplace_back(o);
5288 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
5290 for (
auto o :
obs()) {
5293 out.emplace_back(o);
5304 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
5306 for (
auto o :
obs()) {
5309 out.emplace_back(o);
5324 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
5326 for (
auto o :
vars()) {
5329 out.emplace_back(o);
5340 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
5342 for (
auto o :
pars()) {
5345 out.emplace_back(o);
5357 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
5359 for (
auto o :
pars()) {
5362 out.emplace_back(o);
5374 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
5376 for (
auto o :
pars()) {
5379 out.emplace_back(o);
5391 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
5393 for (
auto o :
pars()) {
5395 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
5398 out.emplace_back(o);
5409 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
5411 for (
auto o :
pars()) {
5415 out.emplace_back(o);
5426 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
5429 for (
auto &
x : *
this) {
5430 for (
auto &
y :
x->vars()) {
5445 if (!
c->getAttribute(
"global")) {
5447 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5449 if (
c->getAttribute(
"global")) {
5450 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5451 _globs.back()->fFolder =
"!globs";
5452 }
else if (
c->getAttribute(
"obs")) {
5453 out.back()->fFolder =
"!robs";
5454 }
else if (
c->getAttribute(
"poi")) {
5455 out.back()->fFolder =
"!poi";
5456 }
else if (
c->getAttribute(
"np") ||
5458 out.back()->fFolder =
"!np";
5460 out.back()->fFolder =
"!floats";
5462 out.back()->fFolder =
"!pp";
5468 out.emplace_back(
g);
5471 for (
auto a : *
p2->get()) {
5472 a->setAttribute(
"obs");
5473 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5476 if (
auto _dglobs =
p2->getGlobalObservables()) {
5478 a->setAttribute(
"obs");
5479 a->setAttribute(
"global");
5480 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5485 a->setAttribute(
"obs");
5486 a->setAttribute(
"global");
5487 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5490 }
else if (
auto _ws =
ws(); _ws) {
5493 a->setAttribute(
"obs");
5494 a->setAttribute(
"global");
5495 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5499 for (
auto &
_g :
_gl->second) {
5500 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5501 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5503 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5512 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5513 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5515 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5521 for (
auto a :
w->allVars()) {
5522 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5526 for (
auto a :
w->allCats()) {
5527 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5536 xRooNode out(
".components",
nullptr, *
this);
5541 for (
auto &o :
p->pdfList()) {
5544 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5562 for (
auto &o :
p2->funcList()) {
5565 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5569 for (
auto &o :
p3->list()) {
5570 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5573 for (
auto &
a : *
p4) {
5574 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5577 for (
auto &o :
p5->components()) {
5580 bool hasClients =
false;
5581 for (
auto &
c : o->clients()) {
5582 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
5589 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5590 if (o->InheritsFrom(
"RooAbsPdf")) {
5591 out.back()->fFolder =
"!pdfs";
5593 out.back()->fFolder =
"!scratch";
5596 for (
auto &o :
p5->allGenericObjects()) {
5600 s = s(0, s.
Index(
';'));
5601 if (
auto _pdf = out.find(s.
Data()); _pdf) {
5603 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
5610 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
5612 out.back()->fFolder =
"!fits";
5614 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5615 if (
strcmp(out.back()->get()->ClassName(),
"TStyle") == 0) {
5616 out.back()->fFolder =
"!styles";
5617 }
else if (
strcmp(out.back()->get()->ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
5618 out.back()->fFolder =
"!scans";
5620 out.back()->fFolder =
"!objects";
5627 if (k.find(
"CACHE_") == 0)
5629 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
5630 out.back()->fFolder =
"!sets";
5634 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
5636 while ((
snap = iter->Next())) {
5637 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
5638 out.back()->fFolder =
"!snapshots";
5644 out.emplace_back(
c);
5651 out.emplace_back(
c);
5665 xRooNode out(
".bins",
nullptr, *
this);
5668 std::map<int, std::shared_ptr<xRooNode>> cats;
5669 for (
auto &
c :
p->indexCat()) {
5670 auto pp =
p->getPdf(
c.first.c_str());
5674 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
5676 for (
auto &[
_,
n] : cats)
5677 out.emplace_back(
n);
5680#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5683 auto &
pSet =
phf->paramList();
5685 for (
auto par :
pSet) {
5686 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
5687 out.back()->fBinNumber = i;
5691 for (
int i = 1; i <=
ax->GetNbins(); i++) {
5697 for (
auto &
ss :
f->bins()[i - 1]->factors())
5704 out.emplace_back(std::make_shared<xRooNode>(
5705 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
5711#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5717 out.back()->fBinNumber = i;
5735 if (!parent->fComp) {
5736 while (!parent->fComp && parent->fParent) {
5737 parent = parent->fParent;
5740 parent = parent->fParent;
5746 for (
auto &o :
p->funcList()) {
5748 if (i >=
p->coefList().size()) {
5750 coefs.add(
p->coefList());
5752 coefs.add(*
p->coefList().at(i));
5759 if (
p2->coefList().empty()) {
5764 for (
auto &o :
p2->pdfList()) {
5766 if (i >=
p2->coefList().size()) {
5770 coefs.add(*
p2->coefList().at(i));
5784 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
5785 "Coefficients of",
coefs));
5786 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
5787 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
5790 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
5792 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
5794 if (!
coefs.empty()) {
5798 }
else if (
coefs.size() == 1) {
5800 if (!
coefs.empty()) {
5819 xRooNode out(
".factors",
nullptr, *
this);
5824 a->setStringAttribute(
"alias",
"samples");
5826 a2->setStringAttribute(
"alias",
"components");
5828 int _npdfs =
p->pdfList().size();
5829 for (
auto &o :
p->pdfList()) {
5830 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5832 out.back()->fFolder =
"!constraints";
5835 for (
auto &o :
p2->components()) {
5836 if (o->InheritsFrom(
"RooProduct")) {
5838 auto x =
xRooNode(
"tmp", *o, *
this).factors();
5840 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
5843 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5852 for (
auto a :
w->allFunctions()) {
5853 if (_obs.contains(*
a))
5856 for (
auto c :
a->clients()) {
5858 if (
c->InheritsFrom(
"RooProduct"))
5862 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5906 xRooNode out(
".variations",
nullptr, *
this);
5919#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5920 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
5922 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
5924 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
5926 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
5927 *
p2->highList().at(i), *
this));
5928 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
5929 *
p2->lowList().at(i), *
this));
5932#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5933 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
5934 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
5935 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
5937 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
5941 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
5942 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
5943 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
5945 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
5969 for (
auto &k : *
this) {
5978 xRooNode out(
".datasets()",
nullptr, *
this);
5984 for (
auto &
d : _ws->allData()) {
5985 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
5986 out.back()->fFolder =
"!datasets";
5999 for (
auto _c :
coords()) {
6003 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6012 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6017 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6024 for (
auto cat : s->indexCat()) {
6025 if (!s->getPdf(cat.first.c_str())) {
6037 cutobs.add(s->indexCat());
6046 for (
auto &
child : *
this) {
6052 for (
auto &
d :
_wsNode.datasets()) {
6058 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6065 out.emplace_back(std::make_shared<xRooNode>(
6070 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6072 if (
d->get()->TestBit(1 << 20))
6073 out.back()->get()->SetBit(1 << 20);
6075 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6077 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6117 for (
auto o : *
fromPad->GetListOfPrimitives()) {
6137 cat->numTypes(), 0, cat->numTypes());
6139 std::map<int, std::string> cats;
6140 for (
auto &
c : *cat) {
6141 cats[
c.second] =
c.first;
6143 for (
auto &[
_, label] : cats) {
6144 theHist->GetXaxis()->SetBinLabel(i++, label.c_str());
6147 auto _binning =
v->getBinningPtr(
nullptr);
6148 if (_binning->isUniform()) {
6152 v->numBins(), _binning->lowBound(), _binning->highBound());
6157 v->numBins(), _binning->array());
6161 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
6174 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
6213 int nevent =
theData->numEntries();
6214 for (
int i = 0; i < nevent; i++) {
6219 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
6225 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
6258 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
6260 double val =
theHist->GetBinContent(i + 1);
6263 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
6266 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
6279 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
6283 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
6284 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
6318 throw std::runtime_error(
"Cannot build graph");
6324 if (
auto _w =
ws();
_w) {
6326 for (
auto o :
_w->allGenericObjects()) {
6328 _fr->ResetBit(1 << 20);
6331 res->SetBit(1 << 20);
6333 auto allVars =
_w->allVars();
6338 throw std::runtime_error(
"Not supported yet");
6352 throw std::runtime_error(
"Not a RooFitResult");
6363#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
6375 if (
sOpt ==
"prefit") {
6389 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
6390 fr->setFinalParList(*
_pars);
6391 for (
auto &
p : fr->floatParsFinal()) {
6395 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
6398 std::shared_ptr<xRooNode>
pConstr;
6405 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
6406 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
6423 for (
auto &_d :
pConstr->vars()) {
6424 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
6448 if (!
_v->getStringAttribute(
"nominal"))
6460 _args.add(
_globs.argList());
6461 fr->setConstParList(_args);
6464 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6467 fr->setInitParList(*
_snap);
6472 if (
auto _w =
ws();
_w) {
6477 for (
auto p :
pars()) {
6481 _fr->floatParsFinal().getCatIndex(cat->GetName(), std::numeric_limits<int>().max())) {
6486 if (
_fr->floatParsFinal().find(
p->GetName()) ||
6487 std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6493 if (
_fr->constPars().find(
p->GetName()) ||
6495 _fr->floatParsFinal().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6504 std::unique_ptr<RooArgList>
_pars(
6506 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
6508 fr->setFinalParList(*
_pars);
6513 for (
size_t i = 0; i <
_pars->size(); i++) {
6515 cov(i, i) = pow(
v->getError(), 2);
6520 fr->setCovarianceMatrix(
cov);
6527 _args.add(
_globs.argList());
6528 fr->setConstParList(_args);
6531 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6534 fr->setInitParList(*
_snap);
6537 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
6541 for (
auto o :
_w->allGenericObjects()) {
6567 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
6569 fr->setFinalParList(*
_pars);
6575 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
6576 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
6577 cov(i,
j) = (*prevCov)(i,
j);
6582 for (
auto &
p : fr->floatParsFinal()) {
6585 cov(i, i) = pow(
v->getError(), 2);
6593 fr->setCovarianceMatrix(
cov);
6600 _args.add(
_globs.argList());
6601 fr->setConstParList(_args);
6604 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6607 fr->setInitParList(*
_snap);
6637 o->setStringAttribute(
"range",
range);
6644 std::string &out =
fRange;
6645 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
6646 out = o->getStringAttribute(
"range");
6648 while (out.empty() && _parent) {
6649 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
6650 out = o->getStringAttribute(
"range");
6651 _parent = _parent->fParent;
6671 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
6691 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
6692 "generate with (found at least %s and %s)",
6710 for (
auto c :
bins()) {
6732 if (
d->get()->TestBit(1 << 20)) {
6738 throw std::runtime_error(
6739 "Need at least one dataset selected (SetChecked) to use for deselected regions");
6769 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
6770 "build nll with (found at least %s and %s)",
6785 for (
auto c :
bins()) {
6806 _d = std::make_shared<xRooNode>(
asi.first, *
this);
6809 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
6819 me.push_back(std::make_shared<xRooNode>(
_data));
6836 for (
int i = 0; i <
opts.GetSize(); i++) {
6839 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
6850 std::dynamic_pointer_cast<RooAbsData>(
_data.fComp), *
_opts);
6948 auto rangeName = (_range.empty()) ?
GetRange() : _range;
6949 if (!rangeName.empty()) {
6960 for (
auto &
c :
bins()) {
6963 _cat.setLabel(
cName);
6970 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
6984 std::vector<TObject *>
funcs;
6985 for (
auto &
c : out.components()) {
6994 funcs.push_back(
c->get());
6998 if (!
funcs.empty()) {
7000 _pdf->setFloor(
false);
7026 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
7028 fr->setCovarianceMatrix(
_tmp);
7030 const_cast<RooArgList &
>(fr->floatParsFinal())
7040 for (
auto c : *
this) {
7041 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
7045 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
7149 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
7158 return getProjection(&intobs,
_normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
7167 fFunc(
"func",
"func",
this,
f),
7168 fCoef(
"coef",
"coef",
this),
7169 fExpPdf(
"expPdf",
"expPdf",
this)
7174 fCoef.setArg(*coef);
7178 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
7190 fExpectedEventsMode(
other.fExpectedEventsMode)
7197 return fFunc->binBoundaries(obs, xlo, xhi);
7202 return (fExpectedEventsMode ? 1. : fFunc) *
7203 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(
_normSet) : 1.) *
7204 (fCoef.absArg() ? fCoef : 1.);
7215#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
7216 double oo = getPropagatedError(fr,
nset_in);
7217 if (std::isnan(
oo)) {
7236 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
7246 std::stringstream
errMsg;
7248 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
7249 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
7251 throw std::runtime_error(
errMsg.str());
7256 if (paramList.
empty())
7291#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7315 std::vector<double>
errVec(paramList.
size());
7316 for (std::size_t i = 0; i < paramList.
size(); i++) {
7317 errVec[i] = std::sqrt(V(i, i));
7318 for (std::size_t
j = i;
j < paramList.
size();
j++) {
7319 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
7326 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7331 double sum = F * (C *
F);
7341 if (
frv->getError() > 1
e-20) {
7358 for (
Int_t i = 0; i <
fpf.size(); i++) {
7361 paramList.
add(*par);
7397 std::vector<double>
errVec(paramList.
size());
7398 for (
int i = 0; i < paramList.
size(); i++) {
7399 errVec[i] = sqrt(V(i, i));
7400 for (
int j = i;
j < paramList.
size();
j++) {
7401 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
7408 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7413 double sum = F * (C *
F);
7427 bool fExpectedEventsMode =
false;
7435 std::cout <<
"Got signal " <<
signum << std::endl;
7437 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
7450 for (
int i = 0; i < obj->numCaches(); i++) {
7456 p->setNormRange(
p->normRange());
7458#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7463 p->setProxyNormSet(
nullptr);
7464 p->_lastNSet =
nullptr;
7467 obj->setValueDirty();
7471 for (
auto &
c :
w->components()) {
7491 for (
auto obj :
a->clients()) {
7498 }
while (
a->clients().size() !=
nClients);
7516 }
else if (
vars.size() == 1) {
7520 throw std::runtime_error(
"multi-dim histo not yet supported");
7523 if (
auto h = out.get<
TH1>()) {
7524 if (
h->GetXaxis()->IsAlphanumeric()) {
7526 h->GetXaxis()->SetName(
"xaxis");
7530 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
7541 std::vector<TH1 *>
hhs;
7550 if (
c->fFolder ==
"!.coeffs")
7557 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
7562 Form(
"ORIGNAME:%s",
c->GetName()));
7566 auto hh =
xRooNode(*
f, *
this).BuildHistogram(
v,
false,
false, !
v ? -1 : 1, !
v ? -1 : 0, fr);
7568 hh->Scale(
sf->getVal());
7570 hh->SetTitle(
c->GetName());
7573 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
7581 auto hh =
samp->BuildHistogram(
v,
false,
false, !
v ? -1 : 1, !
v ? -1 : 0, fr);
7583 hh->Scale(
sf->getVal());
7586 hh->SetTitle(
samp->GetName());
7591 for (
auto &
hh :
hhs) {
7592 if (
h->GetXaxis()->IsAlphanumeric()) {
7594 hh->GetXaxis()->SetName(
"xaxis");
7595 for (
int i = 1; i <=
hh->GetNbinsX(); i++)
7596 hh->GetXaxis()->SetBinLabel(i,
h->GetXaxis()->GetBinLabel(i));
7607 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
7615 hh->SetFillColor(it->second);
7619 hh->SetFillColor((count++) % 100);
7623 if (
hh !=
hh2 &&
hh2->GetFillColor() ==
hh->GetFillColor()) {
7695 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
7702 for (
int i = ll->
GetEntries() - 1; i >= 0; i--) {
7719 dynamic_cast<TAttFill *
>(ll->
At(i))->GetFillStyle() != 0) {
7726 h->GetListOfFunctions()->Add(stack,
"noclearsame");
7727 if (
h->GetSumw2() &&
h->GetSumw2()->GetSum()) {
7728 hCopy->SetFillStyle(3005);
7729 hCopy->SetFillColor(
h->GetLineColor());
7730 hCopy->SetMarkerStyle(0);
7731 h->GetListOfFunctions()->Add(
hCopy->Clone(
".copy"),
"e2same");
7736 h->GetListOfFunctions()->Add(
hCopy,
"histsame");
7737 if (
h->GetSumw2() &&
h->GetSumw2()->GetSum()) {
7739 h->SetFillColor(
h->GetLineColor());
7740 h->SetMarkerStyle(0);
7776 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
7777 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
7778 h->GetXaxis()->SetName(
rar->GetName());
7787 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
7789 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
7790 h->SetBinContent(1,
rar->getVal());
7792 h->SetBinError(1,
x->getError());
7793 h->SetMaximum(
x->hasMax() ?
x->getMax()
7794 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
7795 h->SetMinimum(
x->hasMin() ?
x->getMin()
7796 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
7801 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
7802 if (binningName ==
"")
7803 binningName =
rar->GetName();
7804 if (
x->hasBinning(binningName)) {
7805 if (
x->getBinning(binningName).isUniform()) {
7806 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
7807 x->getMin(binningName),
x->getMax(binningName));
7809 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
7811 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
7813 }
else if (
auto _boundaries =
7814 _or_func( (std::list<double> *)(
nullptr),
7815 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
7816 std::numeric_limits<double>::infinity()));
7818 std::vector<double>
_bins;
7819 for (
auto &
b : *_boundaries) {
7825 }
else if (!
x->hasMax() || !
x->hasMin()) {
7827 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
7829 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
7833 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
7836 std::map<int, std::string> cats;
7837 for (
auto &
c : *cat) {
7838 cats[
c.second] =
c.first;
7840 for (
auto &[
_, label] : cats) {
7841 h->GetXaxis()->SetBinLabel(i++, label.c_str());
7846 h->GetXaxis()->SetTitle(o->GetTitle());
7851 if (
h->GetXaxis()->IsAlphanumeric()) {
7859 if (
auto s =
style(
nullptr,
false); s) {
7864 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
7865 h->GetXaxis()->SetTitle(
vv->GetTitle());
7894 if (!
GETDMP(fr, _finalPars)) {
7922 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
7923 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
7924 cov(i,
j) = (*prevCov)(i,
j);
7944 _pars.remove(*_p,
true);
7977 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
7995 for (
auto o : _obs) {
7997 rr->removeRange(
"coordRange");
7998 rr->setStringAttribute(
"coordRange",
nullptr);
8002 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8003 rr->removeRange(
"coordRange");
8004 rr->setStringAttribute(
"coordRange",
nullptr);
8014 bool hasRange =
false;
8017 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
8027 for (
auto pdf :
bins()) {
8034 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
8036 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
8040 rar =
p->createProjection(
8044 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
8048 p->setNormRange(
"coordRange");
8053 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
8059 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
8069 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
8077 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
8080 x->setVal(
h->GetBinCenter(i));
8082 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
8086 if (
x && !
x->inRange(
"coordRange"))
8092#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8101 r *=
h->GetBinWidth(i);
8109 h->SetBinContent(i,
r);
8117 .getSimplePropagatedError(*fr,
normSet);
8118#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8120 p->_normSet =
nullptr;
8125 .getPropagatedError(
8131 res *=
h->GetBinWidth(i);
8133 h->SetBinError(i, res);
8144 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
8154 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
8167 std::vector<RooAbsArg *> extra;
8170 for (
auto _pdf : s->servers()) {
8172 extra.push_back(_pdf);
8175 extra.push_back(
rar);
8178 for (
auto a : extra)
8185 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
8187 h->GetYaxis()->SetTitle(
"Events");
8189 h->GetYaxis()->SetTitle(
"Probability Mass");
8191 h->GetYaxis()->SetMaxDigits(3);
8204 push_back(std::make_shared<xRooNode>(
data));
8212 return std::numeric_limits<double>::quiet_NaN();
8213 return node->GetBinContent(bin);
8224 std::vector<double> out;
8236 for (
int i = 0; i <
g->GetN(); i++)
8237 integral +=
g->GetPointY(i);
8238 out.push_back(integral);
8243 out.push_back(
g->GetPointY(i));
8264 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
8265 tot +=
h->GetBinContent(i);
8270 out.push_back(
h->GetBinContent(i));
8281 for (
auto &
l :
a->servers()) {
8301 if (
auto o =
get(); o) {
8310#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8314 for (
int i = 0; i <
p->fCGnx; i++) {
8315 for (
int j = 0;
j <
p->fCGny;
j++) {
8316 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
8319 p->FillCollideGrid(o);
8328 if (
p->Collide(i,
j,
iw,
ih)) {
8339 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
8347 gPad->PaintModified();
8353 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
8354 1. -
gPad->GetTopMargin() - 0.08);
8355 l->SetBorderSize(0);
8356 if (
l->GetTextSize() == 0)
8364 l->ConvertNDCtoPad();
8370 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
8373 double w =
p->GetX2NDC() -
p->GetX1NDC();
8374 double h =
p->GetY2NDC() -
p->GetY1NDC();
8376 gPad->PaintModified();
8380 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
8381 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
8382 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
8383 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
8384 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
8385 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
8397 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
8398 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
8406 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
8411 gPad->GetBottomMargin());
8412 l->SetBorderSize(1);
8416 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
8417 l->SetBorderSize(0);
8419 if (
l->GetTextSize() == 0) {
8427 l->SetName(
"legend");
8429 l->ConvertNDCtoPad();
8436 auto i = s.find(
"\n");
8437 if (i == std::string::npos) {
8440 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
8449 for (
auto a : *
l->GetListOfPrimitives()) {
8453 if (
l->GetListOfPrimitives()->GetEntries() > 20)
8457 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
8459 int nn =
l->GetNColumns();
8461 if (
nObj > 1 && (
nObj % nn) == 1) {
8462 l->SetNColumns(
l->GetNColumns() + 1);
8463 if (
l->GetBorderSize() == 0) {
8464 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
8467 if (
l->GetBorderSize() == 0) {
8468 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
8484 fPad->GetCanvas()->Paint();
8485 fPad->GetCanvas()->Update();
8486#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
8487 fPad->GetCanvas()->ResetUpdated();
8502 if (
gROOT->FromPopUp()) {
8503 gROOT->SetFromPopUp(
false);
8506 }
catch (
const std::exception &
e) {
8509 (
gROOT->GetListOfBrowsers()->At(0))
8512 "Exception",
e.what(),
8515 gROOT->SetFromPopUp(
true);
8545 if (
d->get()->TestBit(1 << 20)) {
8551 hs.limits(
"cls visualize");
8563 [](
double a,
double b,
double) {
8566 if (
b == 0 &&
a == 0)
8573 [](
double n,
double b,
double sigma) {
8577 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
8587 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
8596 if (
sOpt2.Contains(
"x=")) {
8598 int _idx =
sOpt2.Index(
"x=");
8614 }
else if (
ii == 1) {
8616 }
else if (
ii == 2) {
8624 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
8627 }
else if (nBins == 1)
8628 xPoints.push_back((min + max) / 2.);
8637 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
8647 if (
sOpt2.Contains(
"force")) {
8661 Error(
"Draw",
"Can only compute forces with PDFs");
8673 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
8675 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
8676 sOpt +=
"auxSignif";
8687 sOpt.ReplaceAll(
"ratio",
"");
8688 sOpt.ReplaceAll(
"significance",
"");
8690 sOpt.ReplaceAll(
"nostack",
"");
8692 sOpt.ReplaceAll(
"same",
"");
8694 sOpt.ReplaceAll(
"goff",
"");
8696 sOpt.ReplaceAll(
"pull",
"");
8700 sOpt.ReplaceAll(
"e",
"");
8702 sOpt.ReplaceAll(
"txt",
"texte");
8704 sOpt.ReplaceAll(
"txt",
"text");
8717 if (
gPad->GetNumber() == 0) {
8737 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
8739 for (
auto o : *
pad->GetListOfPrimitives()) {
8746 :
hAxis->GetXaxis()->GetName())
8768 double ymin =
hh->GetMinimum();
8769 double ymax =
hh->GetMaximum();
8770 if (
hh->GetMaximumStored() == -1111)
8772 if (
hh->GetMinimumStored() == -1111) {
8775 }
else if (
ymin < 0) {
8783 if (
hh->GetSumw2()) {
8786 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
8806 double up =
ymax -
hh->GetBinContent(1);
8831 double ymax = -std::numeric_limits<double>::infinity();
8832 double ymin = std::numeric_limits<double>::infinity();
8833 for (
int i = 0; i <
gr->
GetN(); i++) {
8845 out->SetFillColor(out->GetLineColor());
8846 out->SetMarkerStyle(0);
8853 out->SetPointEYlow(out->GetN() - 1,
GetError());
8854 out->SetPointEYhigh(out->GetN() - 1, out->GetErrorYlow(out->GetN() - 1));
8867 pad->Divide(1, 2, 1
e-9, 1
e-9);
8868 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
8869 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
8871 optNoFR.ReplaceAll(
"pull",
"");
8881 gPad->GetFrame()->SetFillStyle(1001);
8882 gPad->SetTopMargin(0);
8883 gPad->SetBottomMargin(0);
8884 gPad->SetName(
"pull");
8888 Error(
"Draw",
"Couldn't find pull graph");
8897 throw std::runtime_error(
"Could not find scales in fit result");
8899 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
8904 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
8908 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
8909 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
8913 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
8914 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
8915 g->SetEditable(
true);
8916 g->SetHighlight(
true);
8917 g->SetMarkerStyle(20);
8918 g->SetMarkerSize(0.5);
8944 if (!
_v->IsHidden())
8953 pad->SetBorderSize(0);
8975 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
8977 auto _pad =
pad->GetPad(_size);
8978 _pad->SetName(
"legend");
8980 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
8983 while (
pad->GetPad(
x + 1)) {
8984 pad->GetPad(
x + 1)->SetFillStyle(0);
8994 if (_range &&
strlen(_range)) {
9018 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9033 for (
auto &
_v : *
this) {
9040 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9043 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9053 pad->SetBorderSize(0);
9054 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
9057 for (
auto &
_v : *
this) {
9064 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9067 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9076 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9095 if (
sOpt.Contains(
"corr")) {
9098 auto hist = fr->correlationHist(fr->GetName());
9099 hist->SetTitle(fr->GetTitle());
9102 hist->SetStats(
false);
9103 hist->SetDirectory(
nullptr);
9106 hist->GetXaxis()->SetTickSize(0);
9107 hist->GetYaxis()->SetTickSize(0);
9108 hist->SetMinimum(-100);
9111 gPad->SetGrid(1, 1);
9117 if (
sOpt.Contains(
"brakdown")) {
9123 if (
sOpt.Contains(
"brakdown:")) {
9127 std::unique_ptr<RooAbsCollection> _poi(fr->floatParsFinal().selectByAttrib(
"poi",
true));
9128 if (_poi->empty()) {
9129 throw std::runtime_error(
"No floating poi in the fit");
9130 }
else if (_poi->size() != 1) {
9131 throw std::runtime_error(
"Multiple poi in the fit");
9133 poiName = _poi->first()->GetName();
9139 std::set<std::string>
groups;
9140 for (
auto p : fr->floatParsFinal()) {
9143 }
else if (
p->getStringAttribute(
"group")) {
9144 groups.insert(
p->getStringAttribute(
"group"));
9168 for (
auto p : fr->floatParsFinal()) {
9171 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
9172 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
9178 double reducedVar = fr->conditionalCovarianceMatrix(
pars)(idx, idx);
9180 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
9181 pie->SetEntryVal(i, 0);
9190 pie->SetEntryLabel(i,
group.c_str());
9198 double variance = fr->conditionalCovarianceMatrix(*
poi)(0, 0);
9205 pie->SetRadius(0.17);
9214 out->SetTitle(
"Fit Result Pulls");
9218 ugraph->SetTitle(
"Fit Result Pulls");
9220 std::map<std::string, double>
scale;
9221 std::map<std::string, double>
offset;
9222 for (
auto &
p : fr->floatParsFinal()) {
9227 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
9228 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
9237 dynamic_cast<RooRealVar *
>(fr->floatParsInit().find(
p->GetName()))) {
9242 std::shared_ptr<xRooNode>
pConstr;
9245 if (
_vv->hasRange(
"pullScale")) {
9255 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
9256 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
9278 std::string
xName =
pConstr->find(
".x")->get()->GetName();
9280 for (
auto &_d :
pConstr->vars()) {
9281 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
9283 if (
xName == _d->get()->GetName())
9307 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
9311 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
9322 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
9329 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
9341 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
9354 for (
int i = 0; i <
ugraph->GetN(); i++)
9368 graph->SetMarkerStyle(20);
9369 graph->SetMarkerSize(0.5);
9371 graph->SetMaximum(4);
9372 graph->SetMinimum(-4);
9375 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
9377 std::vector<std::pair<double, std::string>>
covariances;
9380 if (
sOpt.Contains(
"impact")) {
9381 if (
sOpt.Contains(
"impact:")) {
9385 std::unique_ptr<RooAbsCollection> _poi(fr->floatParsFinal().selectByAttrib(
"poi",
true));
9386 if (_poi->empty()) {
9387 throw std::runtime_error(
"No floating poi in the fit");
9388 }
else if (_poi->size() != 1) {
9389 throw std::runtime_error(
"Multiple poi in the fit");
9391 poiName = _poi->first()->GetName();
9397 size_t poiIdx = fr->floatParsFinal().index(*
poi);
9407 covariances.emplace_back(fr->covarianceMatrix()(
poiIdx, fr->floatParsFinal().index(label)) /
9408 dynamic_cast<RooRealVar *
>(fr->floatParsFinal().find(label))->getError(),
9412 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
9413 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
9414 : (std::abs(i.first) > std::abs(j.first));
9444 graph->SetTitle(
"Fit Result Impact");
9450 hist =
new TH2D(
GetName(), fr->GetTitle(), 100, -4, 4, std::max(
graph->GetN(), 1), -0.5,
9451 std::max(
graph->GetN(), 1) - 0.5);
9460 hist =
new TH2D(
GetName(), fr->GetTitle(), std::max(
graph->GetN(), 1), -0.5, std::max(
graph->GetN(), 1) - 0.5,
9487 graph->GetHistogram()->GetXaxis()->Set(std::max(
graph->GetN(), 1), -0.5, std::max(
graph->GetN(), 1) - 0.5);
9489 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
9504 gPad->Divide(1, 1, 1
e-9, 1
e-9);
9508 gPad->SetLeftMargin(0.4);
9510 gPad->SetBottomMargin(0.4);
9518 auto _p = fr->floatParsFinal().find(
_axis->GetBinLabel(
ii));
9521 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
9526 if (!
sOpt.Contains(
"impact")) {
9527 for (
int ii = 2;
ii >= 1;
ii--) {
9562 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
9563 pave->SetFillStyle(0);
9564 pave->SetBorderSize(0);
9565 pave->SetMargin(0.);
9566 pave->SetName(
"status");
9567 pave->SetTextAlign(31);
9570 switch (fr->covQual()) {
9572 case 0:
covQualTxt =
"Not calculated";
break;
9574 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
9578 ->SetTextColor((fr->covQual() == 3) ?
kBlack :
kRed);
9581 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
9589 gPad->SetTicks(0, 0);
9593 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
9594 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
9598 double factor = 475. /
gPad->GetCanvas()->GetWh();
9627 for (
int tt = 0;
tt < 2;
tt++) {
9628 auto impact =
static_cast<TH1 *
>(
9632 impact->SetBarWidth(0.9);
9633 impact->SetBarOffset(0.05);
9634 impact->SetLineColor(
kBlack);
9635 impact->SetFillColor(
kAzure - 4);
9636 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
9638 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
9639 impact2->SetDirectory(
nullptr);
9645 auto vv =
dynamic_cast<RooRealVar *
>(fr->floatParsFinal().find(
c.second.c_str()));
9646 auto vv_init =
dynamic_cast<RooRealVar *
>(fr->floatParsInit().find(
c.second.c_str()));
9647 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
9649 :
c.first *
vv->getError() /
vv->getErrorHi() *
9650 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
9653 :
c.first *
vv->getError() /
vv->getErrorLo() *
9654 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
9661 for (
int ii = -1;
ii <= 1;
ii++) {
9674 leg1->SetFillStyle(0);
9675 leg1->SetBorderSize(0);
9676 leg1->SetMargin(0.25);
9677 leg1->SetNColumns(2);
9679 leg1->SetTextSize(
_axis->GetLabelSize());
9680 leg1->SetTextFont(
_axis->GetLabelFont());
9681 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
9682 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
9683 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
9684 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
9685 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
9686 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
9687 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
9688 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
9694 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
9701 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
9709 graph->SetEditable(
false);
9716 for (
int p = 0;
p <
graph->GetN();
p++) {
9719 graph->GetErrorXhigh(
p));
9722 if (
f->InheritsFrom(
"TH1")) {
9731 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
9732 for (
int p = 0;
p <
g->GetN();
p++) {
9733 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
9736 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
9746 graph->SetName(
"pulls");
9767 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
9768 hh->SetDirectory(
nullptr);
9786 for (
auto c : s->bins()) {
9787 auto _pad =
dynamic_cast<TPad *
>(
gPad->GetPrimitive(
c->GetName()));
9792 c->push_back(std::make_shared<xRooNode>(*
this));
9794 c->resize(
c->size() - 1);
9796 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
9815 for (
auto o : *
gPad->GetListOfPrimitives()) {
9840 for (
int i = 0; i <
dataGraph->GetN(); i++)
9857 for (
auto o : *
gPad->GetListOfPrimitives()) {
9858 if (
auto h =
dynamic_cast<TH1 *
>(o);
9868 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
9871 histName = histName(0, histName.
Index(
'|'));
9872 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
9878 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
9890 if (!std::isnan(
yval)) {
9892 if (!std::isnan(yup))
9894 if (!std::isnan(
ydown))
9961 if (!
d->get()->TestBit(1 << 20))
9965 auto _obs =
d->obs();
9969 int nevent =
theData->numEntries();
9970 for (
int i = 0; i < nevent; i++) {
9973 for (
const auto &_c :
_coords) {
9975 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
9985 auto val = _nll.pars()->getRealValue(
initPar->GetName());
9988 auto nllVal = _nll.getEntryVal(i);
9989 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
9990 auto nllVal2 = _nll.getEntryVal(i);
9991 _nll.pars()->setRealValue(
initPar->GetName(), val);
9997 auto val = _nll.pars()->getRealValue(
initPar->GetName());
10000 auto _extTerm = _nll.extendedTerm();
10001 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
10003 _nll.pars()->setRealValue(
initPar->GetName(), val);
10004 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
10009 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
10015 }
else if (
ii == 3) {
10046 :
h->GetXaxis()->GetName())
10049 if (
h->GetXaxis()->IsAlphanumeric()) {
10054 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
10055 rar->InheritsFrom(
"RooSimultaneous"))) {
10058 rar->leafNodeServerList(&s);
10065 for (
auto _p : s) {
10073 if (
_v->hasError()) {
10084 gPad->SetGrid(0, 0);
10086 gPad->SetGrid(1, 1);
10093 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
10096 -std::numeric_limits<double>::infinity(),
10097 std::numeric_limits<double>::infinity()))))
10110 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
10122 gROOT->SetEditHistograms(
true);
10124 gROOT->SetEditHistograms(
false);
10133 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
10138 bool hasError(
false);
10139 for (
int i = 0; i <
h->GetSumw2N(); i++) {
10140 if (
h->GetSumw2()->At(i)) {
10151 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
10152 h->GetYaxis()->SetTitleOffset(1.);
10157 h->SetFillStyle(hasError ? 3005 : 0);
10158 h->SetFillColor(
h->GetLineColor());
10159 h->SetMarkerStyle(0);
10162 errHist->SetDirectory(
nullptr);
10163 h->SetFillStyle(0);
10164 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
10165 h->SetBinError(i, 0);
10180 hCopy->SetDirectory(
nullptr);
10181 _hist->GetListOfFunctions()->Add(node);
10182 _hist->GetListOfFunctions()->Add(
new TExec(
10185 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
10186 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
10187 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
10188 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
10189 "h->SetBinContent(1, "
10190 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
10191 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
10192 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
10193 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
10194 _hist->GetName(), node->GetName())));
10196 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
10197 errHist->SetFillColor(
h->GetLineColor());
10200 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
10201 _hist->SetBinError(1, 0);
10203 _hist->SetStats(
false);
10205 _hist->Draw(((
errHist) ?
"e2" :
""));
10257 errHist->SetFillColor(
h->GetLineColor());
10268 errHist->SetFillColor(
h->GetLineColor());
10275 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
10286 std::vector<TH1 *>
hhs;
10293 if (!
rarNode->components().empty()) {
10295 for (
auto &
c : *
comps) {
10296 if (
c->fFolder ==
"!.coeffs")
10302 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
10305 std::unique_ptr<RooAbsReal>
f(
10306 dynamic_cast<RooAbsReal *
>(
rarNode->components()[0]->get()->Clone(
"tmpCopy")));
10308 Form(
"ORIGNAME:%s",
c->GetName()));
10313 hh->SetName(
c->GetName());
10315 hh->Scale(
sf->getVal());
10316 if (
strlen(
hh->GetTitle()) == 0) {
10317 hh->SetTitle(
c->GetName());
10319 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
10324 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
10340 for (
auto &
samp :
samps.components()) {
10341 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
10343 hh->SetTitle(
samp->GetTitle());
10344 if (
strlen(
hh->GetTitle()) == 0) {
10345 hh->SetTitle(
samp->GetName());
10347 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
10351 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
10355 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
10361 auto hh =
samp->BuildHistogram(
v);
10363 hh->Scale(
sf->getVal());
10365 if (
strlen(
hh->GetTitle()) == 0) {
10366 hh->SetTitle(
samp->GetName());
10368 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
10376 if (!
hhs.empty()) {
10377 for (
auto &
hh :
hhs) {
10428 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
10443 (*ritr)->SetTitle(
_title.c_str());
10447 for (
auto &
hh :
hhs) {
10458 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
10479 stack->
Draw(
"noclear same");
10483 h->Draw(
"axissame");
10489 for (
auto ho : *ll) {
10497 hh->SetFillStyle(1001);
10500 hh->SetFillColor((count++));
10503 for (
auto ho2 : *ll) {
10523 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
10526 hh->SetFillColor(10);
10542 dOpt.ReplaceAll(
"TEXT",
"");
10544 double ymax = -std::numeric_limits<double>::infinity();
10545 double ymin = std::numeric_limits<double>::infinity();
10546 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
10573 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
10582 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
10583 double val =
ratioHist->GetBinContent(i);
10584 double err =
ratioHist->GetBinError(i);
10591 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
10598#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
10607 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
10608 _h->SetDirectory(
nullptr);
10609 _h->SetFillColor(0);
10610 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
10615 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
10616 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
10617 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
10618 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
10628 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
10632 histName = histName(0, histName.
Index(
'|'));
10634 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
10635 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
10638 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
10639 double val =
h->GetBinContent(i);
10640 double err =
h->GetBinError(i);
10641 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
10642 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
10643 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
10644 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
10645 h->GetBinContent(i));
10662 double ymax = -std::numeric_limits<double>::infinity();
10663 double ymin = std::numeric_limits<double>::infinity();
10664 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
10665 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
10666 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
10700 if (
d->get()->TestBit(1 << 20)) {
10722#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
10731 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
10736#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
10740 for (
auto &
c :
w->components()) {
10741 c->_eocache =
nullptr;
10749 if (
auto fitDb =
dynamic_cast<TFile *
>(
gROOT->GetListOfFiles()->FindObject(
"fitDatabase"))) {
10758 for (
auto k : *
source->GetListOfKeys()) {
10759 auto key =
dynamic_cast<TKey *
>(k);
10760 const char *classname = key->GetClassName();
10769 if (
dir->FindKey(key->GetName()))
10772 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
10774 dir->WriteObject(
fc, key->GetName());
10777 TObject *obj = key->ReadObj();
10793#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
10795 for (
auto &
c :
w->components()) {
10796 c->setExpensiveObjectCache(
w->expensiveObjectCache());
10806 return std::numeric_limits<double>::quiet_NaN();
10812 std::vector<double> out;
10813 out.reserve(
size());
10814 for (
auto child : *
this) {
10815 out.push_back(
child->GetContent());
10829 auto rho =
_fr->correlationMatrix();
10838 for (
int m = 0;
m < rho.GetNrows();
m++) {
10845 auto tmp = _p->getVal();
10846 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
10848 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
10851 for (
int n = 0;
n < rho.GetNrows();
n++) {
10859 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
10861 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
10864 for (
int i = 0; i < out.GetNrows(); i++) {
10865 for (
int j = 0;
j < out.GetNrows();
j++) {
10877 double err = std::numeric_limits<double>::quiet_NaN();
10879 std::unique_ptr<RooAbsCollection>
_snap;
10897 p->setNormRange(rangeName);
10898#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
10901 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
10902#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
10904 p->_normSet =
nullptr;
10908 p->setNormRange(
nullptr);
10911 auto f = std::shared_ptr<RooAbsReal>(
10912 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
10916 out *=
f->getVal();
10917 err =
xRooNode(
pr, *
this).GetBinError(-1, fr);
10922 auto ax = (rangeName) ?
GetXaxis() :
nullptr;
10924 auto cv = (
ax && !
rv) ?
dynamic_cast<RooCategory *
>(
ax->GetParent()) :
nullptr;
10926 for (
auto &
v : vals) {
10929 if (
rv && !
rv->inRange(
ax->GetBinCenter(i), rangeName))
10931 if (cv && !cv->isStateInRange(rangeName,
ax->GetBinLabel(i)))
10938 out = std::numeric_limits<double>::quiet_NaN();
10941 _pars.RooAbsCollection::operator=(*_snap);
10943 return std::make_pair(out, err);
10961 std::vector<double> out;
10967 std::shared_ptr<RooFitResult> fr = std::dynamic_pointer_cast<RooFitResult>(
_fr.fComp);
10980 fr = std::dynamic_pointer_cast<RooFitResult>(
frn.fComp);
10983 if (!
GETDMP(fr.get(), _finalPars)) {
11007 if (!
prevCov ||
size_t(
prevCov->GetNcols()) < fr->floatParsFinal().size()) {
11010 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
11011 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
11012 cov(i,
j) = (*prevCov)(i,
j);
11017 for (
auto &
p : fr->floatParsFinal()) {
11024 fr->setCovarianceMatrix(
cov);
11039 if (
auto p =
dynamic_cast<RooAbsPdf *
>(o);
ax && (
p ||
_coefs.get() || o->getAttribute(
"density"))) {
11052 dynamic_cast<RooAbsLValue *
>(
ax->GetParent())->setBin(bin - 1,
ax->GetName());
11059#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11061 p->_normSet =
nullptr;
11071 .getPropagatedError(*fr,
normSet);
11074 res *=
ax->GetBinWidth(bin);
11076 out.push_back(res);
11082std::string cling::printValue(
const xRooNode *
v)
11085 return "nullptr\n";
11088 size_t left =
v->size();
11089 for (
auto n : *
v) {
11095 out +=
n->GetName();
11096 if (out.length() > 100 && left > 0) {
11102 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName())) + out;
11107 return "<nullptr>";
11109 return Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName());
#define ROOT_VERSION(a, b, c)
#define ROOT_VERSION_CODE
RooArgSet * _normSet
Pointer to set with observables used for normalization.
RooAbsData * _data
Pointer to original input dataset.
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
RooAbsReal * _func
Pointer to original input function.
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
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 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 data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t 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 SetFillColor
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)
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.
double GetBinError(int bin, const xRooNode &fr="") const
std::vector< double > GetBinErrors(int binStart=1, int binEnd=0, const xRooNode &fr="") const
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
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)
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)
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)
xRooNode histo(const xRooNode &vars="x", const xRooNode &fr="", bool content=true, bool errors=true) const
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
xRooNode reduced(const std::string &range="", bool invert=false) const
xRooNode variations() const
std::string GetPath() 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
TH1 * BuildHistogram(RooAbsLValue *v=nullptr, bool empty=false, bool errors=false, int binStart=1, int binEnd=0, const xRooNode &fr="") const
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)
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.
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.
virtual const RooArgSet * get() const
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={})
Create a reduced copy of this dataset.
virtual void add(const RooArgSet &row, double weight=1)=0
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.
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.
void setCovQual(Int_t val)
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
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...
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
const RooArgList & constPars() const
Return list of constant parameters.
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
UInt_t numStatusHistory() const
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.
A RooAbsArg implementing string values.
Persistable container for RooFit projects.
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.
bool removeSet(const char *name)
Remove a named set from the workspace.
RooFactoryWSTool & factory()
Return instance to factory tool.
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 SetFillStyle(Style_t fstyle)
Set the fill area 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.
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.
void SetName(const char *name="") override
Set graph name.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
virtual Double_t GetPointY(Int_t i) const
Get y value for point i.
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 ...
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.
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.
void Draw(Option_t *chopt="") override
Draw this stack with its current attributes.
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 Add(TObject *obj) override
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
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).
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 * 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.
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 Range(const char *rangeName, bool adjustNorm=true)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
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.
#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)
TLegend * getLegend(bool create=true, bool doPaint=false)