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 "
440 if (
gEnv->
GetValue(
"XRooFit.SkipInitParErrorInference",
false)) {
441 Warning(
"xRooNode",
"Skipping because XRooFit.SkipInitParErrorInference=true. This is expert-only, you "
442 "should fix your workspaces!");
446 for (
auto &
a : *
this) {
450 if (
a->fFolder ==
"!pdfs") {
452 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
456 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
457 arg && arg->hasError()) {
458 v->setError(arg->getError());
475 if (
strlen(GetTitle()) == 0) {
502 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
503 return a->getStringAttribute(
"alias");
505 return comp->GetName();
518 bool isBool = (
v ==
"TRUE" ||
v ==
"FALSE");
520 if (
value ==
nullptr ||
v ==
"NULLPTR") {
521 if (
a->getAttribute(
name))
522 a->setAttribute(
name,
false);
523 else if (
a->getStringAttribute(
name))
524 a->setStringAttribute(
name,
nullptr);
527 a->setAttribute(
name, (
v ==
"TRUE"));
538 for (
auto a : *
gROOT->GetListOfBrowsers()) {
560 if (o->isSelectedComp() && !val) {
563 o->setAttribute(
"hidden");
564 }
else if (!o->isSelectedComp() && !val) {
569 o->setAttribute(
"hidden",
false);
572 item->CheckItem(!o->getAttribute(
"hidden"));
573 if (o->isSelectedComp()) {
581 if (
auto o =
get(); o) {
583 o->SetBit(1 << 20, val);
585 if (
auto _ws =
ws(); _ws) {
588 if (fr->numStatusHistory() && !_ws->genobj(fr->GetName())) {
590 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
595 _allVars = fr->floatParsFinal();
596 _allVars = fr->constPars();
597 for (
auto &i : fr->floatParsInit()) {
603 for (
auto oo : _ws->allGenericObjects()) {
605 ffr->ResetBit(1 << 20);
609 _ws->allVars() = fr->floatParsInit();
613 for (
auto a : *
gROOT->GetListOfBrowsers()) {
624 if (
auto first =
p->GetParent()->GetFirstChild()) {
626 if (first->HasCheckBox()) {
627 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
628 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
630 }
while ((first = first->GetNextSibling()));
642 if (
auto first = i->GetFirstChild()) {
644 if (first->IsOpen() &&
645 (
TString(first->GetText()) ==
"poi" ||
TString(first->GetText()) ==
"np")) {
646 fb->DoubleClicked(first, 0);
649 }
while ((first = first->GetNextSibling()));
671 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
672 if (!b2 || !b2->GetBrowserImp()) {
679 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
681 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
683 b2->BrowseObject(
this);
688 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
689 _b->GotoDir(
nullptr);
700 if (
auto first =
item->GetFirstChild()) {
702 if (first->HasCheckBox()) {
703 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
704 first->CheckItem(
_obj->get() &&
705 (
_obj->get()->TestBit(1 << 20) ||
708 }
while ((first = first->GetNextSibling()));
721 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
722 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corr10colztext\")",
nullptr, *
this));
723 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
724 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
731 s->SetFillAttributes();
738 Draw(
b->GetDrawOption());
740 }
catch (
const std::exception &
e) {
743 (
gROOT->GetListOfBrowsers()->At(0))
746 "Exception",
e.what(),
753 for (
auto &
c : *
this) {
754 if (!
c->fFolder.empty()) {
765 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
768 for (
auto &
v : *
this) {
769 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
770 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
777 _name = _name(1, _name.
Length());
778 b->Add(
v.get(), _name);
782 for (
auto &
v : *
this) {
785 if (
strcmp(
v->GetName(),
".folders") == 0)
789 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
797 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
805 :
v->get()->GetName());
807 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
809 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
817 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
823 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
830 for (
auto &
c : pi->interpolationCodes())
838 for (
auto &
c :
fiv->interpolationCodes())
848 if (
auto o =
v->get(); o)
849 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
851 if (
auto o =
v->get(); o)
854 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
855 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
858 if (
_fr->status() ||
_fr->covQual() != 3) {
859 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() && !
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
860 }
else if (
_fr->numStatusHistory() == 0) {
861 v->GetTreeItem(
b)->SetColor(
kGray);
864 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
866 v->GetTreeItem(
b)->SetColor(
kGray);
868 v->GetTreeItem(
b)->ClearColor();
872 if (
auto fits =
_htr->GetFitInfo()) {
873 for (
int i = 0; i <
fits->numEntries(); i++) {
875 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
876 v->GetTreeItem(
b)->SetColor(
kRed);
881 v->GetTreeItem(
b)->SetColor(
kBlue);
908 if (_name ==
".memory")
912 if (
auto o =
v->get(); o)
913 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
914 b->Add(
v.get(), _name, -1);
915 if (
auto o =
v->get(); o)
919 b->SetSelected(
this);
932 auto v = std::make_shared<xRooNode>(
vars());
943 if (
strcmp(
b->GetName(),
".vars") == 0)
966 if (
auto v = var();
v)
967 return v->getBinWidth(bin - 1, GetName());
972 if (
auto v = rvar();
v) {
973 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
974 :
v->getBinning(GetName()).binLow(bin - 1);
980 if (
auto v = rvar();
v)
981 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
987 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
994 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
998 void Set(
Int_t nbins,
const double *xbins)
override
1001 v->setBinning(
RooBinning(nbins, xbins), GetName());
1006 std::vector<double> bins(nbins + 1);
1007 for (
int i = 0; i <= nbins; i++)
1008 bins.at(i) = xbins[i];
1009 return Set(nbins, &bins[0]);
1033 for (
auto &o : *
_owned) {
1034 if (
name == o->GetName()) {
1035 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
1046 _parent = _parent->fParent;
1052 std::shared_ptr<TObject> out;
1053 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
1054 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1055 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1060 if (
auto arg =
ws()->
data(
name.c_str()); arg) {
1061 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1062 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1067 if (
auto arg =
ws()->genobj(
name.c_str()); arg) {
1068 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1069 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1074 if (
auto arg =
ws()->embeddedData(
name.c_str()); arg) {
1075 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1076 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1082 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1083 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1093 arg->treeNodeServerList(&nodes);
1106 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1122 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1134 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1135 for (
auto &
v : _obs) {
1171 TString binningName = o->getStringAttribute(
"binning");
1172 auto _bnames =
x->getBinningNames();
1173 bool hasBinning =
false;
1175 if (
b == binningName) {
1183 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1185 o->setStringAttribute(
"binning",
nullptr);
1189 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1195 if (
b == o->GetName()) {
1196 binningName = o->GetName();
1200 if (binningName ==
"") {
1206 (std::list<double> *)(
nullptr),
1208 ? o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1209 std::numeric_limits<double>::infinity())
1212 std::vector<double>
_bins;
1213 for (
auto &
b : *
bins) {
1221 _v->getBinning(o->GetName())
1226 binningName = o->GetName();
1237 if (
r->getBinning(binningName).isUniform()) {
1238 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1240 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1242 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1243 std::vector<double>
bins = {};
1244 for (
int i = 0; i <=
x->numBins(binningName); i++)
1246 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1249 std::map<int, std::string> cats;
1250 for (
auto &
c : *cat) {
1251 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1252 cats[
c.second] =
c.first;
1255 for (
auto &[
_, label] : cats) {
1256 fXAxis->SetBinLabel(i++, label.c_str());
1261 fXAxis->SetName(binningName);
1268 if (
auto o =
get(); o) {
1269 if (o->InheritsFrom(
"RooWorkspace"))
1271 if (o->InheritsFrom(
"RooAbsData"))
1273 if (o->InheritsFrom(
"RooSimultaneous"))
1276 if (o->InheritsFrom(
"RooProdPdf"))
1278 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1281 if (o->InheritsFrom(
"RooFitResult")) {
1282 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1283 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1284 "package.xpm",
"->Browse()");
1286 return "xRooFitRooFitResult";
1288 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1290 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1291 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1293 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1294 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1297 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1301 if (o->InheritsFrom(
"TStyle")) {
1302 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1303 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1304 "bld_colorselect.xpm",
"->Browse()");
1306 return "xRooFitTStyle";
1308 if (o->InheritsFrom(
"RooConstVar")) {
1314 return "TMethodBrowsable-leaf";
1316 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1317 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1318 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1321 return "xRooFitScanStyle";
1323 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1324 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1325 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1328 return "xRooFitTestStyle";
1330 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1331 return "TBranchElement-folder";
1332 if (o->InheritsFrom(
"RooAbsPdf")) {
1333 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1334 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1337 return "xRooFitPDFStyle";
1339 if (o->InheritsFrom(
"RooStats::ModelConfig")) {
1340 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitMCStyle",
true)) {
1341 gClient->GetMimeTypeList()->AddType(
"xRooFitMCStyle",
"xRooFitMCStyle",
"app_t.xpm",
"app_t.xpm",
1344 return "xRooFitMCStyle";
1348 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1350 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1351 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1352 std::numeric_limits<double>::infinity()))))) {
1357 return o->ClassName();
1369 if (
rrs->getAttribute(
"BinnedLikelihood"))
1370 return "BinnedLikelihood";
1373 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1375 if (o->InheritsFrom(
"PiecewiseInterpolation")) {
1387 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"VariedDensity" :
"Varied";
1390 if (o->InheritsFrom(
"RooHistFunc"))
1391 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"SimpleDensity" :
"Simple";
1392 if (o->InheritsFrom(
"RooBinWidthFunction"))
1394 if (o->InheritsFrom(
"ParamHistFunc"))
1396 if (o->InheritsFrom(
"RooRealVar"))
1398 if (o->InheritsFrom(
"RooConstVar"))
1406 xRooNode out(
".coords",
nullptr, *
this);
1408 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1438 if (
auto pos =
pName.Index(
'='); pos != -1) {
1439 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1447 _obs->setVal((high + low) / 2.);
1448 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1450 "coordRange",
"coordRange");
1452 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1457 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1460 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1461 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1465 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1467 throw std::runtime_error(
"Unknown observable, could not find");
1479 }
catch (
const std::exception &
e) {
1488 }
catch (
const std::exception &
e) {
1515 pdf =
p->pdfList().find(
child.GetName());
1518 auto i =
p->pdfList().index(*pdf);
1520#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1521 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1522#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1523 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1525 auto nset =
p->_pdfNSetList.At(i);
1526 p->_pdfNSetList.Remove(nset);
1529 if (
p->_extendedIndex == i)
1530 p->_extendedIndex = -1;
1531 else if (
p->_extendedIndex > i)
1532 p->_extendedIndex--;
1544 arg =
p2->components().find(
child.GetName());
1548#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1549 p2->_compRSet.remove(*arg);
1551 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1553 p2->removeServer(*arg,
true);
1563 }
catch (std::runtime_error &) {
1573 arg =
p4->funcList().find(
child.GetName());
1577 auto idx =
p4->funcList().index(arg);
1582 p4->removeServer(*arg,
true);
1584 std::vector<RooAbsArg *>
_coefs;
1586 if (
ii !=
size_t(idx))
1601 arg =
p5->pdfList().find(
child.GetName());
1605 auto idx =
p5->pdfList().index(arg);
1610 p5->removeServer(*arg,
true);
1612 std::vector<RooAbsArg *>
_coefs;
1614 if (
ii !=
size_t(idx))
1629 arg =
p6->list().find(
child.GetName());
1634 p6->removeServer(*arg,
true);
1642 auto arg =
w->components().find(
child.GetName());
1649 if (arg->hasClients()) {
1650 throw std::runtime_error(
1651 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1654 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1663 throw std::runtime_error(
"Removal not implemented for object type " +
1713 out->setAttribute(
"obs");
1714 out->setAttribute(
"global");
1717 throw std::runtime_error(
"Failed to add global observable");
1721 out->setAttribute(
"poi");
1729 throw std::runtime_error(
"Failed to add parameter of interest");
1733 if (!
fac.Contains(
"[") && !
fac.Contains(
"("))
1739 if (
find(_data->GetName())) {
1740 throw std::runtime_error(
TString::Format(
"Cannot add dataset %s, already exists for %s. If intending to "
1741 "combine datasets, please add directly to dataset",
1751 throw std::runtime_error(
1752 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1755 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1773 }
else if (!_ws->obj(
_fr->GetName())) {
1782 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1790 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1793 if (
auto _d = _ws->data(
child.GetName()); _d) {
1796 l.remove(*_d->get(),
true,
true);
1800 throw std::runtime_error(
"Cannot extend dataset with new columns");
1811 if (
auto __d = _ws->data(
child.GetName()))
1812 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1820 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1829 throw std::runtime_error(
"Cannot create dataset");
1834 throw std::runtime_error(
"Cannot add to null object with no parentage");
1836 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1841 std::rethrow_exception(std::current_exception());
1846 throw std::runtime_error(
"No object");
1856 throw std::runtime_error(
"Can only add datasets to a dataset");
1865 }
else if (
g->GetContent() !=
glob->GetContent()) {
1866 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1871 if (
auto _dglobs =
p->getGlobalObservables()) {
1881 std::set<std::pair<RooAbsCategory *, RooCategory *>> cats;
1883 for (
auto col : *_data->get()) {
1884 if (!
p->get()->contains(*col)) {
1885 ds->addColumn(*col);
1890 throw std::runtime_error(
1891 TString::Format(
"unexpected type for regular observable: %s", col->GetName()));
1904 cats.insert({
c,
c2});
1911 for (
int i = 0; i < _data->numEntries(); i++) {
1912 auto row = _data->get(i);
1913 auto w = _data->weight();
1914 ds->get()->assign(*row);
1915 for (
auto [
c,
c2] : cats) {
1916 c2->setLabel(row->getCatLabel(
c->GetName()));
1918 ds->add(*
ds->get(),
w);
1922 ds->SetTitle(
TString(
ds->GetTitle()) +
" + " + _data->GetTitle());
1929 _ds->addColumn(*_arg);
1930 _arg->setAttribute(
"obs");
1935 throw std::runtime_error(
"Can only add histogram or var/expr or dataset to data");
1939 throw std::runtime_error(
"Could not find pdf");
1940 auto _ax = _pdf->GetXaxis();
1942 throw std::runtime_error(
"Cannot determine binning to add data");
1951 l.remove(*
p->get(),
true,
true);
1955 throw std::runtime_error(
"Cannot extend dataset with new columns");
1962 for (
auto &o :
obs) {
1964 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1965 if (
v->getMin() <
dv->getMin())
1966 dv->setMin(
v->getMin());
1967 if (
v->getMax() >
dv->getMax())
1968 dv->setMax(
v->getMax());
1981 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1983 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1984 throw std::runtime_error(
1985 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1986 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1987 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1988 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1990 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1995 p->add(
obs,
_h->GetBinContent(i));
2004 child.convertForAcquisition(*
this,
sOpt);
2008 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
2010 throw std::runtime_error(
"Something went wrong with pdf acquisition");
2017 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2018 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2019 std::numeric_limits<double>::infinity()));
2020 !_boundaries && _ax->GetNbins() > 0) {
2021#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2022 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2026 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2027 if (!_p->getStringAttribute(
"alias"))
2028 _p->setStringAttribute(
"alias", out->GetName());
2030 throw std::runtime_error(
2031 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2037 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
2041 if (_pdf->canBeExtended()) {
2043 std::cout <<
" warning " << _pdf->GetName() <<
" wont be correctly normalized" << std::endl;
2053 for (
auto i =
p->coefList().size(); i <
p->pdfList().size(); i++) {
2058 *
static_cast<RooAbsPdf *
>(
p->pdfList().at(i))));
2064 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2065 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
2066 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2067 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
2069 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
2101 std::shared_ptr<TObject> out;
2106 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
2111 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
2115 if (!out && !
child.fComp) {
2116 std::shared_ptr<RooAbsArg> _func;
2124 std::unique_ptr<TH1D>
h;
2127 h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(),
2128 _ax->binning()->array());
2130 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
2132 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2133 }
else if (_obs.size() == 1) {
2136 auto _bnames = _x->getBinningNames();
2137 TString binningName =
p->getStringAttribute(
"binning");
2139 if (
b ==
p->GetName()) {
2140 binningName =
p->GetName();
2144 std::unique_ptr<TH1D>
h;
2147 h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
2148 _x->getBinningPtr(binningName)->array());
2150 h->GetXaxis()->SetName(
2153 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2154 Info(
"Add",
"Created SimpleDensity factor %s (xaxis=%s) for %s", _func->GetName(), _obs.at(0)->GetName(),
2157 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
2163 _func->setStringAttribute(
"alias",
child.GetName());
2167 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
2171 _f->setAttribute(
"density");
2172 if (
_f->getAttribute(
"autodensity")) {
2174 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
2178 _f->setAttribute(
"autodensity",
false);
2179 _f->setValueDirty();
2188 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
2189 _f->getAttribute(
"density") ?
"SimpleDensity" :
"Simple",
_f->GetName(),
p->GetName());
2193 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
2198 newName.ReplaceAll(
"_samples",
"");
2200 Warning(
"Add",
"converting samples to components");
2205 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2206 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2207 std::numeric_limits<double>::infinity()));
2208 !_boundaries && _ax->GetNbins() > 0) {
2209#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2210 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2214 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2215 if (!_p->getStringAttribute(
"alias"))
2216 _p->setStringAttribute(
"alias", out->GetName());
2218 throw std::runtime_error(
2219 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2226 if (!_p->canBeExtended()) {
2235 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2242 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
2244 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
2245 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2246 std::numeric_limits<double>::infinity()));
2247 !_boundaries && _ax->GetNbins() > 0) {
2248#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2251 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
2255 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
2256 if (!sumPdf->getStringAttribute(
"alias"))
2257 sumPdf->setStringAttribute(
"alias", out->GetName());
2260 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2261 if (!
_f->getStringAttribute(
"alias"))
2262 _f->setStringAttribute(
"alias", out->GetName());
2264 throw std::runtime_error(
2265 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2273 if (!
p->getStringAttribute(
"binning"))
2274 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2277 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2282 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2291 p->setStringAttribute(
"xvar",
nullptr);
2317 auto out = this->
operator[](
"components")->Add(child);
2336 for (
auto &
_pdfa :
pp->components()) {
2354 auto out = this->
operator[](
"samples")->Add(child);
2357 p2->setStringAttribute(
"xvar",
nullptr);
2370 child.convertForAcquisition(
2371 *
this,
child.get() ?
"" :
"func" );
2375 if (!
w->import(*_d)) {
2378 std::unique_ptr<RooAbsCollection>(
w->allVars().selectCommon(*_d->get()))->setAttribAll(
"obs");
2380 if (_d->getGlobalObservables()) {
2381 std::unique_ptr<RooAbsCollection>
globs(
w->allVars().selectCommon(*_d->getGlobalObservables()));
2382 globs->setAttribAll(
"obs");
2383 globs->setAttribAll(
"global");
2387 throw std::runtime_error(
2398 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2401 std::string
catName =
"channelCat";
2402 if (!
child.empty()) {
2408 _cat->setAttribute(
"obs");
2410 Info(
"Add",
"Created pdf RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2414 if (
coll->isOwning()) {
2416 }
else if (
child.ws() !=
ws()) {
2424 if (
sOpt ==
"pdf") {
2430 }
else if (
sOpt ==
"channel") {
2435 std::shared_ptr<TObject> out;
2436 child.convertForAcquisition(*
this);
2439 }
else if (!
child.fComp) {
2442 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2446 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2452 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2455 }
else if (
sOpt ==
"dataset") {
2458 return (*this).datasets().Add(
child);
2516 a->setAttribute(
"hidden", set);
2527 return a->getAttribute(
"hidden");
2534 if (
get() ==
rhs.get()) {
2546 std::set<std::string>
pdfs;
2547 for (
auto &
c :
rhs.components()) {
2548 if ((*
this)[
"pdfs"]->find(
c->GetName())) {
2549 pdfs.insert(
c->GetName());
2553 Warning(
"Combine",
"No pdfs will be combined. Please check and/or rename pdfs to match");
2555 std::stringstream s;
2556 for (
auto &
p :
pdfs)
2558 Info(
"Combine",
"pdfs that will be combined: %s", s.str().c_str());
2561 std::set<std::string>
_np;
2563 for (
auto &
c :
rhs.np()) {
2564 if (
mynp.find(
c->GetName())) {
2565 _np.insert(
c->GetName());
2569 Warning(
"Combine",
"No correlated np");
2571 std::stringstream s;
2574 Info(
"Combine",
"np that will be shared (correlated): %s", s.str().c_str());
2576 std::set<std::string> _poi;
2578 for (
auto &
c :
rhs.poi()) {
2579 if (
mypoi.find(
c->GetName())) {
2580 _poi.insert(
c->GetName());
2584 Warning(
"Combine",
"No correlated poi");
2586 std::stringstream s;
2587 for (
auto &
p : _poi)
2589 Info(
"Combine",
"poi that will be shared (correlated): %s", s.str().c_str());
2606 for (
auto &
c :
rhs.components()) {
2608 (
c->fFolder ==
"!scratch" ||
c->fFolder ==
"!sets" ||
c->fFolder ==
"!snapshots" ||
c->fFolder ==
"!models"))
2612 Info(
"Combine",
"Combining %s into %s",
c->GetPath().c_str(), _c->GetPath().c_str());
2614 _c->Combine(*
c,
true);
2618 Info(
"Combine",
"Adding %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2621 }
catch (std::exception &
e) {
2622 Warning(
"Combine",
"Could not combine %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2628 for (
auto &
f :
rhs.factors()) {
2631 Info(
"Combine",
"Combining %s into %s",
f->GetPath().c_str(),
_f->GetPath().c_str());
2633 _f->Combine(*
f,
true);
2636 Info(
"Combine",
"Multiplying %s into %s",
f->GetPath().c_str(),
GetPath().c_str());
2644 for (
auto &
c :
rhs.components()) {
2645 if (
c->fFolder ==
"!sets") {
2647 Info(
"Combine",
"Extending set %s",
c->GetName());
2650 Info(
"Combine",
"Defining set %s",
c->GetName());
2657 for (
auto &
ds :
rhs.datasets()) {
2660 Info(
"Combine",
"Combining %s into %s",
ds->GetPath().c_str(),
_ds->GetPath().c_str());
2665 Info(
"Combine",
"Adding %s into %s",
ds->GetPath().c_str(),
GetPath().c_str());
2672 for (
auto &
v :
rhs.variations()) {
2675 Info(
"Combine",
"Combining variation %s into %s",
v->GetPath().c_str(),
_v->GetPath().c_str());
2677 _v->Combine(*
v,
true);
2680 Info(
"Combine",
"Varying %s into %s",
v->GetPath().c_str(),
GetPath().c_str());
2688 for (
auto &
b :
rhs.bins()) {
2690 Info(
"Combine",
"Combining %s into %s",
b->GetPath().c_str(),
_b->GetPath().c_str());
2691 _b->Combine(*
b,
true);
2693 Info(
"Combine",
"Extending with %s into %s",
b->GetPath().c_str(),
GetPath().c_str());
2719 if (!
chans.empty()) {
2730 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2736 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2738 std::shared_ptr<RooProdPdf> pdf =
2739 std::dynamic_pointer_cast<RooProdPdf>(out.
acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2744 std::dynamic_pointer_cast<RooAbsArg>(out.
acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2760 static std::unique_ptr<cout_redirect>
capture;
2770 if (
sOpt.Contains(
"depth=")) {
2775 if (
sOpt.Contains(
"indent=")) {
2781 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2787 if (
get() &&
get() !=
this) {
2792 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2796 std::cout <<
"Minimization Logs:" << std::endl;
2797 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2811 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2817 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2824 for (
auto &
c : pi->interpolationCodes())
2832 for (
auto &
c :
fiv->interpolationCodes())
2841 }
else if (!
get()) {
2842 std::cout << std::endl;
2846 std::vector<std::string> folderNames;
2847 for (
auto &k : *
this) {
2848 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2849 folderNames.push_back(k->fFolder);
2852 for (
auto &
f : folderNames) {
2858 std::cout <<
f << std::endl;
2861 for (
auto &k : *
this) {
2862 if (k->fFolder !=
f) {
2868 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2872 auto _deps = k->coords(
false).argList();
2873 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2875 k->get()->Print(
sOpt);
2879 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2887 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2893 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2900 for (
auto &
c : pi->interpolationCodes())
2908 for (
auto &
c :
fiv->interpolationCodes())
2914 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2920 std::cout <<
" NULL " << std::endl;
2928 for (
size_t i = 0; i <
captureStr.size(); i++) {
2939 (
gROOT->GetListOfBrowsers()->At(0))
2954 double mean = std::numeric_limits<double>::quiet_NaN();
2955 double sigma = mean;
2964 mean = std::numeric_limits<double>::quiet_NaN();
2975 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2981 throw std::runtime_error(
"No error on parameter for poisson constraint");
2983 sigma = pow(
v->getVal() /
v->getError(), 2);
2991 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2992 globs->setConstant();
2993 globs->setAttribute(
"obs");
2994 globs->setAttribute(
"global");
3007 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
3014 globs->setAttribute(
"obs");
3015 globs->setAttribute(
"global");
3016 globs->setConstant();
3025 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
3034 throw std::runtime_error(
"Cannot constrain non arg");
3037 if (!
p->dependsOn(*
_me)) {
3038 throw std::runtime_error(
"Constraint does not depend on constrainee");
3047 throw std::runtime_error(
"Nowhere to put constraint");
3052 for (
auto d :
x->datasets()) {
3062 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
3071 for (
auto &
c : *
x) {
3077 return x->Multiply(
child);
3079 return x->Add(
child,
"+");
3102 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
3125 ?
fParent->mainChild()->GetName()
3132 throw std::runtime_error(
3152#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3159 for (std::size_t i = 0; i <
pSet.size(); i++) {
3169 _bin->fBinNumber = -1;
3198 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3203 std::rethrow_exception(std::current_exception());
3215 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
3219 }
else if (
sOpt ==
"const") {
3222 Info(
"Multiply",
"Scaled %s by new const factor %s",
3226 }
else if (
sOpt ==
"norm") {
3233 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3238 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
3242 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3246 }
else if (
sOpt ==
"shape" ||
sOpt ==
"simple" ||
sOpt ==
"blankshape") {
3251 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
3252 h->SetBinContent(i, 1);
3257 h->SetTitle(
child.GetTitle());
3258 if (
sOpt.Contains(
"shape"))
3262 Info(
"Multiply",
"Scaled %s by new %s factor %s",
3267 }
else if (
sOpt ==
"overall") {
3269 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
3271 Info(
"Multiply",
"Scaled %s by new overall factor %s",
3275 }
else if (
sOpt ==
"func" &&
ws()) {
3280 Info(
"Multiply",
"Scaled %s by new func factor %s",
3293 std::shared_ptr<TObject> out;
3294 child.convertForAcquisition(*
this);
3305 if (
p->coefList().empty() && !
p->pdfList().empty()) {
3306 for (
auto _pdf :
p->pdfList()) {
3312 Info(
"Multiply",
"Created RooExtendedBinding coefficients for all pdfs of %s so that can multiply coef",
3314 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3315 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
3316 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3317 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
3319 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
3321 auto coefs =
p->coefList().at(i);
3330 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
3337 const_cast<RooArgList &
>(
p->coefList()).removeAll();
3347 for (
size_t i = 0; i <
p2->funcList().
size(); i++) {
3349 auto coefs =
p2->coefList().at(i);
3358 for (
size_t j = 0;
j <
p2->coefList().size();
j++) {
3373 throw std::runtime_error(
"this coefs case is not supported");
3377 std::shared_ptr<TObject> out;
3384 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
3386 _f &&
_f->getAttribute(
"autodensity")) {
3396 if (
_f->getAttribute(
"density")) {
3399 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
3403 _f->setValueDirty();
3410 _f->setAttribute(
"autodensity",
false);
3414 Info(
"Multiply",
"Created %s factor %s in %s",
3418 Info(
"Multiply",
"Created Shape factor %s in %s",
child->GetName(),
p->GetName());
3421 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
3422#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3423 p->_compRSet.add(*
_f);
3431 for (
auto &_par :
_out.pars()) {
3434 for (
auto &
_constr : _par->constraints()) {
3442 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
3445 throw std::runtime_error(
"Couldn't find boundConstraint");
3447 _par->Constrain(_pdf);
3456 std::shared_ptr<TObject> out;
3457 child.convertForAcquisition(*
this);
3466 std::shared_ptr<RooAbsPdf> _pdf;
3483 _pdf->setStringAttribute(
"alias",
child.GetName());
3485 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
3486 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
3488 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
3493 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3494#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3496#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
3497 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
3501 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
3502 p2->_extendedIndex =
p2->_pdfList.size() - 1;
3513 std::shared_ptr<TObject> out;
3514 child.convertForAcquisition(*
this);
3520 TString s =
p3->getStringAttribute(
"global_factors");
3523 s += out->GetName();
3524 p3->setStringAttribute(
"global_factors", s);
3527 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3528 out->GetName(),
p3->GetName());
3539 std::set<RooAbsArg *> cl;
3540 for (
auto &arg :
p5->clients()) {
3546 if (cl.size() > 1) {
3551 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3557 for (
auto &
a :
p5->attributes())
3558 new_p->setAttribute(
a.c_str());
3559 for (
auto &
a :
p5->stringAttributes())
3560 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3561 if (!
new_p->getStringAttribute(
"alias"))
3562 new_p->setStringAttribute(
"alias",
p5->GetName());
3565 for (
auto arg : cl) {
3577 throw std::runtime_error(
3579 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3587 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3596 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3598 std::set<RooAbsArg *> cl;
3599 for (
auto &arg :
p5->clients()) {
3607 if (cl.size() > 1) {
3615 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3619 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3620 for (
auto arg : cl) {
3644 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3649 std::rethrow_exception(std::current_exception());
3661 std::string label =
child.GetName();
3662 if (
auto pos = label.find(
'='); pos != std::string::npos)
3663 label = label.substr(pos + 1);
3664 if (!s->indexCat().hasLabel(label)) {
3669 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3674 throw std::runtime_error(
TString::Format(
"Failed to find %s regular observable in %s dataset",
3675 s->indexCat().GetName(),
_ds->GetName()));
3677 dsCat->defineType(label.c_str());
3683 std::shared_ptr<TObject> out;
3684 child.convertForAcquisition(*
this);
3687 }
else if (!
child.fComp) {
3690 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3693 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3698 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3707 _pdf->leafNodeServerList(&
leafs);
3708 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
3712 globs.addClone(*
_ds->getGlobalObservables());
3716 alist += std::string(
aa->GetName()) +
",";
3719 if (!alist.empty()) {
3720 Warning(
"Vary",
"Adding %s to global observables of %s", alist.c_str(),
_ds->GetName());
3726 s->addPdf(*_pdf, label.c_str());
3738 child.convertForAcquisition(*
this);
3740 if (!_c &&
child.get()) {
3741 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3743#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3744 double value = (_c ? _c->getVal() :
p->_nominal);
3747 double value = (_c ? _c->getVal() :
p->nominal());
3752 if (
cName ==
"nominal") {
3756 if (
cName.CountChar(
'=') != 1) {
3757 throw std::runtime_error(
"unsupported variation form");
3762 throw std::runtime_error(
"unsupported variation magnitude");
3775 if (!
p->findServer(*
v)) {
3776#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3777 p->_paramList.add(*
v);
3778 p->_low.push_back(0);
3779 p->_high.push_back(0);
3780 p->_interpCode.push_back(4);
3783 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3784 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3785 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3787 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3792 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3795 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3798 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3801 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3811 if (
cName.CountChar(
'=') != 1) {
3812 throw std::runtime_error(
"unsupported variation form");
3817 throw std::runtime_error(
"unsupported variation magnitude");
3819#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3822 throw std::runtime_error(
3823 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3828 throw std::runtime_error(
3829 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3835 for (
auto par :
p2->paramList()) {
3836 if (
parName == par->GetName()) {
3850 std::shared_ptr<RooHistFunc>
up(
3852 std::shared_ptr<RooHistFunc>
down(
3855#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3856 std::unique_ptr<RooDataHist>
h1(
3858 std::unique_ptr<RooDataHist> h2(
3860 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3866 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3867 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3868#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3869 p2->_highSet.add(*
ups.get());
3870 p2->_lowSet.add(*
downs.get());
3871 p2->_interpCode.push_back(4);
3872 p2->_paramSet.add(*
v);
3876 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3879 p2->setValueDirty();
3883 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3884 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3885 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3903#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
3906 if (
cName.CountChar(
'=') != 1) {
3907 throw std::runtime_error(
"unsupported variation form");
3913 if (!
pmr->indexCategory()->hasLabel(
parVal.Data())) {
3916 auto idx =
pmr->indexCategory()->lookupIndex(
parVal.Data());
3918 throw std::runtime_error(
"Invalid index");
3921 child.convertForAcquisition(*
this);
3924 if (
pmr->getModelList().empty()) {
3925 throw std::runtime_error(
"No real function given for variation, and no nominal function to clone");
3927 _c = std::dynamic_pointer_cast<RooAbsReal>(
3928 acquire(std::shared_ptr<TObject>(
pmr->getModelList().at(0)->Clone(
3932 _c->setStringAttribute(
"alias",
child.GetName());
3942 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3943 throw std::runtime_error(
"Cannot vary pure constants");
3949 std::set<RooAbsArg *> cl;
3950 for (
auto &arg :
p3->clients()) {
3955 if (cl.size() > 1) {
3960 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3963 p3->setStringAttribute(
"origName",
p3->GetName());
3965 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3968 std::vector<double>(), std::vector<double>());
3971 for (
auto &
a :
p3->attributes())
3972 new_p->setAttribute(
a.c_str());
3973 for (
auto &
a :
p3->stringAttributes())
3974 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3978 for (
auto arg : cl) {
3989 std::set<RooAbsArg *> cl;
3990 for (
auto &arg :
p4->clients()) {
3995 if (cl.size() > 1) {
4000 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
4003 p4->setStringAttribute(
"origName",
p4->GetName());
4005 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
4007#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
4008 std::shared_ptr<RooAbsArg>
new_p;
4011 if (
cName.CountChar(
'=') == 1) {
4018 throw std::runtime_error(
"Failed to acquire categorical index for RooMultiReal");
4021 if (
idxCat->numTypes() == 0) {
4022 idxCat->defineType(
"nominal");
4024 Info(
"Vary",
"Creating a RooMultiReal with category %s",
idxCat->GetName());
4041 for (
auto &
a :
p4->attributes())
4042 new_p->setAttribute(
a.c_str());
4043 for (
auto &
a :
p4->stringAttributes())
4044 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
4048 for (
auto arg : cl) {
4091 a->setStringAttribute(
"alias",
GetName());
4094 throw std::runtime_error(
"Cannot determine type");
4099 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
4116 throw std::runtime_error(
"no xaxis");
4121 if (
h->GetXaxis()->IsVariableBinSize()) {
4122 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
4130 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
4139 throw std::runtime_error(
"Failed setting stat error");
4143 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
4155 throw std::runtime_error(
"Assignment failed");
4188 std::map<RooAbsRealLValue *, double>
valsToSet;
4190 auto idx = pattern.
Index(
'=');
4193 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4195 for (
auto p :
_pars.argList()) {
4198 p->setAttribute(
"Constant",
true);
4199 if (!std::isnan(val)) {
4207 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4223 val.
IsAlpha() ? val :
nullptr));
4230 if (
d->get()->TestBit(1 << 20)) {
4240 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
4241 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
4242 auto fr = _nll.minimize();
4245 throw std::runtime_error(
"Fit Failed");
4248 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
4252 (
gROOT->GetListOfBrowsers()->At(0))
4256 if (_nll.fOpts->find(
"GoF")) {
4258 fr->constPars().getRealValue(
".mainterm_pgof"));
4260 if (fr->status() != 0) {
4262 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4266 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
4267 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
4268 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4274 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4279 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4292 fb->DoubleClicked(
p, 0);
4293 if (
auto first =
p->GetFirstChild()) {
4295 if (first->IsOpen() &&
TString(first->GetText()) ==
"fits") {
4296 fb->DoubleClicked(first, 0);
4298 }
while ((first = first->GetNextSibling()));
4308 }
catch (
const std::exception &
e) {
4311 (
gROOT->GetListOfBrowsers()->At(0))
4324 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4337 fb->DoubleClicked(
p, 0);
4338 if (
auto first =
p->GetFirstChild()) {
4340 if (first->IsOpen() &&
TString(first->GetText()) ==
"datasets") {
4341 fb->DoubleClicked(first, 0);
4343 }
while ((first = first->GetNextSibling()));
4353 }
catch (
const std::exception &
e) {
4356 (
gROOT->GetListOfBrowsers()->At(0))
4359 "Exception",
e.what(),
4366 const char *options)
4376 if (
d->get()->TestBit(1 << 20)) {
4382 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
4385 auto idx = pattern.
Index(
'=');
4388 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4390 for (
auto par :
_pars.argList()) {
4393 par->setAttribute(
"Constant",
true);
4394 if (!std::isnan(val)) {
4400 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4416 val.
IsAlpha() ? val :
nullptr));
4420 hs.SetName(
TUUID().AsString());
4432 (
gROOT->GetListOfBrowsers()->At(0))
4435 "Scan Finished with Bad Status Code",
4440 if (
auto res =
hs.result())
4447 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4460 fb->DoubleClicked(
p, 0);
4461 if (
auto first =
p->GetFirstChild()) {
4463 if (first->IsOpen() &&
TString(first->GetText()) ==
"scans") {
4464 fb->DoubleClicked(first, 0);
4466 }
while ((first = first->GetNextSibling()));
4477 }
catch (
const std::exception &
e) {
4480 (
gROOT->GetListOfBrowsers()->At(0))
4491 }
catch (
const std::exception &
e) {
4500#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
4505 for (
auto a : *
this) {
4512 for (
auto c :
args) {
4518 f.SetParName(i,
c->GetName());
4520 f.SetParLimits(i,
v->getMin(),
v->getMax());
4521 if (
v->isConstant())
4522 f.FixParameter(i,
v->getVal());
4524 f.SetParameter(i,
v->getVal());
4525 f.SetParError(i,
v->getError());
4536 (
gROOT->GetListOfBrowsers()->At(0))
4542 for (i = 0; i <
f.GetNpar(); i++) {
4548 f.GetParLimits(i, low, high);
4550 v->setConstant(low);
4552 v->setRange(low, high);
4562 throw std::runtime_error(
"Failed to SetContent");
4563 }
catch (
const std::exception &
e) {
4577 std::shared_ptr<TH1D>
h;
4578 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
4579 if (
_b->isUniform()) {
4586 h->SetOption(
"nostyle");
4601 auto _ax = (bin) ?
GetXaxis() :
nullptr;
4603 throw std::runtime_error(
"Cannot determine binning to fill data");
4605 if (_ax && _ax->GetNbins() < bin) {
4606 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
4607 _ax->GetName(), _ax->GetNbins()));
4613 for (
auto _c :
coords()) {
4617 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
4625 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
4628 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
4637 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
4638 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
4670 l.remove(*_data->get(),
true,
true);
4675 _data->addColumn(*
x);
4685 for (
auto &o :
obs) {
4687 if (
auto dv =
dynamic_cast<RooRealVar *
>(_data->get()->find(
v->GetName()));
dv) {
4688 if (
v->getMin() <
dv->getMin())
4689 dv->setMin(
v->getMin());
4690 if (
v->getMax() >
dv->getMax())
4691 dv->setMax(
v->getMax());
4694 if (
auto dc =
dynamic_cast<RooCategory *
>(_data->get()->find(
c->GetName()));
dc) {
4695 if (!
dc->hasLabel(
c->getCurrentLabel())) {
4696 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
4705 if (
auto _nentries = std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula))->numEntries();
4710 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
4713 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4715 _data->add(*_obs,
_reduced->weight());
4718 for (
int i = 1; i <= _ax->GetNbins(); i++) {
4722 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
4728 if (std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula2))->numEntries() > 0) {
4731 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4733 _data->add(*_obs,
_reduced->weight());
4737 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
4744 throw std::runtime_error(
"RooDataHist not supported yet");
4749 if (!par ||
strlen(par) == 0) {
4752 return it->SetBinContent(bin,
value);
4764 if (!par ||
strlen(par) == 0) {
4777 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
4780#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4793 auto bin_pars =
f->dataHist().get(bin - 1);
4794 if (
f->getAttribute(
"density")) {
4802 f->setStringAttribute(
"symmetrized_by",
nullptr);
4804 x->setStringAttribute(
"symmetrizes",
nullptr);
4805 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4819 f2->setNominal(
value);
4828 push_back(std::make_shared<xRooNode>(
data));
4835 return node->SetBinContent(bin,
value);
4842 push_back(std::make_shared<xRooNode>(
data));
4849 return node->SetContents(obj);
4887 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4896 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4901 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4908 h->SetName(
"statFactor");
4910 h->SetOption(
"blankshape");
4919 throw std::runtime_error(
"Failed creating stat shapeFactor");
4925 TString prefix =
f->getStringAttribute(
"statPrefix");
4926 if (
value && prefix ==
"") {
4930 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4931 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4938 Form(
"#gamma^{%s}_{%d}", prefix.
Data(), bin), 1);
4939#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4946 if (
newVar.get() != var) {
4950 for (std::size_t i = 0; i <
pSet.size(); i++) {
4951 if (
int(i) != bin - 1) {
4966 auto bin_pars =
f->dataHist().get(bin - 1);
4968 if (
f->getAttribute(
"density")) {
4974 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4975 if (s.find(
"sumw_") == 0) {
4977 }
else if (s.find(
"sumw2_") == 0) {
4981 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4983 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4984 rrv->setConstant(
false);
4989 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4994 double _min = tau * (1. - 5. * sqrt(1. / tau));
4995 double _max = tau * (1. + 5. * sqrt(1. / tau));
4998 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4999 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
5001 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
5005 v.constraints().Remove(*
_constr.at(0));
5024 throw std::out_of_range(
name +
" does not exist");
5046 xRooNode out(
".constraints",
nullptr, *
this);
5059 for (
auto &
c :
n.bins()) {
5070 for (
auto p : _ws->allPdfs()) {
5073 if (
p->dependsOn(par)) {
5074 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5082 for (
auto p : o->pdfList()) {
5085 if (
p->dependsOn(par)) {
5086 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5092 for (
auto &
p :
vars()) {
5098 if (
v->getAttribute(
"obs"))
5108 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
5109 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
5111 for (
auto &
c : out) {
5112 if (
c.get() == it->get())
5117 std::string
_cName =
c->GetName();
5121 }
while (
_cName.find(
';') != std::string::npos);
5123 _cName = it->get()->GetName();
5127 }
while (
_cName.find(
';') != std::string::npos);
5135 c->TNamed::SetName(
_cName.c_str());
5149 for (
auto &o : out) {
5150 o->TNamed::SetName(o->get()->GetName());
5171 while (
sOpt2.Contains(
"=")) {
5172 auto pos =
sOpt2.Index(
"=");
5173 auto start =
sOpt2.Index(
";") + 1;
5197 if (
auto pos =
varName.Index(
';'); pos != -1) {
5207 binningName =
ax->GetName();
5208 }
else if (
acquirer.obs().size() == 1)
5212 h->GetXaxis()->GetXmax());
5213 if (
x->getMin() >
h->GetXaxis()->GetXmin())
5214 x->setMin(
h->GetXaxis()->GetXmin());
5215 if (
x->getMax() <
h->GetXaxis()->GetXmax())
5216 x->setMax(
h->GetXaxis()->GetXmax());
5217 if (!
x->hasBinning(binningName.c_str())) {
5218 if (
h->GetXaxis()->IsVariableBinSize()) {
5219 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
5222 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
5223 binningName.c_str());
5225 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
5226 if (
x->getBinningNames().size() == 2) {
5228 x->setBinning(
x->getBinning(binningName.c_str()));
5232 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
5233 throw std::runtime_error(
5234 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
5238 std::shared_ptr<RooAbsArg>
_f;
5245 _f->setStringAttribute(k.c_str(),
v.c_str());
5247 x->setAttribute(
"obs",
true);
5248 }
else if (
sOpt2.Contains(
"shape")) {
5250 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
5251 std::shared_ptr<RooAbsArg> arg;
5252 if (
sOpt2.Contains(
"blankshape")) {
5257 }
else if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
5260 h->GetBinContent(i + 1),
h->GetMinimumStored(),
5261 h->GetMaximumStored());
5265 h->GetBinContent(i + 1));
5273 x->setBinning(
x->getBinning(binningName.c_str()));
5275#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5276 dynamic_cast<ParamHistFunc *
>(
_f.get())->_paramSet.setName(
"paramSet");
5279 .setName(
"paramSet");
5281 x->setBinning(*
tmp);
5284 _f->setStringAttribute(k.c_str(),
v.c_str());
5288 binningName.c_str() );
5290 throw std::runtime_error(
"Couldn't make data hist");
5295 f->setAttribute(
"autodensity");
5299 _f->setStringAttribute(k.c_str(),
v.c_str());
5303 _f->setStringAttribute(
"xvar",
x->GetName());
5304 _f->setStringAttribute(
"binning", binningName.c_str());
5311 _f = std::dynamic_pointer_cast<RooAbsArg>(
tmp.fComp);
5314 _f->setStringAttribute(
"xvar",
x->GetName());
5315 _f->setStringAttribute(
"binning", binningName.c_str());
5325 if (
sName.BeginsWith(
"factory:"))
5356 if (arg->getStringAttribute(
"style")) {
5357 t = arg->getStringAttribute(
"style");
5367 std::shared_ptr<TStyle>
style;
5369 if (!
gROOT->GetStyle(t)) {
5392 if (arg && !arg->getStringAttribute(
"style")) {
5393 arg->setStringAttribute(
"style",
style->GetName());
5411 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
5412 auto out_arg = _ws->arg(
a->GetName());
5419 if (
aName !=
a->GetName())
5420 Warning(
"acquire",
"Renaming to %s",
a->GetName());
5424 if (
auto res = _ws->factory(arg->GetName()); res) {
5431 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
5454 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
5464 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
5470 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
5471 }
else if (arg->InheritsFrom(
"TNamed")) {
5481 out_arg = _ws->genobj(arg->GetName());
5488 if (
aName != arg->GetName()) {
5489 Warning(
"acquire",
"Renaming to %s", arg->GetName());
5491 if (_ws->import(*arg,
false )) {
5495 out_arg = _ws->genobj(arg->GetName());
5507 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
5513 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
5519 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
5525 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
5527 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
5569 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
5572 _x->setBinning(binning,
a->
GetName());
5573 _x->getBinning(
a->GetName()).SetTitle(title);
5574 if (_x->getBinningNames().size() == 2) {
5576 _x->setBinning(_x->getBinning(
a->GetName()));
5581 if (_x->getMax() < high)
5583 if (_x->getMin() > low)
5589 _x->setAttribute(
"obs");
5592 a->setStringAttribute(
"xvar", _x->GetName());
5593 a->setStringAttribute(
"binning",
a->GetName());
5603 if (
ax->IsVariableBinSize()) {
5604 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
5606 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
5612 return find(
name,
false) !=
nullptr;
5620 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5621 for (
auto &
child : *
this) {
5624 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
5637 for (
auto &
child2 :
x.browse()) {
5663 auto out = std::make_shared<xRooNode>(obj, *
this);
5678 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5680 for (
auto &
child : *
this) {
5692 for (
auto &
child2 :
x.browse()) {
5704 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
5722 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
5725 out->SetName(
"!pdfs");
5728 return out->operator[](
name.substr(
partname.length() + 1));
5736 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5738 if (!
b || !
b->GetBrowserImp())
5745 if (!
b->GetBrowserImp())
5761 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5763 if (!
b || !
b->GetBrowserImp())
5770 if (
b->GetBrowserImp()) {
5788 a->setStringAttribute(
"alias",
name);
5789 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5790 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
5815 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5816 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5817 for (
auto &
c :
nn) {
5818 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5821 return std::shared_ptr<xRooNode>(
nullptr);
5826 const std::vector<std::shared_ptr<xRooNode>> &
nn(
n);
5827 for (
auto &
c :
nn) {
5840 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5841 for (
auto &
c :
nn2) {
5842 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5846 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5885 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5898 emplace_back(std::make_shared<xRooNode>(
_coefs));
5910 for (
int i = 0; i < arg->numProxies(); i++) {
5911 auto _proxy = arg->getProxy(i);
5921 for (
auto &
child : *
this) {
5929 for (
auto a2 : *s) {
5930 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5931 if (arg->numProxies() != 1) {
5932 c->fFolder = std::string(
"!.") +
5965 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5978 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5980 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5986 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5987 for (
auto &
c :
nn) {
6010 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
6011 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
6017 if (
auto fit =
hp->ufit()) {
6018 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
6020 if (
auto fit =
hp->cfit_null()) {
6021 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
6023 if (
auto fit =
hp->cfit_alt()) {
6024 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
6026 if (
auto fit =
hp->gfit()) {
6027 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
6029 if (
auto asi =
hp->asimov()) {
6030 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
6031 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
6033 asiP->TNamed::SetName(
"asimov");
6034 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
6040 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
6041 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
6042 if (it->get()->fTimes == 0) {
6043 for (
auto o : *
gROOT->GetListOfBrowsers()) {
6045 if (
b &&
b->GetBrowserImp()) {
6092 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
6094 for (
auto o :
vars()) {
6097 out.emplace_back(o);
6108 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
6110 for (
auto o :
obs()) {
6113 out.emplace_back(o);
6124 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
6126 for (
auto o :
obs()) {
6129 out.emplace_back(o);
6144 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
6146 for (
auto o :
vars()) {
6149 out.emplace_back(o);
6160 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
6162 for (
auto o :
pars()) {
6165 out.emplace_back(o);
6177 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
6179 for (
auto o :
pars()) {
6182 out.emplace_back(o);
6194 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
6196 for (
auto o :
pars()) {
6199 out.emplace_back(o);
6211 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
6213 for (
auto o :
pars()) {
6215 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
6218 out.emplace_back(o);
6229 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
6231 for (
auto o :
pars()) {
6235 out.emplace_back(o);
6246 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
6249 for (
auto &
x : *
this) {
6250 for (
auto &
y :
x->vars()) {
6265 if (!
c->getAttribute(
"global")) {
6267 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6269 if (
c->getAttribute(
"global")) {
6270 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6271 _globs.back()->fFolder =
"!globs";
6272 }
else if (
c->getAttribute(
"obs")) {
6273 out.back()->fFolder =
"!robs";
6274 }
else if (
c->getAttribute(
"poi")) {
6275 out.back()->fFolder =
"!poi";
6276 }
else if (
c->getAttribute(
"np") ||
6278 out.back()->fFolder =
"!np";
6280 out.back()->fFolder =
"!floats";
6282 out.back()->fFolder =
"!pp";
6288 out.emplace_back(
g);
6291 for (
auto a : *
p2->get()) {
6292 a->setAttribute(
"obs");
6293 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6296 if (
auto _dglobs =
p2->getGlobalObservables()) {
6298 a->setAttribute(
"obs");
6299 a->setAttribute(
"global");
6300 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6305 a->setAttribute(
"obs");
6306 a->setAttribute(
"global");
6307 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6310 }
else if (
auto _ws =
ws(); _ws) {
6313 a->setAttribute(
"obs");
6314 a->setAttribute(
"global");
6315 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6319 for (
auto &
_g :
_gl->second) {
6320 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6321 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6323 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6332 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6333 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6335 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6341 for (
auto a :
w->components()) {
6344 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6353 xRooNode out(
".components",
nullptr, *
this);
6358 for (
auto &o :
p->pdfList()) {
6361 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6379 for (
auto &o :
p2->funcList()) {
6382 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6386 for (
auto &o :
p3->list()) {
6387 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6390 for (
auto &
a : *
p4) {
6391 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6394 for (
auto &o :
p5->components()) {
6397 bool hasClients =
false;
6398 for (
auto &
c : o->clients()) {
6399 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
6406 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6407 if (o->InheritsFrom(
"RooAbsPdf")) {
6408 out.back()->fFolder =
"!pdfs";
6410 out.back()->fFolder =
"!scratch";
6413 for (
auto &o :
p5->allGenericObjects()) {
6417 s = s(0, s.
Index(
';'));
6418 if (
auto _pdf = out.
find(s.
Data()); _pdf) {
6420 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
6427 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
6429 out.back()->fFolder =
"!fits";
6431 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6433 out.back()->fFolder =
"!styles";
6434 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
6435 out.back()->fFolder =
"!scans";
6436 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::ModelConfig") == 0) {
6437 out.back()->fFolder =
"!models";
6439 out.back()->fFolder =
"!objects";
6446 if (k.find(
"CACHE_") == 0)
6448 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
6449 out.back()->fFolder =
"!sets";
6453 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
6455 while ((
snap = iter->Next())) {
6456 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
6457 out.back()->fFolder =
"!snapshots";
6462 out.emplace_back(std::make_shared<xRooNode>(
".pdf", *
mc->GetPdf(), *
this));
6464 if (
mc->GetExternalConstraints()) {
6465 out.emplace_back(std::make_shared<xRooNode>(
".extCons", *
mc->GetExternalConstraints(), *
this));
6471 out.emplace_back(
c);
6478 out.emplace_back(
c);
6492 xRooNode out(
".bins",
nullptr, *
this);
6495 std::map<int, std::shared_ptr<xRooNode>> cats;
6496 for (
auto &
c :
p->indexCat()) {
6497 auto pp =
p->getPdf(
c.first.c_str());
6501 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
6503 for (
auto &[
_,
n] : cats)
6504 out.emplace_back(
n);
6507#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6510 auto &
pSet =
phf->paramList();
6512 for (
auto par :
pSet) {
6513 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
6514 out.back()->fBinNumber = i;
6518 for (
int i = 1; i <=
ax->GetNbins(); i++) {
6524 for (
auto &
ss :
f->bins()[i - 1]->factors())
6531 out.emplace_back(std::make_shared<xRooNode>(
6532 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
6538#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6544 out.back()->fBinNumber = i;
6569 std::make_shared<RooProduct>(
".recursiveCoefs",
6574 auto mem = out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
6575 mem->emplace_back(std::make_shared<xRooNode>(
ourCoefs));
6588 if (!parent->fComp) {
6589 while (!parent->fComp && parent->fParent) {
6590 parent = parent->fParent;
6593 parent = parent->fParent;
6599 for (
auto &o :
p->funcList()) {
6601 if (i >=
p->coefList().size()) {
6603 coefs.add(
p->coefList());
6605 coefs.add(*
p->coefList().at(i));
6612 if (
p2->coefList().empty()) {
6617 for (
auto &o :
p2->pdfList()) {
6619 if (i >=
p2->coefList().size()) {
6623 coefs.add(*
p2->coefList().at(i));
6637 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
6638 "Coefficients of",
coefs));
6639 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
6640 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
6643 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
6645 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
6647 if (!
coefs.empty()) {
6651 }
else if (
coefs.size() == 1) {
6653 if (!
coefs.empty()) {
6672 xRooNode out(
".factors",
nullptr, *
this);
6677 a->setStringAttribute(
"alias",
"samples");
6679 a2->setStringAttribute(
"alias",
"components");
6681 int _npdfs =
p->pdfList().size();
6682 for (
auto &o :
p->pdfList()) {
6683 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6684 if (
_npdfs > 5 && o !=
_main.get() && out.back()->robs().size() == 0)
6685 out.back()->fFolder =
"!constraints";
6688 for (
auto &o :
p2->components()) {
6689 if (o->InheritsFrom(
"RooProduct")) {
6691 auto x =
xRooNode(
"tmp", *o, *
this).factors();
6693 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
6696 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6705 for (
auto a :
w->allFunctions()) {
6706 if (_obs.contains(*
a))
6709 for (
auto c :
a->clients()) {
6711 if (
c->InheritsFrom(
"RooProduct")) {
6717 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6761 xRooNode out(
".variations",
nullptr, *
this);
6774#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6775 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
6777 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
6779 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
6781 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
6782 *
p2->highList().at(i), *
this));
6783 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
6784 *
p2->lowList().at(i), *
this));
6787#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6788 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
6789 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
6790 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
6792 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
6796 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
6797 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
6798 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
6800 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
6824 for (
auto &k : *
this) {
6833 xRooNode out(
".datasets()",
nullptr, *
this);
6839 for (
auto &
d : _ws->allData()) {
6840 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
6841 out.back()->fFolder =
"!datasets";
6854 for (
auto _c :
coords()) {
6858 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6867 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6872 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6879 for (
auto cat : s->indexCat()) {
6880 if (!s->getPdf(cat.first.c_str())) {
6892 cutobs.add(s->indexCat());
6901 for (
auto &
child : *
this) {
6907 for (
auto &
d :
_wsNode.datasets()) {
6913 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6920 out.emplace_back(std::make_shared<xRooNode>(
6925 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6927 if (
d->get()->TestBit(1 << 20))
6928 out.back()->get()->
SetBit(1 << 20);
6930 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6932 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6954 xRooNode out(
".parents",
nullptr, *
this);
6956 for (
auto c :
a->clients()) {
6957 out.push_back(std::make_shared<xRooNode>(*
c, *
this));
6966 xRooNode out(
".args",
w->components(), *
this);
6970 xRooNode out(
".args", std::make_shared<RooArgList>(), *
this);
7001 for (
auto o : *
fromPad->GetListOfPrimitives()) {
7021 cat->numTypes(), 0, cat->numTypes());
7023 std::map<int, std::string> cats;
7024 for (
auto &
c : *cat) {
7025 cats[
c.second] =
c.first;
7027 for (
auto &[
_, label] : cats) {
7028 theHist->GetXaxis()->SetBinLabel(i++, label.c_str());
7031 auto _binning =
v->getBinningPtr(
nullptr);
7032 if (_binning->isUniform()) {
7036 v->numBins(), _binning->lowBound(), _binning->highBound());
7041 v->numBins(), _binning->array());
7045 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
7058 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
7073 if (
auto w =
theData->weightVar();
w &&
w->getStringAttribute(
"fitResult")) {
7076 if (
w->getAttribute(
"expected")) {
7093 : (
theHist->GetXaxis()->IsAlphanumeric() ?
theHist->GetXaxis()->GetTimeFormatOnly()
7094 :
theHist->GetXaxis()->GetName()));
7113 int nevent =
theData->numEntries();
7114 for (
int i = 0; i < nevent; i++) {
7119 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
7125 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
7158 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
7160 double val =
theHist->GetBinContent(i + 1);
7163 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
7166 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
7179 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
7183 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
7184 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
7218 throw std::runtime_error(
"Cannot build graph");
7224 if (
auto _w =
ws();
_w) {
7226 for (
auto o :
_w->allGenericObjects()) {
7228 _fr->ResetBit(1 << 20);
7231 res->SetBit(1 << 20);
7233 auto allVars =
_w->allVars();
7238 throw std::runtime_error(
"Not supported yet");
7252 throw std::runtime_error(
"Not a RooFitResult");
7263#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
7275 if (
sOpt ==
"prefit") {
7289 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
7290 fr->setFinalParList(*
_pars);
7291 for (
auto &
p : fr->floatParsFinal()) {
7295 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
7298 std::shared_ptr<xRooNode>
pConstr;
7305 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
7306 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
7323 for (
auto &_d :
pConstr->vars()) {
7324 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
7348 if (!
_v->getStringAttribute(
"nominal"))
7360 _args.add(
_globs.argList());
7361 fr->setConstParList(_args);
7364 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7367 fr->setInitParList(*
_snap);
7372 if (
auto _w =
ws();
_w) {
7379 for (
auto p :
pars()) {
7382 if (
_fr->floatParsFinal().find(
p->GetName()) ||
7384 std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
7388 _fr->constPars().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7393 if (!
_fr->floatParsFinal().find(
p->GetName())) {
7396 std::abs(
_fr->floatParsFinal().getRealValue(
p->GetName(),
7397 std::numeric_limits<double>::quiet_NaN()) -
7401 _fr->floatParsFinal().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7417 for (
size_t i = 0; i <
newFloats.size(); i++) {
7433 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
7436 fr->setCovarianceMatrix(
cov);
7437 fr->setInitParList(
_fr->floatParsInit());
7442 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
7447 for (
auto o :
_w->allGenericObjects()) {
7473 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
7475 fr->setFinalParList(*
_pars);
7481 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
7482 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
7483 cov(i,
j) = (*prevCov)(i,
j);
7488 for (
auto &
p : fr->floatParsFinal()) {
7491 cov(i, i) = pow(
v->getError(), 2);
7499 fr->setCovarianceMatrix(
cov);
7506 _args.add(
_globs.argList());
7507 fr->setConstParList(_args);
7510 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7513 fr->setInitParList(*
_snap);
7543 o->setStringAttribute(
"range",
range);
7550 std::string &out =
fRange;
7551 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
7552 out = o->getStringAttribute(
"range");
7554 while (out.empty() && _parent) {
7555 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
7556 out = o->getStringAttribute(
"range");
7557 _parent = _parent->fParent;
7582 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
7588 return nll(_data,
l);
7606 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7607 "generate with (found at least %s and %s)",
7613 return mainModel->generate(fr, expected, seed);
7621 std::string selected;
7624 for (
auto c :
bins()) {
7635 if (!selected.empty())
7637 selected +=
cName.Data();
7646 if (
d->get()->TestBit(1 << 20)) {
7652 throw std::runtime_error(
7653 "Need at least one dataset selected (SetChecked) to use for deselected regions");
7685 std::unique_ptr<RooFitResult>
newFr;
7687 newFr = std::make_unique<RooFitResult>(*
_fr);
7699 for (
auto par :
_pars) {
7709 newFr = std::make_unique<RooFitResult>(*
_fr);
7710 for (
auto par :
_pars) {
7732 if (
mc->GetExternalConstraints()) {
7734 for (
auto o :
opts) {
7759 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7760 "build nll with (found at least %s and %s)",
7769 throw std::runtime_error(
TString::Format(
"Workspace has multiple pdfs, you must specify which to "
7770 "build nll with (found at least %s and %s)",
7781 std::string selected;
7783 for (
auto c :
bins()) {
7789 if (!selected.empty())
7804 _d = std::make_shared<xRooNode>(
asi.first, *
this);
7807 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
7817 me.push_back(std::make_shared<xRooNode>(_data));
7834 for (
int i = 0; i <
opts.GetSize(); i++) {
7837 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
7848 std::dynamic_pointer_cast<RooAbsData>(_data.
fComp), *
_opts);
7950 while (pattern.NextToken()) {
7958 for (
auto &
c :
bins()) {
7961 _cat.setLabel(
cName);
7971 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
7985 std::vector<TObject *>
funcs;
7995 funcs.push_back(
c->get());
7999 if (!
funcs.empty()) {
8001 _pdf->setFloor(
false);
8027 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
8029 fr->setCovarianceMatrix(
_tmp);
8031 const_cast<RooArgList &
>(fr->floatParsFinal())
8042 for (
auto c : *
this) {
8043 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
8047 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
8077 std::string
noName =
"___";
8079 for (
auto &
c : *
this) {
8171 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
8180 return getProjection(&intobs, _normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
8186 const std::function<
void(
int)> &setBin)
8188 const size_t nBins = bins.size();
8189 std::vector<double> out(nBins, 0.);
8209 if (
rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8219 std::stringstream
errMsg;
8220 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8221 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case."
8225 throw std::runtime_error(
errMsg.str());
8242 for (
size_t i = 0; i <
nPars; i++) {
8243 for (
size_t j = i;
j <
nPars;
j++) {
8244 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8253 for (
size_t k = 0; k < nBins; k++) {
8276 for (
size_t k = 0; k < nBins; k++) {
8283 for (
size_t k = 0; k < nBins; k++) {
8288 for (
size_t k = 0; k < nBins; k++) {
8300 F[k][
ivar] = (
hi - lo) * 0.5;
8306 for (
size_t k = 0; k < nBins; k++) {
8312 for (
size_t k = 0; k < nBins; k++) {
8317 for (
size_t k = 0; k < nBins; k++) {
8329 setBin(bins[nBins - 1]);
8334 for (
size_t k = 0; k < nBins; k++) {
8335 out[k] = std::sqrt(F[k] * (C * F[k]));
8352 fFunc(
"func",
"func",
this,
f),
8353 fCoef(
"coef",
"coef",
this),
8354 fExpPdf(
"expPdf",
"expPdf",
this)
8359 fCoef.setArg(*coef);
8363 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
8375 fExpectedEventsMode(
other.fExpectedEventsMode)
8382 return fFunc->binBoundaries(obs, xlo, xhi);
8387 return (fExpectedEventsMode ? 1. : fFunc) *
8388 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(_normSet) : 1.) *
8389 (fCoef.absArg() ? fCoef : 1.);
8400#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
8401 double oo = getPropagatedError(fr,
nset_in);
8402 if (std::isnan(
oo)) {
8421 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8431 std::stringstream
errMsg;
8433 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8434 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
8436 throw std::runtime_error(
errMsg.str());
8441 if (paramList.
empty())
8476#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8500 std::vector<double>
errVec(paramList.
size());
8501 for (std::size_t i = 0; i < paramList.
size(); i++) {
8502 errVec[i] = std::sqrt(V(i, i));
8503 for (std::size_t
j = i;
j < paramList.
size();
j++) {
8504 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8511 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8516 double sum = F * (C *
F);
8526 if (
frv->getError() > 1
e-20) {
8543 for (
Int_t i = 0; i <
fpf.size(); i++) {
8546 paramList.
add(*par);
8582 std::vector<double>
errVec(paramList.
size());
8583 for (
int i = 0; i < paramList.
size(); i++) {
8584 errVec[i] = sqrt(V(i, i));
8585 for (
int j = i;
j < paramList.
size();
j++) {
8586 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
8593 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8598 double sum = F * (C *
F);
8612 bool fExpectedEventsMode =
false;
8620 std::cout <<
"Got signal " <<
signum << std::endl;
8622 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
8635 for (
int i = 0; i < obj->numCaches(); i++) {
8641 p->setNormRange(
p->normRange());
8643#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8648 p->setProxyNormSet(
nullptr);
8649 p->_lastNSet =
nullptr;
8652 obj->setValueDirty();
8656 for (
auto &
c :
w->components()) {
8676 for (
auto obj :
a->clients()) {
8683 }
while (
a->clients().size() !=
nClients);
8702 out.
fComp = std::shared_ptr<TH1>(
8703 BuildHistogram(
nullptr, !
content,
errors, -1, -1, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
false));
8704 }
else if (
vars.size() == 1) {
8706 out.
fComp = std::shared_ptr<TH1>(
8707 BuildHistogram(
v, !
content,
errors, 1, 0, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
true));
8709 throw std::runtime_error(
"multi-dim histo not yet supported");
8748 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8749 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8750 h->GetXaxis()->SetTimeFormat(
rar->GetName());
8769 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8772 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8773 h->SetBinContent(1,
rar->getVal());
8774 if (
x->getError()) {
8775 h->SetBinError(1,
x->getError());
8776 h->SetFillStyle(3005);
8777 h->SetFillColor(
h->GetLineColor());
8779 h->SetMaximum(
x->hasMax() ?
x->getMax()
8780 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8781 h->SetMinimum(
x->hasMin() ?
x->getMin()
8782 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8785 h->SetMarkerSize(0);
8786 h->SetMarkerStyle(0);
8791 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
8792 if (binningName ==
"")
8793 binningName =
rar->GetName();
8794 if (
x->hasBinning(binningName)) {
8795 if (
x->getBinning(binningName).isUniform()) {
8797 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
8798 x->getMin(binningName),
x->getMax(binningName));
8801 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
8803 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
8805 }
else if (
auto _boundaries =
8806 _or_func( (std::list<double> *)(
nullptr),
8807 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
8808 std::numeric_limits<double>::infinity()));
8810 std::vector<double>
_bins;
8811 for (
auto &
b : *_boundaries) {
8818 }
else if (!
x->hasMax() || !
x->hasMin()) {
8821 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
8824 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
8830 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
8834 std::map<int, std::string> cats;
8835 for (
auto &
c : *cat) {
8836 cats[
c.second] =
c.first;
8838 for (
auto &[
_, label] : cats) {
8839 h->GetXaxis()->SetBinLabel(i++, label.c_str());
8845 h->GetXaxis()->SetTitle(o->GetTitle());
8849 if (
h->GetXaxis()->IsAlphanumeric()) {
8858 if (
auto s =
styles(
nullptr,
false); s) {
8864 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
8865 h->GetXaxis()->SetTitle(
vv->GetTitle());
8894 if (!
GETDMP(fr, _finalPars)) {
8907 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
8908 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
8909 cov(i,
j) = (*prevCov)(i,
j);
8929 _pars.remove(*_p,
true);
8962 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
8980 for (
auto o : _obs) {
8985 rr->setStringAttribute(
"coordRange",
nullptr);
8989 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8993 rr->setStringAttribute(
"coordRange",
nullptr);
9003 bool hasRange =
false;
9006 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
9016 for (
auto pdf :
bins()) {
9023 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
9025 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
9029 rar =
p->createProjection(
9033 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
9037 p->setNormRange(
"coordRange");
9042 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
9048 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
9066 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
9088 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
9091 -std::numeric_limits<double>::infinity(),
9092 std::numeric_limits<double>::infinity()))))
9105 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
9123 auto l =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
9126 h->GetListOfFunctions()->Add(
l, (
setInterp) ?
"lsame" :
"histsame");
9130 h->SetMarkerSize(0);
9131 h->SetFillStyle(3005);
9132 h->SetFillColor(
h->GetLineColor());
9148 auto l =
static_cast<TH1 *
>(
h->Clone(
"toys"));
9151 h->GetListOfFunctions()->Add(
9166 static_cast<TH1 *
>(
main_h->GetListOfFunctions()->FindObject(
"toys"))->GetListOfFunctions()->
Add(
h);
9175 if (
_vv->getError() == 0)
9180 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
9183 x->setVal(
h->GetBinCenter(i));
9185 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
9189 if (
x && !
x->inRange(
"coordRange"))
9193 if (!empty ||
toy > 0) {
9195#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9204 r *=
h->GetBinWidth(i);
9212 h->SetBinContent(i,
r);
9230 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
9240 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
9255 std::unique_ptr<RooAbsReal>
errFunc;
9263 errFunc = std::make_unique<RooProduct>(
9264 "errorEval",
"errorEval",
9269 auto setBin = [&](
int i) {
9271 x->setVal(
h->GetBinCenter(i));
9273 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
9284 std::vector<double>
errHi;
9288#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9291 p->_normSet =
nullptr;
9295 for (
size_t k = 0; k <
errorBins.size(); k++) {
9299 resLo *=
h->GetBinWidth(i);
9300 h->SetBinError(i,
resLo);
9304 resHi *=
h->GetBinWidth(i);
9307 h->SetBinContent(i,
h->GetBinContent(i) + (
resHi -
resLo) * 0.5);
9329 auto nomHist =
static_cast<TH1 *
>(
h->FindObject(
"nominal"));
9332 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9333 std::vector<double> vals;
9341 std::sort(vals.begin(), vals.end());
9350 upVal =
h->GetBinContent(i) + err;
9351 downVal =
h->GetBinContent(i) - err;
9359 std::vector<RooAbsArg *> extra;
9362 for (
auto _pdf : s->servers()) {
9364 extra.push_back(_pdf);
9367 extra.push_back(
rar);
9370 for (
auto a : extra)
9377 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
9379 h->GetYaxis()->SetTitle(
"Events");
9381 h->GetYaxis()->SetTitle(
"Probability Mass");
9383 h->GetYaxis()->SetMaxDigits(3);
9392 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"copy"));
9396 hCopy->SetStats(
false);
9397 h->GetListOfFunctions()->Add(
hCopy,
TString(
h->GetOption()) +
"same");
9398 h->GetListOfFunctions()->Add(
hCopy,
"axissame");
9416 std::vector<TH1 *>
hhs;
9424 if (!
rarNode->components().empty()) {
9427 if (
c->fFolder ==
"!.coeffs" ||
c->fFolder ==
"!.coeffpars")
9433 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
9440 std::unique_ptr<RooAbsReal>
forig(
9441 dynamic_cast<RooAbsReal *
>(
rarNode->components()[0]->get()->Clone(
"tmpCopy0")));
9445 zero.setAttribute(
Form(
"ORIGNAME:%s",
c->GetName()));
9447 std::unique_ptr<RooAbsReal>
f(
dynamic_cast<RooAbsReal *
>(
forig->Clone(
"tmpCopy")));
9452 hh->SetName(
c->GetName());
9454 hh->Scale(
sf->getVal());
9456 hh->SetTitle(
c->GetName());
9463 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9468 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
9472 hh->TH1::Reset(
"ICE");
9487 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
9489 hh->SetTitle(
samp->GetTitle());
9491 hh->SetTitle(
samp->GetName());
9493 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9497 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
9501 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
9507 auto hh =
samp->BuildHistogram(
9508 v, empty,
false ,
binStart,
binEnd,
_fr,
false,
false, 0,
h,
true,
9510 hh->SetName(
samp->GetName());
9512 hh->Scale(
sf->getVal());
9519 hh->SetTitle(
samp->GetName());
9521 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9535 for (
auto &
hh :
hhs) {
9586 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
9601 (*ritr)->SetTitle(
_title.c_str());
9605 for (
auto &
hh :
hhs) {
9616 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
9637 h->GetListOfFunctions()->AddFirst(stack,
"noclear same");
9646 if (
ll &&
ll->GetEntries()) {
9649 for (
auto ho : *
ll) {
9657 hh->SetFillStyle(1001);
9661 if (!
gROOT->GetColor(
hh->GetFillColor())) {
9663 hh->SetFillColor(0);
9667 for (
auto ho2 : *
ll) {
9688 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
9691 hh->SetFillColor(10);
9704 push_back(std::make_shared<xRooNode>(
data));
9712 return std::numeric_limits<double>::quiet_NaN();
9713 return node->GetBinContent(bin);
9724 std::vector<double> out;
9736 for (
int i = 0; i <
g->GetN(); i++)
9737 integral +=
g->GetPointY(i);
9738 out.push_back(integral);
9743 out.push_back(
g->GetPointY(i));
9764 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9765 tot +=
h->GetBinContent(i);
9770 out.push_back(
h->GetBinContent(i));
9781 for (
auto &
l :
a->servers()) {
9801 if (
auto o =
get(); o) {
9810#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9814 for (
int i = 0; i <
p->fCGnx; i++) {
9815 for (
int j = 0;
j <
p->fCGny;
j++) {
9816 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
9819 p->FillCollideGrid(o);
9828 if (
p->Collide(i,
j,
iw,
ih)) {
9839 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
9847 gPad->PaintModified();
9853 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
9854 1. -
gPad->GetTopMargin() - 0.08);
9855 l->SetBorderSize(0);
9856 if (
l->GetTextSize() == 0)
9864 l->ConvertNDCtoPad();
9870 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
9873 double w =
p->GetX2NDC() -
p->GetX1NDC();
9874 double h =
p->GetY2NDC() -
p->GetY1NDC();
9876 gPad->PaintModified();
9880 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
9881 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
9882 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
9883 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
9884 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
9885 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
9897 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
9898 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
9906 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
9907 if (
l =
dynamic_cast<TLegend *
>(
p->GetPrimitive(
"legend"));
l || !create)
9911 gPad->GetBottomMargin());
9912 l->SetBorderSize(1);
9916 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
9917 l->SetBorderSize(0);
9919 if (
l->GetTextSize() == 0) {
9927 l->SetName(
"legend");
9929 l->ConvertNDCtoPad();
9936 auto i = s.find(
"\n");
9937 if (i == std::string::npos) {
9940 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
9949 for (
auto a : *
l->GetListOfPrimitives()) {
9953 if (
l->GetListOfPrimitives()->GetEntries() > 20)
9958 l->GetListOfPrimitives()->RemoveLast();
9959 l->GetListOfPrimitives()->AddFirst(
e);
9960 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
9962 int nn =
l->GetNColumns();
9965 l->SetNColumns(
l->GetNColumns() + 1);
9966 if (
l->GetBorderSize() == 0) {
9967 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
9970 if (
l->GetBorderSize() == 0) {
9971 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
9989#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
10005 if (
gROOT->FromPopUp()) {
10006 gROOT->SetFromPopUp(
false);
10009 }
catch (
const std::exception &
e) {
10012 (
gROOT->GetListOfBrowsers()->At(0))
10015 "Exception",
e.what(),
10018 gROOT->SetFromPopUp(
true);
10050 if (
d->get()->TestBit(1 << 20)) {
10056 hs.limits(
"cls visualize");
10068 [](
double a,
double b,
double) {
10071 if (
b == 0 &&
a == 0)
10078 [](
double n,
double b,
double sigma) {
10082 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
10092 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
10101 if (
sOpt2.Contains(
"x=")) {
10103 int _idx =
sOpt2.Index(
"x=");
10119 }
else if (
ii == 1) {
10121 }
else if (
ii == 2) {
10129 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
10132 }
else if (nBins == 1)
10133 xPoints.push_back((min + max) / 2.);
10142 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
10152 if (
sOpt2.Contains(
"force")) {
10166 Error(
"Draw",
"Can only compute forces with PDFs");
10178 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
10179 sOpt +=
"auxRatio";
10180 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
10181 sOpt +=
"auxSignif";
10192 sOpt.ReplaceAll(
"ratio",
"");
10193 sOpt.ReplaceAll(
"significance",
"");
10195 sOpt.ReplaceAll(
"nostack",
"");
10197 sOpt.ReplaceAll(
"same",
"");
10199 sOpt.ReplaceAll(
"goff",
"");
10201 sOpt.ReplaceAll(
"pull",
"");
10205 sOpt.ReplaceAll(
"e",
"");
10207 sOpt.ReplaceAll(
"txt",
"texte");
10209 sOpt.ReplaceAll(
"txt",
"text");
10222 if (
gPad->GetNumber() == 0) {
10242 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
10244 for (
auto o : *
pad->GetListOfPrimitives()) {
10251 :
hAxis->GetXaxis()->GetName())
10273 double ymin =
hh->GetMinimum();
10274 double ymax =
hh->GetMaximum();
10275 if (
hh->GetMaximumStored() == -1111)
10277 if (
hh->GetMinimumStored() == -1111) {
10280 }
else if (
ymin < 0) {
10288 if (
hh->GetSumw2()) {
10290 double smallestErrUp3 = std::numeric_limits<double>::infinity();
10291 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
10298 bool change =
false;
10311 double up =
ymax -
hh->GetBinContent(1);
10336 double ymax = -std::numeric_limits<double>::infinity();
10337 double ymin = std::numeric_limits<double>::infinity();
10338 for (
int i = 0; i <
gr->
GetN(); i++) {
10342 return std::make_pair(
ymin,
ymax);
10372 pad->Divide(1, 2, 1
e-9, 1
e-9);
10373 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
10374 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
10376 optNoFR.ReplaceAll(
"pull",
"");
10386 gPad->GetFrame()->SetFillStyle(1001);
10387 gPad->SetTopMargin(0);
10388 gPad->SetBottomMargin(0);
10389 gPad->SetName(
"pull");
10393 Error(
"Draw",
"Couldn't find pull graph");
10402 throw std::runtime_error(
"Could not find scales in fit result");
10404 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
10409 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
10413 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
10414 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
10418 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
10419 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
10420 g->SetEditable(
true);
10421 g->SetHighlight(
true);
10422 g->SetMarkerStyle(20);
10423 g->SetMarkerSize(0.5);
10449 if (!
_v->IsHidden())
10458 pad->SetBorderSize(0);
10484 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10487 auto _pad =
pad->GetPad(_size);
10488 _pad->SetName(
"legend");
10490 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
10493 while (
pad->GetPad(
x + 1)) {
10494 pad->GetPad(
x + 1)->SetFillStyle(0);
10504 if (_range &&
strlen(_range)) {
10511 if (
_v->IsHidden())
10528 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10543 for (
auto &
_v : *
this) {
10544 if (
_v->IsHidden())
10550 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10553 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10563 pad->SetBorderSize(0);
10564 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10567 for (
auto &
_v : *
this) {
10568 if (
_v->IsHidden())
10574 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10577 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10586 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10608 if (
sOpt.Contains(
"corr")) {
10615 TH2 *hist =
nullptr;
10618 std::set<std::pair<double, size_t>>
maxCorrs;
10628 std::vector<size_t>
topN;
10638 for (
size_t i = 0; i <
topN.size(); i++) {
10641 for (
size_t j = 0;
j <
topN.size();
j++) {
10664 gPad->SetGrid(1, 1);
10670 if (
sOpt.Contains(
"brakdown")) {
10676 if (
sOpt.Contains(
"brakdown:")) {
10680 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10681 if (_poi->empty()) {
10682 throw std::runtime_error(
"No floating poi in the fit");
10683 }
else if (_poi->size() != 1) {
10684 throw std::runtime_error(
"Multiple poi in the fit");
10686 poiName = _poi->first()->GetName();
10692 std::set<std::string>
groups;
10696 }
else if (
p->getStringAttribute(
"group")) {
10697 groups.insert(
p->getStringAttribute(
"group"));
10699 groups.insert(
p->GetTitle());
10724 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
10725 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
10733 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
10734 pie->SetEntryVal(i, 0);
10743 pie->SetEntryLabel(i,
group.c_str());
10758 pie->SetRadius(0.17);
10767 out->
SetTitle(
"Fit Result Pulls");
10771 ugraph->SetTitle(
"Fit Result Pulls");
10773 std::map<std::string, double>
scale;
10774 std::map<std::string, double>
offset;
10780 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
10781 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
10795 std::shared_ptr<xRooNode>
pConstr;
10798 if (
_vv->hasRange(
"pullScale")) {
10808 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
10809 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
10831 std::string
xName =
pConstr->find(
".x")->get()->GetName();
10833 for (
auto &_d :
pConstr->vars()) {
10834 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
10836 if (
xName == _d->get()->GetName())
10872 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
10887 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10906 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10919 for (
int i = 0; i <
ugraph->GetN(); i++)
10920 ugraph->SetPointX(i, i + graph->GetN());
10933 graph->SetMarkerStyle(20);
10934 graph->SetMarkerSize(0.5);
10936 graph->SetMaximum(4);
10937 graph->SetMinimum(-4);
10940 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
10942 std::vector<std::pair<double, std::string>>
covariances;
10945 if (
sOpt.Contains(
"impact")) {
10946 if (
sOpt.Contains(
"impact:")) {
10950 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10951 if (_poi->empty()) {
10952 throw std::runtime_error(
"No floating poi in the fit");
10953 }
else if (_poi->size() != 1) {
10954 throw std::runtime_error(
"Multiple poi in the fit");
10956 poiName = _poi->first()->GetName();
10977 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
10978 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
10979 : (std::abs(i.first) > std::abs(j.first));
11000 sortedGraph.SetPointError(
sortedGraph.GetN() - 1, 0, 0, graph->GetErrorYlow(i), graph->GetErrorYhigh(i));
11009 graph->SetTitle(
"Fit Result Impact");
11016 std::max(graph->GetN(), 1) - 0.5);
11025 hist =
new TH2D(
GetName(), fr->
GetTitle(), std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5,
11044 graph->GetHistogram()->GetXaxis()->Set(std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5);
11045 for (
int ii = 1;
ii <=
_axis->GetNbins();
ii++) {
11046 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
11061 gPad->Divide(1, 1, 1
e-9, 1
e-9);
11065 gPad->SetLeftMargin(0.4);
11067 gPad->SetBottomMargin(0.4);
11070 auto pNamesHist =
dynamic_cast<TH1F *
>(graph->GetHistogram()->Clone(
"scales"));
11074 for (
int ii = 1;
ii <= graph->GetN();
ii++) {
11078 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
11083 if (!
sOpt.Contains(
"impact")) {
11084 for (
int ii = 2;
ii >= 1;
ii--) {
11119 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
11120 pave->SetFillStyle(0);
11121 pave->SetBorderSize(0);
11122 pave->SetMargin(0.);
11123 pave->SetName(
"status");
11124 pave->SetTextAlign(31);
11130 case 0:
covQualTxt =
"Not calculated";
break;
11132 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
11147 gPad->SetTicks(0, 0);
11151 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
11152 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
11156 double factor = 475. /
gPad->GetCanvas()->GetWh();
11185 for (
int tt = 0;
tt < 2;
tt++) {
11186 auto impact =
static_cast<TH1 *
>(
11187 graph->GetHistogram()->Clone(
TString::Format(
"%s_impact+",
tt == 0 ?
"prefit" :
"postfit")));
11190 impact->SetBarWidth(0.9);
11191 impact->SetBarOffset(0.05);
11192 impact->SetLineColor(
kBlack);
11193 impact->SetFillColor(
kAzure - 4);
11194 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
11196 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
11197 impact2->SetDirectory(
nullptr);
11205 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
11207 :
c.first *
vv->getError() /
vv->getErrorHi() *
11208 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
11211 :
c.first *
vv->getError() /
vv->getErrorLo() *
11212 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
11219 for (
int ii = -1;
ii <= 1;
ii++) {
11232 leg1->SetFillStyle(0);
11233 leg1->SetBorderSize(0);
11234 leg1->SetMargin(0.25);
11235 leg1->SetNColumns(2);
11237 leg1->SetTextSize(
_axis->GetLabelSize());
11238 leg1->SetTextFont(
_axis->GetLabelFont());
11239 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
11240 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11241 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11242 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11243 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
11244 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11245 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11246 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11252 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
11259 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
11267 graph->SetEditable(
false);
11271 graph->GetListOfFunctions()->Add(
pNamesHist,
"same");
11275 for (
int p = 0;
p < graph->GetN();
p++) {
11276 graph->SetPoint(
p, graph->GetPointY(
p), graph->GetPointX(
p));
11277 graph->SetPointError(
p, graph->GetErrorYlow(
p), graph->GetErrorYhigh(
p), graph->GetErrorXlow(
p),
11278 graph->GetErrorXhigh(
p));
11281 if (
f->InheritsFrom(
"TH1")) {
11290 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
11291 for (
int p = 0;
p <
g->GetN();
p++) {
11292 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
11295 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
11305 if (!
sOpt.Contains(
"impact")) {
11312 auto x = graph->GetPointX(graph->GetN() -
ugraphLabels.size() + i);
11313 auto y = graph->GetPointY(graph->GetN() -
ugraphLabels.size() + i) +
11314 graph->GetErrorYhigh(graph->GetN() -
ugraphLabels.size() + i);
11318 t->SetTextSize(0.025);
11319 t->SetTextAngle(90);
11320 graph->GetListOfFunctions()->Add(t);
11324 graph->SetName(
"pulls");
11333 hist->
Draw(
"same");
11345 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
11346 hh->SetDirectory(
nullptr);
11378 if (
auto c = s->bins().find(
catName)) {
11379 c->push_back(std::make_shared<xRooNode>(*
this));
11381 c->resize(
c->size() - 1);
11383 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
11403 for (
auto o : *
gPad->GetListOfPrimitives()) {
11428 for (
int i = 0; i <
dataGraph->GetN(); i++)
11445 for (
auto o : *
gPad->GetListOfPrimitives()) {
11446 if (
auto h =
dynamic_cast<TH1 *
>(o);
11456 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
11459 histName = histName(0, histName.
Index(
'|'));
11460 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
11466 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
11478 if (!std::isnan(
yval)) {
11480 if (!std::isnan(yup))
11482 if (!std::isnan(
ydown))
11549 if (!
d->get()->TestBit(1 << 20))
11553 auto _obs =
d->obs();
11555 auto _nll =
nll(
d);
11557 int nevent =
theData->numEntries();
11558 for (
int i = 0; i < nevent; i++) {
11560 bool _skip =
false;
11561 for (
const auto &_c :
_coords) {
11563 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
11573 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11576 auto nllVal = _nll.getEntryVal(i);
11577 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11578 auto nllVal2 = _nll.getEntryVal(i);
11579 _nll.pars()->setRealValue(
initPar->GetName(), val);
11585 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11588 auto _extTerm = _nll.extendedTermVal();
11589 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11590 auto _extTerm2 = _nll.extendedTermVal();
11591 _nll.pars()->setRealValue(
initPar->GetName(), val);
11592 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
11597 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
11603 }
else if (
ii == 3) {
11629 (
rarNode->get()->InheritsFrom(
"RooRealSumPdf") ||
rarNode->get()->InheritsFrom(
"RooAddPdf") ||
11630 (
v &&
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11638 auto h =
BuildHistogram(
v,
false,
hasErrorOpt, 1, 0,
"",
false,
false, 0,
nullptr,
nostack,
true );
11650 :
h->GetXaxis()->GetName())
11653 if (
h->GetXaxis()->IsAlphanumeric()) {
11661 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
11662 rar->InheritsFrom(
"RooSimultaneous"))) {
11665 rar->leafNodeServerList(&s);
11672 for (
auto _p : s) {
11680 if (
_v->hasError()) {
11691 gPad->SetGrid(0, 0);
11693 gPad->SetGrid(1, 1);
11698 h->SetFillStyle(0);
11747 gROOT->SetEditHistograms(
true);
11749 gROOT->SetEditHistograms(
false);
11758 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
11763 bool hasError(
false);
11764 for (
int i = 0; i <
h->GetSumw2N(); i++) {
11765 if (
h->GetSumw2()->At(i)) {
11776 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
11777 h->GetYaxis()->SetTitleOffset(1.);
11785 if (
rar->getAttribute(
"Logy")) {
11799 hCopy->SetDirectory(
nullptr);
11801 _hist->GetListOfFunctions()->Add(node);
11802 _hist->GetListOfFunctions()->Add(
new TExec(
11805 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
11806 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
11807 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
11808 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
11809 "h->SetBinContent(1, "
11810 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
11811 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
11812 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
11813 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
11814 _hist->GetName(), node->GetName())));
11816 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
11817 errHist->SetFillColor(
h->GetLineColor());
11820 hCopy->SetFillStyle(0);
11821 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
11824 _hist->SetStats(
false);
11881 errHist->SetFillColor(
h->GetLineColor());
11898 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11900 if (
auto stack =
dynamic_cast<THStack *
>(
h->FindObject(
"stack"))) {
11906 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
11907 if (
lnk == stack->GetHists()->FirstLink() &&
h->GetMinimum() >
hhMin) {
12193 dOpt.ReplaceAll(
"TEXT",
"");
12195 double ymax = -std::numeric_limits<double>::infinity();
12196 double ymin = std::numeric_limits<double>::infinity();
12197 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
12226 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
12235 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
12236 double val =
ratioHist->GetBinContent(i);
12237 double err =
ratioHist->GetBinError(i);
12244 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
12251#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
12260 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
12261 _h->SetDirectory(
nullptr);
12262 _h->SetFillColor(0);
12263 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
12268 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
12269 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
12270 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
12271 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
12281 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
12285 histName = histName(0, histName.
Index(
'|'));
12287 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
12288 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
12291 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
12292 double val =
h->GetBinContent(i);
12293 double err =
h->GetBinError(i);
12294 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12295 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
12296 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12297 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
12298 h->GetBinContent(i));
12315 double ymax = -std::numeric_limits<double>::infinity();
12316 double ymin = std::numeric_limits<double>::infinity();
12317 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
12318 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
12319 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
12353 if (
d->get()->TestBit(1 << 20)) {
12401 w->import(*
gROOT->GetListOfColors(),
true);
12404#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
12408 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12413 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
12418#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12422 for (
auto &
c :
w->components()) {
12423 c->_eocache =
nullptr;
12427#if ROOT_VERSION_CODE < ROOT_VERSION(6, 38, 00)
12432 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12438 auto dir =
dest->GetDirectory(
source->GetName());
12442 for (
auto k : *
source->GetListOfKeys()) {
12443 auto key =
dynamic_cast<TKey *
>(k);
12444 const char *classname = key->GetClassName();
12453 if (dir->FindKey(key->GetName()))
12456 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
12458 dir->WriteObject(
fc, key->GetName());
12461 TObject *obj = key->ReadObj();
12463 dir->WriteTObject(obj, key->
GetName());
12470 if (
gROOT->GetListOfFiles()) {
12471 for (
auto key : *
gROOT->GetListOfFiles()) {
12482#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12484 for (
auto &
c :
w->components()) {
12485 c->setExpensiveObjectCache(
w->expensiveObjectCache());
12495 return std::numeric_limits<double>::quiet_NaN();
12501 std::vector<double> out;
12502 out.reserve(
size());
12503 for (
auto child : *
this) {
12504 out.push_back(
child->GetContent());
12518 auto rho =
_fr->correlationMatrix();
12527 for (
int m = 0;
m < rho.GetNrows();
m++) {
12534 auto tmp = _p->getVal();
12535 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
12537 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
12540 for (
int n = 0;
n < rho.GetNrows();
n++) {
12548 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
12550 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
12553 for (
int i = 0; i < out.
GetNrows(); i++) {
12563std::pair<double, double>
12567 double err = std::numeric_limits<double>::quiet_NaN();
12569 std::unique_ptr<RooAbsCollection>
_snap;
12582 out =
c->getVal(
sobs);
12589#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
12592 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
12593#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12595 p->_normSet =
nullptr;
12599 p->setNormRange(
nullptr);
12602 auto f = std::shared_ptr<RooAbsReal>(
12603 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
12607 out *=
f->getVal();
12617 for (
auto &
v : vals) {
12629 out = std::numeric_limits<double>::quiet_NaN();
12632 _pars.RooAbsCollection::operator=(*_snap);
12634 return std::make_pair(out, err);
12653 std::vector<double> out;
12659 binEnd = _hist->GetNbinsX();
12666 _hist->GetBinError(bin));
12793std::string cling::printValue(
const XROOFIT_NAMESPACE_NAME::xRooNode *
v)
12796 return "nullptr\n";
12799 size_t left =
v->size();
12800 for (
auto n : *
v) {
12806 out +=
n->GetName();
12807 if (out.length() > 100 && left > 0) {
12813 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->
GetName())) + out;
12818 return "<nullptr>";
12820 return Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->
GetName());
TVirtualPad * fPad
The pad where it has been drawn.
#define ROOT_VERSION(a, b, c)
#define ROOT_VERSION_CODE
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
TVectorT< Double_t > TVectorD
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
std::string fRange
! only here so can have char* GetRange return so can return nullptr for no range set !...
xRooNode reduced(const std::string &range="", bool invert=false) 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
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
! like a parent but only for use by getObject
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
! appears that if was fXaxis then dialog box for SetXaxis will take as current value
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 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
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'.
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.
void setName(const char *name)
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for binned and unbinned datasets.
RooFit::OwningPtr< RooAbsData > reduce(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a reduced copy of this dataset.
RooArgSet const * getGlobalObservables() const
Returns snapshot of global observables stored in this data.
Abstract base class for objects that are lvalues, i.e.
Abstract interface for all probability density functions.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
Context to temporarily change the error logging mode as long as the context is alive.
Abstract base class for objects that represent a real value and implements functionality common to al...
bool isSelectedComp() const
If true, the current pdf is a selected component (for use in plotting)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void forceNumInt(bool flag=true)
Efficient implementation of a sum of PDFs of the form.
Calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Abstract interface for RooAbsArg proxy classes.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Object to represent discrete states.
bool defineType(const std::string &label)
Define a state with given name.
Named container for two doubles, two integers two object points and three string pointers that can be...
static const RooCmdArg & none()
Return reference to null argument.
TObject * Clone(const char *newName=nullptr) const override
Make a clone of an object using the Streamer facility.
Represents a constant real-valued object.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
TMatrixDSym conditionalCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix, which is calculated as.
void setCovQual(Int_t val)
const TMatrixDSym & covarianceMatrix() const
Return covariance matrix.
Int_t statusCodeHistory(UInt_t icycle) const
const RooArgList & floatParsInit() const
Return list of floating parameters before fit.
TMatrixDSym reducedCovarianceMatrix(const RooArgList ¶ms) const
Return a reduced covariance matrix (Note that Vred is a simple sub-matrix of V, row/columns are order...
const RooArgList & randomizePars() const
Generate random perturbations of the final parameters using the covariance matrix.
void setCovarianceMatrix(TMatrixDSym &V)
Store externally provided correlation matrix in this RooFitResult ;.
double edm() const
Return estimated distance to minimum.
const RooArgList & constPars() const
Return list of constant parameters.
const char * statusLabelHistory(UInt_t icycle) const
Int_t covQual() const
Return MINUIT quality code of covariance matrix.
TH2 * correlationHist(const char *name="correlation_matrix") const
Return TH2D of correlation matrix.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Int_t status() const
Return MINUIT status code.
void setFinalParList(const RooArgList &list)
Fill the list of final values of the floating parameters.
UInt_t numStatusHistory() const
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 SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual Color_t GetLineColor() const
Return the line color.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual Font_t GetTextFont() const
Return the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
Class to manage histogram axis.
virtual void LabelsOption(Option_t *option="h")
Set option(s) to draw axis with labels option can be:
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
TAxis()
Default constructor.
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x
Using a TBrowser one can browse all ROOT objects.
TBrowserImp * GetBrowserImp() const
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
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.
TDirectory::TContext keeps track and restore the current directory.
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 file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Create a dialog for fit function parameter settings.
System file browser, used as TRootBrowser plug-in.
A list tree is a widget that can contain a number of items arranged in a tree structure.
ROOT GUI Window base class.
virtual void SetTitle(const char *title="")
Change the title of the axis.
virtual void ImportAxisAttributes(TAxis *axis)
Internal method to import TAxis attributes to this TGaxis.
TGraph with asymmetric error bars.
virtual void SetPointEYlow(Int_t i, Double_t eyl)
Set EYlow for point i.
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
Set ex and ey values for point pointed by the mouse.
virtual void SetPointEYhigh(Int_t i, Double_t eyh)
Set EYhigh for point i.
Double_t GetErrorYlow(Int_t i) const override
Get low error on Y.
A TGraphErrors is a TGraph with error bars.
Double_t GetErrorYlow(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const override
It returns the error along Y at point i.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void AddPoint(Double_t x, Double_t y)
Append a new point to the graph.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
void SetName(const char *name="") override
Set graph name.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
virtual TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
virtual Double_t GetPointY(Int_t i) const
Get y value for point i.
void SetTitle(const char *title="") override
Change (i.e.
1-D histogram with a double per channel (see TH1 documentation)
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
void SetTitle(const char *title) override
Change/set the title.
virtual Int_t GetNbinsY() const
@ 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.
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 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.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual TCanvas * GetCanvas() const =0
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.
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)
std::vector< double > new_getPropagatedErrors(const RooAbsReal &f, const RooFitResult &fr, const RooArgSet &nset, RooArgList **pars, bool asymHi, bool asymLo, const std::vector< int > &bins, const std::function< void(int)> &setBin)
TLegend * getLegend(bool create=true, bool doPaint=false)