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)
184#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
214#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
220xRooNode::InteractiveObject *xRooNode::gIntObj =
nullptr;
221std::map<std::string, std::tuple<std::function<
double(
double,
double,
double)>,
bool>> xRooNode::auxFunctions;
222void xRooNode::SetAuxFunction(
const char *title,
const std::function<
double(
double,
double,
double)> &func,
225 auxFunctions[title] = std::make_tuple(func,
symmetrize);
244xRooNode::xRooNode(
const char *classname,
const char *
name,
const char *title)
250#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
251 w->_embeddedDataList.Delete();
253 xRooNode(*
w, std::make_shared<xRooNode>()).sterilize();
264xRooNode::xRooNode(
const char *
name,
const std::shared_ptr<TObject> &
comp,
const std::shared_ptr<xRooNode> &parent)
275#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
276 fComp = std::make_shared<RooWorkspace>(
"workspace",
name);
281 Error(
"xRooNode",
"Error reading json workspace %s",
name);
286 Error(
"xRooNode",
"json format workspaces available only in ROOT 6.26 onwards");
292 auto _file = std::make_shared<TFile>(
297 auto keys =
_file->GetListOfKeys();
299 for (
auto &&k : *keys) {
305#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
306 dynamic_cast<RooWorkspace *>(ws)->_embeddedDataList.Delete();
308 xRooNode(*ws, std::make_shared<xRooNode>()).sterilize();
314 fParent = std::make_shared<xRooNode>(
340 for (
auto f : *
gROOT->GetListOfFiles()) {
341 if ((
dynamic_cast<TFile *
>(
f)->GetVersion() / 100) > (
gROOT->GetVersionInt() / 100)) {
342 Warning(
"xRooNode",
"There is file open with version %d > current version %d ... results may be wrong",
343 dynamic_cast<TFile *
>(
f)->GetVersion(),
gROOT->GetVersionInt());
352 for (
auto col : *
colors) {
353 if (!
gROOT->GetListOfColors()->FindObject(col->GetName())) {
354 gROOT->GetListOfColors()->Add(
gROOT->GetListOfColors()->IsOwner() ? col->Clone() : col);
364 for (
auto &
d : _ws->allData()) {
365 for (
auto &
a : *
d->
get()) {
366 if (
auto v = _ws->var(
a->GetName());
v) {
367 v->setAttribute(
"obs");
368 }
else if (
auto c = _ws->cat(
a->GetName());
c) {
369 c->setAttribute(
"obs");
376 if (
checkCount == 0 && !_ws->allData().empty())
377 _ws->allData().back()->SetBit(1 << 20,
true);
380 for (
auto s : *_set) {
382 _ws->var(s->GetName())->setStringAttribute(
"nominal",
TString::Format(
"%f",
v->getVal()));
390 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
393 s->setAttribute(
"obs");
394 s->setAttribute(
"global");
397 const_cast<RooArgSet &
>(
v).setAttribAll(
"obs");
400 s->setAttribute(
"poi");
412 const_cast<RooArgSet &
>(
v).setAttribAll(
"np");
416 _ws->defineSet(
"globalObservables",
_allGlobs);
421 if (!_ws->allPdfs().empty()) {
424 for (
auto &
p :
np()) {
428 if (!
v->hasError()) {
437 "Inferring initial errors of %d parameters (%s%s) (give all nuisance parameters an error to avoid "
442 for (
auto &
a : *
this) {
446 if (
a->fFolder ==
"!pdfs") {
448 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
452 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
453 arg && arg->hasError()) {
454 v->setError(arg->getError());
470 if (
strlen(GetTitle()) == 0) {
497 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
498 return a->getStringAttribute(
"alias");
500 return comp->GetName();
513 bool isBool = (
v ==
"TRUE" ||
v ==
"FALSE");
515 if (
value ==
nullptr ||
v ==
"NULLPTR") {
516 if (
a->getAttribute(
name))
517 a->setAttribute(
name,
false);
518 else if (
a->getStringAttribute(
name))
519 a->setStringAttribute(
name,
nullptr);
522 a->setAttribute(
name, (
v ==
"TRUE"));
533 for (
auto a : *
gROOT->GetListOfBrowsers()) {
555 if (o->isSelectedComp() && !val) {
558 o->setAttribute(
"hidden");
559 }
else if (!o->isSelectedComp() && !val) {
564 o->setAttribute(
"hidden",
false);
567 item->CheckItem(!o->getAttribute(
"hidden"));
568 if (o->isSelectedComp()) {
576 if (
auto o =
get(); o) {
578 o->SetBit(1 << 20, val);
580 if (
auto _ws =
ws(); _ws) {
583 if (fr->numStatusHistory() && !_ws->genobj(fr->GetName())) {
585 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
590 _allVars = fr->floatParsFinal();
591 _allVars = fr->constPars();
592 for (
auto &i : fr->floatParsInit()) {
598 for (
auto oo : _ws->allGenericObjects()) {
600 ffr->ResetBit(1 << 20);
604 _ws->allVars() = fr->floatParsInit();
608 for (
auto a : *
gROOT->GetListOfBrowsers()) {
619 if (
auto first =
p->GetParent()->GetFirstChild()) {
621 if (first->HasCheckBox()) {
622 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
623 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
625 }
while ((first = first->GetNextSibling()));
637 if (
auto first = i->GetFirstChild()) {
639 if (first->IsOpen() &&
640 (
TString(first->GetText()) ==
"poi" ||
TString(first->GetText()) ==
"np")) {
641 fb->DoubleClicked(first, 0);
644 }
while ((first = first->GetNextSibling()));
666 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
667 if (!b2 || !b2->GetBrowserImp()) {
674 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
676 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
678 b2->BrowseObject(
this);
683 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
690 _b->GotoDir(
nullptr);
701 if (
auto first =
item->GetFirstChild()) {
703 if (first->HasCheckBox()) {
704 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
705 first->CheckItem(
_obj->get() &&
706 (
_obj->get()->TestBit(1 << 20) ||
709 }
while ((first = first->GetNextSibling()));
722 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
723 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corr10colztext\")",
nullptr, *
this));
724 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
725 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
732 s->SetFillAttributes();
739 Draw(
b->GetDrawOption());
741 }
catch (
const std::exception &
e) {
744 (
gROOT->GetListOfBrowsers()->At(0))
747 "Exception",
e.what(),
754 for (
auto &
c : *
this) {
755 if (!
c->fFolder.empty()) {
766 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
769 for (
auto &
v : *
this) {
770 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
771 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
778 _name = _name(1, _name.
Length());
779 b->Add(
v.get(), _name);
783 for (
auto &
v : *
this) {
786 if (
strcmp(
v->GetName(),
".folders") == 0)
790 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
798 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
806 :
v->get()->GetName());
808 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
810 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
818 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
824 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
833 if (
auto o =
v->get(); o)
834 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
836 if (
auto o =
v->get(); o)
839 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
840 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
843 if (
_fr->status() ||
_fr->covQual() != 3) {
844 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() && !
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
845 }
else if (
_fr->numStatusHistory() == 0) {
846 v->GetTreeItem(
b)->SetColor(
kGray);
849 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
851 v->GetTreeItem(
b)->SetColor(
kGray);
853 v->GetTreeItem(
b)->ClearColor();
857 if (
auto fits =
_htr->GetFitInfo()) {
858 for (
int i = 0; i <
fits->numEntries(); i++) {
860 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
861 v->GetTreeItem(
b)->SetColor(
kRed);
866 v->GetTreeItem(
b)->SetColor(
kBlue);
893 if (_name ==
".memory")
897 if (
auto o =
v->get(); o)
898 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
899 b->Add(
v.get(), _name, -1);
900 if (
auto o =
v->get(); o)
904 b->SetSelected(
this);
917 auto v = std::make_shared<xRooNode>(
vars());
928 if (
strcmp(
b->GetName(),
".vars") == 0)
951 if (
auto v = var();
v)
952 return v->getBinWidth(bin - 1, GetName());
957 if (
auto v = rvar();
v) {
958 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
959 :
v->getBinning(GetName()).binLow(bin - 1);
965 if (
auto v = rvar();
v)
966 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
972 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
979 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
983 void Set(
Int_t nbins,
const double *xbins)
override
986 v->setBinning(
RooBinning(nbins, xbins), GetName());
991 std::vector<double> bins(nbins + 1);
992 for (
int i = 0; i <= nbins; i++)
993 bins.at(i) = xbins[i];
994 return Set(nbins, &bins[0]);
1018 for (
auto &o : *
_owned) {
1019 if (
name == o->GetName()) {
1020 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
1031 _parent = _parent->fParent;
1037 std::shared_ptr<TObject> out;
1038 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
1039 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1040 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1045 if (
auto arg =
ws()->
data(
name.c_str()); arg) {
1046 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1047 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1052 if (
auto arg =
ws()->genobj(
name.c_str()); arg) {
1053 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1054 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1059 if (
auto arg =
ws()->embeddedData(
name.c_str()); arg) {
1060 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1061 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1067 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1068 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1078 arg->treeNodeServerList(&nodes);
1091 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1107 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1119 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1120 for (
auto &
v : _obs) {
1156 TString binningName = o->getStringAttribute(
"binning");
1157 auto _bnames =
x->getBinningNames();
1158 bool hasBinning =
false;
1160 if (
b == binningName) {
1168 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1170 o->setStringAttribute(
"binning",
nullptr);
1174 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1180 if (
b == o->GetName()) {
1181 binningName = o->GetName();
1185 if (binningName ==
"") {
1191 (std::list<double> *)(
nullptr),
1193 ? o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1194 std::numeric_limits<double>::infinity())
1197 std::vector<double>
_bins;
1198 for (
auto &
b : *
bins) {
1206 _v->getBinning(o->GetName())
1211 binningName = o->GetName();
1222 if (
r->getBinning(binningName).isUniform()) {
1223 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1225 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1227 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1228 std::vector<double>
bins = {};
1229 for (
int i = 0; i <=
x->numBins(binningName); i++)
1231 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1234 std::map<int, std::string> cats;
1235 for (
auto &
c : *cat) {
1236 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1237 cats[
c.second] =
c.first;
1240 for (
auto &[
_, label] : cats) {
1241 fXAxis->SetBinLabel(i++, label.c_str());
1246 fXAxis->SetName(binningName);
1253 if (
auto o =
get(); o) {
1254 if (o->InheritsFrom(
"RooWorkspace"))
1256 if (o->InheritsFrom(
"RooAbsData"))
1258 if (o->InheritsFrom(
"RooSimultaneous"))
1261 if (o->InheritsFrom(
"RooProdPdf"))
1263 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1266 if (o->InheritsFrom(
"RooFitResult")) {
1267 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1268 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1269 "package.xpm",
"->Browse()");
1271 return "xRooFitRooFitResult";
1273 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1275 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1276 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1278 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1279 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1282 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1286 if (o->InheritsFrom(
"TStyle")) {
1287 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1288 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1289 "bld_colorselect.xpm",
"->Browse()");
1291 return "xRooFitTStyle";
1293 if (o->InheritsFrom(
"RooConstVar")) {
1299 return "TMethodBrowsable-leaf";
1301 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1302 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1303 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1306 return "xRooFitScanStyle";
1308 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1309 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1310 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1313 return "xRooFitTestStyle";
1315 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1316 return "TBranchElement-folder";
1317 if (o->InheritsFrom(
"RooAbsPdf")) {
1318 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1319 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1322 return "xRooFitPDFStyle";
1324 if (o->InheritsFrom(
"RooStats::ModelConfig")) {
1325 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitMCStyle",
true)) {
1326 gClient->GetMimeTypeList()->AddType(
"xRooFitMCStyle",
"xRooFitMCStyle",
"app_t.xpm",
"app_t.xpm",
1329 return "xRooFitMCStyle";
1333 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1335 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1336 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1337 std::numeric_limits<double>::infinity()))))) {
1342 return o->ClassName();
1353 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1355 if (o->InheritsFrom(
"PiecewiseInterpolation")) {
1367 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"VariedDensity" :
"Varied";
1370 if (o->InheritsFrom(
"RooHistFunc"))
1371 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"SimpleDensity" :
"Simple";
1372 if (o->InheritsFrom(
"RooBinWidthFunction"))
1374 if (o->InheritsFrom(
"ParamHistFunc"))
1376 if (o->InheritsFrom(
"RooRealVar"))
1378 if (o->InheritsFrom(
"RooConstVar"))
1386 xRooNode out(
".coords",
nullptr, *
this);
1388 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1418 if (
auto pos =
pName.Index(
'='); pos != -1) {
1419 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1427 _obs->setVal((high + low) / 2.);
1428 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1430 "coordRange",
"coordRange");
1432 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1437 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1440 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1441 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1445 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1447 throw std::runtime_error(
"Unknown observable, could not find");
1459 }
catch (
const std::exception &
e) {
1468 }
catch (
const std::exception &
e) {
1495 pdf =
p->pdfList().find(
child.GetName());
1498 auto i =
p->pdfList().index(*pdf);
1500#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1501 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1502#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1503 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1505 auto nset =
p->_pdfNSetList.At(i);
1506 p->_pdfNSetList.Remove(nset);
1509 if (
p->_extendedIndex == i)
1510 p->_extendedIndex = -1;
1511 else if (
p->_extendedIndex > i)
1512 p->_extendedIndex--;
1524 arg =
p2->components().find(
child.GetName());
1528#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1529 p2->_compRSet.remove(*arg);
1531 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1533 p2->removeServer(*arg,
true);
1543 }
catch (std::runtime_error &) {
1553 arg =
p4->funcList().find(
child.GetName());
1557 auto idx =
p4->funcList().index(arg);
1562 p4->removeServer(*arg,
true);
1564 std::vector<RooAbsArg *>
_coefs;
1566 if (
ii !=
size_t(idx))
1581 arg =
p5->pdfList().find(
child.GetName());
1585 auto idx =
p5->pdfList().index(arg);
1590 p5->removeServer(*arg,
true);
1592 std::vector<RooAbsArg *>
_coefs;
1594 if (
ii !=
size_t(idx))
1609 arg =
p6->list().find(
child.GetName());
1614 p6->removeServer(*arg,
true);
1622 auto arg =
w->components().find(
child.GetName());
1629 if (arg->hasClients()) {
1630 throw std::runtime_error(
1631 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1634 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1635 Info(
"Remove",
"Deleted %s from workspace %s", out.GetName(),
GetName());
1643 throw std::runtime_error(
"Removal not implemented for object type " +
1693 out->setAttribute(
"obs");
1694 out->setAttribute(
"global");
1697 throw std::runtime_error(
"Failed to add global observable");
1701 out->setAttribute(
"poi");
1709 throw std::runtime_error(
"Failed to add parameter of interest");
1713 if (!
fac.Contains(
"[") && !
fac.Contains(
"("))
1719 if (
find(_data->GetName())) {
1720 throw std::runtime_error(
TString::Format(
"Cannot add dataset %s, already exists for %s. If intending to "
1721 "combine datasets, please add directly to dataset",
1731 throw std::runtime_error(
1732 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1735 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1753 }
else if (!_ws->obj(
_fr->GetName())) {
1762 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1770 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1773 if (
auto _d = _ws->data(
child.GetName()); _d) {
1776 l.remove(*_d->get(),
true,
true);
1780 throw std::runtime_error(
"Cannot extend dataset with new columns");
1791 if (
auto __d = _ws->data(
child.GetName()))
1792 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1800 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1809 throw std::runtime_error(
"Cannot create dataset");
1814 throw std::runtime_error(
"Cannot add to null object with no parentage");
1816 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1821 std::rethrow_exception(std::current_exception());
1826 throw std::runtime_error(
"No object");
1836 throw std::runtime_error(
"Can only add datasets to a dataset");
1845 }
else if (
g->GetContent() !=
glob->GetContent()) {
1846 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1851 if (
auto _dglobs =
p->getGlobalObservables()) {
1861 std::set<std::pair<RooAbsCategory *, RooCategory *>> cats;
1863 for (
auto col : *_data->get()) {
1864 if (!
p->get()->contains(*col)) {
1865 ds->addColumn(*col);
1870 throw std::runtime_error(
1871 TString::Format(
"unexpected type for regular observable: %s", col->GetName()));
1884 cats.insert({
c,
c2});
1891 for (
int i = 0; i < _data->numEntries(); i++) {
1892 auto row = _data->get(i);
1893 auto w = _data->weight();
1894 ds->get()->assign(*row);
1895 for (
auto [
c,
c2] : cats) {
1896 c2->setLabel(row->getCatLabel(
c->GetName()));
1898 ds->add(*
ds->get(),
w);
1902 ds->SetTitle(
TString(
ds->GetTitle()) +
" + " + _data->GetTitle());
1908 throw std::runtime_error(
"Can only add histogram or dataset to data");
1912 throw std::runtime_error(
"Could not find pdf");
1913 auto _ax = _pdf->GetXaxis();
1915 throw std::runtime_error(
"Cannot determine binning to add data");
1924 l.remove(*
p->get(),
true,
true);
1928 throw std::runtime_error(
"Cannot extend dataset with new columns");
1935 for (
auto &o :
obs) {
1937 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1938 if (
v->getMin() <
dv->getMin())
1939 dv->setMin(
v->getMin());
1940 if (
v->getMax() >
dv->getMax())
1941 dv->setMax(
v->getMax());
1954 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1956 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1957 throw std::runtime_error(
1958 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1959 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1960 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1961 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1963 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1968 p->add(
obs,
_h->GetBinContent(i));
1978 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
1980 throw std::runtime_error(
"Something went wrong with pdf acquisition");
1987 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
1988 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1989 std::numeric_limits<double>::infinity()));
1990 !_boundaries && _ax->GetNbins() > 0) {
1991#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
1992 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
1996 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
1997 if (!_p->getStringAttribute(
"alias"))
1998 _p->setStringAttribute(
"alias", out->GetName());
2000 throw std::runtime_error(
2001 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2007 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
2011 if (_pdf->canBeExtended()) {
2013 std::cout <<
" warning " << _pdf->GetName() <<
" wont be correctly normalized" << std::endl;
2023 for (
auto i =
p->coefList().size(); i <
p->pdfList().size(); i++) {
2028 *
static_cast<RooAbsPdf *
>(
p->pdfList().at(i))));
2034 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2035 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
2036 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2037 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
2039 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
2071 std::shared_ptr<TObject> out;
2076 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
2081 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
2085 if (!out && !
child.fComp) {
2086 std::shared_ptr<RooAbsArg> _func;
2097 std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(), _ax->binning()->array());
2099 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
2101 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2102 }
else if (_obs.size() == 1) {
2105 auto _bnames = _x->getBinningNames();
2106 TString binningName =
p->getStringAttribute(
"binning");
2108 if (
b ==
p->GetName()) {
2109 binningName =
p->GetName();
2115 auto h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
2116 _x->getBinningPtr(binningName)->array());
2118 h->GetXaxis()->SetName(
2121 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2122 Info(
"Add",
"Created SimpleDensity factor %s (xaxis=%s) for %s", _func->GetName(), _obs.at(0)->GetName(),
2125 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
2131 _func->setStringAttribute(
"alias",
child.GetName());
2135 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
2139 _f->setAttribute(
"density");
2140 if (
_f->getAttribute(
"autodensity")) {
2142 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
2146 _f->setAttribute(
"autodensity",
false);
2147 _f->setValueDirty();
2156 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
2157 _f->getAttribute(
"density") ?
"SimpleDensity" :
"Simple",
_f->GetName(),
p->GetName());
2161 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
2166 newName.ReplaceAll(
"_samples",
"");
2168 Warning(
"Add",
"converting samples to components");
2173 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2174 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2175 std::numeric_limits<double>::infinity()));
2176 !_boundaries && _ax->GetNbins() > 0) {
2177#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2178 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2182 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2183 if (!_p->getStringAttribute(
"alias"))
2184 _p->setStringAttribute(
"alias", out->GetName());
2186 throw std::runtime_error(
2187 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2194 if (!_p->canBeExtended()) {
2203 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2210 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
2212 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
2213 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2214 std::numeric_limits<double>::infinity()));
2215 !_boundaries && _ax->GetNbins() > 0) {
2216#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2219 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
2223 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
2224 if (!sumPdf->getStringAttribute(
"alias"))
2225 sumPdf->setStringAttribute(
"alias", out->GetName());
2228 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2229 if (!
_f->getStringAttribute(
"alias"))
2230 _f->setStringAttribute(
"alias", out->GetName());
2232 throw std::runtime_error(
2233 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2241 if (!
p->getStringAttribute(
"binning"))
2242 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2245 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2250 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2259 p->setStringAttribute(
"xvar",
nullptr);
2285 auto out = this->
operator[](
"components")->Add(child);
2304 for (
auto &
_pdfa :
pp->components()) {
2322 auto out = this->
operator[](
"samples")->Add(child);
2325 p2->setStringAttribute(
"xvar",
nullptr);
2338 child.convertForAcquisition(
2339 *
this,
child.get() ?
"" :
"func" );
2343 if (!
w->import(*_d)) {
2346 std::unique_ptr<RooAbsCollection>(
w->allVars().selectCommon(*_d->get()))->setAttribAll(
"obs");
2348 if (_d->getGlobalObservables()) {
2349 std::unique_ptr<RooAbsCollection>
globs(
w->allVars().selectCommon(*_d->getGlobalObservables()));
2350 globs->setAttribAll(
"obs");
2351 globs->setAttribAll(
"global");
2355 throw std::runtime_error(
2366 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2369 std::string
catName =
"channelCat";
2370 if (!
child.empty()) {
2376 _cat->setAttribute(
"obs");
2378 Info(
"Add",
"Created pdf RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2382 if (
coll->isOwning()) {
2384 }
else if (
child.ws() !=
ws()) {
2392 if (
sOpt ==
"pdf") {
2398 }
else if (
sOpt ==
"channel") {
2403 std::shared_ptr<TObject> out;
2404 child.convertForAcquisition(*
this);
2407 }
else if (!
child.fComp) {
2410 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2414 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2420 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2423 }
else if (
sOpt ==
"dataset") {
2426 return (*this).datasets().Add(
child);
2484 a->setAttribute(
"hidden", set);
2495 return a->getAttribute(
"hidden");
2502 if (
get() ==
rhs.get()) {
2514 std::set<std::string>
pdfs;
2515 for (
auto &
c :
rhs.components()) {
2516 if ((*
this)[
"pdfs"]->find(
c->GetName())) {
2517 pdfs.insert(
c->GetName());
2521 Warning(
"Combine",
"No pdfs will be combined. Please check and/or rename pdfs to match");
2523 std::stringstream s;
2524 for (
auto &
p :
pdfs)
2526 Info(
"Combine",
"pdfs that will be combined: %s", s.str().c_str());
2529 std::set<std::string>
_np;
2531 for (
auto &
c :
rhs.np()) {
2532 if (
mynp.find(
c->GetName())) {
2533 _np.insert(
c->GetName());
2537 Warning(
"Combine",
"No correlated np");
2539 std::stringstream s;
2542 Info(
"Combine",
"np that will be shared (correlated): %s", s.str().c_str());
2544 std::set<std::string> _poi;
2546 for (
auto &
c :
rhs.poi()) {
2547 if (
mypoi.find(
c->GetName())) {
2548 _poi.insert(
c->GetName());
2552 Warning(
"Combine",
"No correlated poi");
2554 std::stringstream s;
2555 for (
auto &
p : _poi)
2557 Info(
"Combine",
"poi that will be shared (correlated): %s", s.str().c_str());
2574 for (
auto &
c :
rhs.components()) {
2576 (
c->fFolder ==
"!scratch" ||
c->fFolder ==
"!sets" ||
c->fFolder ==
"!snapshots" ||
c->fFolder ==
"!models"))
2580 Info(
"Combine",
"Combining %s into %s",
c->GetPath().c_str(), _c->GetPath().c_str());
2582 _c->Combine(*
c,
true);
2586 Info(
"Combine",
"Adding %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2589 }
catch (std::exception &
e) {
2590 Warning(
"Combine",
"Could not combine %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2596 for (
auto &
f :
rhs.factors()) {
2599 Info(
"Combine",
"Combining %s into %s",
f->GetPath().c_str(),
_f->GetPath().c_str());
2601 _f->Combine(*
f,
true);
2604 Info(
"Combine",
"Multiplying %s into %s",
f->GetPath().c_str(),
GetPath().c_str());
2612 for (
auto &
c :
rhs.components()) {
2613 if (
c->fFolder ==
"!sets") {
2615 Info(
"Combine",
"Extending set %s",
c->GetName());
2618 Info(
"Combine",
"Defining set %s",
c->GetName());
2625 for (
auto &
ds :
rhs.datasets()) {
2628 Info(
"Combine",
"Combining %s into %s",
ds->GetPath().c_str(),
_ds->GetPath().c_str());
2633 Info(
"Combine",
"Adding %s into %s",
ds->GetPath().c_str(),
GetPath().c_str());
2640 for (
auto &
v :
rhs.variations()) {
2643 Info(
"Combine",
"Combining variation %s into %s",
v->GetPath().c_str(),
_v->GetPath().c_str());
2645 _v->Combine(*
v,
true);
2648 Info(
"Combine",
"Varying %s into %s",
v->GetPath().c_str(),
GetPath().c_str());
2656 for (
auto &
b :
rhs.bins()) {
2658 Info(
"Combine",
"Combining %s into %s",
b->GetPath().c_str(),
_b->GetPath().c_str());
2659 _b->Combine(*
b,
true);
2661 Info(
"Combine",
"Extending with %s into %s",
b->GetPath().c_str(),
GetPath().c_str());
2687 if (!
chans.empty()) {
2698 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2704 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2706 std::shared_ptr<RooProdPdf> pdf =
2707 std::dynamic_pointer_cast<RooProdPdf>(out.acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2712 std::dynamic_pointer_cast<RooAbsArg>(out.acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2728 static std::unique_ptr<cout_redirect>
capture;
2738 if (
sOpt.Contains(
"depth=")) {
2743 if (
sOpt.Contains(
"indent=")) {
2749 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2755 if (
get() &&
get() !=
this) {
2760 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2764 std::cout <<
"Minimization Logs:" << std::endl;
2765 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2779 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2785 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2793 }
else if (!
get()) {
2794 std::cout << std::endl;
2798 std::vector<std::string> folderNames;
2799 for (
auto &k : *
this) {
2800 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2801 folderNames.push_back(k->fFolder);
2804 for (
auto &
f : folderNames) {
2810 std::cout <<
f << std::endl;
2813 for (
auto &k : *
this) {
2814 if (k->fFolder !=
f) {
2820 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2824 auto _deps = k->coords(
false).argList();
2825 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2827 k->get()->Print(
sOpt);
2831 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2839 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2845 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2850 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2856 std::cout <<
" NULL " << std::endl;
2864 for (
size_t i = 0; i <
captureStr.size(); i++) {
2875 (
gROOT->GetListOfBrowsers()->At(0))
2890 double mean = std::numeric_limits<double>::quiet_NaN();
2891 double sigma = mean;
2900 mean = std::numeric_limits<double>::quiet_NaN();
2911 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2917 throw std::runtime_error(
"No error on parameter for poisson constraint");
2919 sigma = pow(
v->getVal() /
v->getError(), 2);
2927 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2928 globs->setConstant();
2929 globs->setAttribute(
"obs");
2930 globs->setAttribute(
"global");
2943 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
2950 globs->setAttribute(
"obs");
2951 globs->setAttribute(
"global");
2952 globs->setConstant();
2961 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
2970 throw std::runtime_error(
"Cannot constrain non arg");
2973 if (!
p->dependsOn(*
_me)) {
2974 throw std::runtime_error(
"Constraint does not depend on constrainee");
2983 throw std::runtime_error(
"Nowhere to put constraint");
2988 for (
auto d :
x->datasets()) {
2998 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
3007 for (
auto &
c : *
x) {
3013 return x->Multiply(
child);
3015 return x->Add(
child,
"+");
3038 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
3061 ?
fParent->mainChild()->GetName()
3068 throw std::runtime_error(
3088#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3095 for (std::size_t i = 0; i <
pSet.size(); i++) {
3105 _bin->fBinNumber = -1;
3134 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3139 std::rethrow_exception(std::current_exception());
3151 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
3155 }
else if (
sOpt ==
"const") {
3158 Info(
"Multiply",
"Scaled %s by new const factor %s",
3162 }
else if (
sOpt ==
"norm") {
3169 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3174 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
3178 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3182 }
else if (
sOpt ==
"shape" ||
sOpt ==
"simple" ||
sOpt ==
"blankshape") {
3187 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
3188 h->SetBinContent(i, 1);
3193 h->SetTitle(
child.GetTitle());
3194 if (
sOpt.Contains(
"shape"))
3198 Info(
"Multiply",
"Scaled %s by new %s factor %s",
3203 }
else if (
sOpt ==
"overall") {
3205 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
3207 Info(
"Multiply",
"Scaled %s by new overall factor %s",
3211 }
else if (
sOpt ==
"func" &&
ws()) {
3216 Info(
"Multiply",
"Scaled %s by new func factor %s",
3229 std::shared_ptr<TObject> out;
3230 child.convertForAcquisition(*
this);
3241 if (
p->coefList().empty() && !
p->pdfList().empty()) {
3242 for (
auto _pdf :
p->pdfList()) {
3248 Info(
"Multiply",
"Created RooExtendedBinding coefficients for all pdfs of %s so that can multiply coef",
3250 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3251 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
3252 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3253 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
3255 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
3257 auto coefs =
p->coefList().at(i);
3266 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
3273 const_cast<RooArgList &
>(
p->coefList()).removeAll();
3283 for (
size_t i = 0; i <
p2->funcList().
size(); i++) {
3285 auto coefs =
p2->coefList().at(i);
3294 for (
size_t j = 0;
j <
p2->coefList().size();
j++) {
3309 throw std::runtime_error(
"this coefs case is not supported");
3313 std::shared_ptr<TObject> out;
3320 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
3322 _f &&
_f->getAttribute(
"autodensity")) {
3332 if (
_f->getAttribute(
"density")) {
3335 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
3339 _f->setValueDirty();
3346 _f->setAttribute(
"autodensity",
false);
3350 Info(
"Multiply",
"Created %s factor %s in %s",
3354 Info(
"Multiply",
"Created Shape factor %s in %s",
child->GetName(),
p->GetName());
3357 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
3358#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3359 p->_compRSet.add(*
_f);
3367 for (
auto &_par :
_out.pars()) {
3370 for (
auto &
_constr : _par->constraints()) {
3378 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
3381 throw std::runtime_error(
"Couldn't find boundConstraint");
3383 _par->Constrain(_pdf);
3392 std::shared_ptr<TObject> out;
3393 child.convertForAcquisition(*
this);
3402 std::shared_ptr<RooAbsPdf> _pdf;
3419 _pdf->setStringAttribute(
"alias",
child.GetName());
3421 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
3422 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
3424 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
3429 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3430#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3432#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
3433 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
3437 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
3438 p2->_extendedIndex =
p2->_pdfList.size() - 1;
3449 std::shared_ptr<TObject> out;
3450 child.convertForAcquisition(*
this);
3456 TString s =
p3->getStringAttribute(
"global_factors");
3459 s += out->GetName();
3460 p3->setStringAttribute(
"global_factors", s);
3463 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3464 out->GetName(),
p3->GetName());
3475 std::set<RooAbsArg *> cl;
3476 for (
auto &arg :
p5->clients()) {
3482 if (cl.size() > 1) {
3487 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3493 for (
auto &
a :
p5->attributes())
3494 new_p->setAttribute(
a.c_str());
3495 for (
auto &
a :
p5->stringAttributes())
3496 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3497 if (!
new_p->getStringAttribute(
"alias"))
3498 new_p->setStringAttribute(
"alias",
p5->GetName());
3501 for (
auto arg : cl) {
3513 throw std::runtime_error(
3515 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3523 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3532 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3534 std::set<RooAbsArg *> cl;
3535 for (
auto &arg :
p5->clients()) {
3543 if (cl.size() > 1) {
3551 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3555 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3556 for (
auto arg : cl) {
3580 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3585 std::rethrow_exception(std::current_exception());
3597 std::string label =
child.GetName();
3598 if (
auto pos = label.find(
'='); pos != std::string::npos)
3599 label = label.substr(pos + 1);
3600 if (!s->indexCat().hasLabel(label)) {
3605 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3610 throw std::runtime_error(
TString::Format(
"Failed to find %s regular observable in %s dataset",
3611 s->indexCat().GetName(),
_ds->GetName()));
3613 dsCat->defineType(label.c_str());
3619 std::shared_ptr<TObject> out;
3620 child.convertForAcquisition(*
this);
3623 }
else if (!
child.fComp) {
3626 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3629 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3634 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3643 _pdf->leafNodeServerList(&
leafs);
3644 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
3648 globs.addClone(*
_ds->getGlobalObservables());
3652 alist += std::string(
aa->GetName()) +
",";
3655 if (!alist.empty()) {
3656 Warning(
"Vary",
"Adding %s to global observables of %s", alist.c_str(),
_ds->GetName());
3662 s->addPdf(*_pdf, label.c_str());
3674 child.convertForAcquisition(*
this);
3676 if (!_c &&
child.get()) {
3677 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3679#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3680 double value = (_c ? _c->getVal() :
p->_nominal);
3683 double value = (_c ? _c->getVal() :
p->nominal());
3688 if (
cName ==
"nominal") {
3692 if (
cName.CountChar(
'=') != 1) {
3693 throw std::runtime_error(
"unsupported variation form");
3698 throw std::runtime_error(
"unsupported variation magnitude");
3711 if (!
p->findServer(*
v)) {
3712#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3713 p->_paramList.add(*
v);
3714 p->_low.push_back(0);
3715 p->_high.push_back(0);
3716 p->_interpCode.push_back(4);
3719 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3720 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3721 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3723 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3728 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3731 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3734 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3737 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3747 if (
cName.CountChar(
'=') != 1) {
3748 throw std::runtime_error(
"unsupported variation form");
3753 throw std::runtime_error(
"unsupported variation magnitude");
3755#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3758 throw std::runtime_error(
3759 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3764 throw std::runtime_error(
3765 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3771 for (
auto par :
p2->paramList()) {
3772 if (
parName == par->GetName()) {
3786 std::shared_ptr<RooHistFunc>
up(
3788 std::shared_ptr<RooHistFunc>
down(
3791#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3792 std::unique_ptr<RooDataHist>
h1(
3794 std::unique_ptr<RooDataHist> h2(
3796 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3802 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3803 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3804#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3805 p2->_highSet.add(*
ups.get());
3806 p2->_lowSet.add(*
downs.get());
3807 p2->_interpCode.push_back(4);
3808 p2->_paramSet.add(*
v);
3812 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3815 p2->setValueDirty();
3819 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3820 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3821 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3839#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
3842 if (
cName.CountChar(
'=') != 1) {
3843 throw std::runtime_error(
"unsupported variation form");
3849 if (!
pmr->indexCategory()->hasLabel(
parVal.Data())) {
3852 auto idx =
pmr->indexCategory()->lookupIndex(
parVal.Data());
3854 throw std::runtime_error(
"Invalid index");
3857 child.convertForAcquisition(*
this);
3860 if (
pmr->getModelList().empty()) {
3861 throw std::runtime_error(
"No real function given for variation, and no nominal function to clone");
3863 _c = std::dynamic_pointer_cast<RooAbsReal>(
3864 acquire(std::shared_ptr<TObject>(
pmr->getModelList().at(0)->Clone(
3868 _c->setStringAttribute(
"alias",
child.GetName());
3878 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3879 throw std::runtime_error(
"Cannot vary pure constants");
3885 std::set<RooAbsArg *> cl;
3886 for (
auto &arg :
p3->clients()) {
3891 if (cl.size() > 1) {
3896 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3899 p3->setStringAttribute(
"origName",
p3->GetName());
3901 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3904 std::vector<double>(), std::vector<double>());
3907 for (
auto &
a :
p3->attributes())
3908 new_p->setAttribute(
a.c_str());
3909 for (
auto &
a :
p3->stringAttributes())
3910 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3914 for (
auto arg : cl) {
3925 std::set<RooAbsArg *> cl;
3926 for (
auto &arg :
p4->clients()) {
3931 if (cl.size() > 1) {
3936 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
3939 p4->setStringAttribute(
"origName",
p4->GetName());
3941 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
3943#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
3944 std::shared_ptr<RooAbsArg>
new_p;
3947 if (
cName.CountChar(
'=') == 1) {
3954 throw std::runtime_error(
"Failed to acquire categorical index for RooMultiReal");
3957 if (
idxCat->numTypes() == 0) {
3958 idxCat->defineType(
"nominal");
3960 Info(
"Vary",
"Creating a RooMultiReal with category %s",
idxCat->GetName());
3977 for (
auto &
a :
p4->attributes())
3978 new_p->setAttribute(
a.c_str());
3979 for (
auto &
a :
p4->stringAttributes())
3980 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3984 for (
auto arg : cl) {
4027 a->setStringAttribute(
"alias",
GetName());
4030 throw std::runtime_error(
"Cannot determine type");
4035 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
4052 throw std::runtime_error(
"no xaxis");
4057 if (
h->GetXaxis()->IsVariableBinSize()) {
4058 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
4066 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
4075 throw std::runtime_error(
"Failed setting stat error");
4079 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
4091 throw std::runtime_error(
"Assignment failed");
4124 std::map<RooAbsRealLValue *, double>
valsToSet;
4126 auto idx = pattern.
Index(
'=');
4129 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4131 for (
auto p :
_pars.argList()) {
4134 p->setAttribute(
"Constant",
true);
4135 if (!std::isnan(val)) {
4143 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4159 val.
IsAlpha() ? val :
nullptr));
4166 if (
d->get()->TestBit(1 << 20)) {
4176 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
4177 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
4178 auto fr = _nll.minimize();
4181 throw std::runtime_error(
"Fit Failed");
4184 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
4188 (
gROOT->GetListOfBrowsers()->At(0))
4192 if (_nll.fOpts->find(
"GoF")) {
4195 if (fr->status() != 0) {
4197 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4201 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
4202 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
4203 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4209 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4214 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4227 fb->DoubleClicked(
p, 0);
4228 if (
auto first =
p->GetFirstChild()) {
4230 if (first->IsOpen() &&
TString(first->GetText()) ==
"fits") {
4231 fb->DoubleClicked(first, 0);
4233 }
while ((first = first->GetNextSibling()));
4243 }
catch (
const std::exception &
e) {
4246 (
gROOT->GetListOfBrowsers()->At(0))
4259 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4272 fb->DoubleClicked(
p, 0);
4273 if (
auto first =
p->GetFirstChild()) {
4275 if (first->IsOpen() &&
TString(first->GetText()) ==
"datasets") {
4276 fb->DoubleClicked(first, 0);
4278 }
while ((first = first->GetNextSibling()));
4288 }
catch (
const std::exception &
e) {
4291 (
gROOT->GetListOfBrowsers()->At(0))
4294 "Exception",
e.what(),
4301 const char *options)
4311 if (
d->get()->TestBit(1 << 20)) {
4317 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
4320 auto idx = pattern.
Index(
'=');
4323 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4325 for (
auto par :
_pars.argList()) {
4328 par->setAttribute(
"Constant",
true);
4329 if (!std::isnan(val)) {
4335 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4351 val.
IsAlpha() ? val :
nullptr));
4355 hs.SetName(
TUUID().AsString());
4367 (
gROOT->GetListOfBrowsers()->At(0))
4370 "Scan Finished with Bad Status Code",
4375 if (
auto res =
hs.result())
4382 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4395 fb->DoubleClicked(
p, 0);
4396 if (
auto first =
p->GetFirstChild()) {
4398 if (first->IsOpen() &&
TString(first->GetText()) ==
"scans") {
4399 fb->DoubleClicked(first, 0);
4401 }
while ((first = first->GetNextSibling()));
4412 }
catch (
const std::exception &
e) {
4415 (
gROOT->GetListOfBrowsers()->At(0))
4426 }
catch (
const std::exception &
e) {
4435#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
4440 for (
auto a : *
this) {
4447 for (
auto c : args) {
4453 f.SetParName(i,
c->GetName());
4455 f.SetParLimits(i,
v->getMin(),
v->getMax());
4456 if (
v->isConstant())
4457 f.FixParameter(i,
v->getVal());
4459 f.SetParameter(i,
v->getVal());
4460 f.SetParError(i,
v->getError());
4471 (
gROOT->GetListOfBrowsers()->At(0))
4477 for (i = 0; i <
f.GetNpar(); i++) {
4478 auto c = args.
find(
f.GetParName(i));
4483 f.GetParLimits(i, low, high);
4485 v->setConstant(low);
4487 v->setRange(low, high);
4497 throw std::runtime_error(
"Failed to SetContent");
4498 }
catch (
const std::exception &
e) {
4512 std::shared_ptr<TH1D>
h;
4513 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
4516 if (
_b->isUniform()) {
4521 h->SetOption(
"nostyle");
4522 h->SetDirectory(
nullptr);
4538 auto _ax = (bin) ?
GetXaxis() :
nullptr;
4540 throw std::runtime_error(
"Cannot determine binning to fill data");
4542 if (_ax && _ax->GetNbins() < bin) {
4543 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
4544 _ax->GetName(), _ax->GetNbins()));
4550 for (
auto _c :
coords()) {
4554 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
4562 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
4565 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
4574 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
4575 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
4607 l.remove(*_data->get(),
true,
true);
4612 _data->addColumn(*
x);
4622 for (
auto &o :
obs) {
4624 if (
auto dv =
dynamic_cast<RooRealVar *
>(_data->get()->find(
v->GetName()));
dv) {
4625 if (
v->getMin() <
dv->getMin())
4626 dv->setMin(
v->getMin());
4627 if (
v->getMax() >
dv->getMax())
4628 dv->setMax(
v->getMax());
4631 if (
auto dc =
dynamic_cast<RooCategory *
>(_data->get()->find(
c->GetName()));
dc) {
4632 if (!
dc->hasLabel(
c->getCurrentLabel())) {
4633 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
4642 if (
auto _nentries = std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula))->numEntries();
4647 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
4650 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4652 _data->add(*_obs,
_reduced->weight());
4655 for (
int i = 1; i <= _ax->GetNbins(); i++) {
4659 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
4665 if (std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula2))->numEntries() > 0) {
4668 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4670 _data->add(*_obs,
_reduced->weight());
4674 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
4681 throw std::runtime_error(
"RooDataHist not supported yet");
4686 if (!par ||
strlen(par) == 0) {
4689 return it->SetBinContent(bin,
value);
4701 if (!par ||
strlen(par) == 0) {
4714 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
4717#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4730 auto bin_pars =
f->dataHist().get(bin - 1);
4731 if (
f->getAttribute(
"density")) {
4739 f->setStringAttribute(
"symmetrized_by",
nullptr);
4741 x->setStringAttribute(
"symmetrizes",
nullptr);
4742 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4756 f2->setNominal(
value);
4765 push_back(std::make_shared<xRooNode>(
data));
4772 return node->SetBinContent(bin,
value);
4779 push_back(std::make_shared<xRooNode>(
data));
4786 return node->SetContents(obj);
4824 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4833 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4838 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4845 h->SetName(
"statFactor");
4847 h->SetOption(
"blankshape");
4856 throw std::runtime_error(
"Failed creating stat shapeFactor");
4862 TString prefix =
f->getStringAttribute(
"statPrefix");
4863 if (
value && prefix ==
"") {
4867 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4868 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4875 Form(
"#gamma^{%s}_{%d}", prefix.
Data(), bin), 1);
4876#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4883 if (
newVar.get() != var) {
4887 for (std::size_t i = 0; i <
pSet.size(); i++) {
4888 if (
int(i) != bin - 1) {
4903 auto bin_pars =
f->dataHist().get(bin - 1);
4905 if (
f->getAttribute(
"density")) {
4911 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4912 if (s.find(
"sumw_") == 0) {
4914 }
else if (s.find(
"sumw2_") == 0) {
4918 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4920 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4921 rrv->setConstant(
false);
4926 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4931 double _min = tau * (1. - 5. * sqrt(1. / tau));
4932 double _max = tau * (1. + 5. * sqrt(1. / tau));
4935 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4936 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
4938 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
4942 v.constraints().Remove(*
_constr.at(0));
4961 throw std::out_of_range(
name +
" does not exist");
4983 xRooNode out(
".constraints",
nullptr, *
this);
4996 for (
auto &
c :
n.bins()) {
5007 for (
auto p : _ws->allPdfs()) {
5010 if (
p->dependsOn(par)) {
5011 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5019 for (
auto p : o->pdfList()) {
5022 if (
p->dependsOn(par)) {
5023 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5029 for (
auto &
p :
vars()) {
5035 if (
v->getAttribute(
"obs"))
5045 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
5046 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
5048 for (
auto &
c : out) {
5049 if (
c.get() == it->get())
5054 std::string
_cName =
c->GetName();
5058 }
while (
_cName.find(
';') != std::string::npos);
5060 _cName = it->get()->GetName();
5064 }
while (
_cName.find(
';') != std::string::npos);
5072 c->TNamed::SetName(
_cName.c_str());
5086 for (
auto &o : out) {
5087 o->TNamed::SetName(o->get()->GetName());
5108 while (
sOpt2.Contains(
"=")) {
5109 auto pos =
sOpt2.Index(
"=");
5110 auto start =
sOpt2.Index(
";") + 1;
5134 if (
auto pos =
varName.Index(
';'); pos != -1) {
5144 binningName =
ax->GetName();
5145 }
else if (
acquirer.obs().size() == 1)
5149 h->GetXaxis()->GetXmax());
5150 if (
x->getMin() >
h->GetXaxis()->GetXmin())
5151 x->setMin(
h->GetXaxis()->GetXmin());
5152 if (
x->getMax() <
h->GetXaxis()->GetXmax())
5153 x->setMax(
h->GetXaxis()->GetXmax());
5154 if (!
x->hasBinning(binningName.c_str())) {
5155 if (
h->GetXaxis()->IsVariableBinSize()) {
5156 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
5159 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
5160 binningName.c_str());
5162 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
5163 if (
x->getBinningNames().size() == 2) {
5165 x->setBinning(
x->getBinning(binningName.c_str()));
5169 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
5170 throw std::runtime_error(
5171 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
5175 std::shared_ptr<RooAbsArg>
_f;
5182 _f->setStringAttribute(k.c_str(),
v.c_str());
5184 x->setAttribute(
"obs",
true);
5185 }
else if (
sOpt2.Contains(
"shape")) {
5187 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
5188 std::shared_ptr<RooAbsArg> arg;
5189 if (
sOpt2.Contains(
"blankshape")) {
5194 }
else if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
5197 h->GetBinContent(i + 1),
h->GetMinimumStored(),
5198 h->GetMaximumStored());
5202 h->GetBinContent(i + 1));
5209 auto tmp =
dynamic_cast<RooAbsBinning *
>(
x->getBinningPtr(
nullptr)->Clone());
5210 x->setBinning(
x->getBinning(binningName.c_str()));
5212#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5213 dynamic_cast<ParamHistFunc *
>(
_f.get())->_paramSet.setName(
"paramSet");
5216 .setName(
"paramSet");
5218 x->setBinning(*tmp);
5221 _f->setStringAttribute(k.c_str(),
v.c_str());
5225 binningName.c_str() );
5227 throw std::runtime_error(
"Couldn't make data hist");
5232 f->setAttribute(
"autodensity");
5236 _f->setStringAttribute(k.c_str(),
v.c_str());
5240 _f->setStringAttribute(
"xvar",
x->GetName());
5241 _f->setStringAttribute(
"binning", binningName.c_str());
5248 _f = std::dynamic_pointer_cast<RooAbsArg>(tmp.fComp);
5251 _f->setStringAttribute(
"xvar",
x->GetName());
5252 _f->setStringAttribute(
"binning", binningName.c_str());
5292 if (arg->getStringAttribute(
"style")) {
5293 t = arg->getStringAttribute(
"style");
5303 std::shared_ptr<TStyle>
style;
5305 if (!
gROOT->GetStyle(t)) {
5328 if (arg && !arg->getStringAttribute(
"style")) {
5329 arg->setStringAttribute(
"style",
style->GetName());
5347 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
5348 auto out_arg = _ws->arg(
a->GetName());
5355 if (
aName !=
a->GetName())
5356 Warning(
"acquire",
"Renaming to %s",
a->GetName());
5360 if (
auto res = _ws->factory(arg->GetName()); res) {
5367 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
5390 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
5400 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
5406 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
5407 }
else if (arg->InheritsFrom(
"TNamed")) {
5417 out_arg = _ws->genobj(arg->GetName());
5424 if (
aName != arg->GetName()) {
5425 Warning(
"acquire",
"Renaming to %s", arg->GetName());
5427 if (_ws->import(*arg,
false )) {
5431 out_arg = _ws->genobj(arg->GetName());
5443 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
5449 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
5455 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
5461 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
5463 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
5505 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
5508 _x->setBinning(binning,
a->
GetName());
5509 _x->getBinning(
a->GetName()).SetTitle(title);
5510 if (_x->getBinningNames().size() == 2) {
5512 _x->setBinning(_x->getBinning(
a->GetName()));
5517 if (_x->getMax() < high)
5519 if (_x->getMin() > low)
5525 _x->setAttribute(
"obs");
5528 a->setStringAttribute(
"xvar", _x->GetName());
5529 a->setStringAttribute(
"binning",
a->GetName());
5539 if (
ax->IsVariableBinSize()) {
5540 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
5542 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
5548 return find(
name,
false) !=
nullptr;
5556 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5557 for (
auto &
child : *
this) {
5560 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
5573 for (
auto &
child2 :
x.browse()) {
5599 auto out = std::make_shared<xRooNode>(obj, *
this);
5614 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5616 for (
auto &
child : *
this) {
5628 for (
auto &
child2 :
x.browse()) {
5640 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
5658 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
5661 out->SetName(
"!pdfs");
5664 return out->operator[](
name.substr(
partname.length() + 1));
5672 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5674 if (!
b || !
b->GetBrowserImp())
5681 if (!
b->GetBrowserImp())
5697 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5699 if (!
b || !
b->GetBrowserImp())
5706 if (
b->GetBrowserImp()) {
5724 a->setStringAttribute(
"alias",
name);
5725 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5726 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
5751 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5752 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5753 for (
auto &
c :
nn) {
5754 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5757 return std::shared_ptr<xRooNode>(
nullptr);
5762 const std::vector<std::shared_ptr<xRooNode>> &
nn(
n);
5763 for (
auto &
c :
nn) {
5776 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5777 for (
auto &
c :
nn2) {
5778 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5782 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5821 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5834 emplace_back(std::make_shared<xRooNode>(
_coefs));
5846 for (
int i = 0; i < arg->numProxies(); i++) {
5847 auto _proxy = arg->getProxy(i);
5857 for (
auto &
child : *
this) {
5865 for (
auto a2 : *s) {
5866 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5867 if (arg->numProxies() != 1) {
5868 c->fFolder = std::string(
"!.") +
5901 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5914 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5916 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5922 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5923 for (
auto &
c :
nn) {
5946 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
5947 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
5953 if (
auto fit =
hp->ufit()) {
5954 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
5956 if (
auto fit =
hp->cfit_null()) {
5957 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
5959 if (
auto fit =
hp->cfit_alt()) {
5960 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
5962 if (
auto fit =
hp->gfit()) {
5963 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
5965 if (
auto asi =
hp->asimov()) {
5966 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
5967 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
5969 asiP->TNamed::SetName(
"asimov");
5970 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
5976 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
5977 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
5978 if (it->get()->fTimes == 0) {
5979 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5981 if (
b &&
b->GetBrowserImp()) {
6028 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
6030 for (
auto o :
vars()) {
6033 out.emplace_back(o);
6044 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
6046 for (
auto o :
obs()) {
6049 out.emplace_back(o);
6060 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
6062 for (
auto o :
obs()) {
6065 out.emplace_back(o);
6080 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
6082 for (
auto o :
vars()) {
6085 out.emplace_back(o);
6096 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
6098 for (
auto o :
pars()) {
6101 out.emplace_back(o);
6113 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
6115 for (
auto o :
pars()) {
6118 out.emplace_back(o);
6130 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
6132 for (
auto o :
pars()) {
6135 out.emplace_back(o);
6147 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
6149 for (
auto o :
pars()) {
6151 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
6154 out.emplace_back(o);
6165 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
6167 for (
auto o :
pars()) {
6171 out.emplace_back(o);
6182 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
6185 for (
auto &
x : *
this) {
6186 for (
auto &
y :
x->vars()) {
6201 if (!
c->getAttribute(
"global")) {
6203 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6205 if (
c->getAttribute(
"global")) {
6206 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6207 _globs.back()->fFolder =
"!globs";
6208 }
else if (
c->getAttribute(
"obs")) {
6209 out.back()->fFolder =
"!robs";
6210 }
else if (
c->getAttribute(
"poi")) {
6211 out.back()->fFolder =
"!poi";
6212 }
else if (
c->getAttribute(
"np") ||
6214 out.back()->fFolder =
"!np";
6216 out.back()->fFolder =
"!floats";
6218 out.back()->fFolder =
"!pp";
6224 out.emplace_back(
g);
6227 for (
auto a : *
p2->get()) {
6228 a->setAttribute(
"obs");
6229 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6232 if (
auto _dglobs =
p2->getGlobalObservables()) {
6234 a->setAttribute(
"obs");
6235 a->setAttribute(
"global");
6236 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6241 a->setAttribute(
"obs");
6242 a->setAttribute(
"global");
6243 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6246 }
else if (
auto _ws =
ws(); _ws) {
6249 a->setAttribute(
"obs");
6250 a->setAttribute(
"global");
6251 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6255 for (
auto &
_g :
_gl->second) {
6256 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6257 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6259 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6268 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6269 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6271 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6277 for (
auto a :
w->allVars()) {
6278 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6282 for (
auto a :
w->allCats()) {
6283 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6292 xRooNode out(
".components",
nullptr, *
this);
6297 for (
auto &o :
p->pdfList()) {
6300 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6318 for (
auto &o :
p2->funcList()) {
6321 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6325 for (
auto &o :
p3->list()) {
6326 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6329 for (
auto &
a : *
p4) {
6330 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6333 for (
auto &o :
p5->components()) {
6336 bool hasClients =
false;
6337 for (
auto &
c : o->clients()) {
6338 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
6345 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6346 if (o->InheritsFrom(
"RooAbsPdf")) {
6347 out.back()->fFolder =
"!pdfs";
6349 out.back()->fFolder =
"!scratch";
6352 for (
auto &o :
p5->allGenericObjects()) {
6356 s = s(0, s.
Index(
';'));
6357 if (
auto _pdf = out.find(s.
Data()); _pdf) {
6359 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
6366 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
6368 out.back()->fFolder =
"!fits";
6370 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6371 if (
strcmp(out.back()->get()->ClassName(),
"TStyle") == 0) {
6372 out.back()->fFolder =
"!styles";
6373 }
else if (
strcmp(out.back()->get()->ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
6374 out.back()->fFolder =
"!scans";
6375 }
else if (
strcmp(out.back()->get()->ClassName(),
"RooStats::ModelConfig") == 0) {
6376 out.back()->fFolder =
"!models";
6378 out.back()->fFolder =
"!objects";
6385 if (k.find(
"CACHE_") == 0)
6387 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
6388 out.back()->fFolder =
"!sets";
6392 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
6394 while ((
snap = iter->Next())) {
6395 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
6396 out.back()->fFolder =
"!snapshots";
6401 out.emplace_back(std::make_shared<xRooNode>(
".pdf", *
mc->GetPdf(), *
this));
6403 if (
mc->GetExternalConstraints()) {
6404 out.emplace_back(std::make_shared<xRooNode>(
".extCons", *
mc->GetExternalConstraints(), *
this));
6410 out.emplace_back(
c);
6417 out.emplace_back(
c);
6431 xRooNode out(
".bins",
nullptr, *
this);
6434 std::map<int, std::shared_ptr<xRooNode>> cats;
6435 for (
auto &
c :
p->indexCat()) {
6436 auto pp =
p->getPdf(
c.first.c_str());
6440 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
6442 for (
auto &[
_,
n] : cats)
6443 out.emplace_back(
n);
6446#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6449 auto &
pSet =
phf->paramList();
6451 for (
auto par :
pSet) {
6452 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
6453 out.back()->fBinNumber = i;
6457 for (
int i = 1; i <=
ax->GetNbins(); i++) {
6463 for (
auto &
ss :
f->bins()[i - 1]->factors())
6470 out.emplace_back(std::make_shared<xRooNode>(
6471 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
6477#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6483 out.back()->fBinNumber = i;
6508 std::make_shared<RooProduct>(
".recursiveCoefs",
6513 auto mem = out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
6514 mem->emplace_back(std::make_shared<xRooNode>(
ourCoefs));
6527 if (!parent->fComp) {
6528 while (!parent->fComp && parent->fParent) {
6529 parent = parent->fParent;
6532 parent = parent->fParent;
6538 for (
auto &o :
p->funcList()) {
6540 if (i >=
p->coefList().size()) {
6542 coefs.add(
p->coefList());
6544 coefs.add(*
p->coefList().at(i));
6551 if (
p2->coefList().empty()) {
6556 for (
auto &o :
p2->pdfList()) {
6558 if (i >=
p2->coefList().size()) {
6562 coefs.add(*
p2->coefList().at(i));
6576 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
6577 "Coefficients of",
coefs));
6578 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
6579 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
6582 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
6584 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
6586 if (!
coefs.empty()) {
6590 }
else if (
coefs.size() == 1) {
6592 if (!
coefs.empty()) {
6611 xRooNode out(
".factors",
nullptr, *
this);
6616 a->setStringAttribute(
"alias",
"samples");
6618 a2->setStringAttribute(
"alias",
"components");
6620 int _npdfs =
p->pdfList().size();
6621 for (
auto &o :
p->pdfList()) {
6622 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6623 if (
_npdfs > 5 && o !=
_main.get() && out.back()->robs().size() == 0)
6624 out.back()->fFolder =
"!constraints";
6627 for (
auto &o :
p2->components()) {
6628 if (o->InheritsFrom(
"RooProduct")) {
6630 auto x =
xRooNode(
"tmp", *o, *
this).factors();
6632 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
6635 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6644 for (
auto a :
w->allFunctions()) {
6645 if (_obs.contains(*
a))
6648 for (
auto c :
a->clients()) {
6650 if (
c->InheritsFrom(
"RooProduct")) {
6656 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6700 xRooNode out(
".variations",
nullptr, *
this);
6713#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6714 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
6716 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
6718 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
6720 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
6721 *
p2->highList().at(i), *
this));
6722 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
6723 *
p2->lowList().at(i), *
this));
6726#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6727 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
6728 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
6729 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
6731 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
6735 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
6736 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
6737 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
6739 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
6763 for (
auto &k : *
this) {
6772 xRooNode out(
".datasets()",
nullptr, *
this);
6778 for (
auto &
d : _ws->allData()) {
6779 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
6780 out.back()->fFolder =
"!datasets";
6793 for (
auto _c :
coords()) {
6797 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6806 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6811 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6818 for (
auto cat : s->indexCat()) {
6819 if (!s->getPdf(cat.first.c_str())) {
6831 cutobs.add(s->indexCat());
6840 for (
auto &
child : *
this) {
6846 for (
auto &
d :
_wsNode.datasets()) {
6852 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6859 out.emplace_back(std::make_shared<xRooNode>(
6864 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6866 if (
d->get()->TestBit(1 << 20))
6867 out.back()->get()->SetBit(1 << 20);
6869 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6871 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6913 for (
auto o : *
fromPad->GetListOfPrimitives()) {
6933 cat->numTypes(), 0, cat->numTypes());
6935 std::map<int, std::string> cats;
6936 for (
auto &
c : *cat) {
6937 cats[
c.second] =
c.first;
6939 for (
auto &[
_, label] : cats) {
6940 theHist->GetXaxis()->SetBinLabel(i++, label.c_str());
6943 auto _binning =
v->getBinningPtr(
nullptr);
6944 if (_binning->isUniform()) {
6948 v->numBins(), _binning->lowBound(), _binning->highBound());
6953 v->numBins(), _binning->array());
6957 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
6970 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
6992 : (
theHist->GetXaxis()->IsAlphanumeric() ?
theHist->GetXaxis()->GetTimeFormatOnly()
6993 :
theHist->GetXaxis()->GetName()));
7012 int nevent =
theData->numEntries();
7013 for (
int i = 0; i < nevent; i++) {
7018 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
7024 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
7057 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
7059 double val =
theHist->GetBinContent(i + 1);
7062 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
7065 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
7078 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
7082 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
7083 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
7117 throw std::runtime_error(
"Cannot build graph");
7123 if (
auto _w =
ws();
_w) {
7125 for (
auto o :
_w->allGenericObjects()) {
7127 _fr->ResetBit(1 << 20);
7130 res->SetBit(1 << 20);
7132 auto allVars =
_w->allVars();
7137 throw std::runtime_error(
"Not supported yet");
7151 throw std::runtime_error(
"Not a RooFitResult");
7162#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
7174 if (
sOpt ==
"prefit") {
7188 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
7189 fr->setFinalParList(*
_pars);
7190 for (
auto &
p : fr->floatParsFinal()) {
7194 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
7197 std::shared_ptr<xRooNode>
pConstr;
7204 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
7205 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
7222 for (
auto &_d :
pConstr->vars()) {
7223 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
7247 if (!
_v->getStringAttribute(
"nominal"))
7259 _args.add(
_globs.argList());
7260 fr->setConstParList(_args);
7263 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7266 fr->setInitParList(*
_snap);
7271 if (
auto _w =
ws();
_w) {
7278 for (
auto p :
pars()) {
7281 if (
_fr->floatParsFinal().find(
p->GetName()) ||
7283 std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
7287 _fr->constPars().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7292 if (!
_fr->floatParsFinal().find(
p->GetName())) {
7295 std::abs(
_fr->floatParsFinal().getRealValue(
p->GetName(),
7296 std::numeric_limits<double>::quiet_NaN()) -
7300 _fr->floatParsFinal().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7316 for (
size_t i = 0; i <
newFloats.size(); i++) {
7332 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
7335 fr->setCovarianceMatrix(
cov);
7336 fr->setInitParList(
_fr->floatParsInit());
7341 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
7346 for (
auto o :
_w->allGenericObjects()) {
7372 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
7374 fr->setFinalParList(*
_pars);
7380 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
7381 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
7382 cov(i,
j) = (*prevCov)(i,
j);
7387 for (
auto &
p : fr->floatParsFinal()) {
7390 cov(i, i) = pow(
v->getError(), 2);
7398 fr->setCovarianceMatrix(
cov);
7405 _args.add(
_globs.argList());
7406 fr->setConstParList(_args);
7409 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7412 fr->setInitParList(*
_snap);
7442 o->setStringAttribute(
"range",
range);
7449 std::string &out =
fRange;
7450 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
7451 out = o->getStringAttribute(
"range");
7453 while (out.empty() && _parent) {
7454 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
7455 out = o->getStringAttribute(
"range");
7456 _parent = _parent->fParent;
7481 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
7487 return nll(_data,
l);
7505 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7506 "generate with (found at least %s and %s)",
7520 std::string selected;
7523 for (
auto c :
bins()) {
7534 if (!selected.empty())
7536 selected +=
cName.Data();
7545 if (
d->get()->TestBit(1 << 20)) {
7551 throw std::runtime_error(
7552 "Need at least one dataset selected (SetChecked) to use for deselected regions");
7584 std::unique_ptr<RooFitResult>
newFr;
7586 newFr = std::make_unique<RooFitResult>(*
_fr);
7598 for (
auto par :
_pars) {
7608 newFr = std::make_unique<RooFitResult>(*
_fr);
7609 for (
auto par :
_pars) {
7631 if (
mc->GetExternalConstraints()) {
7633 for (
auto o :
opts) {
7658 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7659 "build nll with (found at least %s and %s)",
7668 throw std::runtime_error(
TString::Format(
"Workspace has multiple pdfs, you must specify which to "
7669 "build nll with (found at least %s and %s)",
7680 std::string selected;
7682 for (
auto c :
bins()) {
7688 if (!selected.empty())
7703 _d = std::make_shared<xRooNode>(
asi.first, *
this);
7706 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
7716 me.push_back(std::make_shared<xRooNode>(_data));
7733 for (
int i = 0; i <
opts.GetSize(); i++) {
7736 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
7747 std::dynamic_pointer_cast<RooAbsData>(_data.
fComp), *
_opts);
7857 for (
auto &
c :
bins()) {
7860 _cat.setLabel(
cName);
7867 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
7881 std::vector<TObject *>
funcs;
7882 for (
auto &
c : out.components()) {
7891 funcs.push_back(
c->get());
7895 if (!
funcs.empty()) {
7897 _pdf->setFloor(
false);
7923 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
7925 fr->setCovarianceMatrix(
_tmp);
7927 const_cast<RooArgList &
>(fr->floatParsFinal())
7938 for (
auto c : *
this) {
7939 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
7943 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
8047 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
8056 return getProjection(&intobs, _normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
8072 return rrv->getErrorHi();
8074 return rrv->getErrorLo();
8076 return rrv->getError();
8093 if (
rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8103 std::stringstream
errMsg;
8104 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8105 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case."
8109 throw std::runtime_error(
errMsg.str());
8121 : fr.reducedCovarianceMatrix(*
_pars));
8125 double nomVal =
f.getVal(nset);
8175 for (std::size_t i = 0; i <
_pars->size(); i++) {
8176 errVec[i] = std::sqrt(V(i, i));
8177 for (std::size_t
j = i;
j <
_pars->size();
j++) {
8178 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8184 double sum = F * (
C *
F);
8200 fFunc(
"func",
"func",
this,
f),
8201 fCoef(
"coef",
"coef",
this),
8202 fExpPdf(
"expPdf",
"expPdf",
this)
8207 fCoef.setArg(*coef);
8211 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
8223 fExpectedEventsMode(
other.fExpectedEventsMode)
8230 return fFunc->binBoundaries(obs, xlo, xhi);
8235 return (fExpectedEventsMode ? 1. : fFunc) *
8236 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(_normSet) : 1.) *
8237 (fCoef.absArg() ? fCoef : 1.);
8248#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
8249 double oo = getPropagatedError(fr,
nset_in);
8250 if (std::isnan(
oo)) {
8269 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8279 std::stringstream
errMsg;
8281 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8282 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
8284 throw std::runtime_error(
errMsg.str());
8289 if (paramList.
empty())
8324#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8348 std::vector<double>
errVec(paramList.
size());
8349 for (std::size_t i = 0; i < paramList.
size(); i++) {
8350 errVec[i] = std::sqrt(V(i, i));
8351 for (std::size_t
j = i;
j < paramList.
size();
j++) {
8352 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8359 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8364 double sum = F * (C *
F);
8374 if (
frv->getError() > 1
e-20) {
8391 for (
Int_t i = 0; i <
fpf.size(); i++) {
8394 paramList.
add(*par);
8430 std::vector<double>
errVec(paramList.
size());
8431 for (
int i = 0; i < paramList.
size(); i++) {
8432 errVec[i] = sqrt(V(i, i));
8433 for (
int j = i;
j < paramList.
size();
j++) {
8434 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
8441 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8446 double sum = F * (C *
F);
8460 bool fExpectedEventsMode =
false;
8468 std::cout <<
"Got signal " <<
signum << std::endl;
8470 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
8483 for (
int i = 0; i < obj->numCaches(); i++) {
8489 p->setNormRange(
p->normRange());
8491#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8496 p->setProxyNormSet(
nullptr);
8497 p->_lastNSet =
nullptr;
8500 obj->setValueDirty();
8504 for (
auto &
c :
w->components()) {
8524 for (
auto obj :
a->clients()) {
8531 }
while (
a->clients().size() !=
nClients);
8550 out.fComp = std::shared_ptr<TH1>(
8551 BuildHistogram(
nullptr, !
content,
errors, -1, -1, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
false));
8552 }
else if (
vars.size() == 1) {
8554 out.fComp = std::shared_ptr<TH1>(
8555 BuildHistogram(
v, !
content,
errors, 1, 0, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
true));
8557 throw std::runtime_error(
"multi-dim histo not yet supported");
8597 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8598 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8599 h->GetXaxis()->SetTimeFormat(
rar->GetName());
8608 if (
h->GetListOfFunctions())
8611 h->SetTitle(
rar->GetTitle());
8616 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8618 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8619 h->SetBinContent(1,
rar->getVal());
8620 if (
x->getError()) {
8621 h->SetBinError(1,
x->getError());
8622 h->SetFillStyle(3005);
8623 h->SetFillColor(
h->GetLineColor());
8625 h->SetMaximum(
x->hasMax() ?
x->getMax()
8626 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8627 h->SetMinimum(
x->hasMin() ?
x->getMin()
8628 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8631 h->SetMarkerSize(0);
8632 h->SetMarkerStyle(0);
8637 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
8638 if (binningName ==
"")
8639 binningName =
rar->GetName();
8640 if (
x->hasBinning(binningName)) {
8641 if (
x->getBinning(binningName).isUniform()) {
8642 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
8643 x->getMin(binningName),
x->getMax(binningName));
8645 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
8647 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
8649 }
else if (
auto _boundaries =
8650 _or_func( (std::list<double> *)(
nullptr),
8651 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
8652 std::numeric_limits<double>::infinity()));
8654 std::vector<double>
_bins;
8655 for (
auto &
b : *_boundaries) {
8661 }
else if (!
x->hasMax() || !
x->hasMin()) {
8663 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
8665 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
8669 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
8672 std::map<int, std::string> cats;
8673 for (
auto &
c : *cat) {
8674 cats[
c.second] =
c.first;
8676 for (
auto &[
_, label] : cats) {
8677 h->GetXaxis()->SetBinLabel(i++, label.c_str());
8683 h->GetXaxis()->SetTitle(o->GetTitle());
8687 if (
h->GetXaxis()->IsAlphanumeric()) {
8696 if (
auto s =
styles(
nullptr,
false); s) {
8702 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
8703 h->GetXaxis()->SetTitle(
vv->GetTitle());
8732 if (!
GETDMP(fr, _finalPars)) {
8745 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
8746 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
8747 cov(i,
j) = (*prevCov)(i,
j);
8767 _pars.remove(*_p,
true);
8800 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
8818 for (
auto o : _obs) {
8820 rr->removeRange(
"coordRange");
8821 rr->setStringAttribute(
"coordRange",
nullptr);
8825 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8826 rr->removeRange(
"coordRange");
8827 rr->setStringAttribute(
"coordRange",
nullptr);
8837 bool hasRange =
false;
8840 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
8850 for (
auto pdf :
bins()) {
8857 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
8859 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
8863 rar =
p->createProjection(
8867 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
8871 p->setNormRange(
"coordRange");
8876 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
8882 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
8900 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
8922 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
8925 -std::numeric_limits<double>::infinity(),
8926 std::numeric_limits<double>::infinity()))))
8939 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
8957 auto l =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
8960 h->GetListOfFunctions()->Add(
l, (
setInterp) ?
"lsame" :
"histsame");
8964 h->SetMarkerSize(0);
8965 h->SetFillStyle(3005);
8966 h->SetFillColor(
h->GetLineColor());
8982 auto l =
static_cast<TH1 *
>(
h->Clone(
"toys"));
8985 h->GetListOfFunctions()->Add(
8999 static_cast<TH1 *
>(
main_h->GetListOfFunctions()->FindObject(
"toys"))->GetListOfFunctions()->
Add(
h);
9008 if (
_vv->getError() == 0)
9013 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
9016 x->setVal(
h->GetBinCenter(i));
9018 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
9022 if (
x && !
x->inRange(
"coordRange"))
9026 if (!empty ||
toy > 0) {
9028#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9037 r *=
h->GetBinWidth(i);
9045 h->SetBinContent(i,
r);
9062#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9064 p->_normSet =
nullptr;
9082 res *=
h->GetBinWidth(i);
9084 h->SetBinError(i, res);
9100 res *=
h->GetBinWidth(i);
9105 h->SetBinContent(i,
h->GetBinContent(i) + (res -
h->GetBinError(i)) * 0.5);
9106 h->SetBinError(i, (res +
h->GetBinError(i)) * 0.5);
9118 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
9128 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
9154 auto nomHist =
static_cast<TH1 *
>(
h->FindObject(
"nominal"));
9157 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9158 std::vector<double> vals;
9166 std::sort(vals.begin(), vals.end());
9175 upVal =
h->GetBinContent(i) + err;
9176 downVal =
h->GetBinContent(i) - err;
9184 std::vector<RooAbsArg *> extra;
9187 for (
auto _pdf : s->servers()) {
9189 extra.push_back(_pdf);
9192 extra.push_back(
rar);
9195 for (
auto a : extra)
9202 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
9204 h->GetYaxis()->SetTitle(
"Events");
9206 h->GetYaxis()->SetTitle(
"Probability Mass");
9208 h->GetYaxis()->SetMaxDigits(3);
9217 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"copy"));
9221 hCopy->SetStats(
false);
9222 h->GetListOfFunctions()->Add(
hCopy,
TString(
h->GetOption()) +
"same");
9223 h->GetListOfFunctions()->Add(
hCopy,
"axissame");
9241 std::vector<TH1 *>
hhs;
9248 if (!
rarNode->components().empty()) {
9251 if (
c->fFolder ==
"!.coeffs")
9257 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
9262 std::unique_ptr<RooAbsReal>
f(
9264 zero.setAttribute(
Form(
"ORIGNAME:%s",
c->GetName()));
9269 hh->SetName(
c->GetName());
9271 hh->Scale(
sf->getVal());
9273 hh->SetTitle(
c->GetName());
9275 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9280 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
9297 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
9299 hh->SetTitle(
samp->GetTitle());
9301 hh->SetTitle(
samp->GetName());
9303 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9307 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
9311 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
9317 auto hh =
samp->BuildHistogram(
9318 v, empty,
false ,
binStart,
binEnd,
_fr,
false,
false, 0,
h,
true,
9320 hh->SetName(
samp->GetName());
9322 hh->Scale(
sf->getVal());
9325 hh->SetTitle(
samp->GetName());
9327 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9336 for (
auto &
hh :
hhs) {
9387 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
9402 (*ritr)->SetTitle(
_title.c_str());
9406 for (
auto &
hh :
hhs) {
9417 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
9438 h->GetListOfFunctions()->AddFirst(stack,
"noclear same");
9447 if (
ll &&
ll->GetEntries()) {
9450 for (
auto ho : *
ll) {
9458 hh->SetFillStyle(1001);
9462 if (!
gROOT->GetColor(
hh->GetFillColor())) {
9464 hh->SetFillColor(0);
9468 for (
auto ho2 : *
ll) {
9489 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
9492 hh->SetFillColor(10);
9505 push_back(std::make_shared<xRooNode>(
data));
9513 return std::numeric_limits<double>::quiet_NaN();
9514 return node->GetBinContent(bin);
9525 std::vector<double> out;
9537 for (
int i = 0; i <
g->GetN(); i++)
9538 integral +=
g->GetPointY(i);
9539 out.push_back(integral);
9544 out.push_back(
g->GetPointY(i));
9565 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9566 tot +=
h->GetBinContent(i);
9571 out.push_back(
h->GetBinContent(i));
9582 for (
auto &
l :
a->servers()) {
9602 if (
auto o =
get(); o) {
9611#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9615 for (
int i = 0; i <
p->fCGnx; i++) {
9616 for (
int j = 0;
j <
p->fCGny;
j++) {
9617 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
9620 p->FillCollideGrid(o);
9629 if (
p->Collide(i,
j,
iw,
ih)) {
9640 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
9648 gPad->PaintModified();
9654 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
9655 1. -
gPad->GetTopMargin() - 0.08);
9656 l->SetBorderSize(0);
9657 if (
l->GetTextSize() == 0)
9665 l->ConvertNDCtoPad();
9671 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
9674 double w =
p->GetX2NDC() -
p->GetX1NDC();
9675 double h =
p->GetY2NDC() -
p->GetY1NDC();
9677 gPad->PaintModified();
9681 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
9682 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
9683 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
9684 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
9685 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
9686 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
9698 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
9699 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
9707 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
9708 if (
l =
dynamic_cast<TLegend *
>(
p->GetPrimitive(
"legend"));
l || !create)
9712 gPad->GetBottomMargin());
9713 l->SetBorderSize(1);
9717 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
9718 l->SetBorderSize(0);
9720 if (
l->GetTextSize() == 0) {
9728 l->SetName(
"legend");
9730 l->ConvertNDCtoPad();
9737 auto i = s.find(
"\n");
9738 if (i == std::string::npos) {
9741 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
9750 for (
auto a : *
l->GetListOfPrimitives()) {
9754 if (
l->GetListOfPrimitives()->GetEntries() > 20)
9759 l->GetListOfPrimitives()->RemoveLast();
9760 l->GetListOfPrimitives()->AddFirst(
e);
9761 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
9763 int nn =
l->GetNColumns();
9766 l->SetNColumns(
l->GetNColumns() + 1);
9767 if (
l->GetBorderSize() == 0) {
9768 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
9771 if (
l->GetBorderSize() == 0) {
9772 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
9788 fPad->GetCanvas()->Paint();
9789 fPad->GetCanvas()->Update();
9790#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
9791 fPad->GetCanvas()->ResetUpdated();
9806 if (
gROOT->FromPopUp()) {
9807 gROOT->SetFromPopUp(
false);
9810 }
catch (
const std::exception &
e) {
9813 (
gROOT->GetListOfBrowsers()->At(0))
9816 "Exception",
e.what(),
9819 gROOT->SetFromPopUp(
true);
9851 if (
d->get()->TestBit(1 << 20)) {
9857 hs.limits(
"cls visualize");
9869 [](
double a,
double b,
double) {
9872 if (
b == 0 &&
a == 0)
9879 [](
double n,
double b,
double sigma) {
9883 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
9893 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
9902 if (
sOpt2.Contains(
"x=")) {
9904 int _idx =
sOpt2.Index(
"x=");
9920 }
else if (
ii == 1) {
9922 }
else if (
ii == 2) {
9930 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
9933 }
else if (nBins == 1)
9934 xPoints.push_back((min + max) / 2.);
9943 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
9953 if (
sOpt2.Contains(
"force")) {
9967 Error(
"Draw",
"Can only compute forces with PDFs");
9979 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
9981 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
9982 sOpt +=
"auxSignif";
9993 sOpt.ReplaceAll(
"ratio",
"");
9994 sOpt.ReplaceAll(
"significance",
"");
9996 sOpt.ReplaceAll(
"nostack",
"");
9998 sOpt.ReplaceAll(
"same",
"");
10000 sOpt.ReplaceAll(
"goff",
"");
10002 sOpt.ReplaceAll(
"pull",
"");
10006 sOpt.ReplaceAll(
"e",
"");
10008 sOpt.ReplaceAll(
"txt",
"texte");
10010 sOpt.ReplaceAll(
"txt",
"text");
10023 if (
gPad->GetNumber() == 0) {
10043 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
10045 for (
auto o : *
pad->GetListOfPrimitives()) {
10052 :
hAxis->GetXaxis()->GetName())
10074 double ymin =
hh->GetMinimum();
10075 double ymax =
hh->GetMaximum();
10076 if (
hh->GetMaximumStored() == -1111)
10078 if (
hh->GetMinimumStored() == -1111) {
10081 }
else if (
ymin < 0) {
10089 if (
hh->GetSumw2()) {
10091 double smallestErrUp3 = std::numeric_limits<double>::infinity();
10092 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
10112 double up =
ymax -
hh->GetBinContent(1);
10137 double ymax = -std::numeric_limits<double>::infinity();
10138 double ymin = std::numeric_limits<double>::infinity();
10139 for (
int i = 0; i <
gr->
GetN(); i++) {
10143 return std::make_pair(
ymin,
ymax);
10151 out->SetFillColor(out->GetLineColor());
10152 out->SetMarkerStyle(0);
10159 out->SetPointEYlow(out->GetN() - 1,
GetError());
10160 out->SetPointEYhigh(out->GetN() - 1, out->GetErrorYlow(out->GetN() - 1));
10173 pad->Divide(1, 2, 1
e-9, 1
e-9);
10174 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
10175 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
10177 optNoFR.ReplaceAll(
"pull",
"");
10187 gPad->GetFrame()->SetFillStyle(1001);
10188 gPad->SetTopMargin(0);
10189 gPad->SetBottomMargin(0);
10190 gPad->SetName(
"pull");
10194 Error(
"Draw",
"Couldn't find pull graph");
10203 throw std::runtime_error(
"Could not find scales in fit result");
10205 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
10210 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
10214 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
10215 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
10219 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
10220 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
10221 g->SetEditable(
true);
10222 g->SetHighlight(
true);
10223 g->SetMarkerStyle(20);
10224 g->SetMarkerSize(0.5);
10250 if (!
_v->IsHidden())
10259 pad->SetBorderSize(0);
10285 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10288 auto _pad =
pad->GetPad(_size);
10289 _pad->SetName(
"legend");
10291 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
10294 while (
pad->GetPad(
x + 1)) {
10295 pad->GetPad(
x + 1)->SetFillStyle(0);
10305 if (_range &&
strlen(_range)) {
10312 if (
_v->IsHidden())
10329 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10344 for (
auto &
_v : *
this) {
10345 if (
_v->IsHidden())
10351 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10354 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10364 pad->SetBorderSize(0);
10365 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10368 for (
auto &
_v : *
this) {
10369 if (
_v->IsHidden())
10375 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10378 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10387 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10409 if (
sOpt.Contains(
"corr")) {
10416 TH2 *hist =
nullptr;
10419 std::set<std::pair<double, size_t>>
maxCorrs;
10429 std::vector<size_t>
topN;
10439 for (
size_t i = 0; i <
topN.size(); i++) {
10442 for (
size_t j = 0;
j <
topN.size();
j++) {
10465 gPad->SetGrid(1, 1);
10471 if (
sOpt.Contains(
"brakdown")) {
10477 if (
sOpt.Contains(
"brakdown:")) {
10481 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10482 if (_poi->empty()) {
10483 throw std::runtime_error(
"No floating poi in the fit");
10484 }
else if (_poi->size() != 1) {
10485 throw std::runtime_error(
"Multiple poi in the fit");
10487 poiName = _poi->first()->GetName();
10493 std::set<std::string>
groups;
10497 }
else if (
p->getStringAttribute(
"group")) {
10498 groups.insert(
p->getStringAttribute(
"group"));
10500 groups.insert(
p->GetTitle());
10525 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
10526 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
10534 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
10535 pie->SetEntryVal(i, 0);
10544 pie->SetEntryLabel(i,
group.c_str());
10559 pie->SetRadius(0.17);
10568 out->SetTitle(
"Fit Result Pulls");
10572 ugraph->SetTitle(
"Fit Result Pulls");
10574 std::map<std::string, double>
scale;
10575 std::map<std::string, double>
offset;
10581 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
10582 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
10596 std::shared_ptr<xRooNode>
pConstr;
10599 if (
_vv->hasRange(
"pullScale")) {
10609 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
10610 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
10632 std::string
xName =
pConstr->find(
".x")->get()->GetName();
10634 for (
auto &_d :
pConstr->vars()) {
10635 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
10637 if (
xName == _d->get()->GetName())
10673 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
10677 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
10688 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10695 out->SetPointError(out->GetN() - 1, 0, 0, (-
_v->getErrorLo()) /
prefitError,
10707 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10720 for (
int i = 0; i <
ugraph->GetN(); i++)
10721 ugraph->SetPointX(i, i + graph->GetN());
10734 graph->SetMarkerStyle(20);
10735 graph->SetMarkerSize(0.5);
10737 graph->SetMaximum(4);
10738 graph->SetMinimum(-4);
10741 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
10743 std::vector<std::pair<double, std::string>>
covariances;
10746 if (
sOpt.Contains(
"impact")) {
10747 if (
sOpt.Contains(
"impact:")) {
10751 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10752 if (_poi->empty()) {
10753 throw std::runtime_error(
"No floating poi in the fit");
10754 }
else if (_poi->size() != 1) {
10755 throw std::runtime_error(
"Multiple poi in the fit");
10757 poiName = _poi->first()->GetName();
10778 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
10779 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
10780 : (std::abs(i.first) > std::abs(j.first));
10801 sortedGraph.SetPointError(
sortedGraph.GetN() - 1, 0, 0, graph->GetErrorYlow(i), graph->GetErrorYhigh(i));
10810 graph->SetTitle(
"Fit Result Impact");
10817 std::max(graph->GetN(), 1) - 0.5);
10826 hist =
new TH2D(
GetName(), fr->
GetTitle(), std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5,
10853 graph->GetHistogram()->GetXaxis()->Set(std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5);
10854 for (
int ii = 1;
ii <=
_axis->GetNbins();
ii++) {
10855 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
10870 gPad->Divide(1, 1, 1
e-9, 1
e-9);
10874 gPad->SetLeftMargin(0.4);
10876 gPad->SetBottomMargin(0.4);
10879 auto pNamesHist =
dynamic_cast<TH1F *
>(graph->GetHistogram()->Clone(
"scales"));
10883 for (
int ii = 1;
ii <= graph->GetN();
ii++) {
10887 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
10892 if (!
sOpt.Contains(
"impact")) {
10893 for (
int ii = 2;
ii >= 1;
ii--) {
10928 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
10929 pave->SetFillStyle(0);
10930 pave->SetBorderSize(0);
10931 pave->SetMargin(0.);
10932 pave->SetName(
"status");
10933 pave->SetTextAlign(31);
10939 case 0:
covQualTxt =
"Not calculated";
break;
10941 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
10956 gPad->SetTicks(0, 0);
10960 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
10961 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
10965 double factor = 475. /
gPad->GetCanvas()->GetWh();
10994 for (
int tt = 0;
tt < 2;
tt++) {
10995 auto impact =
static_cast<TH1 *
>(
10996 graph->GetHistogram()->Clone(
TString::Format(
"%s_impact+",
tt == 0 ?
"prefit" :
"postfit")));
10999 impact->SetBarWidth(0.9);
11000 impact->SetBarOffset(0.05);
11001 impact->SetLineColor(
kBlack);
11002 impact->SetFillColor(
kAzure - 4);
11003 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
11005 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
11006 impact2->SetDirectory(
nullptr);
11014 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
11016 :
c.first *
vv->getError() /
vv->getErrorHi() *
11017 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
11020 :
c.first *
vv->getError() /
vv->getErrorLo() *
11021 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
11028 for (
int ii = -1;
ii <= 1;
ii++) {
11041 leg1->SetFillStyle(0);
11042 leg1->SetBorderSize(0);
11043 leg1->SetMargin(0.25);
11044 leg1->SetNColumns(2);
11046 leg1->SetTextSize(
_axis->GetLabelSize());
11047 leg1->SetTextFont(
_axis->GetLabelFont());
11048 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
11049 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11050 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11051 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11052 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
11053 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11054 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11055 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11061 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
11068 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
11076 graph->SetEditable(
false);
11080 graph->GetListOfFunctions()->Add(
pNamesHist,
"same");
11084 for (
int p = 0;
p < graph->GetN();
p++) {
11085 graph->SetPoint(
p, graph->GetPointY(
p), graph->GetPointX(
p));
11086 graph->SetPointError(
p, graph->GetErrorYlow(
p), graph->GetErrorYhigh(
p), graph->GetErrorXlow(
p),
11087 graph->GetErrorXhigh(
p));
11090 if (
f->InheritsFrom(
"TH1")) {
11099 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
11100 for (
int p = 0;
p <
g->GetN();
p++) {
11101 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
11104 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
11114 if (!
sOpt.Contains(
"impact")) {
11121 auto x = graph->GetPointX(graph->GetN() -
ugraphLabels.size() + i);
11122 auto y = graph->GetPointY(graph->GetN() -
ugraphLabels.size() + i) +
11123 graph->GetErrorYhigh(graph->GetN() -
ugraphLabels.size() + i);
11127 t->SetTextSize(0.025);
11128 t->SetTextAngle(90);
11129 graph->GetListOfFunctions()->Add(t);
11133 graph->SetName(
"pulls");
11142 hist->
Draw(
"same");
11154 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
11155 hh->SetDirectory(
nullptr);
11173 for (
auto c : s->bins()) {
11174 auto _pad =
dynamic_cast<TPad *
>(
gPad->GetPrimitive(
c->GetName()));
11179 c->push_back(std::make_shared<xRooNode>(*
this));
11181 c->resize(
c->size() - 1);
11183 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
11202 for (
auto o : *
gPad->GetListOfPrimitives()) {
11227 for (
int i = 0; i <
dataGraph->GetN(); i++)
11244 for (
auto o : *
gPad->GetListOfPrimitives()) {
11245 if (
auto h =
dynamic_cast<TH1 *
>(o);
11255 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
11258 histName = histName(0, histName.
Index(
'|'));
11259 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
11265 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
11277 if (!std::isnan(
yval)) {
11279 if (!std::isnan(yup))
11281 if (!std::isnan(
ydown))
11348 if (!
d->get()->TestBit(1 << 20))
11352 auto _obs =
d->obs();
11354 auto _nll =
nll(
d);
11356 int nevent =
theData->numEntries();
11357 for (
int i = 0; i < nevent; i++) {
11359 bool _skip =
false;
11360 for (
const auto &_c :
_coords) {
11362 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
11372 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11375 auto nllVal = _nll.getEntryVal(i);
11376 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11377 auto nllVal2 = _nll.getEntryVal(i);
11378 _nll.pars()->setRealValue(
initPar->GetName(), val);
11384 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11387 auto _extTerm = _nll.extendedTermVal();
11388 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11389 auto _extTerm2 = _nll.extendedTermVal();
11390 _nll.pars()->setRealValue(
initPar->GetName(), val);
11391 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
11396 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
11402 }
else if (
ii == 3) {
11428 (
rarNode->get()->InheritsFrom(
"RooRealSumPdf") ||
rarNode->get()->InheritsFrom(
"RooAddPdf") ||
11429 (
v &&
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11437 auto h =
BuildHistogram(
v,
false,
hasErrorOpt, 1, 0,
"",
false,
false, 0,
nullptr,
nostack,
true );
11449 :
h->GetXaxis()->GetName())
11452 if (
h->GetXaxis()->IsAlphanumeric()) {
11460 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
11461 rar->InheritsFrom(
"RooSimultaneous"))) {
11464 rar->leafNodeServerList(&s);
11471 for (
auto _p : s) {
11479 if (
_v->hasError()) {
11490 gPad->SetGrid(0, 0);
11492 gPad->SetGrid(1, 1);
11497 h->SetFillStyle(0);
11546 gROOT->SetEditHistograms(
true);
11548 gROOT->SetEditHistograms(
false);
11557 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
11562 bool hasError(
false);
11563 for (
int i = 0; i <
h->GetSumw2N(); i++) {
11564 if (
h->GetSumw2()->At(i)) {
11575 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
11576 h->GetYaxis()->SetTitleOffset(1.);
11594 hCopy->SetDirectory(
nullptr);
11596 _hist->GetListOfFunctions()->Add(node);
11597 _hist->GetListOfFunctions()->Add(
new TExec(
11600 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
11601 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
11602 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
11603 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
11604 "h->SetBinContent(1, "
11605 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
11606 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
11607 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
11608 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
11609 _hist->GetName(), node->GetName())));
11611 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
11612 errHist->SetFillColor(
h->GetLineColor());
11615 hCopy->SetFillStyle(0);
11616 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
11619 _hist->SetStats(
false);
11676 errHist->SetFillColor(
h->GetLineColor());
11693 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11695 if (
auto stack =
dynamic_cast<THStack *
>(
h->FindObject(
"stack"))) {
11701 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
11702 if (
lnk == stack->GetHists()->FirstLink() &&
h->GetMinimum() >
hhMin) {
11988 dOpt.ReplaceAll(
"TEXT",
"");
11990 double ymax = -std::numeric_limits<double>::infinity();
11991 double ymin = std::numeric_limits<double>::infinity();
11992 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
12021 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
12030 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
12031 double val =
ratioHist->GetBinContent(i);
12032 double err =
ratioHist->GetBinError(i);
12039 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
12046#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
12055 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
12056 _h->SetDirectory(
nullptr);
12057 _h->SetFillColor(0);
12058 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
12063 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
12064 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
12065 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
12066 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
12076 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
12080 histName = histName(0, histName.
Index(
'|'));
12082 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
12083 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
12086 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
12087 double val =
h->GetBinContent(i);
12088 double err =
h->GetBinError(i);
12089 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12090 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
12091 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12092 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
12093 h->GetBinContent(i));
12110 double ymax = -std::numeric_limits<double>::infinity();
12111 double ymin = std::numeric_limits<double>::infinity();
12112 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
12113 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
12114 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
12148 if (
d->get()->TestBit(1 << 20)) {
12196 w->import(*
gROOT->GetListOfColors(),
true);
12199#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
12203 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12208 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
12213#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12217 for (
auto &
c :
w->components()) {
12218 c->_eocache =
nullptr;
12223 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12229 auto dir =
dest->GetDirectory(
source->GetName());
12233 for (
auto k : *
source->GetListOfKeys()) {
12234 auto key =
dynamic_cast<TKey *
>(k);
12235 const char *classname = key->GetClassName();
12244 if (dir->FindKey(key->GetName()))
12247 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
12249 dir->WriteObject(
fc, key->GetName());
12252 TObject *obj = key->ReadObj();
12254 dir->WriteTObject(obj, key->
GetName());
12261 if (
gROOT->GetListOfFiles()) {
12262 for (
auto key : *
gROOT->GetListOfFiles()) {
12273#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12275 for (
auto &
c :
w->components()) {
12276 c->setExpensiveObjectCache(
w->expensiveObjectCache());
12286 return std::numeric_limits<double>::quiet_NaN();
12292 std::vector<double> out;
12293 out.reserve(
size());
12294 for (
auto child : *
this) {
12295 out.push_back(
child->GetContent());
12309 auto rho =
_fr->correlationMatrix();
12318 for (
int m = 0;
m < rho.GetNrows();
m++) {
12325 auto tmp = _p->getVal();
12326 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
12328 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
12331 for (
int n = 0;
n < rho.GetNrows();
n++) {
12339 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
12341 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
12344 for (
int i = 0; i < out.GetNrows(); i++) {
12345 for (
int j = 0;
j < out.GetNrows();
j++) {
12354std::pair<double, double>
12358 double err = std::numeric_limits<double>::quiet_NaN();
12360 std::unique_ptr<RooAbsCollection>
_snap;
12373 out =
c->getVal(
sobs);
12380#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
12383 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
12384#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12386 p->_normSet =
nullptr;
12390 p->setNormRange(
nullptr);
12393 auto f = std::shared_ptr<RooAbsReal>(
12394 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
12398 out *=
f->getVal();
12408 for (
auto &
v : vals) {
12420 out = std::numeric_limits<double>::quiet_NaN();
12423 _pars.RooAbsCollection::operator=(*_snap);
12425 return std::make_pair(out, err);
12444 std::vector<double> out;
12450 binEnd = _hist->GetNbinsX();
12457 _hist->GetBinError(bin));
12582std::string cling::printValue(
const xRooNode *
v)
12585 return "nullptr\n";
12588 size_t left =
v->size();
12589 for (
auto n : *
v) {
12595 out +=
n->GetName();
12596 if (out.length() > 100 && left > 0) {
12602 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->GetName())) + out;
12607 return "<nullptr>";
12609 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
const char Option_t
Option string (const char)
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, int tsType=0)
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 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
void _fit_(const char *constParValues="", const char *options="GoF")
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.
double GetError(const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
xRooNode constraints() const
std::shared_ptr< xRooNode > fProvider
std::shared_ptr< TStyle > style(TObject *initObject=nullptr, bool autoCreate=true) const
xRooNode mainChild() const
xRooNode fitResult(const char *opt="") const
std::shared_ptr< TAxis > fXAxis
only here so can have char* GetRange return so can return nullptr for no range set (required for RooC...
xRooNode coords(bool setVals=true) const
xRooNode Vary(const xRooNode &child)
xRooNode Constrain(const xRooNode &child)
static std::map< std::string, std::tuple< std::function< double(double, double, double)>, bool > > auxFunctions
xRooNode pars() const
List of parameters (non-observables) of this node.
void _SetContent_(double value)
void SetFitResult(const RooFitResult *fr=nullptr)
void _ShowVars_(bool set=true)
xRooNode coefs(bool recurse=false) const
bool IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
double GetBinData(int bin, const xRooNode &data="obsData")
bool SetBinError(int bin, double value)
void _Vary_(const char *what)
bool SetContents(const TObject &obj)
std::shared_ptr< TObject > fComp
std::pair< double, double > IntegralAndError(const xRooNode &fr="", const char *rangeName=nullptr, int nToys=0, bool errorsHi=false, bool errorsLo=false) const
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 Combine(const xRooNode &rhs, bool silent=false)
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
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)
void _SetAttribute_(const char *name, const char *value=nullptr)
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
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.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
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...
std::string contentsString() const
Return comma separated list of contained object names as STL string.
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.
< A class that holds configuration information for a model using a workspace as a store
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 Size_t GetMarkerSize() const
Return the marker size.
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.
static Int_t GetColorPalette(Int_t i)
Static function returning the color number i in current palette.
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
static Int_t GetNumberOfColors()
Static function returning number of colors in the color palette.
Describe directory structure in memory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
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 TMemFile is like a normal TFile except that it reads and writes only from memory.
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 SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
virtual void Delete(Option_t *option="")
Delete this object.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
@ kCanDelete
if object in a list can be deleted
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
The most important graphics class in the ROOT system.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void SetY1NDC(Double_t y1)
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
virtual void SetY2NDC(Double_t y2)
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Regular expression class.
This class creates a ROOT object browser, constituted by three main tabs.
Sequenceable collection abstract base class.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t Atof() const
Return floating-point value contained in string.
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.
CoordSystem::Scalar get(DisplacementVector2D< CoordSystem, Tag > const &p)
bool EndsWith(std::string_view string, std::string_view suffix)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
static constexpr auto NumIntegration
Alias of MsgLevel::NumericIntegration for backwards compatibility.
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)