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))
176#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
180#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
209#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
215xRooNode::InteractiveObject *xRooNode::gIntObj =
nullptr;
216std::map<std::string, std::tuple<std::function<
double(
double,
double,
double)>,
bool>> xRooNode::auxFunctions;
217void xRooNode::SetAuxFunction(
const char *title,
const std::function<
double(
double,
double,
double)> &func,
220 auxFunctions[title] = std::make_tuple(func,
symmetrize);
239xRooNode::xRooNode(
const char *classname,
const char *
name,
const char *title)
245#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
246 w->_embeddedDataList.Delete();
248 xRooNode(*
w, std::make_shared<xRooNode>()).sterilize();
259xRooNode::xRooNode(
const char *
name,
const std::shared_ptr<TObject> &
comp,
const std::shared_ptr<xRooNode> &parent)
270#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
271 fComp = std::make_shared<RooWorkspace>(
"workspace",
name);
276 Error(
"xRooNode",
"Error reading json workspace %s",
name);
281 Error(
"xRooNode",
"json format workspaces available only in ROOT 6.26 onwards");
287 auto _file = std::make_shared<TFile>(
292 auto keys =
_file->GetListOfKeys();
294 for (
auto &&k : *keys) {
300#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
301 dynamic_cast<RooWorkspace *>(ws)->_embeddedDataList.Delete();
303 xRooNode(*ws, std::make_shared<xRooNode>()).sterilize();
309 fParent = std::make_shared<xRooNode>(
329 for (
auto f : *
gROOT->GetListOfFiles()) {
330 if ((
dynamic_cast<TFile *
>(
f)->GetVersion() / 100) > (
gROOT->GetVersionInt() / 100)) {
331 Warning(
"xRooNode",
"There is file open with version %d > current version %d ... results may be wrong",
332 dynamic_cast<TFile *
>(
f)->GetVersion(),
gROOT->GetVersionInt());
338 gROOT->GetListOfColors()->Clear();
339 for (
auto col : *
colors) {
340 gROOT->GetListOfColors()->Add(col);
346 for (
auto &
d : _ws->allData()) {
347 for (
auto &
a : *
d->get()) {
348 if (
auto v = _ws->var(
a->GetName());
v) {
349 v->setAttribute(
"obs");
350 }
else if (
auto c = _ws->cat(
a->GetName());
c) {
351 c->setAttribute(
"obs");
358 if (
checkCount == 0 && !_ws->allData().empty())
359 _ws->allData().back()->SetBit(1 << 20,
true);
362 for (
auto s : *_set) {
364 _ws->var(s->GetName())->setStringAttribute(
"nominal",
TString::Format(
"%f",
v->getVal()));
372 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
375 s->setAttribute(
"obs");
376 s->setAttribute(
"global");
379 const_cast<RooArgSet &
>(
v).setAttribAll(
"obs");
382 s->setAttribute(
"poi");
394 const_cast<RooArgSet &
>(
v).setAttribAll(
"np");
398 _ws->defineSet(
"globalObservables",
_allGlobs);
403 if (!_ws->allPdfs().empty()) {
406 for (
auto &
p :
np()) {
410 if (!
v->hasError()) {
419 "Inferring initial errors of %d parameters (%s%s) (give all nuisance parameters an error to avoid "
424 for (
auto &
a : *
this) {
428 if (
a->fFolder ==
"!pdfs") {
430 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
434 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
435 arg && arg->hasError()) {
436 v->setError(arg->getError());
452 if (
strlen(GetTitle()) == 0) {
479 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
480 return a->getStringAttribute(
"alias");
482 return comp->GetName();
501 if (o->isSelectedComp() && !val) {
504 o->setAttribute(
"hidden");
505 }
else if (!o->isSelectedComp() && !val) {
510 o->setAttribute(
"hidden",
false);
513 item->CheckItem(!o->getAttribute(
"hidden"));
514 if (o->isSelectedComp()) {
517 item->SetColor(
kGray);
522 if (
auto o =
get(); o) {
524 o->SetBit(1 << 20, val);
526 if (
auto _ws =
ws(); _ws) {
529 if (fr->numStatusHistory() && !_ws->genobj(fr->GetName())) {
531 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
536 _allVars = fr->floatParsFinal();
537 _allVars = fr->constPars();
538 for (
auto &i : fr->floatParsInit()) {
544 for (
auto oo : _ws->allGenericObjects()) {
546 ffr->ResetBit(1 << 20);
550 _ws->allVars() = fr->floatParsInit();
554 if (
auto first = item->GetParent()->GetFirstChild()) {
556 if (first->HasCheckBox()) {
557 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
558 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
560 }
while ((first = first->GetNextSibling()));
573 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
574 if (!b2 || !b2->GetBrowserImp()) {
581 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
583 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
585 b2->BrowseObject(
this);
590 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
597 _b->GotoDir(
nullptr);
608 if (
auto first = item->GetFirstChild()) {
610 if (first->HasCheckBox()) {
611 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
612 first->CheckItem(
_obj->get() &&
613 (
_obj->get()->TestBit(1 << 20) ||
616 }
while ((first = first->GetNextSibling()));
629 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
630 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corr10colztext\")",
nullptr, *
this));
631 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
632 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
639 s->SetFillAttributes();
646 Draw(
b->GetDrawOption());
648 }
catch (
const std::exception &
e) {
651 (
gROOT->GetListOfBrowsers()->At(0))
654 "Exception",
e.what(),
661 for (
auto &
c : *
this) {
662 if (!
c->fFolder.empty()) {
673 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
676 for (
auto &
v : *
this) {
677 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
678 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
685 _name = _name(1, _name.
Length());
686 b->Add(
v.get(), _name);
690 for (
auto &
v : *
this) {
693 if (
strcmp(
v->GetName(),
".folders") == 0)
697 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
705 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
713 :
v->get()->GetName());
715 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
717 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
725 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
731 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
740 if (
auto o =
v->get(); o)
741 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
743 if (
auto o =
v->get(); o)
746 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
747 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
750 if (
_fr->status() ||
_fr->covQual() != 3) {
751 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() && !
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
752 }
else if (
_fr->numStatusHistory() == 0) {
753 v->GetTreeItem(
b)->SetColor(
kGray);
756 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
758 v->GetTreeItem(
b)->SetColor(
kGray);
760 v->GetTreeItem(
b)->ClearColor();
764 if (
auto fits =
_htr->GetFitInfo()) {
765 for (
int i = 0; i <
fits->numEntries(); i++) {
767 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
768 v->GetTreeItem(
b)->SetColor(
kRed);
773 v->GetTreeItem(
b)->SetColor(
kBlue);
800 if (_name ==
".memory")
804 if (
auto o =
v->get(); o)
805 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
806 b->Add(
v.get(), _name, -1);
807 if (
auto o =
v->get(); o)
811 b->SetSelected(
this);
824 auto v = std::make_shared<xRooNode>(
vars());
835 if (
strcmp(
b->GetName(),
".vars") == 0)
858 if (
auto v = var();
v)
859 return v->getBinWidth(bin - 1, GetName());
864 if (
auto v = rvar();
v) {
865 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
866 :
v->getBinning(GetName()).binLow(bin - 1);
872 if (
auto v = rvar();
v)
873 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
879 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
886 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
890 void Set(
Int_t nbins,
const double *xbins)
override
893 v->setBinning(
RooBinning(nbins, xbins), GetName());
898 std::vector<double> bins(nbins + 1);
899 for (
int i = 0; i <= nbins; i++)
900 bins.at(i) = xbins[i];
901 return Set(nbins, &bins[0]);
913 Int_t FindFixBin(
double x)
const override {
return (binning()) ? (binning()->binNumber(
x) + 1) :
x; }
926 if (
name == o->GetName()) {
927 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
938 _parent = _parent->fParent;
944 std::shared_ptr<TObject> out;
945 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
946 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
947 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
952 if (
auto arg =
ws()->
data(
name.c_str()); arg) {
953 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
954 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
959 if (
auto arg =
ws()->genobj(
name.c_str()); arg) {
960 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
961 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
966 if (
auto arg =
ws()->embeddedData(
name.c_str()); arg) {
967 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
968 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
974 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
975 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
985 arg->treeNodeServerList(&nodes);
998 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1014 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1026 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1027 for (
auto &
v : _obs) {
1053 if (o !=
dynamic_cast<TObject *
>(
x)) {
1058 TString binningName = o->getStringAttribute(
"binning");
1059 auto _bnames =
x->getBinningNames();
1060 bool hasBinning =
false;
1062 if (
b == binningName) {
1070 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1072 o->setStringAttribute(
"binning",
nullptr);
1076 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1082 if (
b == o->GetName()) {
1083 binningName = o->GetName();
1087 if (binningName ==
"") {
1093 (std::list<double> *)(
nullptr),
1094 o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1095 std::numeric_limits<double>::infinity()));
1097 std::vector<double>
_bins;
1098 for (
auto &
b : *
bins) {
1106 _v->getBinning(o->GetName())
1111 binningName = o->GetName();
1122 if (
r->getBinning(binningName).isUniform()) {
1123 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1125 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1127 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1128 std::vector<double>
bins = {};
1129 for (
int i = 0; i <=
x->numBins(binningName); i++)
1131 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1134 std::map<int, std::string> cats;
1135 for (
auto &
c : *cat) {
1136 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1137 cats[
c.second] =
c.first;
1140 for (
auto &[
_, label] : cats) {
1141 fXAxis->SetBinLabel(i++, label.c_str());
1146 fXAxis->SetName(binningName);
1153 if (
auto o =
get(); o) {
1154 if (o->InheritsFrom(
"RooWorkspace"))
1156 if (o->InheritsFrom(
"RooAbsData"))
1158 if (o->InheritsFrom(
"RooSimultaneous"))
1161 if (o->InheritsFrom(
"RooProdPdf"))
1163 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1166 if (o->InheritsFrom(
"RooFitResult")) {
1167 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1168 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1169 "package.xpm",
"->Browse()");
1171 return "xRooFitRooFitResult";
1173 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1175 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1176 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1178 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1179 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1182 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1186 if (o->InheritsFrom(
"TStyle")) {
1187 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1188 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1189 "bld_colorselect.xpm",
"->Browse()");
1191 return "xRooFitTStyle";
1193 if (o->InheritsFrom(
"RooConstVar")) {
1199 return "TMethodBrowsable-leaf";
1201 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1202 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1203 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1206 return "xRooFitScanStyle";
1208 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1209 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1210 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1213 return "xRooFitTestStyle";
1215 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1216 return "TBranchElement-folder";
1217 if (o->InheritsFrom(
"RooAbsPdf")) {
1218 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1219 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1222 return "xRooFitPDFStyle";
1224 if (o->InheritsFrom(
"RooStats::ModelConfig")) {
1225 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitMCStyle",
true)) {
1226 gClient->GetMimeTypeList()->AddType(
"xRooFitMCStyle",
"xRooFitMCStyle",
"app_t.xpm",
"app_t.xpm",
1229 return "xRooFitMCStyle";
1233 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1235 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1236 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1237 std::numeric_limits<double>::infinity()))))) {
1242 return o->ClassName();
1253 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1255 if (o->InheritsFrom(
"PiecewiseInterpolation")) {
1266 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"VariedDensity" :
"Varied";
1269 if (o->InheritsFrom(
"RooHistFunc"))
1270 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"SimpleDensity" :
"Simple";
1271 if (o->InheritsFrom(
"RooBinWidthFunction"))
1273 if (o->InheritsFrom(
"ParamHistFunc"))
1275 if (o->InheritsFrom(
"RooRealVar"))
1277 if (o->InheritsFrom(
"RooConstVar"))
1285 xRooNode out(
".coords",
nullptr, *
this);
1287 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1317 if (
auto pos =
pName.Index(
'='); pos != -1) {
1318 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1326 _obs->setVal((high + low) / 2.);
1327 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1329 "coordRange",
"coordRange");
1331 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1336 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1339 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1340 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1344 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1346 throw std::runtime_error(
"Unknown observable, could not find");
1358 }
catch (
const std::exception &
e) {
1367 }
catch (
const std::exception &
e) {
1394 pdf =
p->pdfList().find(
child.GetName());
1397 auto i =
p->pdfList().index(*pdf);
1399#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1400 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1401#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1402 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1404 auto nset =
p->_pdfNSetList.At(i);
1405 p->_pdfNSetList.Remove(nset);
1408 if (
p->_extendedIndex == i)
1409 p->_extendedIndex = -1;
1410 else if (
p->_extendedIndex > i)
1411 p->_extendedIndex--;
1423 arg =
p2->components().find(
child.GetName());
1427#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1428 p2->_compRSet.remove(*arg);
1430 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1432 p2->removeServer(*arg,
true);
1442 }
catch (std::runtime_error &) {
1452 arg =
p4->funcList().find(
child.GetName());
1456 auto idx =
p4->funcList().index(arg);
1461 p4->removeServer(*arg,
true);
1463 std::vector<RooAbsArg *>
_coefs;
1465 if (
ii !=
size_t(idx))
1480 arg =
p5->pdfList().find(
child.GetName());
1484 auto idx =
p5->pdfList().index(arg);
1489 p5->removeServer(*arg,
true);
1491 std::vector<RooAbsArg *>
_coefs;
1493 if (
ii !=
size_t(idx))
1508 arg =
p6->list().find(
child.GetName());
1513 p6->removeServer(*arg,
true);
1521 auto arg =
w->components().find(
child.GetName());
1528 if (arg->hasClients()) {
1529 throw std::runtime_error(
1530 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1533 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1534 Info(
"Remove",
"Deleted %s from workspace %s", out.GetName(),
GetName());
1542 throw std::runtime_error(
"Removal not implemented for object type " +
1592 out->setAttribute(
"obs");
1593 out->setAttribute(
"global");
1596 throw std::runtime_error(
"Failed to add global observable");
1600 out->setAttribute(
"poi");
1608 throw std::runtime_error(
"Failed to add parameter of interest");
1612 if (!
fac.Contains(
"["))
1620 throw std::runtime_error(
1621 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1624 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1642 }
else if (!_ws->obj(
_fr->GetName())) {
1651 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1659 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1662 if (
auto _d = _ws->data(
child.GetName()); _d) {
1665 l.remove(*_d->get(),
true,
true);
1669 throw std::runtime_error(
"Cannot extend dataset with new columns");
1680 if (
auto __d = _ws->data(
child.GetName()))
1681 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1689 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1698 throw std::runtime_error(
"Cannot create dataset");
1703 throw std::runtime_error(
"Cannot add to null object with no parentage");
1705 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1710 std::rethrow_exception(std::current_exception());
1715 throw std::runtime_error(
"No object");
1725 throw std::runtime_error(
"Can only add datasets to a dataset");
1734 }
else if (
g->GetContent() !=
glob->GetContent()) {
1735 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1740 if (
auto _dglobs =
p->getGlobalObservables()) {
1750 for (
auto col : *_data->get()) {
1751 if (!
p->get()->contains(*col)) {
1752 ds->addColumn(*col);
1756 ds->SetTitle(
TString(
ds->GetTitle()) +
" + " + _data->GetTitle());
1762 throw std::runtime_error(
"Can only add histogram or dataset to data");
1766 throw std::runtime_error(
"Could not find pdf");
1767 auto _ax = _pdf->GetXaxis();
1769 throw std::runtime_error(
"Cannot determine binning to add data");
1778 l.remove(*
p->get(),
true,
true);
1782 throw std::runtime_error(
"Cannot extend dataset with new columns");
1789 for (
auto &o :
obs) {
1791 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1792 if (
v->getMin() <
dv->getMin())
1793 dv->setMin(
v->getMin());
1794 if (
v->getMax() >
dv->getMax())
1795 dv->setMax(
v->getMax());
1799 if (!
dc->hasLabel(
c->getCurrentLabel())) {
1800 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
1806 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1808 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1809 throw std::runtime_error(
1810 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1811 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1812 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1813 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1815 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1820 p->add(
obs,
_h->GetBinContent(i));
1830 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
1832 throw std::runtime_error(
"Something went wrong with pdf acquisition");
1839 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
1840 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1841 std::numeric_limits<double>::infinity()));
1842 !_boundaries && _ax->GetNbins() > 0) {
1843#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1844 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
1848 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1849 if (!_p->getStringAttribute(
"alias"))
1850 _p->setStringAttribute(
"alias", out->GetName());
1852 throw std::runtime_error(
1853 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
1859 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
1863 if (_pdf->canBeExtended()) {
1874 for (
auto i =
p->coefList().size(); i <
p->pdfList().size(); i++) {
1879 *
static_cast<RooAbsPdf *
>(
p->pdfList().at(i))));
1885 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
1886 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
1887 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
1888 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
1890 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
1922 std::shared_ptr<TObject> out;
1927 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
1932 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
1936 if (!out && !
child.fComp) {
1937 std::shared_ptr<RooAbsArg> _func;
1948 std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(), _ax->binning()->array());
1950 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
1952 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1953 }
else if (_obs.size() == 1) {
1956 auto _bnames = _x->getBinningNames();
1957 TString binningName =
p->getStringAttribute(
"binning");
1959 if (
b ==
p->GetName()) {
1960 binningName =
p->GetName();
1966 auto h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
1967 _x->getBinningPtr(binningName)->array());
1969 h->GetXaxis()->SetName(
1972 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
1973 Info(
"Add",
"Created SimpleDensity factor %s (xaxis=%s) for %s", _func->GetName(), _obs.at(0)->GetName(),
1976 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
1982 _func->setStringAttribute(
"alias",
child.GetName());
1986 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
1990 _f->setAttribute(
"density");
1991 if (
_f->getAttribute(
"autodensity")) {
1993 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
1997 _f->setAttribute(
"autodensity",
false);
1998 _f->setValueDirty();
2007 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
2008 _f->getAttribute(
"density") ?
"SimpleDensity" :
"Simple",
_f->GetName(),
p->GetName());
2012 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
2017 newName.ReplaceAll(
"_samples",
"");
2019 Warning(
"Add",
"converting samples to components");
2024 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2025 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2026 std::numeric_limits<double>::infinity()));
2027 !_boundaries && _ax->GetNbins() > 0) {
2028#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2029 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2033 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2034 if (!_p->getStringAttribute(
"alias"))
2035 _p->setStringAttribute(
"alias", out->GetName());
2037 throw std::runtime_error(
2038 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2045 if (!_p->canBeExtended()) {
2054 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2061 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
2063 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
2064 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2065 std::numeric_limits<double>::infinity()));
2066 !_boundaries && _ax->GetNbins() > 0) {
2067#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2070 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
2074 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
2075 if (!sumPdf->getStringAttribute(
"alias"))
2076 sumPdf->setStringAttribute(
"alias", out->GetName());
2079 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2080 if (!
_f->getStringAttribute(
"alias"))
2081 _f->setStringAttribute(
"alias", out->GetName());
2083 throw std::runtime_error(
2084 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2092 if (!
p->getStringAttribute(
"binning"))
2093 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2096 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2101 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2110 p->setStringAttribute(
"xvar",
nullptr);
2135 auto out = this->
operator[](
"components")->Add(child);
2154 for (
auto &
_pdfa :
pp->components()) {
2172 auto out = this->
operator[](
"samples")->Add(child);
2175 p2->setStringAttribute(
"xvar",
nullptr);
2188 child.convertForAcquisition(
2189 *
this,
child.get() ?
"" :
"func" );
2193 if (!
w->import(*_d)) {
2196 std::unique_ptr<RooAbsCollection>(
w->allVars().selectCommon(*_d->get()))->setAttribAll(
"obs");
2198 if (_d->getGlobalObservables()) {
2199 std::unique_ptr<RooAbsCollection>
globs(
w->allVars().selectCommon(*_d->getGlobalObservables()));
2200 globs->setAttribAll(
"obs");
2201 globs->setAttribAll(
"global");
2205 throw std::runtime_error(
2216 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2219 std::string
catName =
"channelCat";
2220 if (!
child.empty()) {
2226 _cat->setAttribute(
"obs");
2228 Info(
"Add",
"Created pdf RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2233 if (
sOpt ==
"pdf") {
2239 }
else if (
sOpt ==
"channel") {
2244 std::shared_ptr<TObject> out;
2245 child.convertForAcquisition(*
this);
2248 }
else if (!
child.fComp) {
2251 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2255 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2261 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2264 }
else if (
sOpt ==
"dataset") {
2267 return (*this).datasets().Add(
child);
2325 a->setAttribute(
"hidden", set);
2336 return a->getAttribute(
"hidden");
2343 if (
get() ==
rhs.get()) {
2351 for (
auto &
c :
rhs.components()) {
2359 for (
auto &
f :
rhs.factors()) {
2367 for (
auto &
v :
rhs.variations()) {
2395 if (!
chans.empty()) {
2406 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2412 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2414 std::shared_ptr<RooProdPdf> pdf =
2415 std::dynamic_pointer_cast<RooProdPdf>(out.acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2420 std::dynamic_pointer_cast<RooAbsArg>(out.acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2436 static std::unique_ptr<cout_redirect>
capture;
2446 if (
sOpt.Contains(
"depth=")) {
2451 if (
sOpt.Contains(
"indent=")) {
2457 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2463 if (
get() &&
get() !=
this) {
2468 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2472 std::cout <<
"Minimization Logs:" << std::endl;
2473 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2487 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2493 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2501 }
else if (!
get()) {
2502 std::cout << std::endl;
2506 std::vector<std::string> folderNames;
2507 for (
auto &k : *
this) {
2508 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2509 folderNames.push_back(k->fFolder);
2512 for (
auto &
f : folderNames) {
2518 std::cout <<
f << std::endl;
2521 for (
auto &k : *
this) {
2522 if (k->fFolder !=
f) {
2528 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2532 auto _deps = k->coords(
false).argList();
2533 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2535 k->get()->Print(
sOpt);
2539 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2547 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2553 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2558 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2564 std::cout <<
" NULL " << std::endl;
2572 for (
size_t i = 0; i <
captureStr.size(); i++) {
2583 (
gROOT->GetListOfBrowsers()->At(0))
2598 double mean = std::numeric_limits<double>::quiet_NaN();
2599 double sigma = mean;
2608 mean = std::numeric_limits<double>::quiet_NaN();
2619 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2625 throw std::runtime_error(
"No error on parameter for poisson constraint");
2627 sigma = pow(
v->getVal() /
v->getError(), 2);
2635 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2636 globs->setConstant();
2637 globs->setAttribute(
"obs");
2638 globs->setAttribute(
"global");
2651 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
2658 globs->setAttribute(
"obs");
2659 globs->setAttribute(
"global");
2660 globs->setConstant();
2669 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
2678 throw std::runtime_error(
"Cannot constrain non arg");
2681 if (!
p->dependsOn(*
_me)) {
2682 throw std::runtime_error(
"Constraint does not depend on constrainee");
2691 throw std::runtime_error(
"Nowhere to put constraint");
2696 for (
auto d :
x->datasets()) {
2706 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
2715 for (
auto &
c : *
x) {
2721 return x->Multiply(
child);
2723 return x->Add(
child,
"+");
2746 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
2769 ?
fParent->mainChild()->GetName()
2776 throw std::runtime_error(
2796#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
2803 for (std::size_t i = 0; i <
pSet.size(); i++) {
2813 _bin->fBinNumber = -1;
2842 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
2847 std::rethrow_exception(std::current_exception());
2859 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
2863 }
else if(
sOpt==
"const") {
2866 Info(
"Multiply",
"Scaled %s by new const factor %s",
2870 }
else if (
sOpt ==
"norm") {
2877 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2882 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
2886 Info(
"Multiply",
"Scaled %s by new norm factor %s",
2890 }
else if (
sOpt ==
"shape" ||
sOpt ==
"simple" ||
sOpt ==
"blankshape") {
2895 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
2896 h->SetBinContent(i, 1);
2901 h->SetTitle(
child.GetTitle());
2902 if (
sOpt.Contains(
"shape"))
2906 Info(
"Multiply",
"Scaled %s by new %s factor %s",
2911 }
else if (
sOpt ==
"overall") {
2913 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
2915 Info(
"Multiply",
"Scaled %s by new overall factor %s",
2919 }
else if (
sOpt ==
"func" &&
ws()) {
2924 Info(
"Multiply",
"Scaled %s by new func factor %s",
2937 std::shared_ptr<TObject> out;
2938 child.convertForAcquisition(*
this);
2949 if (
p->coefList().empty() && !
p->pdfList().empty()) {
2950 for (
auto _pdf :
p->pdfList()) {
2956 Info(
"Multiply",
"Created RooExtendedBinding coefficients for all pdfs of %s so that can multiply coef",
2958 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2959 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
2960 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2961 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
2963 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
2965 auto coefs =
p->coefList().at(i);
2974 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
2981 const_cast<RooArgList &
>(
p->coefList()).removeAll();
2991 for (
size_t i = 0; i <
p2->funcList().
size(); i++) {
2993 auto coefs =
p2->coefList().at(i);
3002 for (
size_t j = 0;
j <
p2->coefList().size();
j++) {
3017 throw std::runtime_error(
"this coefs case is not supported");
3021 std::shared_ptr<TObject> out;
3028 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
3030 _f &&
_f->getAttribute(
"autodensity")) {
3040 if (
_f->getAttribute(
"density")) {
3043 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
3047 _f->setValueDirty();
3054 _f->setAttribute(
"autodensity",
false);
3058 Info(
"Multiply",
"Created %s factor %s in %s",
3062 Info(
"Multiply",
"Created Shape factor %s in %s",
child->GetName(),
p->GetName());
3065 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
3066#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3067 p->_compRSet.add(*
_f);
3075 for (
auto &_par :
_out.pars()) {
3078 for (
auto &
_constr : _par->constraints()) {
3086 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
3089 throw std::runtime_error(
"Couldn't find boundConstraint");
3091 _par->Constrain(_pdf);
3100 std::shared_ptr<TObject> out;
3101 child.convertForAcquisition(*
this);
3110 std::shared_ptr<RooAbsPdf> _pdf;
3127 _pdf->setStringAttribute(
"alias",
child.GetName());
3129 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
3130 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
3132 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
3137 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3138#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3140#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
3141 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
3145 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
3146 p2->_extendedIndex =
p2->_pdfList.size() - 1;
3157 std::shared_ptr<TObject> out;
3158 child.convertForAcquisition(*
this);
3164 TString s =
p3->getStringAttribute(
"global_factors");
3167 s += out->GetName();
3168 p3->setStringAttribute(
"global_factors", s);
3171 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3172 out->GetName(),
p3->GetName());
3183 std::set<RooAbsArg *> cl;
3184 for (
auto &arg :
p5->clients()) {
3190 if (cl.size() > 1) {
3195 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3201 for (
auto &
a :
p5->attributes())
3202 new_p->setAttribute(
a.c_str());
3203 for (
auto &
a :
p5->stringAttributes())
3204 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3205 if (!
new_p->getStringAttribute(
"alias"))
3206 new_p->setStringAttribute(
"alias",
p5->GetName());
3209 for (
auto arg : cl) {
3221 throw std::runtime_error(
3223 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3231 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3240 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3242 std::set<RooAbsArg *> cl;
3243 for (
auto &arg :
p5->clients()) {
3251 if (cl.size() > 1) {
3259 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3263 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3264 for (
auto arg : cl) {
3288 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3293 std::rethrow_exception(std::current_exception());
3305 std::string label =
child.GetName();
3306 if (
auto pos = label.find(
'='); pos != std::string::npos)
3307 label = label.substr(pos + 1);
3308 if (!s->indexCat().hasLabel(label)) {
3311 std::shared_ptr<TObject> out;
3312 child.convertForAcquisition(*
this);
3315 }
else if (!
child.fComp) {
3318 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3321 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3322 s->addPdf(*_pdf, label.c_str());
3334 child.convertForAcquisition(*
this);
3336 if (!_c &&
child.get()) {
3337 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3339#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3340 double value = (_c ? _c->getVal() :
p->_nominal);
3343 double value = (_c ? _c->getVal() :
p->nominal());
3348 if (
cName ==
"nominal") {
3352 if (
cName.CountChar(
'=') != 1) {
3353 throw std::runtime_error(
"unsupported variation form");
3358 throw std::runtime_error(
"unsupported variation magnitude");
3371 if (!
p->findServer(*
v)) {
3372#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3373 p->_paramList.add(*
v);
3374 p->_low.push_back(0);
3375 p->_high.push_back(0);
3376 p->_interpCode.push_back(4);
3379 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3380 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3381 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3383 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3388 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3391 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3394 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3397 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3407 if (
cName.CountChar(
'=') != 1) {
3408 throw std::runtime_error(
"unsupported variation form");
3413 throw std::runtime_error(
"unsupported variation magnitude");
3415#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3418 throw std::runtime_error(
3419 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3424 throw std::runtime_error(
3425 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3431 for (
auto par :
p2->paramList()) {
3432 if (
parName == par->GetName()) {
3446 std::shared_ptr<RooHistFunc>
up(
3448 std::shared_ptr<RooHistFunc>
down(
3451#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3452 std::unique_ptr<RooDataHist>
h1(
3454 std::unique_ptr<RooDataHist> h2(
3456 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3462 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3463 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3464#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3465 p2->_highSet.add(*
ups.get());
3466 p2->_lowSet.add(*
downs.get());
3467 p2->_interpCode.push_back(4);
3468 p2->_paramSet.add(*
v);
3472 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3475 p2->setValueDirty();
3479 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3480 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3481 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3502 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3503 throw std::runtime_error(
"Cannot vary pure constants");
3509 std::set<RooAbsArg *> cl;
3510 for (
auto &arg :
p3->clients()) {
3515 if (cl.size() > 1) {
3520 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3523 p3->setStringAttribute(
"origName",
p3->GetName());
3525 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3528 std::vector<double>(), std::vector<double>());
3531 for (
auto &
a :
p3->attributes())
3532 new_p->setAttribute(
a.c_str());
3533 for (
auto &
a :
p3->stringAttributes())
3534 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3538 for (
auto arg : cl) {
3549 std::set<RooAbsArg *> cl;
3550 for (
auto &arg :
p4->clients()) {
3555 if (cl.size() > 1) {
3560 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
3563 p4->setStringAttribute(
"origName",
p4->GetName());
3565 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
3570 for (
auto &
a :
p4->attributes())
3571 new_p->setAttribute(
a.c_str());
3572 for (
auto &
a :
p4->stringAttributes())
3573 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3577 for (
auto arg : cl) {
3620 a->setStringAttribute(
"alias",
GetName());
3623 throw std::runtime_error(
"Cannot determine type");
3628 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
3645 throw std::runtime_error(
"no xaxis");
3650 if (
h->GetXaxis()->IsVariableBinSize()) {
3651 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
3659 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
3668 throw std::runtime_error(
"Failed setting stat error");
3672 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
3684 throw std::runtime_error(
"Assignment failed");
3714 std::map<RooAbsRealLValue *, double>
valsToSet;
3716 auto idx = pattern.
Index(
'=');
3719 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3721 for (
auto p :
_pars.argList()) {
3724 p->setAttribute(
"Constant",
true);
3725 if (!std::isnan(val)) {
3733 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
3755 if (
d->get()->TestBit(1 << 20)) {
3765 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
3766 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
3767 auto fr = _nll.minimize();
3770 throw std::runtime_error(
"Fit Failed");
3773 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
3777 (
gROOT->GetListOfBrowsers()->At(0))
3780 if (fr->status() != 0) {
3782 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3785 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
3786 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
3787 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3792 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n-------------%s",
3795 }
catch (
const std::exception &
e) {
3798 (
gROOT->GetListOfBrowsers()->At(0))
3809 }
catch (
const std::exception &
e) {
3812 (
gROOT->GetListOfBrowsers()->At(0))
3815 "Exception",
e.what(),
3831 if (
d->get()->TestBit(1 << 20)) {
3837 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
3840 auto idx = pattern.
Index(
'=');
3843 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
3845 for (
auto par :
_pars.argList()) {
3848 par->setAttribute(
"Constant",
true);
3849 if (!std::isnan(val)) {
3855 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
3875 hs.SetName(
TUUID().AsString());
3887 (
gROOT->GetListOfBrowsers()->At(0))
3890 "Scan Finished with Bad Status Code",
3895 if (
auto res =
hs.result())
3901 }
catch (
const std::exception &
e) {
3904 (
gROOT->GetListOfBrowsers()->At(0))
3915 }
catch (
const std::exception &
e) {
3924#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
3929 for (
auto a : *
this) {
3936 for (
auto c : args) {
3942 f.SetParName(i,
c->GetName());
3944 f.SetParLimits(i,
v->getMin(),
v->getMax());
3945 if (
v->isConstant())
3946 f.FixParameter(i,
v->getVal());
3948 f.SetParameter(i,
v->getVal());
3949 f.SetParError(i,
v->getError());
3960 (
gROOT->GetListOfBrowsers()->At(0))
3966 for (i = 0; i <
f.GetNpar(); i++) {
3967 auto c = args.
find(
f.GetParName(i));
3972 f.GetParLimits(i, low, high);
3974 v->setConstant(low);
3976 v->setRange(low, high);
3986 throw std::runtime_error(
"Failed to SetContent");
3987 }
catch (
const std::exception &
e) {
4001 std::shared_ptr<TH1D>
h;
4002 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
4005 if (
_b->isUniform()) {
4010 h->SetOption(
"nostyle");
4011 h->SetDirectory(
nullptr);
4027 auto _ax = (bin) ?
GetXaxis() :
nullptr;
4029 throw std::runtime_error(
"Cannot determine binning to fill data");
4031 if (_ax && _ax->GetNbins() < bin) {
4032 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
4033 _ax->GetName(), _ax->GetNbins()));
4039 for (
auto _c :
coords()) {
4043 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
4051 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
4054 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
4063 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
4064 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
4096 l.remove(*_data->get(),
true,
true);
4101 _data->addColumn(*
x);
4111 for (
auto &o :
obs) {
4113 if (
auto dv =
dynamic_cast<RooRealVar *
>(_data->get()->find(
v->GetName()));
dv) {
4114 if (
v->getMin() <
dv->getMin())
4115 dv->setMin(
v->getMin());
4116 if (
v->getMax() >
dv->getMax())
4117 dv->setMax(
v->getMax());
4120 if (
auto dc =
dynamic_cast<RooCategory *
>(_data->get()->find(
c->GetName()));
dc) {
4121 if (!
dc->hasLabel(
c->getCurrentLabel())) {
4122 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
4131 if (
auto _nentries = std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula))->numEntries();
4136 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
4139 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4141 _data->add(*_obs,
_reduced->weight());
4144 for (
int i = 1; i <= _ax->GetNbins(); i++) {
4148 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
4154 if (std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula2))->numEntries() > 0) {
4157 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4159 _data->add(*_obs,
_reduced->weight());
4163 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
4170 throw std::runtime_error(
"RooDataHist not supported yet");
4175 if (!par ||
strlen(par) == 0) {
4178 return it->SetBinContent(bin,
value);
4190 if (!par ||
strlen(par) == 0) {
4203 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
4206#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4219 auto bin_pars =
f->dataHist().get(bin - 1);
4220 if (
f->getAttribute(
"density")) {
4228 f->setStringAttribute(
"symmetrized_by",
nullptr);
4230 x->setStringAttribute(
"symmetrizes",
nullptr);
4231 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4245 f2->setNominal(
value);
4254 push_back(std::make_shared<xRooNode>(
data));
4261 return node->SetBinContent(bin,
value);
4268 push_back(std::make_shared<xRooNode>(
data));
4275 return node->SetContents(obj);
4313 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4322 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4327 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4334 h->SetName(
"statFactor");
4336 h->SetOption(
"blankshape");
4345 throw std::runtime_error(
"Failed creating stat shapeFactor");
4351 TString prefix =
f->getStringAttribute(
"statPrefix");
4352 if (
value && prefix ==
"") {
4356 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4357 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4364 Form(
"#gamma^{%s}_{%d}", prefix.
Data(), bin), 1);
4365#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4372 if (
newVar.get() != var) {
4376 for (std::size_t i = 0; i <
pSet.size(); i++) {
4377 if (
int(i) != bin - 1) {
4392 auto bin_pars =
f->dataHist().get(bin - 1);
4394 if (
f->getAttribute(
"density")) {
4400 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4401 if (s.find(
"sumw_") == 0) {
4403 }
else if (s.find(
"sumw2_") == 0) {
4407 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4409 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4410 rrv->setConstant(
false);
4415 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4420 double _min = tau * (1. - 5. * sqrt(1. / tau));
4421 double _max = tau * (1. + 5. * sqrt(1. / tau));
4424 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4425 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
4427 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
4431 v.constraints().Remove(*
_constr.at(0));
4450 throw std::out_of_range(
name +
" does not exist");
4472 xRooNode out(
".constraints",
nullptr, *
this);
4485 for (
auto &
c :
n.bins()) {
4496 for (
auto p : _ws->allPdfs()) {
4499 if (
p->dependsOn(par)) {
4500 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4508 for (
auto p : o->pdfList()) {
4511 if (
p->dependsOn(par)) {
4512 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
4518 for (
auto &
p :
vars()) {
4524 if (
v->getAttribute(
"obs"))
4534 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
4535 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
4537 for (
auto &
c : out) {
4538 if (
c.get() == it->get())
4543 std::string
_cName =
c->GetName();
4547 }
while (
_cName.find(
';') != std::string::npos);
4549 _cName = it->get()->GetName();
4553 }
while (
_cName.find(
';') != std::string::npos);
4561 c->TNamed::SetName(
_cName.c_str());
4575 for (
auto &o : out) {
4576 o->TNamed::SetName(o->get()->GetName());
4597 while (
sOpt2.Contains(
"=")) {
4598 auto pos =
sOpt2.Index(
"=");
4599 auto start =
sOpt2.Index(
";") + 1;
4623 if (
auto pos =
varName.Index(
';'); pos != -1) {
4633 binningName =
ax->GetName();
4634 }
else if (
acquirer.obs().size() == 1)
4638 h->GetXaxis()->GetXmax());
4639 if (
x->getMin() >
h->GetXaxis()->GetXmin())
4640 x->setMin(
h->GetXaxis()->GetXmin());
4641 if (
x->getMax() <
h->GetXaxis()->GetXmax())
4642 x->setMax(
h->GetXaxis()->GetXmax());
4643 if (!
x->hasBinning(binningName.c_str())) {
4644 if (
h->GetXaxis()->IsVariableBinSize()) {
4645 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
4648 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
4649 binningName.c_str());
4651 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
4652 if (
x->getBinningNames().size() == 2) {
4654 x->setBinning(
x->getBinning(binningName.c_str()));
4658 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
4659 throw std::runtime_error(
4660 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
4664 std::shared_ptr<RooAbsArg>
_f;
4671 _f->setStringAttribute(k.c_str(),
v.c_str());
4673 x->setAttribute(
"obs",
true);
4674 }
else if (
sOpt2.Contains(
"shape")) {
4676 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
4677 std::shared_ptr<RooAbsArg> arg;
4678 if (
sOpt2.Contains(
"blankshape")) {
4683 }
else if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
4685 h->GetBinContent(i + 1),
h->GetMinimumStored(),
4686 h->GetMaximumStored());
4689 h->GetBinContent(i + 1));
4696 auto tmp =
dynamic_cast<RooAbsBinning *
>(
x->getBinningPtr(
nullptr)->Clone());
4697 x->setBinning(
x->getBinning(binningName.c_str()));
4699#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4700 dynamic_cast<ParamHistFunc *
>(
_f.get())->_paramSet.setName(
"paramSet");
4703 .setName(
"paramSet");
4705 x->setBinning(*tmp);
4708 _f->setStringAttribute(k.c_str(),
v.c_str());
4712 binningName.c_str() );
4714 throw std::runtime_error(
"Couldn't make data hist");
4719 f->setAttribute(
"autodensity");
4723 _f->setStringAttribute(k.c_str(),
v.c_str());
4727 _f->setStringAttribute(
"xvar",
x->GetName());
4728 _f->setStringAttribute(
"binning", binningName.c_str());
4735 _f = std::dynamic_pointer_cast<RooAbsArg>(tmp.fComp);
4738 _f->setStringAttribute(
"xvar",
x->GetName());
4739 _f->setStringAttribute(
"binning", binningName.c_str());
4779 if (arg->getStringAttribute(
"style")) {
4780 t = arg->getStringAttribute(
"style");
4790 std::shared_ptr<TStyle>
style;
4792 if (!
gROOT->GetStyle(t)) {
4815 if (arg && !arg->getStringAttribute(
"style")) {
4816 arg->setStringAttribute(
"style",
style->GetName());
4834 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
4835 auto out_arg = _ws->arg(
a->GetName());
4842 if (
aName !=
a->GetName())
4843 Warning(
"acquire",
"Renaming to %s",
a->GetName());
4847 if (
auto res = _ws->factory(arg->GetName()); res) {
4854 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
4875 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
4881 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
4882 }
else if (arg->InheritsFrom(
"RooFitResult") || arg->InheritsFrom(
"TTree") || arg->IsA() ==
TStyle::Class() ||
4883 arg->InheritsFrom(
"RooStats::HypoTestInverterResult") ||
4884 arg->InheritsFrom(
"RooStats::HypoTestResult")) {
4894 out_arg = _ws->genobj(arg->GetName());
4901 if (
aName != arg->GetName()) {
4902 Warning(
"acquire",
"Renaming to %s", arg->GetName());
4904 if (_ws->import(*arg,
false )) {
4908 out_arg = _ws->genobj(arg->GetName());
4934 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
4940 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
4946 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
4952 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
4954 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
4996 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
4999 _x->setBinning(binning,
a->
GetName());
5000 _x->getBinning(
a->GetName()).SetTitle(title);
5001 if (_x->getBinningNames().size() == 2) {
5003 _x->setBinning(_x->getBinning(
a->GetName()));
5008 if (_x->getMax() < high)
5010 if (_x->getMin() > low)
5016 _x->setAttribute(
"obs");
5019 a->setStringAttribute(
"xvar", _x->GetName());
5020 a->setStringAttribute(
"binning",
a->GetName());
5030 if (
ax->IsVariableBinSize()) {
5031 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
5033 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
5039 return find(
name,
false) !=
nullptr;
5047 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5048 for (
auto &
child : *
this) {
5051 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
5064 for (
auto &
child2 :
x.browse()) {
5090 auto out = std::make_shared<xRooNode>(obj, *
this);
5105 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5107 for (
auto &
child : *
this) {
5119 for (
auto &
child2 :
x.browse()) {
5131 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
5149 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
5152 out->SetName(
"!pdfs");
5155 return out->operator[](
name.substr(
partname.length() + 1));
5163 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5165 if (!
b || !
b->GetBrowserImp())
5172 if (!
b->GetBrowserImp())
5188 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5190 if (!
b || !
b->GetBrowserImp())
5197 if (
b->GetBrowserImp()) {
5215 a->setStringAttribute(
"alias",
name);
5216 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5217 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
5219 item->SetText(
name);
5242 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5243 std::vector<std::shared_ptr<xRooNode>> &nn = *
this;
5244 for (
auto &
c : nn) {
5245 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5248 return std::shared_ptr<xRooNode>(
nullptr);
5253 const std::vector<std::shared_ptr<xRooNode>> &nn(
n);
5254 for (
auto &
c : nn) {
5267 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5268 for (
auto &
c :
nn2) {
5269 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5273 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5312 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5325 emplace_back(std::make_shared<xRooNode>(
_coefs));
5337 for (
int i = 0; i < arg->numProxies(); i++) {
5338 auto _proxy = arg->getProxy(i);
5348 for (
auto &
child : *
this) {
5356 for (
auto a2 : *s) {
5357 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5358 if (arg->numProxies() != 1) {
5359 c->fFolder = std::string(
"!.") +
5392 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5405 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5407 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5413 std::vector<std::shared_ptr<xRooNode>> &nn = *
this;
5414 for (
auto &
c : nn) {
5437 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
5438 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
5444 if (
auto fit =
hp->ufit()) {
5445 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
5447 if (
auto fit =
hp->cfit_null()) {
5448 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
5450 if (
auto fit =
hp->cfit_alt()) {
5451 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
5453 if (
auto fit =
hp->gfit()) {
5454 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
5456 if (
auto asi =
hp->asimov()) {
5457 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
5458 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
5460 asiP->TNamed::SetName(
"asimov");
5461 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
5467 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
5468 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
5469 if (it->get()->fTimes == 0) {
5470 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5472 if (
b &&
b->GetBrowserImp()) {
5519 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
5521 for (
auto o :
vars()) {
5524 out.emplace_back(o);
5535 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
5537 for (
auto o :
obs()) {
5540 out.emplace_back(o);
5551 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
5553 for (
auto o :
obs()) {
5556 out.emplace_back(o);
5571 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
5573 for (
auto o :
vars()) {
5576 out.emplace_back(o);
5587 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
5589 for (
auto o :
pars()) {
5592 out.emplace_back(o);
5604 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
5606 for (
auto o :
pars()) {
5609 out.emplace_back(o);
5621 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
5623 for (
auto o :
pars()) {
5626 out.emplace_back(o);
5638 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
5640 for (
auto o :
pars()) {
5642 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
5645 out.emplace_back(o);
5656 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
5658 for (
auto o :
pars()) {
5662 out.emplace_back(o);
5673 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
5676 for (
auto &
x : *
this) {
5677 for (
auto &
y :
x->vars()) {
5692 if (!
c->getAttribute(
"global")) {
5694 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5696 if (
c->getAttribute(
"global")) {
5697 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
5698 _globs.back()->fFolder =
"!globs";
5699 }
else if (
c->getAttribute(
"obs")) {
5700 out.back()->fFolder =
"!robs";
5701 }
else if (
c->getAttribute(
"poi")) {
5702 out.back()->fFolder =
"!poi";
5703 }
else if (
c->getAttribute(
"np") ||
5705 out.back()->fFolder =
"!np";
5707 out.back()->fFolder =
"!floats";
5709 out.back()->fFolder =
"!pp";
5715 out.emplace_back(
g);
5718 for (
auto a : *
p2->get()) {
5719 a->setAttribute(
"obs");
5720 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5723 if (
auto _dglobs =
p2->getGlobalObservables()) {
5725 a->setAttribute(
"obs");
5726 a->setAttribute(
"global");
5727 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5732 a->setAttribute(
"obs");
5733 a->setAttribute(
"global");
5734 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5737 }
else if (
auto _ws =
ws(); _ws) {
5740 a->setAttribute(
"obs");
5741 a->setAttribute(
"global");
5742 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5746 for (
auto &
_g :
_gl->second) {
5747 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5748 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5750 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5759 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
5760 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
5762 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
5768 for (
auto a :
w->allVars()) {
5769 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5773 for (
auto a :
w->allCats()) {
5774 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5783 xRooNode out(
".components",
nullptr, *
this);
5788 for (
auto &o :
p->pdfList()) {
5791 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5809 for (
auto &o :
p2->funcList()) {
5812 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5816 for (
auto &o :
p3->list()) {
5817 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5820 for (
auto &
a : *
p4) {
5821 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
5824 for (
auto &o :
p5->components()) {
5827 bool hasClients =
false;
5828 for (
auto &
c : o->clients()) {
5829 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
5836 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5837 if (o->InheritsFrom(
"RooAbsPdf")) {
5838 out.back()->fFolder =
"!pdfs";
5840 out.back()->fFolder =
"!scratch";
5843 for (
auto &o :
p5->allGenericObjects()) {
5847 s = s(0, s.
Index(
';'));
5848 if (
auto _pdf = out.find(s.
Data()); _pdf) {
5850 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
5857 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
5859 out.back()->fFolder =
"!fits";
5861 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
5862 if (
strcmp(out.back()->get()->ClassName(),
"TStyle") == 0) {
5863 out.back()->fFolder =
"!styles";
5864 }
else if (
strcmp(out.back()->get()->ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
5865 out.back()->fFolder =
"!scans";
5866 }
else if (
strcmp(out.back()->get()->ClassName(),
"RooStats::ModelConfig") == 0) {
5867 out.back()->fFolder =
"!models";
5869 out.back()->fFolder =
"!objects";
5876 if (k.find(
"CACHE_") == 0)
5878 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
5879 out.back()->fFolder =
"!sets";
5883 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
5885 while ((
snap = iter->Next())) {
5886 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
5887 out.back()->fFolder =
"!snapshots";
5892 out.emplace_back(std::make_shared<xRooNode>(
".pdf", *
mc->GetPdf(), *
this));
5894 if (
mc->GetExternalConstraints()) {
5895 out.emplace_back(std::make_shared<xRooNode>(
".extCons", *
mc->GetExternalConstraints(), *
this));
5901 out.emplace_back(
c);
5908 out.emplace_back(
c);
5922 xRooNode out(
".bins",
nullptr, *
this);
5925 std::map<int, std::shared_ptr<xRooNode>> cats;
5926 for (
auto &
c :
p->indexCat()) {
5927 auto pp =
p->getPdf(
c.first.c_str());
5931 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
5933 for (
auto &[
_,
n] : cats)
5934 out.emplace_back(
n);
5937#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5940 auto &
pSet =
phf->paramList();
5942 for (
auto par :
pSet) {
5943 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
5944 out.back()->fBinNumber = i;
5948 for (
int i = 1; i <=
ax->GetNbins(); i++) {
5954 for (
auto &
ss :
f->bins()[i - 1]->factors())
5961 out.emplace_back(std::make_shared<xRooNode>(
5962 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
5968#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5974 out.back()->fBinNumber = i;
5999 std::make_shared<RooProduct>(
".recursiveCoefs",
6004 auto mem = out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
6005 mem->emplace_back(std::make_shared<xRooNode>(
ourCoefs));
6018 if (!parent->fComp) {
6019 while (!parent->fComp && parent->fParent) {
6020 parent = parent->fParent;
6023 parent = parent->fParent;
6029 for (
auto &o :
p->funcList()) {
6031 if (i >=
p->coefList().size()) {
6033 coefs.add(
p->coefList());
6035 coefs.add(*
p->coefList().at(i));
6042 if (
p2->coefList().empty()) {
6047 for (
auto &o :
p2->pdfList()) {
6049 if (i >=
p2->coefList().size()) {
6053 coefs.add(*
p2->coefList().at(i));
6067 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
6068 "Coefficients of",
coefs));
6069 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
6070 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
6073 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
6075 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
6077 if (!
coefs.empty()) {
6081 }
else if (
coefs.size() == 1) {
6083 if (!
coefs.empty()) {
6102 xRooNode out(
".factors",
nullptr, *
this);
6107 a->setStringAttribute(
"alias",
"samples");
6109 a2->setStringAttribute(
"alias",
"components");
6111 int _npdfs =
p->pdfList().size();
6112 for (
auto &o :
p->pdfList()) {
6113 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6115 out.back()->fFolder =
"!constraints";
6118 for (
auto &o :
p2->components()) {
6119 if (o->InheritsFrom(
"RooProduct")) {
6121 auto x =
xRooNode(
"tmp", *o, *
this).factors();
6123 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
6126 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6135 for (
auto a :
w->allFunctions()) {
6136 if (_obs.contains(*
a))
6139 for (
auto c :
a->clients()) {
6141 if (
c->InheritsFrom(
"RooProduct")) {
6147 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6191 xRooNode out(
".variations",
nullptr, *
this);
6204#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6205 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
6207 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
6209 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
6211 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
6212 *
p2->highList().at(i), *
this));
6213 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
6214 *
p2->lowList().at(i), *
this));
6217#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6218 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
6219 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
6220 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
6222 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
6226 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
6227 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
6228 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
6230 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
6254 for (
auto &k : *
this) {
6263 xRooNode out(
".datasets()",
nullptr, *
this);
6269 for (
auto &
d : _ws->allData()) {
6270 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
6271 out.back()->fFolder =
"!datasets";
6284 for (
auto _c :
coords()) {
6288 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6297 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6302 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6309 for (
auto cat : s->indexCat()) {
6310 if (!s->getPdf(cat.first.c_str())) {
6322 cutobs.add(s->indexCat());
6331 for (
auto &
child : *
this) {
6337 for (
auto &
d :
_wsNode.datasets()) {
6343 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6350 out.emplace_back(std::make_shared<xRooNode>(
6355 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6357 if (
d->get()->TestBit(1 << 20))
6358 out.back()->get()->SetBit(1 << 20);
6360 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6362 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6404 for (
auto o : *
fromPad->GetListOfPrimitives()) {
6424 cat->numTypes(), 0, cat->numTypes());
6426 std::map<int, std::string> cats;
6427 for (
auto &
c : *cat) {
6428 cats[
c.second] =
c.first;
6430 for (
auto &[
_, label] : cats) {
6431 theHist->GetXaxis()->SetBinLabel(i++, label.c_str());
6434 auto _binning =
v->getBinningPtr(
nullptr);
6435 if (_binning->isUniform()) {
6439 v->numBins(), _binning->lowBound(), _binning->highBound());
6444 v->numBins(), _binning->array());
6448 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
6461 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
6482 : (
theHist->GetXaxis()->IsAlphanumeric() ?
theHist->GetXaxis()->GetTimeFormatOnly()
6483 :
theHist->GetXaxis()->GetName()));
6502 int nevent =
theData->numEntries();
6503 for (
int i = 0; i < nevent; i++) {
6508 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
6514 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
6547 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
6549 double val =
theHist->GetBinContent(i + 1);
6552 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
6555 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
6568 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
6572 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
6573 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
6607 throw std::runtime_error(
"Cannot build graph");
6613 if (
auto _w =
ws();
_w) {
6615 for (
auto o :
_w->allGenericObjects()) {
6617 _fr->ResetBit(1 << 20);
6620 res->SetBit(1 << 20);
6622 auto allVars =
_w->allVars();
6627 throw std::runtime_error(
"Not supported yet");
6641 throw std::runtime_error(
"Not a RooFitResult");
6652#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
6664 if (
sOpt ==
"prefit") {
6678 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
6679 fr->setFinalParList(*
_pars);
6680 for (
auto &
p : fr->floatParsFinal()) {
6684 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
6687 std::shared_ptr<xRooNode>
pConstr;
6694 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
6695 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
6712 for (
auto &_d :
pConstr->vars()) {
6713 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
6737 if (!
_v->getStringAttribute(
"nominal"))
6749 _args.add(
_globs.argList());
6750 fr->setConstParList(_args);
6753 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6756 fr->setInitParList(*
_snap);
6761 if (
auto _w =
ws();
_w) {
6767 for (
auto p :
pars()) {
6770 if(
_fr->floatParsFinal().find(
p->GetName()) ||
6771 (
p->get<
RooAbsReal>() && std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6774 _fr->constPars().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
6779 if(!
_fr->floatParsFinal().find(
p->GetName())) {
6781 }
else if((
p->get<
RooAbsReal>() && std::abs(
_fr->floatParsFinal().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
6784 _fr->floatParsFinal().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
6800 for(
size_t i=0;i<
newFloats.size();i++) {
6816 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
6819 fr->setCovarianceMatrix(
cov);
6820 fr->setInitParList(
_fr->floatParsInit());
6825 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
6831 for (
auto o :
_w->allGenericObjects()) {
6857 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
6859 fr->setFinalParList(*
_pars);
6865 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
6866 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
6867 cov(i,
j) = (*prevCov)(i,
j);
6872 for (
auto &
p : fr->floatParsFinal()) {
6875 cov(i, i) = pow(
v->getError(), 2);
6883 fr->setCovarianceMatrix(
cov);
6890 _args.add(
_globs.argList());
6891 fr->setConstParList(_args);
6894 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
6897 fr->setInitParList(*
_snap);
6927 o->setStringAttribute(
"range",
range);
6934 std::string &out =
fRange;
6935 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
6936 out = o->getStringAttribute(
"range");
6938 while (out.empty() && _parent) {
6939 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
6940 out = o->getStringAttribute(
"range");
6941 _parent = _parent->fParent;
6966 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
6972 return nll(_data,
l);
6990 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
6991 "generate with (found at least %s and %s)",
7008 for (
auto c :
bins()) {
7030 if (
d->get()->TestBit(1 << 20)) {
7036 throw std::runtime_error(
7037 "Need at least one dataset selected (SetChecked) to use for deselected regions");
7068 std::unique_ptr<RooFitResult>
newFr;
7070 newFr = std::make_unique<RooFitResult>(*
_fr);
7082 for(
auto par :
_pars) {
7090 newFr = std::make_unique<RooFitResult>(*
_fr);
7091 for(
auto par :
_pars) {
7116 if (
mc->GetExternalConstraints()) {
7118 for (
auto o :
opts) {
7143 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7144 "build nll with (found at least %s and %s)",
7153 throw std::runtime_error(
TString::Format(
"Workspace has multiple pdfs, you must specify which to "
7154 "build nll with (found at least %s and %s)",
7167 for (
auto c :
bins()) {
7188 _d = std::make_shared<xRooNode>(
asi.first, *
this);
7191 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
7201 me.push_back(std::make_shared<xRooNode>(_data));
7218 for (
int i = 0; i <
opts.GetSize(); i++) {
7221 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
7232 std::dynamic_pointer_cast<RooAbsData>(_data.
fComp), *
_opts);
7330 auto rangeName = (_range.empty()) ?
GetRange() : _range;
7331 if (!rangeName.empty()) {
7342 for (
auto &
c :
bins()) {
7345 _cat.setLabel(
cName);
7352 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
7366 std::vector<TObject *>
funcs;
7367 for (
auto &
c : out.components()) {
7376 funcs.push_back(
c->get());
7380 if (!
funcs.empty()) {
7382 _pdf->setFloor(
false);
7408 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
7410 fr->setCovarianceMatrix(
_tmp);
7412 const_cast<RooArgList &
>(fr->floatParsFinal())
7423 for (
auto c : *
this) {
7424 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
7428 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
7532 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
7541 return getProjection(&intobs, _normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
7557 return rrv->getErrorHi();
7559 return rrv->getErrorLo();
7561 return rrv->getError();
7578 if (
rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
7588 std::stringstream
errMsg;
7589 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
7590 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case."
7593 throw std::runtime_error(
errMsg.str());
7605 : fr.reducedCovarianceMatrix(*
_pars));
7609 double nomVal =
f.getVal(nset);
7659 for (std::size_t i = 0; i <
_pars->size(); i++) {
7660 errVec[i] = std::sqrt(V(i, i));
7661 for (std::size_t
j = i;
j <
_pars->size();
j++) {
7662 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
7668 double sum = F * (
C *
F);
7684 fFunc(
"func",
"func",
this,
f),
7685 fCoef(
"coef",
"coef",
this),
7686 fExpPdf(
"expPdf",
"expPdf",
this)
7691 fCoef.setArg(*coef);
7695 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
7707 fExpectedEventsMode(
other.fExpectedEventsMode)
7714 return fFunc->binBoundaries(obs, xlo, xhi);
7719 return (fExpectedEventsMode ? 1. : fFunc) *
7720 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(_normSet) : 1.) *
7721 (fCoef.absArg() ? fCoef : 1.);
7732#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
7733 double oo = getPropagatedError(fr,
nset_in);
7734 if (std::isnan(
oo)) {
7753 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
7763 std::stringstream
errMsg;
7765 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
7766 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
7768 throw std::runtime_error(
errMsg.str());
7773 if (paramList.
empty())
7808#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7832 std::vector<double>
errVec(paramList.
size());
7833 for (std::size_t i = 0; i < paramList.
size(); i++) {
7834 errVec[i] = std::sqrt(V(i, i));
7835 for (std::size_t
j = i;
j < paramList.
size();
j++) {
7836 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
7843 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7848 double sum = F * (C *
F);
7858 if (
frv->getError() > 1
e-20) {
7875 for (
Int_t i = 0; i <
fpf.size(); i++) {
7878 paramList.
add(*par);
7914 std::vector<double>
errVec(paramList.
size());
7915 for (
int i = 0; i < paramList.
size(); i++) {
7916 errVec[i] = sqrt(V(i, i));
7917 for (
int j = i;
j < paramList.
size();
j++) {
7918 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
7925 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
7930 double sum = F * (C *
F);
7944 bool fExpectedEventsMode =
false;
7952 std::cout <<
"Got signal " <<
signum << std::endl;
7954 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
7967 for (
int i = 0; i < obj->numCaches(); i++) {
7973 p->setNormRange(
p->normRange());
7975#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
7980 p->setProxyNormSet(
nullptr);
7981 p->_lastNSet =
nullptr;
7984 obj->setValueDirty();
7988 for (
auto &
c :
w->components()) {
8008 for (
auto obj :
a->clients()) {
8015 }
while (
a->clients().size() !=
nClients);
8034 out.fComp = std::shared_ptr<TH1>(
8035 BuildHistogram(
nullptr, !
content,
errors, -1, -1, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
false));
8036 }
else if (
vars.size() == 1) {
8038 out.fComp = std::shared_ptr<TH1>(
8039 BuildHistogram(
v, !
content,
errors, 1, 0, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
true));
8041 throw std::runtime_error(
"multi-dim histo not yet supported");
8080 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8081 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8082 h->GetXaxis()->SetTimeFormat(
rar->GetName());
8091 if (
h->GetListOfFunctions())
8094 h->SetTitle(
rar->GetTitle());
8099 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8101 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8102 h->SetBinContent(1,
rar->getVal());
8103 if (
x->getError()) {
8104 h->SetBinError(1,
x->getError());
8105 h->SetFillStyle(3005);
8106 h->SetFillColor(
h->GetLineColor());
8108 h->SetMaximum(
x->hasMax() ?
x->getMax()
8109 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8110 h->SetMinimum(
x->hasMin() ?
x->getMin()
8111 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8114 h->SetMarkerSize(0);
8115 h->SetMarkerStyle(0);
8120 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
8121 if (binningName ==
"")
8122 binningName =
rar->GetName();
8123 if (
x->hasBinning(binningName)) {
8124 if (
x->getBinning(binningName).isUniform()) {
8125 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
8126 x->getMin(binningName),
x->getMax(binningName));
8128 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
8130 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
8132 }
else if (
auto _boundaries =
8133 _or_func( (std::list<double> *)(
nullptr),
8134 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
8135 std::numeric_limits<double>::infinity()));
8137 std::vector<double>
_bins;
8138 for (
auto &
b : *_boundaries) {
8144 }
else if (!
x->hasMax() || !
x->hasMin()) {
8146 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
8148 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
8152 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
8155 std::map<int, std::string> cats;
8156 for (
auto &
c : *cat) {
8157 cats[
c.second] =
c.first;
8159 for (
auto &[
_, label] : cats) {
8160 h->GetXaxis()->SetBinLabel(i++, label.c_str());
8166 h->GetXaxis()->SetTitle(o->GetTitle());
8170 if (
h->GetXaxis()->IsAlphanumeric()) {
8179 if (
auto s =
styles(
nullptr,
false); s) {
8185 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
8186 h->GetXaxis()->SetTitle(
vv->GetTitle());
8215 if (!
GETDMP(fr, _finalPars)) {
8228 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
8229 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
8230 cov(i,
j) = (*prevCov)(i,
j);
8250 _pars.remove(*_p,
true);
8283 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
8301 for (
auto o : _obs) {
8303 rr->removeRange(
"coordRange");
8304 rr->setStringAttribute(
"coordRange",
nullptr);
8308 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8309 rr->removeRange(
"coordRange");
8310 rr->setStringAttribute(
"coordRange",
nullptr);
8320 bool hasRange =
false;
8323 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
8333 for (
auto pdf :
bins()) {
8340 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
8342 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
8346 rar =
p->createProjection(
8350 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
8354 p->setNormRange(
"coordRange");
8359 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
8365 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
8383 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
8405 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
8408 -std::numeric_limits<double>::infinity(),
8409 std::numeric_limits<double>::infinity()))))
8422 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
8440 auto l =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
8443 h->GetListOfFunctions()->Add(
l, (
setInterp) ?
"lsame" :
"histsame");
8447 h->SetMarkerSize(0);
8448 h->SetFillStyle(3005);
8449 h->SetFillColor(
h->GetLineColor());
8465 auto l =
static_cast<TH1 *
>(
h->Clone(
"toys"));
8468 h->GetListOfFunctions()->Add(
8482 static_cast<TH1 *
>(
main_h->GetListOfFunctions()->FindObject(
"toys"))->GetListOfFunctions()->
Add(
h);
8487 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
8490 x->setVal(
h->GetBinCenter(i));
8492 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
8496 if (
x && !
x->inRange(
"coordRange"))
8500 if (!empty ||
toy > 0) {
8502#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8511 r *=
h->GetBinWidth(i);
8519 h->SetBinContent(i,
r);
8536#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8538 p->_normSet =
nullptr;
8556 res *=
h->GetBinWidth(i);
8558 h->SetBinError(i, res);
8574 res *=
h->GetBinWidth(i);
8579 h->SetBinContent(i,
h->GetBinContent(i) + (res -
h->GetBinError(i)) * 0.5);
8580 h->SetBinError(i, (res +
h->GetBinError(i)) * 0.5);
8592 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
8602 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
8628 auto nomHist =
static_cast<TH1 *
>(
h->FindObject(
"nominal"));
8631 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
8632 std::vector<double> vals;
8640 std::sort(vals.begin(), vals.end());
8649 upVal =
h->GetBinContent(i) + err;
8650 downVal =
h->GetBinContent(i) - err;
8658 std::vector<RooAbsArg *> extra;
8661 for (
auto _pdf : s->servers()) {
8663 extra.push_back(_pdf);
8666 extra.push_back(
rar);
8669 for (
auto a : extra)
8676 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
8678 h->GetYaxis()->SetTitle(
"Events");
8680 h->GetYaxis()->SetTitle(
"Probability Mass");
8682 h->GetYaxis()->SetMaxDigits(3);
8691 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"copy"));
8695 hCopy->SetStats(
false);
8696 h->GetListOfFunctions()->Add(
hCopy,
TString(
h->GetOption()) +
"same");
8697 h->GetListOfFunctions()->Add(
hCopy,
"axissame");
8715 std::vector<TH1 *>
hhs;
8722 if (!
rarNode->components().empty()) {
8725 if (
c->fFolder ==
"!.coeffs")
8731 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
8736 std::unique_ptr<RooAbsReal>
f(
8738 zero.setAttribute(
Form(
"ORIGNAME:%s",
c->GetName()));
8743 hh->SetName(
c->GetName());
8745 hh->Scale(
sf->getVal());
8747 hh->SetTitle(
c->GetName());
8749 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8754 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
8771 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
8773 hh->SetTitle(
samp->GetTitle());
8775 hh->SetTitle(
samp->GetName());
8777 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8781 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
8785 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
8791 auto hh =
samp->BuildHistogram(
8792 v, empty,
false ,
binStart,
binEnd,
_fr,
false,
false, 0,
h,
true,
8794 hh->SetName(
samp->GetName());
8796 hh->Scale(
sf->getVal());
8799 hh->SetTitle(
samp->GetName());
8801 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
8810 for (
auto &
hh :
hhs) {
8861 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
8876 (*ritr)->SetTitle(
_title.c_str());
8880 for (
auto &
hh :
hhs) {
8891 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
8912 h->GetListOfFunctions()->AddFirst(stack,
"noclear same");
8924 for (
auto ho : *ll) {
8932 hh->SetFillStyle(1001);
8935 hh->SetFillColor((count++));
8938 for (
auto ho2 : *ll) {
8959 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
8962 hh->SetFillColor(10);
8975 push_back(std::make_shared<xRooNode>(
data));
8983 return std::numeric_limits<double>::quiet_NaN();
8984 return node->GetBinContent(bin);
8995 std::vector<double> out;
9007 for (
int i = 0; i <
g->GetN(); i++)
9008 integral +=
g->GetPointY(i);
9009 out.push_back(integral);
9014 out.push_back(
g->GetPointY(i));
9035 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9036 tot +=
h->GetBinContent(i);
9041 out.push_back(
h->GetBinContent(i));
9052 for (
auto &
l :
a->servers()) {
9072 if (
auto o =
get(); o) {
9081#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9085 for (
int i = 0; i <
p->fCGnx; i++) {
9086 for (
int j = 0;
j <
p->fCGny;
j++) {
9087 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
9090 p->FillCollideGrid(o);
9099 if (
p->Collide(i,
j,
iw,
ih)) {
9110 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
9118 gPad->PaintModified();
9124 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
9125 1. -
gPad->GetTopMargin() - 0.08);
9126 l->SetBorderSize(0);
9127 if (
l->GetTextSize() == 0)
9135 l->ConvertNDCtoPad();
9141 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
9144 double w =
p->GetX2NDC() -
p->GetX1NDC();
9145 double h =
p->GetY2NDC() -
p->GetY1NDC();
9147 gPad->PaintModified();
9151 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
9152 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
9153 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
9154 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
9155 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
9156 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
9168 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
9169 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
9177 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
9178 if (
l =
dynamic_cast<TLegend *
>(
p->GetPrimitive(
"legend"));
l || !create)
9182 gPad->GetBottomMargin());
9183 l->SetBorderSize(1);
9187 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
9188 l->SetBorderSize(0);
9190 if (
l->GetTextSize() == 0) {
9198 l->SetName(
"legend");
9200 l->ConvertNDCtoPad();
9207 auto i = s.find(
"\n");
9208 if (i == std::string::npos) {
9211 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
9220 for (
auto a : *
l->GetListOfPrimitives()) {
9224 if (
l->GetListOfPrimitives()->GetEntries() > 20)
9229 l->GetListOfPrimitives()->RemoveLast();
9230 l->GetListOfPrimitives()->AddFirst(
e);
9231 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
9233 int nn =
l->GetNColumns();
9235 if (
nObj > 1 && (
nObj % nn) == 1) {
9236 l->SetNColumns(
l->GetNColumns() + 1);
9237 if (
l->GetBorderSize() == 0) {
9238 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
9241 if (
l->GetBorderSize() == 0) {
9242 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
9258 fPad->GetCanvas()->Paint();
9259 fPad->GetCanvas()->Update();
9260#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
9261 fPad->GetCanvas()->ResetUpdated();
9276 if (
gROOT->FromPopUp()) {
9277 gROOT->SetFromPopUp(
false);
9280 }
catch (
const std::exception &
e) {
9283 (
gROOT->GetListOfBrowsers()->At(0))
9286 "Exception",
e.what(),
9289 gROOT->SetFromPopUp(
true);
9321 if (
d->get()->TestBit(1 << 20)) {
9327 hs.limits(
"cls visualize");
9339 [](
double a,
double b,
double) {
9342 if (
b == 0 &&
a == 0)
9349 [](
double n,
double b,
double sigma) {
9353 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
9363 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
9372 if (
sOpt2.Contains(
"x=")) {
9374 int _idx =
sOpt2.Index(
"x=");
9390 }
else if (
ii == 1) {
9392 }
else if (
ii == 2) {
9400 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
9403 }
else if (nBins == 1)
9404 xPoints.push_back((min + max) / 2.);
9413 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
9423 if (
sOpt2.Contains(
"force")) {
9437 Error(
"Draw",
"Can only compute forces with PDFs");
9449 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
9451 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
9452 sOpt +=
"auxSignif";
9463 sOpt.ReplaceAll(
"ratio",
"");
9464 sOpt.ReplaceAll(
"significance",
"");
9466 sOpt.ReplaceAll(
"nostack",
"");
9468 sOpt.ReplaceAll(
"same",
"");
9470 sOpt.ReplaceAll(
"goff",
"");
9472 sOpt.ReplaceAll(
"pull",
"");
9476 sOpt.ReplaceAll(
"e",
"");
9478 sOpt.ReplaceAll(
"txt",
"texte");
9480 sOpt.ReplaceAll(
"txt",
"text");
9493 if (
gPad->GetNumber() == 0) {
9513 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
9515 for (
auto o : *
pad->GetListOfPrimitives()) {
9522 :
hAxis->GetXaxis()->GetName())
9544 double ymin =
hh->GetMinimum();
9545 double ymax =
hh->GetMaximum();
9546 if (
hh->GetMaximumStored() == -1111)
9548 if (
hh->GetMinimumStored() == -1111) {
9551 }
else if (
ymin < 0) {
9559 if (
hh->GetSumw2()) {
9562 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
9582 double up =
ymax -
hh->GetBinContent(1);
9607 double ymax = -std::numeric_limits<double>::infinity();
9608 double ymin = std::numeric_limits<double>::infinity();
9609 for (
int i = 0; i <
gr->
GetN(); i++) {
9621 out->SetFillColor(out->GetLineColor());
9622 out->SetMarkerStyle(0);
9629 out->SetPointEYlow(out->GetN() - 1,
GetError());
9630 out->SetPointEYhigh(out->GetN() - 1, out->GetErrorYlow(out->GetN() - 1));
9643 pad->Divide(1, 2, 1
e-9, 1
e-9);
9644 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
9645 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
9647 optNoFR.ReplaceAll(
"pull",
"");
9657 gPad->GetFrame()->SetFillStyle(1001);
9658 gPad->SetTopMargin(0);
9659 gPad->SetBottomMargin(0);
9660 gPad->SetName(
"pull");
9664 Error(
"Draw",
"Couldn't find pull graph");
9673 throw std::runtime_error(
"Could not find scales in fit result");
9675 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
9680 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
9684 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
9685 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
9689 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
9690 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
9691 g->SetEditable(
true);
9692 g->SetHighlight(
true);
9693 g->SetMarkerStyle(20);
9694 g->SetMarkerSize(0.5);
9720 if (!
_v->IsHidden())
9729 pad->SetBorderSize(0);
9751 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
9753 auto _pad =
pad->GetPad(_size);
9754 _pad->SetName(
"legend");
9756 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
9759 while (
pad->GetPad(
x + 1)) {
9760 pad->GetPad(
x + 1)->SetFillStyle(0);
9770 if (_range &&
strlen(_range)) {
9794 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9809 for (
auto &
_v : *
this) {
9816 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9819 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9829 pad->SetBorderSize(0);
9830 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
9833 for (
auto &
_v : *
this) {
9840 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
9843 if (
_v->get()->InheritsFrom(
"RooConstVar"))
9852 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
9874 if (
sOpt.Contains(
"corr")) {
9880 TH2* hist =
nullptr;
9883 std::set<std::pair<double,size_t>>
maxCorrs;
9892 std::vector<size_t>
topN;
9901 for(
size_t i = 0;i<
topN.size();i++) {
9904 for(
size_t j = 0;
j<
topN.size();
j++) {
9926 gPad->SetGrid(1, 1);
9932 if (
sOpt.Contains(
"brakdown")) {
9938 if (
sOpt.Contains(
"brakdown:")) {
9942 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
9943 if (_poi->empty()) {
9944 throw std::runtime_error(
"No floating poi in the fit");
9945 }
else if (_poi->size() != 1) {
9946 throw std::runtime_error(
"Multiple poi in the fit");
9948 poiName = _poi->first()->GetName();
9954 std::set<std::string>
groups;
9958 }
else if (
p->getStringAttribute(
"group")) {
9959 groups.insert(
p->getStringAttribute(
"group"));
9986 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
9987 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
9995 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
9996 pie->SetEntryVal(i, 0);
10005 pie->SetEntryLabel(i,
group.c_str());
10020 pie->SetRadius(0.17);
10029 out->SetTitle(
"Fit Result Pulls");
10033 ugraph->SetTitle(
"Fit Result Pulls");
10035 std::map<std::string, double>
scale;
10036 std::map<std::string, double>
offset;
10042 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
10043 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
10057 std::shared_ptr<xRooNode>
pConstr;
10060 if (
_vv->hasRange(
"pullScale")) {
10070 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
10071 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
10093 std::string
xName =
pConstr->find(
".x")->get()->GetName();
10095 for (
auto &_d :
pConstr->vars()) {
10096 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
10098 if (
xName == _d->get()->GetName())
10122 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
10126 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
10137 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10144 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
10156 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10169 for (
int i = 0; i <
ugraph->GetN(); i++)
10170 ugraph->SetPointX(i, i + graph->GetN());
10183 graph->SetMarkerStyle(20);
10184 graph->SetMarkerSize(0.5);
10186 graph->SetMaximum(4);
10187 graph->SetMinimum(-4);
10190 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
10192 std::vector<std::pair<double, std::string>>
covariances;
10195 if (
sOpt.Contains(
"impact")) {
10196 if (
sOpt.Contains(
"impact:")) {
10200 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10201 if (_poi->empty()) {
10202 throw std::runtime_error(
"No floating poi in the fit");
10203 }
else if (_poi->size() != 1) {
10204 throw std::runtime_error(
"Multiple poi in the fit");
10206 poiName = _poi->first()->GetName();
10227 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
10228 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
10229 : (std::abs(i.first) > std::abs(j.first));
10250 sortedGraph.SetPointError(
sortedGraph.GetN() - 1, 0, 0, graph->GetErrorYlow(i), graph->GetErrorYhigh(i));
10259 graph->SetTitle(
"Fit Result Impact");
10266 std::max(graph->GetN(), 1) - 0.5);
10275 hist =
new TH2D(
GetName(), fr->
GetTitle(), std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5,
10302 graph->GetHistogram()->GetXaxis()->Set(std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5);
10303 for (
int ii = 1;
ii <=
_axis->GetNbins();
ii++) {
10304 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
10319 gPad->Divide(1, 1, 1
e-9, 1
e-9);
10323 gPad->SetLeftMargin(0.4);
10325 gPad->SetBottomMargin(0.4);
10328 auto pNamesHist =
dynamic_cast<TH1F *
>(graph->GetHistogram()->Clone(
"scales"));
10332 for (
int ii = 1;
ii <= graph->GetN();
ii++) {
10336 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
10341 if (!
sOpt.Contains(
"impact")) {
10342 for (
int ii = 2;
ii >= 1;
ii--) {
10377 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
10378 pave->SetFillStyle(0);
10379 pave->SetBorderSize(0);
10380 pave->SetMargin(0.);
10381 pave->SetName(
"status");
10382 pave->SetTextAlign(31);
10387 case 0:
covQualTxt =
"Not calculated";
break;
10389 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
10404 gPad->SetTicks(0, 0);
10408 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
10409 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
10413 double factor = 475. /
gPad->GetCanvas()->GetWh();
10442 for (
int tt = 0;
tt < 2;
tt++) {
10443 auto impact =
static_cast<TH1 *
>(
10444 graph->GetHistogram()->Clone(
TString::Format(
"%s_impact+",
tt == 0 ?
"prefit" :
"postfit")));
10447 impact->SetBarWidth(0.9);
10448 impact->SetBarOffset(0.05);
10449 impact->SetLineColor(
kBlack);
10450 impact->SetFillColor(
kAzure - 4);
10451 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
10453 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
10454 impact2->SetDirectory(
nullptr);
10462 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
10464 :
c.first *
vv->getError() /
vv->getErrorHi() *
10465 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
10468 :
c.first *
vv->getError() /
vv->getErrorLo() *
10469 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
10476 for (
int ii = -1;
ii <= 1;
ii++) {
10489 leg1->SetFillStyle(0);
10490 leg1->SetBorderSize(0);
10491 leg1->SetMargin(0.25);
10492 leg1->SetNColumns(2);
10494 leg1->SetTextSize(
_axis->GetLabelSize());
10495 leg1->SetTextFont(
_axis->GetLabelFont());
10496 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
10497 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
10498 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
10499 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
10500 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
10501 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
10502 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
10503 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
10509 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
10516 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
10524 graph->SetEditable(
false);
10528 graph->GetListOfFunctions()->Add(
pNamesHist,
"same");
10532 for (
int p = 0;
p < graph->GetN();
p++) {
10533 graph->SetPoint(
p, graph->GetPointY(
p), graph->GetPointX(
p));
10534 graph->SetPointError(
p, graph->GetErrorYlow(
p), graph->GetErrorYhigh(
p), graph->GetErrorXlow(
p),
10535 graph->GetErrorXhigh(
p));
10538 if (
f->InheritsFrom(
"TH1")) {
10547 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
10548 for (
int p = 0;
p <
g->GetN();
p++) {
10549 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
10552 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
10562 if(!
sOpt.Contains(
"impact")) {
10568 auto x = graph->GetPointX(graph->GetN()-
ugraphLabels.size()+i);
10569 auto y = graph->GetPointY(graph->GetN()-
ugraphLabels.size()+i)+graph->GetErrorYhigh(graph->GetN()-
ugraphLabels.size()+i);
10573 t->SetTextSize(0.025);
10574 t->SetTextAngle(90);
10575 graph->GetListOfFunctions()->Add(t);
10579 graph->SetName(
"pulls");
10588 hist->
Draw(
"same");
10600 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
10601 hh->SetDirectory(
nullptr);
10619 for (
auto c : s->bins()) {
10620 auto _pad =
dynamic_cast<TPad *
>(
gPad->GetPrimitive(
c->GetName()));
10625 c->push_back(std::make_shared<xRooNode>(*
this));
10627 c->resize(
c->size() - 1);
10629 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
10648 for (
auto o : *
gPad->GetListOfPrimitives()) {
10673 for (
int i = 0; i <
dataGraph->GetN(); i++)
10690 for (
auto o : *
gPad->GetListOfPrimitives()) {
10691 if (
auto h =
dynamic_cast<TH1 *
>(o);
10701 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
10704 histName = histName(0, histName.
Index(
'|'));
10705 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
10711 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
10723 if (!std::isnan(
yval)) {
10725 if (!std::isnan(yup))
10727 if (!std::isnan(
ydown))
10794 if (!
d->get()->TestBit(1 << 20))
10798 auto _obs =
d->obs();
10800 auto _nll =
nll(
d);
10802 int nevent =
theData->numEntries();
10803 for (
int i = 0; i < nevent; i++) {
10805 bool _skip =
false;
10806 for (
const auto &_c :
_coords) {
10808 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
10818 auto val = _nll.pars()->getRealValue(
initPar->GetName());
10821 auto nllVal = _nll.getEntryVal(i);
10822 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
10823 auto nllVal2 = _nll.getEntryVal(i);
10824 _nll.pars()->setRealValue(
initPar->GetName(), val);
10830 auto val = _nll.pars()->getRealValue(
initPar->GetName());
10833 auto _extTerm = _nll.extendedTermVal();
10834 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
10835 auto _extTerm2 = _nll.extendedTermVal();
10836 _nll.pars()->setRealValue(
initPar->GetName(), val);
10837 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
10842 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
10848 }
else if (
ii == 3) {
10874 (
rarNode->get()->InheritsFrom(
"RooRealSumPdf") ||
rarNode->get()->InheritsFrom(
"RooAddPdf") ||
10875 (
v &&
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
10883 auto h =
BuildHistogram(
v,
false,
hasErrorOpt, 1, 0,
"",
false,
false, 0,
nullptr,
nostack,
true );
10895 :
h->GetXaxis()->GetName())
10898 if (
h->GetXaxis()->IsAlphanumeric()) {
10906 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
10907 rar->InheritsFrom(
"RooSimultaneous"))) {
10910 rar->leafNodeServerList(&s);
10917 for (
auto _p : s) {
10925 if (
_v->hasError()) {
10936 gPad->SetGrid(0, 0);
10938 gPad->SetGrid(1, 1);
10943 h->SetFillStyle(0);
10992 gROOT->SetEditHistograms(
true);
10994 gROOT->SetEditHistograms(
false);
11003 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
11008 bool hasError(
false);
11009 for (
int i = 0; i <
h->GetSumw2N(); i++) {
11010 if (
h->GetSumw2()->At(i)) {
11021 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
11022 h->GetYaxis()->SetTitleOffset(1.);
11040 hCopy->SetDirectory(
nullptr);
11042 _hist->GetListOfFunctions()->Add(node);
11043 _hist->GetListOfFunctions()->Add(
new TExec(
11046 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
11047 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
11048 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
11049 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
11050 "h->SetBinContent(1, "
11051 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
11052 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
11053 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
11054 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
11055 _hist->GetName(), node->GetName())));
11057 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
11058 errHist->SetFillColor(
h->GetLineColor());
11061 hCopy->SetFillStyle(0);
11062 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
11065 _hist->SetStats(
false);
11122 errHist->SetFillColor(
h->GetLineColor());
11139 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11141 if (
auto stack =
dynamic_cast<THStack *
>(
h->FindObject(
"stack"))) {
11147 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
11148 if (
lnk == stack->GetHists()->FirstLink() &&
h->GetMinimum() >
hhMin) {
11434 dOpt.ReplaceAll(
"TEXT",
"");
11436 double ymax = -std::numeric_limits<double>::infinity();
11437 double ymin = std::numeric_limits<double>::infinity();
11438 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
11467 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
11476 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
11477 double val =
ratioHist->GetBinContent(i);
11478 double err =
ratioHist->GetBinError(i);
11485 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
11492#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
11501 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
11502 _h->SetDirectory(
nullptr);
11503 _h->SetFillColor(0);
11504 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
11509 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
11510 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
11511 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
11512 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
11522 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
11526 histName = histName(0, histName.
Index(
'|'));
11528 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
11529 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
11532 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
11533 double val =
h->GetBinContent(i);
11534 double err =
h->GetBinError(i);
11535 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
11536 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
11537 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
11538 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
11539 h->GetBinContent(i));
11556 double ymax = -std::numeric_limits<double>::infinity();
11557 double ymin = std::numeric_limits<double>::infinity();
11558 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
11559 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
11560 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
11594 if (
d->get()->TestBit(1 << 20)) {
11615 w->import(*
gROOT->GetListOfColors(),
true);
11618#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
11627 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
11632#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11636 for (
auto &
c :
w->components()) {
11637 c->_eocache =
nullptr;
11645 if (
auto fitDb =
dynamic_cast<TFile *
>(
gROOT->GetListOfFiles()->FindObject(
"fitDatabase"))) {
11650 auto dir =
dest->GetDirectory(
source->GetName());
11654 for (
auto k : *
source->GetListOfKeys()) {
11655 auto key =
dynamic_cast<TKey *
>(k);
11656 const char *classname = key->GetClassName();
11665 if (dir->FindKey(key->GetName()))
11668 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
11670 dir->WriteObject(
fc, key->GetName());
11673 TObject *obj = key->ReadObj();
11675 dir->WriteTObject(obj, key->
GetName());
11689#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11691 for (
auto &
c :
w->components()) {
11692 c->setExpensiveObjectCache(
w->expensiveObjectCache());
11702 return std::numeric_limits<double>::quiet_NaN();
11708 std::vector<double> out;
11709 out.reserve(
size());
11710 for (
auto child : *
this) {
11711 out.push_back(
child->GetContent());
11725 auto rho =
_fr->correlationMatrix();
11734 for (
int m = 0;
m < rho.GetNrows();
m++) {
11741 auto tmp = _p->getVal();
11742 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
11744 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
11747 for (
int n = 0;
n < rho.GetNrows();
n++) {
11755 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
11757 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
11760 for (
int i = 0; i < out.GetNrows(); i++) {
11761 for (
int j = 0;
j < out.GetNrows();
j++) {
11773 double err = std::numeric_limits<double>::quiet_NaN();
11775 std::unique_ptr<RooAbsCollection>
_snap;
11788 out =
c->getVal(
sobs);
11794 p->setNormRange(rangeName);
11795#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
11798 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
11799#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
11801 p->_normSet =
nullptr;
11805 p->setNormRange(
nullptr);
11808 auto f = std::shared_ptr<RooAbsReal>(
11809 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
11813 out *=
f->getVal();
11814 err =
xRooNode(
pr, *
this).GetBinError(-1, fr);
11819 auto ax = (rangeName) ?
GetXaxis() :
nullptr;
11823 for (
auto &
v : vals) {
11826 if (
rv && !
rv->inRange(
ax->GetBinCenter(i), rangeName))
11828 if (
cv && !
cv->isStateInRange(rangeName,
ax->GetBinLabel(i)))
11835 out = std::numeric_limits<double>::quiet_NaN();
11838 _pars.RooAbsCollection::operator=(*_snap);
11840 return std::make_pair(out, err);
11859 std::vector<double> out;
11865 binEnd = _hist->GetNbinsX();
11872 _hist->GetBinError(bin));
11997std::string cling::printValue(
const xRooNode *
v)
12000 return "nullptr\n";
12003 size_t left =
v->size();
12004 for (
auto n : *
v) {
12010 out +=
n->GetName();
12011 if (out.length() > 100 && left > 0) {
12017 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName())) + out;
12022 return "<nullptr>";
12024 return Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName());
#define ROOT_VERSION(a, b, c)
#define ROOT_VERSION_CODE
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
double GetBinLowEdge(Int_t bin) const override
Return low edge of bin.
double GetBinUpEdge(Int_t bin) const override
Return up edge of bin.
Int_t FindFixBin(double x) const override
Find bin number corresponding to abscissa x.
void Set(Int_t nbins, const double *xbins) override
Initialize axis with variable bins.
RooAbsRealLValue * rvar() const
void SetTitle(const char *title) override
Set the title of the TNamed.
void Set(Int_t nbins, double xmin, double xmax) override
Initialize axis with fix bins.
Int_t FindFixBin(const char *label) const override
Find bin number with label.
RooAbsLValue * var() const
const RooAbsBinning * binning() const
void Set(Int_t nbins, const float *xbins) override
Initialize axis with variable bins.
const char * GetTitle() const override
Returns title of object.
double GetBinWidth(Int_t bin) const override
Return bin width.
PadRefresher(TVirtualPad *p)
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
double getSimplePropagatedError(const RooFitResult &fr, const RooArgSet &nset_in) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
TObject * clone(const char *newname) const override
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Retrieve bin boundaries if this distribution is binned in obs.
PdfWrapper(const PdfWrapper &other, const char *name=nullptr)
PdfWrapper(RooAbsReal &f, RooAbsReal *coef, bool expEvMode=false, RooAbsPdf *expPdf=nullptr)
The PiecewiseInterpolation is a class that can morph distributions into each other,...
static std::shared_ptr< RooLinkedList > createNLLOptions()
static std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > generateFrom(RooAbsPdf &pdf, const RooFitResult &fr, bool expected=false, int seed=0)
static xRooNLLVar createNLL(const std::shared_ptr< RooAbsPdf > pdf, const std::shared_ptr< RooAbsData > data, const RooLinkedList &nllOpts)
static std::pair< double, double > matchPrecision(const std::pair< double, double > &in)
void Draw(Option_t *opt="") override
Default Draw method for all objects.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
This xRooNLLVar object has several special methods, e.g.
xRooHypoSpace hypoSpace(const char *parName, int nPoints, double low, double high, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown)
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
void _Add_(const char *name, const char *opt)
TH1 * BuildHistogram(RooAbsLValue *v=nullptr, bool empty=false, bool errors=false, int binStart=1, int binEnd=0, const xRooNode &fr="", bool errorsHi=false, bool errorsLo=false, int nErrorToys=0, TH1 *templateHist=nullptr, bool nostack=true, bool setInterp=false) const
xRooNode filter(const xRooNode &range) const
std::vector< std::shared_ptr< xRooNode > > fBrowsables
xRooNLLVar nll(const xRooNode &_data, std::initializer_list< RooCmdArg > nllOpts) const
xRooNode poi() const
List of parameters of interest: parameters marked as "of interest" These parameters have the "poi" at...
void SetName(const char *name) override
Set the name of the TNamed.
TGListTreeItem * GetTreeItem(TBrowser *b) const
void SetTitle(const char *title) override
Set the title of the TNamed.
xRooNode Multiply(const xRooNode &child, Option_t *opt="")
xRooNode Replace(const xRooNode &node)
bool SetData(const TObject &obj, const xRooNode &data="obsData")
xRooNode datasets() const
xRooNode Remove(const xRooNode &child)
xRooNode globs() const
List of global observables of this node.
xRooNode Combine(const xRooNode &rhs)
xRooNode Add(const xRooNode &child, Option_t *opt="")
xRooNode(const char *type, const char *name, const char *title="")
const char * GetIconName() const override
Returns mime type name of object.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
bool _IsShowVars_() const
TGraph * BuildGraph(RooAbsLValue *v=nullptr, bool includeZeros=false, TVirtualPad *fromPad=nullptr) const
const std::shared_ptr< xRooNode > & at(size_t idx, bool browseResult=true) const
const char * GetNodeType() const
bool SetBinContent(int bin, double value, const char *par=nullptr, double parVal=1)
std::shared_ptr< xRooNode > operator[](size_t idx)
void Checked(TObject *obj, bool val)
void Print(Option_t *opt="") const override
Print TNamed name and title.
double GetContent() const
std::shared_ptr< T > acquireNew(Args &&...args)
xRooNode components() const
void SaveAs(const char *filename="", Option_t *option="") const override
Save this object in the file specified by filename.
xRooNode bins() const
bins of a channel or sample, or channels of a multi-channel pdf
std::shared_ptr< xRooNode > find(const std::string &name, bool browseResult=true) const
TGListTree * GetListTree(TBrowser *b) const
xRooNode styles(TObject *initObject=nullptr, bool autoCreate=true) const
bool fInterrupted
appears that if was fXaxis then dialog box for SetXaxis will take as current value
xRooNode generate(const xRooNode &fr="", bool expected=false, int seed=0)
void Inspect() const override
Dump contents of this object in a graphics canvas.
std::shared_ptr< xRooNode > getBrowsable(const char *name) const
bool SetXaxis(const RooAbsBinning &binning)
double GetBinError(int bin, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
RooArgList argList() const
bool SetBinData(int bin, double value, const xRooNode &data="obsData")
void SetHidden(bool set=true)
std::vector< double > GetBinContents(int binStart=1, int binEnd=0) const
xRooNode pp() const
List of prespecified parameters: non-floatable parameters.
xRooNode constraints() const
std::shared_ptr< xRooNode > fProvider
std::shared_ptr< TStyle > style(TObject *initObject=nullptr, bool autoCreate=true) const
xRooNode mainChild() const
xRooNode fitResult(const char *opt="") const
std::shared_ptr< TAxis > fXAxis
only here so can have char* GetRange return so can return nullptr for no range set (required for RooC...
xRooNode coords(bool setVals=true) const
xRooNode Vary(const xRooNode &child)
xRooNode Constrain(const xRooNode &child)
static std::map< std::string, std::tuple< std::function< double(double, double, double)>, bool > > auxFunctions
xRooNode pars() const
List of parameters (non-observables) of this node.
void _SetContent_(double value)
void SetFitResult(const RooFitResult *fr=nullptr)
void _ShowVars_(bool set=true)
xRooNode coefs(bool recurse=false) const
bool IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
double GetBinData(int bin, const xRooNode &data="obsData")
bool SetBinError(int bin, double value)
void _Vary_(const char *what)
void _fit_(const char *constParValues="", const char *options="")
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)
std::shared_ptr< TObject > getObject(const std::string &name, const std::string &type="") const
xRooNode np() const
List of nuisance parameters: non-constant parameters that are not marked of interest,...
xRooNode floats() const
List of parameters that are currently non-constant These parameters do not have the "Constant" attrib...
bool contains(const std::string &name) const
double GetBinContent(int bin) const
xRooNode reduced(const std::string &range="", bool invert=false) const
xRooNode variations() const
std::string GetPath() const
std::vector< double > GetBinErrors(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
auto begin() const -> xRooNodeIterator
std::shared_ptr< xRooNode > parentPdf() const
like a parent but only for use by getObject
bool SetContent(double value)
void _scan_(const char *what="plr", double nToys=0, const char *xvar="", int nPointsX=0, double lowX=0, double highX=0, const char *constParValues="", const char *options="")
std::shared_ptr< xRooNode > fParent
std::pair< double, double > IntegralAndError(const xRooNode &fr="", const char *rangeName=nullptr) const
xRooNode robs() const
List of regular observables of this node.
TClass * IsA() const override
xRooNode & operator=(const TObject &o)
auto end() const -> xRooNodeIterator
xRooNode consts() const
List of parameters that are currently constant.
void _SetBinContent_(int bin, double value, const char *par="", double parVal=1)
std::shared_ptr< TObject > acquire(const std::shared_ptr< TObject > &arg, bool checkFactory=false, bool mustBeNew=false)
std::function< xRooNode(xRooNode *) fBrowseOperation)
xRooNode histo(const xRooNode &vars="x", const xRooNode &fr="", bool content=true, bool errors=true, bool stack=true, bool errorsHi=false, bool errorsLo=false, int nErrorToys=0) const
void Browse(TBrowser *b=nullptr) override
Browse object. May be overridden for another default action.
xRooNode obs() const
List of observables (global and regular) of this node.
void SetRange(const char *range, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN())
static void SetAuxFunction(const char *title, const std::function< double(double, double, double)> &func, bool symmetrize=false)
std::shared_ptr< TObject > convertForAcquisition(xRooNode &acquirer, const char *opt="") const
double GetError(const xRooNode &fr="") const
xRooNode vars() const
List of variables (observables and parameters) of this node.
const char * GetRange() const
TMatrixDSym covariances(const xRooNode &fr="") const
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
void SetName(const char *name) override
Set the name of the TNamed.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Abstract base class for RooRealVar binning definitions.
virtual double highBound() const =0
virtual double lowBound() const =0
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
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...
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for binned and unbinned datasets.
RooFit::OwningPtr< RooAbsData > reduce(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a reduced copy of this dataset.
RooArgSet const * getGlobalObservables() const
Returns snapshot of global observables stored in this data.
Abstract base class for objects that are lvalues, i.e.
Abstract interface for all probability density functions.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
Context to temporarily change the error logging mode as long as the context is alive.
Abstract base class for objects that represent a real value and implements functionality common to al...
bool isSelectedComp() const
If true, the current pdf is a selected component (for use in plotting)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void forceNumInt(bool flag=true)
Efficient implementation of a sum of PDFs of the form.
Calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Abstract interface for RooAbsArg proxy classes.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
Named container for two doubles, two integers two object points and three string pointers that can be...
static const RooCmdArg & none()
Return reference to null argument.
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Represents a constant real-valued object.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
TMatrixDSym conditionalCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix, which is calculated as.
void setCovQual(Int_t val)
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
Int_t statusCodeHistory(UInt_t icycle) const
const RooArgList & floatParsInit() const
Return list of floating parameters before fit.
TMatrixDSym reducedCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
const RooArgList & randomizePars() const
Generate random perturbations of the final parameters using the covariance matrix.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
double edm() const
Return estimated distance to minimum.
const RooArgList & constPars() const
Return list of constant parameters.
const char * statusLabelHistory(UInt_t icycle) const
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
TH2 * correlationHist(const char *name="correlation_matrix") const
Return TH2D of correlation matrix.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Int_t status() const
Return MINUIT status code.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
UInt_t numStatusHistory() const
const TMatrixDSym & correlationMatrix() const
Return correlation matrix ;.
double minNll() const
Return minimized -log(L) value.
Implementation of a probability density function that takes a RooArgList of servers and a C++ express...
A real-valued function sampled from a multidimensional histogram.
bool isBinnedDistribution(const RooArgSet &) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
static RooMsgService & instance()
Return reference to singleton instance.
Implementation of a RooCacheManager<RooAbsCacheElement> that specializes in the storage of cache elem...
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
A RooAbsPdf implementation that represent a projection of a given input p.d.f and the object returned...
RooProjectedPdf()
Default constructor.
Implements a PDF constructed from a sum of functions:
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setError(double value)
bool hasError(bool allowZero=true) const
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
HypoTestResult is a base class for results from hypothesis tests.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
A RooAbsArg implementing string values.
Persistable container for RooFit projects.
bool removeSet(const char *name)
Remove a named set from the workspace.
RooFactoryWSTool & factory()
Return instance to factory tool.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
virtual void SetTickSize(Float_t size=0.03)
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 ...
void SetTitle(const char *title) override
Change/set the title.
virtual Int_t GetNbinsY() const
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
@ kNoTitle
Don't draw the histogram title.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
virtual void SetMaximum(Double_t maximum=-1111)
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="")
Performs the operation: this = this + c1*f1 if errors are defined (see TH1::Sumw2),...
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetMinimum(Double_t minimum=-1111)
TList * GetListOfFunctions() const
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
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)
Service class for 2-D histogram classes.
Int_t Fill(Double_t) override
Invalid Fill method.
The Histogram stack class.
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
To draw Mathematical Formula.
Storage class for one entry of a TLegend.
This class displays a legend box (TPaveText) containing several legend entries.
Use the TLine constructor to create a simple line.
virtual void SetY2(Double_t y2)
virtual void SetX2(Double_t x2)
virtual void SetX1(Double_t x1)
virtual void SetY1(Double_t y1)
void Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
The TNamed class is the base class for all named ROOT classes.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Wrapper around a TObject so it can be stored in a TList.
Mother of all ROOT objects.
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void Delete(Option_t *option="")
Delete this object.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
@ kCanDelete
if object in a list can be deleted
The most important graphics class in the ROOT system.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void SetY1NDC(Double_t y1)
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
virtual void SetY2NDC(Double_t y2)
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Regular expression class.
This class creates a ROOT object browser, constituted by three main tabs.
Sequenceable collection abstract base class.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TStyle objects may be created to define special styles.
void SetPaintTextFormat(const char *format="g")
Int_t GetOptTitle() const
Float_t GetLabelSize(Option_t *axis="X") const
Return label size.
Float_t GetPadRightMargin() const
Style_t GetTitleFont(Option_t *axis="X") const
Return title font.
Bool_t GetHistMinimumZero() const
Float_t GetPadLeftMargin() const
Float_t GetTitleYSize() const
Double_t GetHistTopMargin() const
Float_t GetPadBottomMargin() const
const char * GetPaintTextFormat() const
Float_t GetPadTopMargin() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
double evaluate() const override
Evaluate projected p.d.f.
TObject * clone(const char *newname) const override
double expectedEvents(const RooArgSet *nset) const override
Return expected number of events to be used in calculation of extended likelihood.
ExtendMode extendMode() const override
Returns ability of PDF to provide extended likelihood terms.
RooCmdArg RecycleConflictNodes(bool flag=true)
RooConstVar & RooConst(double val)
RooCmdArg Embedded(bool flag=true)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg ExternalConstraints(const RooArgSet &constraintPdfs)
RooCmdArg Range(const char *rangeName, bool adjustNorm=true)
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
constexpr Double_t C()
Velocity of light in .
Double_t Prob(Double_t chi2, Int_t ndf)
Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf...
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
Double_t StdDev(Long64_t n, const T *a, const Double_t *w=nullptr)
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE
bool isNaNWithPayload() const
Test if this struct has a float packed into its mantissa.
static float unpackNaN(double val)
If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the manti...
static uint64_t sum(uint64_t i)
void(* gOldHandlerr)(int)
void addLegendEntry(TObject *o, const char *title, const char *opt)
void buildHistogramInterrupt(int signum)
auto GETACTBROWSER(TRootBrowser *b)
auto & GETWSSNAPSHOTS(RooWorkspace *w)
bool TopRightPlaceBox(TPad *p, TObject *o, double w, double h, double &xl, double &yb)
TPaveText * getPave(const char *name="labels", bool create=true, bool doPaint=false)
std::string formatLegendString(const std::string &s)
auto GETROOTDIR(TGFileBrowser *b)
const xRooNode * runningNode
auto GETLISTTREE(TGFileBrowser *b)
const T & _or_func(const T &a, const T &b)
double new_getPropagatedError(const RooAbsReal &f, const RooFitResult &fr, const RooArgSet &nset={}, RooArgList **pars=nullptr, bool asymHi=false, bool asymLo=false)
TLegend * getLegend(bool create=true, bool doPaint=false)