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 should fix your workspaces!");
445 for (
auto &
a : *
this) {
449 if (
a->fFolder ==
"!pdfs") {
451 auto fr =
a->floats().reduced(
parNames).fitResult(
"prefit");
455 if (
auto arg =
dynamic_cast<RooRealVar *
>(
_fr->floatParsFinal().find(
v->GetName()));
456 arg && arg->hasError()) {
457 v->setError(arg->getError());
474 if (
strlen(GetTitle()) == 0) {
501 if (
auto a = std::dynamic_pointer_cast<RooAbsArg>(
comp);
a &&
a->getStringAttribute(
"alias"))
502 return a->getStringAttribute(
"alias");
504 return comp->GetName();
517 bool isBool = (
v ==
"TRUE" ||
v ==
"FALSE");
519 if (
value ==
nullptr ||
v ==
"NULLPTR") {
520 if (
a->getAttribute(
name))
521 a->setAttribute(
name,
false);
522 else if (
a->getStringAttribute(
name))
523 a->setStringAttribute(
name,
nullptr);
526 a->setAttribute(
name, (
v ==
"TRUE"));
537 for (
auto a : *
gROOT->GetListOfBrowsers()) {
559 if (o->isSelectedComp() && !val) {
562 o->setAttribute(
"hidden");
563 }
else if (!o->isSelectedComp() && !val) {
568 o->setAttribute(
"hidden",
false);
571 item->CheckItem(!o->getAttribute(
"hidden"));
572 if (o->isSelectedComp()) {
580 if (
auto o =
get(); o) {
582 o->SetBit(1 << 20, val);
584 if (
auto _ws =
ws(); _ws) {
587 if (fr->numStatusHistory() && !_ws->genobj(fr->GetName())) {
589 if (
auto wfr =
dynamic_cast<RooFitResult *
>(_ws->genobj(fr->GetName()))) {
594 _allVars = fr->floatParsFinal();
595 _allVars = fr->constPars();
596 for (
auto &i : fr->floatParsInit()) {
602 for (
auto oo : _ws->allGenericObjects()) {
604 ffr->ResetBit(1 << 20);
608 _ws->allVars() = fr->floatParsInit();
612 for (
auto a : *
gROOT->GetListOfBrowsers()) {
623 if (
auto first =
p->GetParent()->GetFirstChild()) {
625 if (first->HasCheckBox()) {
626 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
627 first->CheckItem(
_obj->get() &&
_obj->get()->TestBit(1 << 20));
629 }
while ((first = first->GetNextSibling()));
641 if (
auto first = i->GetFirstChild()) {
643 if (first->IsOpen() &&
644 (
TString(first->GetText()) ==
"poi" ||
TString(first->GetText()) ==
"np")) {
645 fb->DoubleClicked(first, 0);
648 }
while ((first = first->GetNextSibling()));
670 auto b2 =
dynamic_cast<TBrowser *
>(
gROOT->GetListOfBrowsers()->Last());
671 if (!b2 || !b2->GetBrowserImp()) {
678 b2 =
new TBrowser(
"nodeBrowser",
this,
"RooFit Browser");
680 }
else if (
strcmp(b2->GetName(),
"nodeBrowser") == 0) {
682 b2->BrowseObject(
this);
687 _b->AddFSDirectory(
"Workspaces",
nullptr,
"SetRootDir");
688 _b->GotoDir(
nullptr);
699 if (
auto first =
item->GetFirstChild()) {
701 if (first->HasCheckBox()) {
702 auto _obj =
static_cast<xRooNode *
>(first->GetUserData());
703 first->CheckItem(
_obj->get() &&
704 (
_obj->get()->TestBit(1 << 20) ||
707 }
while ((first = first->GetNextSibling()));
720 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"pull\")",
nullptr, *
this));
721 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"corr10colztext\")",
nullptr, *
this));
722 if (std::unique_ptr<RooAbsCollection>(
_fr->floatParsFinal().selectByAttrib(
"poi",
true))->size() == 1) {
723 fBrowsables.push_back(std::make_shared<xRooNode>(
".Draw(\"impact\")",
nullptr, *
this));
730 s->SetFillAttributes();
737 Draw(
b->GetDrawOption());
739 }
catch (
const std::exception &
e) {
742 (
gROOT->GetListOfBrowsers()->At(0))
745 "Exception",
e.what(),
752 for (
auto &
c : *
this) {
753 if (!
c->fFolder.empty()) {
764 _folders = emplace_back(std::make_shared<xRooNode>(
".folders",
nullptr, *
this));
767 for (
auto &
v : *
this) {
768 if (!
v->fFolder.empty() && !
_folders->find(
v->fFolder,
false)) {
769 _folders->emplace_back(std::make_shared<xRooNode>(
v->fFolder.c_str(),
nullptr, *
this));
776 _name = _name(1, _name.
Length());
777 b->Add(
v.get(), _name);
781 for (
auto &
v : *
this) {
784 if (
strcmp(
v->GetName(),
".folders") == 0)
788 if (
_fr && ((
_fr->status() == 0 &&
_fr->numStatusHistory() == 0) || (
_fr->floatParsFinal().empty()))) {
796 _name = _name(
strlen(
v->get()->ClassName()) + 2, _name.
Length());
804 :
v->get()->GetName());
806 }
else if (
v->get() && !
v->get<
TFile>() && !
TString(
v->GetName()).BeginsWith(
'/'))
808 if (
auto _type =
v->GetNodeType();
strlen(_type)) {
816 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
822 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
829 for(
auto&
c : pi->interpolationCodes())
interpCodes.insert(
c);
841 if (
auto o =
v->get(); o)
842 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
844 if (
auto o =
v->get(); o)
847 dynamic_cast<TQObject *
>(
b->GetBrowserImp())
848 ->Connect(
"Checked(TObject *, bool)",
ClassName(),
v.get(),
"Checked(TObject *, bool)");
851 if (
_fr->status() ||
_fr->covQual() != 3) {
852 v->GetTreeItem(
b)->SetColor((
_fr->numStatusHistory() && !
_fr->floatParsFinal().empty()) ?
kRed :
kBlue);
853 }
else if (
_fr->numStatusHistory() == 0) {
854 v->GetTreeItem(
b)->SetColor(
kGray);
857 if ((
v->fFolder ==
"!np" ||
v->fFolder ==
"!poi")) {
859 v->GetTreeItem(
b)->SetColor(
kGray);
861 v->GetTreeItem(
b)->ClearColor();
865 if (
auto fits =
_htr->GetFitInfo()) {
866 for (
int i = 0; i <
fits->numEntries(); i++) {
868 if (
fits->get(i)->getCatIndex(
"type") != 5 &&
fits->get(i)->getRealValue(
"status") != 0) {
869 v->GetTreeItem(
b)->SetColor(
kRed);
874 v->GetTreeItem(
b)->SetColor(
kBlue);
901 if (_name ==
".memory")
905 if (
auto o =
v->get(); o)
906 v->TNamed::SetNameTitle(o->GetName(), o->ClassName());
907 b->Add(
v.get(), _name, -1);
908 if (
auto o =
v->get(); o)
912 b->SetSelected(
this);
925 auto v = std::make_shared<xRooNode>(
vars());
936 if (
strcmp(
b->GetName(),
".vars") == 0)
959 if (
auto v = var();
v)
960 return v->getBinWidth(bin - 1, GetName());
965 if (
auto v = rvar();
v) {
966 return (bin ==
v->getBinning(GetName()).numBins() + 1) ?
v->getBinning(GetName()).binHigh(bin - 2)
967 :
v->getBinning(GetName()).binLow(bin - 1);
973 if (
auto v = rvar();
v)
974 return (bin == 0) ?
v->getBinning(GetName()).binLow(bin) :
v->getBinning(GetName()).binHigh(bin - 1);
980 return (binning() &&
strlen(binning()->GetTitle())) ? binning()->GetTitle() : GetParent()->GetTitle();
987 dynamic_cast<TNamed *
>(GetParent())->SetTitle(title);
991 void Set(
Int_t nbins,
const double *xbins)
override
994 v->setBinning(
RooBinning(nbins, xbins), GetName());
999 std::vector<double> bins(nbins + 1);
1000 for (
int i = 0; i <= nbins; i++)
1001 bins.at(i) = xbins[i];
1002 return Set(nbins, &bins[0]);
1026 for (
auto &o : *
_owned) {
1027 if (
name == o->GetName()) {
1028 if (
type.empty() || o->get()->InheritsFrom(
type.c_str()))
1039 _parent = _parent->fParent;
1045 std::shared_ptr<TObject> out;
1046 if (
auto arg =
ws()->arg(
name.c_str()); arg) {
1047 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1048 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1053 if (
auto arg =
ws()->
data(
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()->genobj(
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()->embeddedData(
name.c_str()); arg) {
1068 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1069 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1075 auto _tmp = std::shared_ptr<TObject>(arg, [](
TObject *) {});
1076 if (!
type.empty() && arg->InheritsFrom(
type.c_str()))
1086 arg->treeNodeServerList(&nodes);
1099 cat && cat->numTypes() !=
fXAxis->GetNbins()) {
1115 if (
auto xName = o->getStringAttribute(
"xvar");
xName) {
1127 }
else if (
auto _obs =
obs(); !_obs.empty()) {
1128 for (
auto &
v : _obs) {
1164 TString binningName = o->getStringAttribute(
"binning");
1165 auto _bnames =
x->getBinningNames();
1166 bool hasBinning =
false;
1168 if (
b == binningName) {
1176 Warning(
"GetXaxis",
"Binning %s not defined on %s - clearing", binningName.
Data(),
1178 o->setStringAttribute(
"binning",
nullptr);
1182 if (binningName ==
"" && o !=
dynamic_cast<TObject *
>(
x)) {
1188 if (
b == o->GetName()) {
1189 binningName = o->GetName();
1193 if (binningName ==
"") {
1199 (std::list<double> *)(
nullptr),
1201 ? o->binBoundaries(*
dynamic_cast<RooAbsRealLValue *
>(
x), -std::numeric_limits<double>::infinity(),
1202 std::numeric_limits<double>::infinity())
1205 std::vector<double>
_bins;
1206 for (
auto &
b : *
bins) {
1214 _v->getBinning(o->GetName())
1219 binningName = o->GetName();
1230 if (
r->getBinning(binningName).isUniform()) {
1231 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getMin(binningName),
r->getMax(binningName));
1233 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName),
r->getBinning(binningName).array());
1235 }
else if (
auto cat =
dynamic_cast<RooCategory *
>(
x)) {
1236 std::vector<double>
bins = {};
1237 for (
int i = 0; i <=
x->numBins(binningName); i++)
1239 fXAxis = std::make_shared<Axis2>(
x->numBins(binningName), &
bins[0]);
1242 std::map<int, std::string> cats;
1243 for (
auto &
c : *cat) {
1244 if (cat->isStateInRange(binningName,
c.first.c_str())) {
1245 cats[
c.second] =
c.first;
1248 for (
auto &[
_, label] : cats) {
1249 fXAxis->SetBinLabel(i++, label.c_str());
1254 fXAxis->SetName(binningName);
1261 if (
auto o =
get(); o) {
1262 if (o->InheritsFrom(
"RooWorkspace"))
1264 if (o->InheritsFrom(
"RooAbsData"))
1266 if (o->InheritsFrom(
"RooSimultaneous"))
1269 if (o->InheritsFrom(
"RooProdPdf"))
1271 if (o->InheritsFrom(
"RooRealSumPdf") || o->InheritsFrom(
"RooAddPdf"))
1274 if (o->InheritsFrom(
"RooFitResult")) {
1275 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitRooFitResult",
true)) {
1276 gClient->GetMimeTypeList()->AddType(
"xRooFitRooFitResult",
"xRooFitRooFitResult",
"package.xpm",
1277 "package.xpm",
"->Browse()");
1279 return "xRooFitRooFitResult";
1281 if (o->InheritsFrom(
"RooRealVar") || o->InheritsFrom(
"RooCategory")) {
1283 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitObs",
true)) {
1284 gClient->GetMimeTypeList()->AddType(
"xRooFitObs",
"xRooFitObs",
"x_pic.xpm",
"x_pic.xpm",
"->Browse()");
1286 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitGlobs",
true)) {
1287 gClient->GetMimeTypeList()->AddType(
"xRooFitGlobs",
"xRooFitGlobs",
"z_pic.xpm",
"z_pic.xpm",
1290 return (
get<RooAbsArg>()->getAttribute(
"global") ?
"xRooFitGlobs" :
"xRooFitObs");
1294 if (o->InheritsFrom(
"TStyle")) {
1295 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTStyle",
true)) {
1296 gClient->GetMimeTypeList()->AddType(
"xRooFitTStyle",
"xRooFitTStyle",
"bld_colorselect.xpm",
1297 "bld_colorselect.xpm",
"->Browse()");
1299 return "xRooFitTStyle";
1301 if (o->InheritsFrom(
"RooConstVar")) {
1307 return "TMethodBrowsable-leaf";
1309 if (o->InheritsFrom(
"RooStats::HypoTestInverterResult")) {
1310 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitScanStyle",
true)) {
1311 gClient->GetMimeTypeList()->AddType(
"xRooFitScanStyle",
"xRooFitScanStyle",
"f2_s.xpm",
"f2_s.xpm",
1314 return "xRooFitScanStyle";
1316 if (o->InheritsFrom(
"RooStats::HypoTestResult")) {
1317 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitTestStyle",
true)) {
1318 gClient->GetMimeTypeList()->AddType(
"xRooFitTestStyle",
"xRooFitTestStyle",
"diamond.xpm",
"diamond.xpm",
1321 return "xRooFitTestStyle";
1323 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1324 return "TBranchElement-folder";
1325 if (o->InheritsFrom(
"RooAbsPdf")) {
1326 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitPDFStyle",
true)) {
1327 gClient->GetMimeTypeList()->AddType(
"xRooFitPDFStyle",
"xRooFitPDFStyle",
"pdf.xpm",
"pdf.xpm",
1330 return "xRooFitPDFStyle";
1332 if (o->InheritsFrom(
"RooStats::ModelConfig")) {
1333 if (!
gClient->GetMimeTypeList()->GetIcon(
"xRooFitMCStyle",
true)) {
1334 gClient->GetMimeTypeList()->AddType(
"xRooFitMCStyle",
"xRooFitMCStyle",
"app_t.xpm",
"app_t.xpm",
1337 return "xRooFitMCStyle";
1341 _ax && (
a->isBinnedDistribution(*
dynamic_cast<RooAbsArg *
>(_ax->GetParent())) ||
1343 std::unique_ptr<std::list<double>>(
a->binBoundaries(
1344 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
1345 std::numeric_limits<double>::infinity()))))) {
1350 return o->ClassName();
1362 if(
rrs->getAttribute(
"BinnedLikelihood"))
return "BinnedLikelihood";
1365 if (o->InheritsFrom(
"RooStats::HistFactory::FlexibleInterpVar"))
1367 if (o->InheritsFrom(
"PiecewiseInterpolation")) {
1379 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"VariedDensity" :
"Varied";
1382 if (o->InheritsFrom(
"RooHistFunc"))
1383 return (
dynamic_cast<RooAbsArg *
>(o)->getAttribute(
"density")) ?
"SimpleDensity" :
"Simple";
1384 if (o->InheritsFrom(
"RooBinWidthFunction"))
1386 if (o->InheritsFrom(
"ParamHistFunc"))
1388 if (o->InheritsFrom(
"RooRealVar"))
1390 if (o->InheritsFrom(
"RooConstVar"))
1398 xRooNode out(
".coords",
nullptr, *
this);
1400 auto _p = std::shared_ptr<xRooNode>(
const_cast<xRooNode *
>(
this), [](
xRooNode *) {});
1430 if (
auto pos =
pName.Index(
'='); pos != -1) {
1431 if (pos > 0 &&
pName(pos - 1) ==
'<') {
1439 _obs->setVal((high + low) / 2.);
1440 static_cast<RooRealVar *
>(_obs.get())->setRange(
"coordRange", low, high);
1442 "coordRange",
"coordRange");
1444 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1449 }
else if (
auto _obs = _p->getObject<
RooAbsArg>(
pName(0, pos)); _obs) {
1452 _cat->setLabel(
pName(pos + 1,
pName.Length()));
1453 }
else if (
auto _var =
dynamic_cast<RooAbsRealLValue *
>(_obs.get()); _var) {
1457 out.emplace_back(std::make_shared<xRooNode>(_obs->GetName(), _obs, _p));
1459 throw std::runtime_error(
"Unknown observable, could not find");
1471 }
catch (
const std::exception &
e) {
1480 }
catch (
const std::exception &
e) {
1507 pdf =
p->pdfList().find(
child.GetName());
1510 auto i =
p->pdfList().index(*pdf);
1512#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1513 const_cast<RooArgList &
>(
p->pdfList()).remove(*pdf);
1514#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
1515 p->_pdfNSetList.erase(
p->_pdfNSetList.
begin() + i);
1517 auto nset =
p->_pdfNSetList.At(i);
1518 p->_pdfNSetList.Remove(nset);
1521 if (
p->_extendedIndex == i)
1522 p->_extendedIndex = -1;
1523 else if (
p->_extendedIndex > i)
1524 p->_extendedIndex--;
1536 arg =
p2->components().find(
child.GetName());
1540#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
1541 p2->_compRSet.remove(*arg);
1543 const_cast<RooArgList &
>(
p2->realComponents()).remove(*arg);
1545 p2->removeServer(*arg,
true);
1555 }
catch (std::runtime_error &) {
1565 arg =
p4->funcList().find(
child.GetName());
1569 auto idx =
p4->funcList().index(arg);
1574 p4->removeServer(*arg,
true);
1576 std::vector<RooAbsArg *>
_coefs;
1578 if (
ii !=
size_t(idx))
1593 arg =
p5->pdfList().find(
child.GetName());
1597 auto idx =
p5->pdfList().index(arg);
1602 p5->removeServer(*arg,
true);
1604 std::vector<RooAbsArg *>
_coefs;
1606 if (
ii !=
size_t(idx))
1621 arg =
p6->list().find(
child.GetName());
1626 p6->removeServer(*arg,
true);
1634 auto arg =
w->components().find(
child.GetName());
1641 if (arg->hasClients()) {
1642 throw std::runtime_error(
1643 TString::Format(
"Cannot remove %s from workspace %s, because it has dependencies - first remove from those",
1646 const_cast<RooArgSet &
>(
w->components()).remove(*arg);
1655 throw std::runtime_error(
"Removal not implemented for object type " +
1705 out->setAttribute(
"obs");
1706 out->setAttribute(
"global");
1709 throw std::runtime_error(
"Failed to add global observable");
1713 out->setAttribute(
"poi");
1721 throw std::runtime_error(
"Failed to add parameter of interest");
1725 if (!
fac.Contains(
"[") && !
fac.Contains(
"("))
1731 if (
find(_data->GetName())) {
1732 throw std::runtime_error(
TString::Format(
"Cannot add dataset %s, already exists for %s. If intending to "
1733 "combine datasets, please add directly to dataset",
1743 throw std::runtime_error(
1744 "Datasets can only be created for pdfs or workspaces (except if generated dataset, then must be pdf)");
1747 if (
sOpt ==
"asimov" ||
sOpt ==
"toy") {
1765 }
else if (!_ws->obj(
_fr->GetName())) {
1774 std::unique_ptr<RooAbsCollection>
_globs(_obs.selectByAttrib(
"global",
true));
1782 _obs.add(*
dynamic_cast<RooAbsArg *
>(
ax->GetParent()));
1785 if (
auto _d = _ws->data(
child.GetName()); _d) {
1788 l.remove(*_d->get(),
true,
true);
1792 throw std::runtime_error(
"Cannot extend dataset with new columns");
1803 if (
auto __d = _ws->data(
child.GetName()))
1804 __d->SetBit(1 << 20, _ws->allData().size() == 1);
1812 auto out = std::shared_ptr<TObject>(_ws->data(
child.GetName()), [](
TObject *) {});
1821 throw std::runtime_error(
"Cannot create dataset");
1826 throw std::runtime_error(
"Cannot add to null object with no parentage");
1828 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
1833 std::rethrow_exception(std::current_exception());
1838 throw std::runtime_error(
"No object");
1848 throw std::runtime_error(
"Can only add datasets to a dataset");
1857 }
else if (
g->GetContent() !=
glob->GetContent()) {
1858 Warning(
"Add",
"Global observable %s=%g in dataset %s mismatches %s value %g ... ignoring latter",
1863 if (
auto _dglobs =
p->getGlobalObservables()) {
1873 std::set<std::pair<RooAbsCategory *, RooCategory *>> cats;
1875 for (
auto col : *_data->get()) {
1876 if (!
p->get()->contains(*col)) {
1877 ds->addColumn(*col);
1882 throw std::runtime_error(
1883 TString::Format(
"unexpected type for regular observable: %s", col->GetName()));
1896 cats.insert({
c,
c2});
1903 for (
int i = 0; i < _data->numEntries(); i++) {
1904 auto row = _data->get(i);
1905 auto w = _data->weight();
1906 ds->get()->assign(*row);
1907 for (
auto [
c,
c2] : cats) {
1908 c2->setLabel(row->getCatLabel(
c->GetName()));
1910 ds->add(*
ds->get(),
w);
1914 ds->SetTitle(
TString(
ds->GetTitle()) +
" + " + _data->GetTitle());
1921 _ds->addColumn(*_arg);
1922 _arg->setAttribute(
"obs");
1927 throw std::runtime_error(
"Can only add histogram or var/expr or dataset to data");
1931 throw std::runtime_error(
"Could not find pdf");
1932 auto _ax = _pdf->GetXaxis();
1934 throw std::runtime_error(
"Cannot determine binning to add data");
1943 l.remove(*
p->get(),
true,
true);
1947 throw std::runtime_error(
"Cannot extend dataset with new columns");
1954 for (
auto &o :
obs) {
1956 if (
auto dv =
dynamic_cast<RooRealVar *
>(
p->get()->find(
v->GetName()));
dv) {
1957 if (
v->getMin() <
dv->getMin())
1958 dv->setMin(
v->getMin());
1959 if (
v->getMax() >
dv->getMax())
1960 dv->setMax(
v->getMax());
1973 for (
int i = 1; i <=
_h->GetNbinsX(); i++) {
1975 if (!
_h->GetXaxis()->GetBinLabel(i)) {
1976 throw std::runtime_error(
1977 TString::Format(
"Categorical observable %s requires bin labels", _ax->GetParent()->GetName()));
1978 }
else if (!cat->hasLabel(
_h->GetXaxis()->GetBinLabel(i))) {
1979 throw std::runtime_error(
TString::Format(
"Categorical observable %s does not have label %s",
1980 _ax->GetParent()->GetName(),
_h->GetXaxis()->GetBinLabel(i)));
1982 cat->setLabel(
_h->GetXaxis()->GetBinLabel(i));
1987 p->add(
obs,
_h->GetBinContent(i));
1996 child.convertForAcquisition(*
this,
sOpt);
2000 auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out);
2002 throw std::runtime_error(
"Something went wrong with pdf acquisition");
2009 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2010 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2011 std::numeric_limits<double>::infinity()));
2012 !_boundaries && _ax->GetNbins() > 0) {
2013#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2014 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2018 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2019 if (!_p->getStringAttribute(
"alias"))
2020 _p->setStringAttribute(
"alias", out->GetName());
2022 throw std::runtime_error(
2023 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2029 if (!(_pdf->canBeExtended() &&
p->coefList().empty())) {
2033 if (_pdf->canBeExtended()) {
2035 std::cout <<
" warning " << _pdf->GetName() <<
" wont be correctly normalized" << std::endl;
2045 for (
auto i =
p->coefList().size(); i <
p->pdfList().size(); i++) {
2050 *
static_cast<RooAbsPdf *
>(
p->pdfList().at(i))));
2056 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2057 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
2058 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
2059 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
2061 const_cast<RooArgList &
>(
p->pdfList()).add(*_pdf);
2093 std::shared_ptr<TObject> out;
2098 if (std::dynamic_pointer_cast<TH1>(
cc) && !
TString(
cc->GetOption()).
Contains(
"nostyle")) {
2103 Info(
"Add",
"Adding existing function %s to %s",
child.GetName(),
p->GetName());
2107 if (!out && !
child.fComp) {
2108 std::shared_ptr<RooAbsArg> _func;
2116 std::unique_ptr<TH1D>
h;
2119 h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _ax->GetNbins(),
2120 _ax->binning()->array());
2122 h->GetXaxis()->SetName(
TString::Format(
"%s;%s", _ax->GetParent()->GetName(), _ax->GetName()));
2124 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2125 }
else if (_obs.size() == 1) {
2128 auto _bnames = _x->getBinningNames();
2129 TString binningName =
p->getStringAttribute(
"binning");
2131 if (
b ==
p->GetName()) {
2132 binningName =
p->GetName();
2136 std::unique_ptr<TH1D>
h;
2139 h = std::make_unique<TH1D>(
child.GetName(),
child.GetTitle(), _x->numBins(binningName),
2140 _x->getBinningPtr(binningName)->array());
2142 h->GetXaxis()->SetName(
2145 _func = std::dynamic_pointer_cast<RooAbsArg>(
acquire(
xRooNode(*h).convertForAcquisition(*
this)));
2146 Info(
"Add",
"Created SimpleDensity factor %s (xaxis=%s) for %s", _func->GetName(), _obs.at(0)->GetName(),
2149 throw std::runtime_error(
"Unsupported creation of new component in SumPdf for this many obs");
2155 _func->setStringAttribute(
"alias",
child.GetName());
2159 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
2163 _f->setAttribute(
"density");
2164 if (
_f->getAttribute(
"autodensity")) {
2166 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
2170 _f->setAttribute(
"autodensity",
false);
2171 _f->setValueDirty();
2180 Info(
"Add",
"Created %s factor RooHistFunc::%s for %s",
2181 _f->getAttribute(
"density") ?
"SimpleDensity" :
"Simple",
_f->GetName(),
p->GetName());
2185 if (
auto _p = std::dynamic_pointer_cast<RooAbsPdf>(out); _p) {
2190 newName.ReplaceAll(
"_samples",
"");
2192 Warning(
"Add",
"converting samples to components");
2197 if (
auto _boundaries = std::unique_ptr<std::list<double>>(_p->binBoundaries(
2198 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2199 std::numeric_limits<double>::infinity()));
2200 !_boundaries && _ax->GetNbins() > 0) {
2201#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2202 Warning(
"Add",
"Adding unbinned pdf %s to binned %s - will wrap with RooBinSamplingPdf(...)",
2206 _p->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2207 if (!_p->getStringAttribute(
"alias"))
2208 _p->setStringAttribute(
"alias", out->GetName());
2210 throw std::runtime_error(
2211 "unsupported addition of unbinned pdf to binned model - please upgrade to at least ROOT 6.24");
2218 if (!_p->canBeExtended()) {
2227 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
2234 _f->dependsOn(*
static_cast<RooAbsArg *
>(_ax->GetParent()))) {
2236 if (
auto _boundaries = std::unique_ptr<std::list<double>>(
_f->binBoundaries(
2237 *
dynamic_cast<RooAbsRealLValue *
>(_ax->GetParent()), -std::numeric_limits<double>::infinity(),
2238 std::numeric_limits<double>::infinity()));
2239 !_boundaries && _ax->GetNbins() > 0) {
2240#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 24, 00)
2243 "Adding unbinned function %s to binned %s - will wrap with RooRealSumPdf(RooBinSamplingPdf(...))",
2247 sumPdf->setStringAttribute(
"alias",
_f->getStringAttribute(
"alias"));
2248 if (!sumPdf->getStringAttribute(
"alias"))
2249 sumPdf->setStringAttribute(
"alias", out->GetName());
2252 _f->setStringAttribute(
"alias", std::dynamic_pointer_cast<RooAbsArg>(out)->getStringAttribute(
"alias"));
2253 if (!
_f->getStringAttribute(
"alias"))
2254 _f->setStringAttribute(
"alias", out->GetName());
2256 throw std::runtime_error(
2257 "unsupported addition of unbinned function to binned model - please upgrade to at least ROOT 6.24");
2265 if (!
p->getStringAttribute(
"binning"))
2266 p->setStringAttribute(
"binning",
_f->getStringAttribute(
"binning"));
2269 if (
auto gf =
p->getStringAttribute(
"global_factors");
gf) {
2274 throw std::runtime_error(
TString::Format(
"Could not find global factor %s", pattern.
Data()));
2283 p->setStringAttribute(
"xvar",
nullptr);
2309 auto out = this->
operator[](
"components")->Add(child);
2328 for (
auto &
_pdfa :
pp->components()) {
2346 auto out = this->
operator[](
"samples")->Add(child);
2349 p2->setStringAttribute(
"xvar",
nullptr);
2362 child.convertForAcquisition(
2363 *
this,
child.get() ?
"" :
"func" );
2367 if (!
w->import(*_d)) {
2370 std::unique_ptr<RooAbsCollection>(
w->allVars().selectCommon(*_d->get()))->setAttribAll(
"obs");
2372 if (_d->getGlobalObservables()) {
2373 std::unique_ptr<RooAbsCollection>
globs(
w->allVars().selectCommon(*_d->getGlobalObservables()));
2374 globs->setAttribAll(
"obs");
2375 globs->setAttribAll(
"global");
2379 throw std::runtime_error(
2390 if (!
child.empty() ||
child.fFolder ==
"!pdfs") {
2393 std::string
catName =
"channelCat";
2394 if (!
child.empty()) {
2400 _cat->setAttribute(
"obs");
2402 Info(
"Add",
"Created pdf RooSimultaneous::%s in workspace %s", out->GetName(),
w->GetName());
2406 if (
coll->isOwning()) {
2408 }
else if (
child.ws() !=
ws()) {
2416 if (
sOpt ==
"pdf") {
2422 }
else if (
sOpt ==
"channel") {
2427 std::shared_ptr<TObject> out;
2428 child.convertForAcquisition(*
this);
2431 }
else if (!
child.fComp) {
2434 Info(
"Add",
"Created channel RooProdPdf::%s in workspace %s", out->GetName(),
get()->
GetName());
2438 }
else if (
sOpt ==
"sample" ||
sOpt ==
"func") {
2444 return (*
this)[
"samples"]->Add(
child,
sOpt ==
"func" ?
"func" :
"");
2447 }
else if (
sOpt ==
"dataset") {
2450 return (*this).datasets().Add(
child);
2508 a->setAttribute(
"hidden", set);
2519 return a->getAttribute(
"hidden");
2526 if (
get() ==
rhs.get()) {
2538 std::set<std::string>
pdfs;
2539 for (
auto &
c :
rhs.components()) {
2540 if ((*
this)[
"pdfs"]->find(
c->GetName())) {
2541 pdfs.insert(
c->GetName());
2545 Warning(
"Combine",
"No pdfs will be combined. Please check and/or rename pdfs to match");
2547 std::stringstream s;
2548 for (
auto &
p :
pdfs)
2550 Info(
"Combine",
"pdfs that will be combined: %s", s.str().c_str());
2553 std::set<std::string>
_np;
2555 for (
auto &
c :
rhs.np()) {
2556 if (
mynp.find(
c->GetName())) {
2557 _np.insert(
c->GetName());
2561 Warning(
"Combine",
"No correlated np");
2563 std::stringstream s;
2566 Info(
"Combine",
"np that will be shared (correlated): %s", s.str().c_str());
2568 std::set<std::string> _poi;
2570 for (
auto &
c :
rhs.poi()) {
2571 if (
mypoi.find(
c->GetName())) {
2572 _poi.insert(
c->GetName());
2576 Warning(
"Combine",
"No correlated poi");
2578 std::stringstream s;
2579 for (
auto &
p : _poi)
2581 Info(
"Combine",
"poi that will be shared (correlated): %s", s.str().c_str());
2598 for (
auto &
c :
rhs.components()) {
2600 (
c->fFolder ==
"!scratch" ||
c->fFolder ==
"!sets" ||
c->fFolder ==
"!snapshots" ||
c->fFolder ==
"!models"))
2604 Info(
"Combine",
"Combining %s into %s",
c->GetPath().c_str(), _c->GetPath().c_str());
2606 _c->Combine(*
c,
true);
2610 Info(
"Combine",
"Adding %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2613 }
catch (std::exception &
e) {
2614 Warning(
"Combine",
"Could not combine %s into %s",
c->GetPath().c_str(),
GetPath().c_str());
2620 for (
auto &
f :
rhs.factors()) {
2623 Info(
"Combine",
"Combining %s into %s",
f->GetPath().c_str(),
_f->GetPath().c_str());
2625 _f->Combine(*
f,
true);
2628 Info(
"Combine",
"Multiplying %s into %s",
f->GetPath().c_str(),
GetPath().c_str());
2636 for (
auto &
c :
rhs.components()) {
2637 if (
c->fFolder ==
"!sets") {
2639 Info(
"Combine",
"Extending set %s",
c->GetName());
2642 Info(
"Combine",
"Defining set %s",
c->GetName());
2649 for (
auto &
ds :
rhs.datasets()) {
2652 Info(
"Combine",
"Combining %s into %s",
ds->GetPath().c_str(),
_ds->GetPath().c_str());
2657 Info(
"Combine",
"Adding %s into %s",
ds->GetPath().c_str(),
GetPath().c_str());
2664 for (
auto &
v :
rhs.variations()) {
2667 Info(
"Combine",
"Combining variation %s into %s",
v->GetPath().c_str(),
_v->GetPath().c_str());
2669 _v->Combine(*
v,
true);
2672 Info(
"Combine",
"Varying %s into %s",
v->GetPath().c_str(),
GetPath().c_str());
2680 for (
auto &
b :
rhs.bins()) {
2682 Info(
"Combine",
"Combining %s into %s",
b->GetPath().c_str(),
_b->GetPath().c_str());
2683 _b->Combine(*
b,
true);
2685 Info(
"Combine",
"Extending with %s into %s",
b->GetPath().c_str(),
GetPath().c_str());
2711 if (!
chans.empty()) {
2722 c->shallowCopy(
name +
"_" +
c->get()->GetName(), std::shared_ptr<xRooNode>(&out, [](
xRooNode *) {}));
2728 }
else if (
auto p =
dynamic_cast<RooProdPdf *
>(o);
p) {
2730 std::shared_ptr<RooProdPdf> pdf =
2731 std::dynamic_pointer_cast<RooProdPdf>(out.
acquire(std::shared_ptr<TObject>(
p->Clone()),
false,
2736 std::dynamic_pointer_cast<RooAbsArg>(out.
acquire(std::shared_ptr<TObject>(
main->Clone()),
false,
true));
2752 static std::unique_ptr<cout_redirect>
capture;
2762 if (
sOpt.Contains(
"depth=")) {
2767 if (
sOpt.Contains(
"indent=")) {
2773 sOpt.Replace(
sOpt.Index(
"m"), 1,
"");
2779 if (
get() &&
get() !=
this) {
2784 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2788 std::cout <<
"Minimization Logs:" << std::endl;
2789 std::cout << dynamic_cast<RooStringVar *>(
_fr->constPars().find(
".log"))->getVal() << std::endl;
2803 for (
size_t i = 0; i <
fv->dependents().
size(); i++) {
2809 for (
size_t i = 0; i <
gv->dependents().
size(); i++) {
2816 for(
auto&
c : pi->interpolationCodes())
interpCodes.insert(
c);
2827 }
else if (!
get()) {
2828 std::cout << std::endl;
2832 std::vector<std::string> folderNames;
2833 for (
auto &k : *
this) {
2834 if (std::find(folderNames.begin(), folderNames.end(), k->fFolder) == folderNames.end()) {
2835 folderNames.push_back(k->fFolder);
2838 for (
auto &
f : folderNames) {
2844 std::cout <<
f << std::endl;
2847 for (
auto &k : *
this) {
2848 if (k->fFolder !=
f) {
2854 std::cout << i++ <<
") " << k->GetName() <<
" : ";
2858 auto _deps = k->coords(
false).argList();
2859 auto _snap = std::unique_ptr<RooAbsCollection>(
_deps.snapshot());
2861 k->get()->Print(
sOpt);
2865 if (
auto _type = k->GetNodeType();
strlen(_type)) {
2873 for (
size_t j = 0;
j <
fv->dependents().
size();
j++) {
2879 for (
size_t j = 0;
j <
gv->dependents().
size();
j++) {
2886 for(
auto&
c : pi->interpolationCodes())
interpCodes.insert(
c);
2894 std::cout << k->get()->ClassName() <<
"::" << k->get()->GetName() <<
_suffix.Data() << std::endl;
2900 std::cout <<
" NULL " << std::endl;
2908 for (
size_t i = 0; i <
captureStr.size(); i++) {
2919 (
gROOT->GetListOfBrowsers()->At(0))
2934 double mean = std::numeric_limits<double>::quiet_NaN();
2935 double sigma = mean;
2944 mean = std::numeric_limits<double>::quiet_NaN();
2955 throw std::runtime_error(
"No error on parameter for gaussian constraint");
2961 throw std::runtime_error(
"No error on parameter for poisson constraint");
2963 sigma = pow(
v->getVal() /
v->getError(), 2);
2971 (
v->getVal() + 5 *
v->getError()) *
tau_val);
2972 globs->setConstant();
2973 globs->setAttribute(
"obs");
2974 globs->setAttribute(
"global");
2987 Info(
"Constrain",
"Added poisson constraint pdf RooPoisson::%s (tau=%g) for %s", out->GetName(),
tau_val,
2994 globs->setAttribute(
"obs");
2995 globs->setAttribute(
"global");
2996 globs->setConstant();
3005 Info(
"Constrain",
"Added gaussian constraint pdf RooGaussian::%s (mean=%g,sigma=%g) for %s", out->GetName(),
3014 throw std::runtime_error(
"Cannot constrain non arg");
3017 if (!
p->dependsOn(*
_me)) {
3018 throw std::runtime_error(
"Constraint does not depend on constrainee");
3027 throw std::runtime_error(
"Nowhere to put constraint");
3032 for (
auto d :
x->datasets()) {
3042 if (k ==
"globalObservables" ||
TString(k).
EndsWith(
"_GlobalObservables")) {
3051 for (
auto &
c : *
x) {
3057 return x->Multiply(
child);
3059 return x->Add(
child,
"+");
3082 auto o = std::dynamic_pointer_cast<RooAbsReal>(
acquire(
child.fComp));
3105 ?
fParent->mainChild()->GetName()
3112 throw std::runtime_error(
3132#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3139 for (std::size_t i = 0; i <
pSet.size(); i++) {
3149 _bin->fBinNumber = -1;
3178 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3183 std::rethrow_exception(std::current_exception());
3195 Info(
"Multiply",
"Scaled %s by existing factor %s::%s",
3199 }
else if (
sOpt ==
"const") {
3202 Info(
"Multiply",
"Scaled %s by new const factor %s",
3206 }
else if (
sOpt ==
"norm") {
3213 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3218 throw std::runtime_error(
TString::Format(
"Failed to create new normFactor %s",
child.GetName()));
3222 Info(
"Multiply",
"Scaled %s by new norm factor %s",
3226 }
else if (
sOpt ==
"shape" ||
sOpt ==
"simple" ||
sOpt ==
"blankshape") {
3231 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
3232 h->SetBinContent(i, 1);
3237 h->SetTitle(
child.GetTitle());
3238 if (
sOpt.Contains(
"shape"))
3242 Info(
"Multiply",
"Scaled %s by new %s factor %s",
3247 }
else if (
sOpt ==
"overall") {
3249 child.GetName(),
child.GetTitle(),
RooArgList(), 1, std::vector<double>(), std::vector<double>()));
3251 Info(
"Multiply",
"Scaled %s by new overall factor %s",
3255 }
else if (
sOpt ==
"func" &&
ws()) {
3260 Info(
"Multiply",
"Scaled %s by new func factor %s",
3273 std::shared_ptr<TObject> out;
3274 child.convertForAcquisition(*
this);
3285 if (
p->coefList().empty() && !
p->pdfList().empty()) {
3286 for (
auto _pdf :
p->pdfList()) {
3292 Info(
"Multiply",
"Created RooExtendedBinding coefficients for all pdfs of %s so that can multiply coef",
3294 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3295 p->Class()->GetDataMemberOffset(
"_allExtendable")) =
false;
3296 *
reinterpret_cast<bool *
>(
reinterpret_cast<unsigned char *
>(
p) +
3297 p->Class()->GetDataMemberOffset(
"_haveLastCoef")) =
true;
3299 for (
size_t i = 0; i <
p->pdfList().size(); i++) {
3301 auto coefs =
p->coefList().at(i);
3310 for (
size_t j = 0;
j <
p->coefList().size();
j++) {
3317 const_cast<RooArgList &
>(
p->coefList()).removeAll();
3327 for (
size_t i = 0; i <
p2->funcList().
size(); i++) {
3329 auto coefs =
p2->coefList().at(i);
3338 for (
size_t j = 0;
j <
p2->coefList().size();
j++) {
3353 throw std::runtime_error(
"this coefs case is not supported");
3357 std::shared_ptr<TObject> out;
3364 if (
auto _f = std::dynamic_pointer_cast<RooHistFunc>(
3366 _f &&
_f->getAttribute(
"autodensity")) {
3376 if (
_f->getAttribute(
"density")) {
3379 for (
int i = 0; i <
_f->dataHist().numEntries(); i++) {
3383 _f->setValueDirty();
3390 _f->setAttribute(
"autodensity",
false);
3394 Info(
"Multiply",
"Created %s factor %s in %s",
3398 Info(
"Multiply",
"Created Shape factor %s in %s",
child->GetName(),
p->GetName());
3401 if (
auto _f = std::dynamic_pointer_cast<RooAbsReal>(out);
_f) {
3402#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3403 p->_compRSet.add(*
_f);
3411 for (
auto &_par :
_out.pars()) {
3414 for (
auto &
_constr : _par->constraints()) {
3422 Info(
"Multiply",
"Pulling in %s boundConstraint: %s", _par->GetName(), s);
3425 throw std::runtime_error(
"Couldn't find boundConstraint");
3427 _par->Constrain(_pdf);
3436 std::shared_ptr<TObject> out;
3437 child.convertForAcquisition(*
this);
3446 std::shared_ptr<RooAbsPdf> _pdf;
3463 _pdf->setStringAttribute(
"alias",
child.GetName());
3465 _pdf->setStringAttribute(
"xvar",
p2->getStringAttribute(
"xvar"));
3466 _pdf->setStringAttribute(
"binning",
p2->getStringAttribute(
"binning"));
3468 Info(
"Multiply",
"Created %s::%s in channel %s", _pdf->ClassName(), _pdf->GetName(),
p2->GetName());
3473 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3474#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3476#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
3477 p2->_pdfNSetList.emplace_back(std::make_unique<RooArgSet>(
"nset"));
3481 if (!
p2->canBeExtended() && _pdf->canBeExtended()) {
3482 p2->_extendedIndex =
p2->_pdfList.size() - 1;
3493 std::shared_ptr<TObject> out;
3494 child.convertForAcquisition(*
this);
3500 TString s =
p3->getStringAttribute(
"global_factors");
3503 s += out->GetName();
3504 p3->setStringAttribute(
"global_factors", s);
3507 "Flagged %s as a global factor in channel %s (is applied to all current and future samples in the channel)",
3508 out->GetName(),
p3->GetName());
3519 std::set<RooAbsArg *> cl;
3520 for (
auto &arg :
p5->clients()) {
3526 if (cl.size() > 1) {
3531 Warning(
"Multiply",
"Scaling %s that has multiple clients",
p5->GetName());
3537 for (
auto &
a :
p5->attributes())
3538 new_p->setAttribute(
a.c_str());
3539 for (
auto &
a :
p5->stringAttributes())
3540 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3541 if (!
new_p->getStringAttribute(
"alias"))
3542 new_p->setStringAttribute(
"alias",
p5->GetName());
3545 for (
auto arg : cl) {
3557 throw std::runtime_error(
3559 (!
child.get() &&
strlen(opt) == 0) ?
" (forgot to specify factor type?)" :
""));
3567 throw std::runtime_error(
"Only replacement of RooAbsArg is supported");
3576 new_p = std::dynamic_pointer_cast<RooAbsArg>(out).get();
3578 std::set<RooAbsArg *> cl;
3579 for (
auto &arg :
p5->clients()) {
3587 if (cl.size() > 1) {
3595 Warning(
"Replace",
"Replacing %s in all clients: %s",
p5->GetName(),
clientList.str().c_str());
3599 new_p->setAttribute(
Form(
"ORIGNAME:%s",
p5->GetName()));
3600 for (
auto arg : cl) {
3624 auto _ref = emplace_back(std::shared_ptr<xRooNode>(&
const_cast<xRooNode &
>(
child), [](
TObject *) {}));
3629 std::rethrow_exception(std::current_exception());
3641 std::string label =
child.GetName();
3642 if (
auto pos = label.find(
'='); pos != std::string::npos)
3643 label = label.substr(pos + 1);
3644 if (!s->indexCat().hasLabel(label)) {
3649 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3654 throw std::runtime_error(
TString::Format(
"Failed to find %s regular observable in %s dataset",
3655 s->indexCat().GetName(),
_ds->GetName()));
3657 dsCat->defineType(label.c_str());
3663 std::shared_ptr<TObject> out;
3664 child.convertForAcquisition(*
this);
3667 }
else if (!
child.fComp) {
3670 Info(
"Vary",
"Created channel RooProdPdf::%s in model %s", out->GetName(), s->GetName());
3673 if (
auto _pdf = std::dynamic_pointer_cast<RooAbsPdf>(out); _pdf) {
3678 if (
auto bb =
_ds->getBrowsable(
".sourceds")) {
3687 _pdf->leafNodeServerList(&
leafs);
3688 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
3692 globs.addClone(*
_ds->getGlobalObservables());
3696 alist += std::string(
aa->GetName()) +
",";
3699 if (!alist.empty()) {
3700 Warning(
"Vary",
"Adding %s to global observables of %s", alist.c_str(),
_ds->GetName());
3706 s->addPdf(*_pdf, label.c_str());
3718 child.convertForAcquisition(*
this);
3720 if (!_c &&
child.get()) {
3721 throw std::runtime_error(
"Only pure consts can be set as variations of a flexible interpvar");
3723#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3724 double value = (_c ? _c->getVal() :
p->_nominal);
3727 double value = (_c ? _c->getVal() :
p->nominal());
3732 if (
cName ==
"nominal") {
3736 if (
cName.CountChar(
'=') != 1) {
3737 throw std::runtime_error(
"unsupported variation form");
3742 throw std::runtime_error(
"unsupported variation magnitude");
3755 if (!
p->findServer(*
v)) {
3756#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3757 p->_paramList.add(*
v);
3758 p->_low.push_back(0);
3759 p->_high.push_back(0);
3760 p->_interpCode.push_back(4);
3763 const_cast<std::vector<double> &
>(
p->low()).push_back(0);
3764 const_cast<std::vector<double> &
>(
p->high()).push_back(0);
3765 const_cast<std::vector<int> &
>(
p->interpolationCodes()).push_back(4);
3767 v->setAttribute(
Form(
"SYMMETRIC%s_%s", high ?
"+" :
"-",
GetName()));
3772 if (
v->getAttribute(
Form(
"SYMMETRIC+_%s",
GetName()))) {
3775 v->setAttribute(
Form(
"SYMMETRIC-_%s",
GetName()),
false);
3778 if (
v->getAttribute(
Form(
"SYMMETRIC-_%s",
GetName()))) {
3781 v->setAttribute(
Form(
"SYMMETRIC+_%s",
GetName()),
false);
3791 if (
cName.CountChar(
'=') != 1) {
3792 throw std::runtime_error(
"unsupported variation form");
3797 throw std::runtime_error(
"unsupported variation magnitude");
3799#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3802 throw std::runtime_error(
3803 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->_nominal.absArg()->ClassName()));
3808 throw std::runtime_error(
3809 TString::Format(
"Interpolating %s instead of RooHistFunc",
p2->nominalHist()->ClassName()));
3815 for (
auto par :
p2->paramList()) {
3816 if (
parName == par->GetName()) {
3830 std::shared_ptr<RooHistFunc>
up(
3832 std::shared_ptr<RooHistFunc>
down(
3835#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3836 std::unique_ptr<RooDataHist>
h1(
3838 std::unique_ptr<RooDataHist> h2(
3840 up->_dataHist =
dynamic_cast<RooDataHist *
>(
f->dataHist().Clone(
Form(
"hist_%s",
up->GetName())));
3846 auto ups = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
up,
false,
true));
3847 auto downs = std::dynamic_pointer_cast<RooHistFunc>(
acquire(
down,
false,
true));
3848#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
3849 p2->_highSet.add(*
ups.get());
3850 p2->_lowSet.add(*
downs.get());
3851 p2->_interpCode.push_back(4);
3852 p2->_paramSet.add(*
v);
3856 const_cast<std::vector<int> &
>(
p2->interpolationCodes()).push_back(4);
3859 p2->setValueDirty();
3863 f->setStringAttribute(
"symmetrizes",
otherf->GetName());
3864 f->setStringAttribute(
"symmetrize_nominal",
nomf->GetName());
3865 otherf->setStringAttribute(
"symmetrized_by",
f->GetName());
3883#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
3886 if (
cName.CountChar(
'=') != 1) {
3887 throw std::runtime_error(
"unsupported variation form");
3893 if (!
pmr->indexCategory()->hasLabel(
parVal.Data())) {
3896 auto idx =
pmr->indexCategory()->lookupIndex(
parVal.Data());
3898 throw std::runtime_error(
"Invalid index");
3901 child.convertForAcquisition(*
this);
3904 if (
pmr->getModelList().empty()) {
3905 throw std::runtime_error(
"No real function given for variation, and no nominal function to clone");
3907 _c = std::dynamic_pointer_cast<RooAbsReal>(
3908 acquire(std::shared_ptr<TObject>(
pmr->getModelList().at(0)->Clone(
3912 _c->setStringAttribute(
"alias",
child.GetName());
3922 if (
p3->getAttribute(
"RooRealConstant_Factory_Object")) {
3923 throw std::runtime_error(
"Cannot vary pure constants");
3929 std::set<RooAbsArg *> cl;
3930 for (
auto &arg :
p3->clients()) {
3935 if (cl.size() > 1) {
3940 Warning(
"Vary",
"Varying %s that has multiple clients",
p3->GetName());
3943 p3->setStringAttribute(
"origName",
p3->GetName());
3945 p3->SetName(
Form(
"%s_nominal",
p3->GetName()));
3948 std::vector<double>(), std::vector<double>());
3951 for (
auto &
a :
p3->attributes())
3952 new_p->setAttribute(
a.c_str());
3953 for (
auto &
a :
p3->stringAttributes())
3954 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
3958 for (
auto arg : cl) {
3969 std::set<RooAbsArg *> cl;
3970 for (
auto &arg :
p4->clients()) {
3975 if (cl.size() > 1) {
3980 Warning(
"Vary",
"Varying %s that has multiple clients",
p4->GetName());
3983 p4->setStringAttribute(
"origName",
p4->GetName());
3985 p4->SetName(
Form(
"%s_nominal",
p4->GetName()));
3987#if ROOT_VERSION_CODE > ROOT_VERSION(6, 37, 00)
3988 std::shared_ptr<RooAbsArg>
new_p;
3991 if (
cName.CountChar(
'=') == 1) {
3998 throw std::runtime_error(
"Failed to acquire categorical index for RooMultiReal");
4001 if (
idxCat->numTypes() == 0) {
4002 idxCat->defineType(
"nominal");
4004 Info(
"Vary",
"Creating a RooMultiReal with category %s",
idxCat->GetName());
4021 for (
auto &
a :
p4->attributes())
4022 new_p->setAttribute(
a.c_str());
4023 for (
auto &
a :
p4->stringAttributes())
4024 new_p->setStringAttribute(
a.first.c_str(),
a.second.c_str());
4028 for (
auto arg : cl) {
4071 a->setStringAttribute(
"alias",
GetName());
4074 throw std::runtime_error(
"Cannot determine type");
4079 if (
auto h =
dynamic_cast<const TH1 *
>(&o);
h) {
4096 throw std::runtime_error(
"no xaxis");
4101 if (
h->GetXaxis()->IsVariableBinSize()) {
4102 _v->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()));
4110 for (
int bin = 1; bin <=
h->GetNbinsX(); bin++) {
4119 throw std::runtime_error(
"Failed setting stat error");
4123 }
else if (
auto _c =
dynamic_cast<const RooConstVar *
>(&o); _c) {
4135 throw std::runtime_error(
"Assignment failed");
4168 std::map<RooAbsRealLValue *, double>
valsToSet;
4170 auto idx = pattern.
Index(
'=');
4173 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4175 for (
auto p :
_pars.argList()) {
4178 p->setAttribute(
"Constant",
true);
4179 if (!std::isnan(val)) {
4187 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4203 val.
IsAlpha() ? val :
nullptr));
4210 if (
d->get()->TestBit(1 << 20)) {
4220 _nll.fitConfigOptions()->SetValue(
"LogSize", 65536);
4221 _nll.fitConfig()->MinimizerOptions().SetPrintLevel(0);
4222 auto fr = _nll.minimize();
4225 throw std::runtime_error(
"Fit Failed");
4228 for (
unsigned int i = 0; i < fr->numStatusHistory(); i++) {
4232 (
gROOT->GetListOfBrowsers()->At(0))
4236 if (_nll.fOpts->find(
"GoF")) {
4237 gofResult =
TString::Format(
"GoF p-value = %g (mainTerm = %g)\n", fr->constPars().getRealValue(
".pgof"),fr->constPars().getRealValue(
".mainterm_pgof"));
4239 if (fr->status() != 0) {
4241 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4245 }
else if (fr->covQual() != 3 && _nll.fitConfig()->ParabErrors()) {
4246 new TGMsgBox(
gClient->GetRoot(),
w,
"Fit Finished with Bad Covariance Quality",
4247 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4253 TString::Format(
"%s\nData = %s\nFit Status Code = %d\nCov Quality = %d\n%s-------------%s",
4258 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4271 fb->DoubleClicked(
p, 0);
4272 if (
auto first =
p->GetFirstChild()) {
4274 if (first->IsOpen() &&
TString(first->GetText()) ==
"fits") {
4275 fb->DoubleClicked(first, 0);
4277 }
while ((first = first->GetNextSibling()));
4287 }
catch (
const std::exception &
e) {
4290 (
gROOT->GetListOfBrowsers()->At(0))
4303 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4316 fb->DoubleClicked(
p, 0);
4317 if (
auto first =
p->GetFirstChild()) {
4319 if (first->IsOpen() &&
TString(first->GetText()) ==
"datasets") {
4320 fb->DoubleClicked(first, 0);
4322 }
while ((first = first->GetNextSibling()));
4332 }
catch (
const std::exception &
e) {
4335 (
gROOT->GetListOfBrowsers()->At(0))
4338 "Exception",
e.what(),
4345 const char *options)
4355 if (
d->get()->TestBit(1 << 20)) {
4361 std::unique_ptr<RooAbsCollection>
snap(
_pars.argList().snapshot());
4364 auto idx = pattern.
Index(
'=');
4367 (idx == -1) ? std::numeric_limits<double>::quiet_NaN() :
TString(pattern(idx + 1, pattern.
Length())).
Atof();
4369 for (
auto par :
_pars.argList()) {
4372 par->setAttribute(
"Constant",
true);
4373 if (!std::isnan(val)) {
4379 throw std::runtime_error(std::string(
"Unrecognised parameter: ") +
pat.Data());
4395 val.
IsAlpha() ? val :
nullptr));
4399 hs.SetName(
TUUID().AsString());
4411 (
gROOT->GetListOfBrowsers()->At(0))
4414 "Scan Finished with Bad Status Code",
4419 if (
auto res =
hs.result())
4426 for (
auto a : *
gROOT->GetListOfBrowsers()) {
4439 fb->DoubleClicked(
p, 0);
4440 if (
auto first =
p->GetFirstChild()) {
4442 if (first->IsOpen() &&
TString(first->GetText()) ==
"scans") {
4443 fb->DoubleClicked(first, 0);
4445 }
while ((first = first->GetNextSibling()));
4456 }
catch (
const std::exception &
e) {
4459 (
gROOT->GetListOfBrowsers()->At(0))
4470 }
catch (
const std::exception &
e) {
4479#if ROOT_VERSION_CODE > ROOT_VERSION(6, 29, 00)
4484 for (
auto a : *
this) {
4491 for (
auto c : args) {
4497 f.SetParName(i,
c->GetName());
4499 f.SetParLimits(i,
v->getMin(),
v->getMax());
4500 if (
v->isConstant())
4501 f.FixParameter(i,
v->getVal());
4503 f.SetParameter(i,
v->getVal());
4504 f.SetParError(i,
v->getError());
4515 (
gROOT->GetListOfBrowsers()->At(0))
4521 for (i = 0; i <
f.GetNpar(); i++) {
4522 auto c = args.
find(
f.GetParName(i));
4527 f.GetParLimits(i, low, high);
4529 v->setConstant(low);
4531 v->setRange(low, high);
4541 throw std::runtime_error(
"Failed to SetContent");
4542 }
catch (
const std::exception &
e) {
4556 std::shared_ptr<TH1D>
h;
4557 auto _b =
dynamic_cast<Axis2 *
>(
ax)->binning();
4558 if (
_b->isUniform()) {
4565 h->SetOption(
"nostyle");
4580 auto _ax = (bin) ?
GetXaxis() :
nullptr;
4582 throw std::runtime_error(
"Cannot determine binning to fill data");
4584 if (_ax && _ax->GetNbins() < bin) {
4585 throw std::out_of_range(
TString::Format(
"%s range %s only has %d bins", _ax->GetParent()->GetName(),
4586 _ax->GetName(), _ax->GetNbins()));
4592 for (
auto _c :
coords()) {
4596 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
4604 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
4607 throw std::runtime_error(
"SetBinContent of data: Unsupported coordinate type");
4616 cut2 =
TString::Format(
"%s >= %f && %s < %f", _ax->GetParent()->GetName(), _ax->GetBinLowEdge(bin),
4617 _ax->GetParent()->GetName(), _ax->GetBinUpEdge(bin));
4649 l.remove(*_data->get(),
true,
true);
4654 _data->addColumn(*
x);
4664 for (
auto &o :
obs) {
4666 if (
auto dv =
dynamic_cast<RooRealVar *
>(_data->get()->find(
v->GetName()));
dv) {
4667 if (
v->getMin() <
dv->getMin())
4668 dv->setMin(
v->getMin());
4669 if (
v->getMax() >
dv->getMax())
4670 dv->setMax(
v->getMax());
4673 if (
auto dc =
dynamic_cast<RooCategory *
>(_data->get()->find(
c->GetName()));
dc) {
4674 if (!
dc->hasLabel(
c->getCurrentLabel())) {
4675 dc->defineType(
c->getCurrentLabel(),
c->getCurrentIndex());
4684 if (
auto _nentries = std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula))->numEntries();
4689 Info(
"SetBinContent",
"Binning %s in channel: %s",
GetName(), cut.
Data());
4692 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4694 _data->add(*_obs,
_reduced->weight());
4697 for (
int i = 1; i <= _ax->GetNbins(); i++) {
4701 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(i - 1, _ax->GetName());
4707 if (std::unique_ptr<RooAbsData>(_data->reduce(
cutFormula2))->numEntries() > 0) {
4710 for (
int j = 0;
j <
_reduced->numEntries();
j++) {
4712 _data->add(*_obs,
_reduced->weight());
4716 dynamic_cast<RooAbsLValue *
>(_ax->GetParent())->setBin(bin - 1, _ax->GetName());
4723 throw std::runtime_error(
"RooDataHist not supported yet");
4728 if (!par ||
strlen(par) == 0) {
4731 return it->SetBinContent(bin,
value);
4743 if (!par ||
strlen(par) == 0) {
4756 if (
strcmp(
c->GetName(),
Form(
"%g",
c->getVal())) == 0) {
4759#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 00)
4772 auto bin_pars =
f->dataHist().get(bin - 1);
4773 if (
f->getAttribute(
"density")) {
4781 f->setStringAttribute(
"symmetrized_by",
nullptr);
4783 x->setStringAttribute(
"symmetrizes",
nullptr);
4784 x->setStringAttribute(
"symmetrize_nominal",
nullptr);
4798 f2->setNominal(
value);
4807 push_back(std::make_shared<xRooNode>(
data));
4814 return node->SetBinContent(bin,
value);
4821 push_back(std::make_shared<xRooNode>(
data));
4828 return node->SetContents(obj);
4866 throw std::runtime_error(
"stat factor must be a paramhistfunc");
4875 for (
auto &
p :
xRooNode(
"tmp", *
f, std::shared_ptr<xRooNode>(
nullptr)).vars()) {
4880 auto h = std::unique_ptr<TH1>(
f->dataHist().createHistogram(
parNames
4887 h->SetName(
"statFactor");
4889 h->SetOption(
"blankshape");
4898 throw std::runtime_error(
"Failed creating stat shapeFactor");
4904 TString prefix =
f->getStringAttribute(
"statPrefix");
4905 if (
value && prefix ==
"") {
4909 while (_p && !(_p->get()->InheritsFrom(
"RooRealSumPdf") || _p->get()->InheritsFrom(
"RooAddPdf") ||
4910 _p->get()->InheritsFrom(
"RooWorkspace") || _p->get()->InheritsFrom(
"RooAddition"))) {
4917 Form(
"#gamma^{%s}_{%d}", prefix.
Data(), bin), 1);
4918#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
4925 if (
newVar.get() != var) {
4929 for (std::size_t i = 0; i <
pSet.size(); i++) {
4930 if (
int(i) != bin - 1) {
4945 auto bin_pars =
f->dataHist().get(bin - 1);
4947 if (
f->getAttribute(
"density")) {
4953 for (
auto &[s,
sv] :
rrv->stringAttributes()) {
4954 if (s.find(
"sumw_") == 0) {
4956 }
else if (s.find(
"sumw2_") == 0) {
4960 if (
sumw2 &&
sumw2 != std::numeric_limits<double>::infinity()) {
4962 rrv->setError((tau < 1
e-15) ? 1
e15 : ( 1. / sqrt(tau)));
4963 rrv->setConstant(
false);
4968 rrv->setStringAttribute(
"boundConstraint",
_constr.Add(
"poisson").get()->GetName());
4973 double _min = tau * (1. - 5. * sqrt(1. / tau));
4974 double _max = tau * (1. + 5. * sqrt(1. / tau));
4977 _constr.at(0)->pp().at(0)->SetBinContent(0, tau);
4978 rrv->setStringAttribute(
"boundConstraint",
_constr.at(0)->get()->GetName());
4980 rrv->setRange(std::max((1. - 5. * sqrt(1. / tau)), 1
e-15), 1. + 5. * sqrt(1. / tau));
4984 v.constraints().Remove(*
_constr.at(0));
5003 throw std::out_of_range(
name +
" does not exist");
5025 xRooNode out(
".constraints",
nullptr, *
this);
5038 for (
auto &
c :
n.bins()) {
5049 for (
auto p : _ws->allPdfs()) {
5052 if (
p->dependsOn(par)) {
5053 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5061 for (
auto p : o->pdfList()) {
5064 if (
p->dependsOn(par)) {
5065 out.emplace_back(std::make_shared<xRooNode>(par.GetName(), *
p, *
this));
5071 for (
auto &
p :
vars()) {
5077 if (
v->getAttribute(
"obs"))
5087 auto it = out.std::vector<std::shared_ptr<xRooNode>>
::begin();
5088 while (it != out.std::vector<std::shared_ptr<xRooNode>>
::end()) {
5090 for (
auto &
c : out) {
5091 if (
c.get() == it->get())
5096 std::string
_cName =
c->GetName();
5100 }
while (
_cName.find(
';') != std::string::npos);
5102 _cName = it->get()->GetName();
5106 }
while (
_cName.find(
';') != std::string::npos);
5114 c->TNamed::SetName(
_cName.c_str());
5128 for (
auto &o : out) {
5129 o->TNamed::SetName(o->get()->GetName());
5150 while (
sOpt2.Contains(
"=")) {
5151 auto pos =
sOpt2.Index(
"=");
5152 auto start =
sOpt2.Index(
";") + 1;
5176 if (
auto pos =
varName.Index(
';'); pos != -1) {
5186 binningName =
ax->GetName();
5187 }
else if (
acquirer.obs().size() == 1)
5191 h->GetXaxis()->GetXmax());
5192 if (
x->getMin() >
h->GetXaxis()->GetXmin())
5193 x->setMin(
h->GetXaxis()->GetXmin());
5194 if (
x->getMax() <
h->GetXaxis()->GetXmax())
5195 x->setMax(
h->GetXaxis()->GetXmax());
5196 if (!
x->hasBinning(binningName.c_str())) {
5197 if (
h->GetXaxis()->IsVariableBinSize()) {
5198 x->setBinning(
RooBinning(
h->GetNbinsX(),
h->GetXaxis()->GetXbins()->GetArray()), binningName.c_str());
5201 RooUniformBinning(
h->GetXaxis()->GetXmin(),
h->GetXaxis()->GetXmax(),
h->GetXaxis()->GetNbins()),
5202 binningName.c_str());
5204 x->getBinning(binningName.c_str()).
SetTitle(
h->GetXaxis()->GetTitle());
5205 if (
x->getBinningNames().size() == 2) {
5207 x->setBinning(
x->getBinning(binningName.c_str()));
5211 if (
x->getBinning(binningName.c_str()).numBins() !=
h->GetNbinsX()) {
5212 throw std::runtime_error(
5213 TString::Format(
"binning mismatch for binning %s of %s", binningName.c_str(),
x->GetName()));
5217 std::shared_ptr<RooAbsArg>
_f;
5224 _f->setStringAttribute(k.c_str(),
v.c_str());
5226 x->setAttribute(
"obs",
true);
5227 }
else if (
sOpt2.Contains(
"shape")) {
5229 for (
int i = 0; i <
x->getBinning(binningName.c_str()).numBins(); i++) {
5230 std::shared_ptr<RooAbsArg> arg;
5231 if (
sOpt2.Contains(
"blankshape")) {
5236 }
else if (
h->GetMinimumStored() != -1111 ||
h->GetMaximumStored() != -1111) {
5239 h->GetBinContent(i + 1),
h->GetMinimumStored(),
5240 h->GetMaximumStored());
5244 h->GetBinContent(i + 1));
5252 x->setBinning(
x->getBinning(binningName.c_str()));
5254#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
5255 dynamic_cast<ParamHistFunc *
>(
_f.get())->_paramSet.setName(
"paramSet");
5258 .setName(
"paramSet");
5260 x->setBinning(*
tmp);
5263 _f->setStringAttribute(k.c_str(),
v.c_str());
5267 binningName.c_str() );
5269 throw std::runtime_error(
"Couldn't make data hist");
5274 f->setAttribute(
"autodensity");
5278 _f->setStringAttribute(k.c_str(),
v.c_str());
5282 _f->setStringAttribute(
"xvar",
x->GetName());
5283 _f->setStringAttribute(
"binning", binningName.c_str());
5290 _f = std::dynamic_pointer_cast<RooAbsArg>(
tmp.fComp);
5293 _f->setStringAttribute(
"xvar",
x->GetName());
5294 _f->setStringAttribute(
"binning", binningName.c_str());
5334 if (arg->getStringAttribute(
"style")) {
5335 t = arg->getStringAttribute(
"style");
5345 std::shared_ptr<TStyle>
style;
5347 if (!
gROOT->GetStyle(t)) {
5370 if (arg && !arg->getStringAttribute(
"style")) {
5371 arg->setStringAttribute(
"style",
style->GetName());
5389 if (
auto a =
dynamic_cast<RooAbsArg *
>(arg.get());
a) {
5390 auto out_arg = _ws->arg(
a->GetName());
5397 if (
aName !=
a->GetName())
5398 Warning(
"acquire",
"Renaming to %s",
a->GetName());
5402 if (
auto res = _ws->factory(arg->GetName()); res) {
5409 Info(
"acquire",
"A copy of %s has been added to workspace %s",
a->GetName(), _ws->GetName());
5432 std::unique_ptr<RooAbsCollection>
globals(
leafs.selectByAttrib(
"global",
true));
5442 }
else if (
auto a2 =
dynamic_cast<RooAbsData *
>(arg.get());
a2) {
5448 return std::shared_ptr<TObject>(_ws->embeddedData(arg->GetName()), [](
TObject *) {});
5449 }
else if (arg->InheritsFrom(
"TNamed")) {
5459 out_arg = _ws->genobj(arg->GetName());
5466 if (
aName != arg->GetName()) {
5467 Warning(
"acquire",
"Renaming to %s", arg->GetName());
5469 if (_ws->import(*arg,
false )) {
5473 out_arg = _ws->genobj(arg->GetName());
5485 auto out =
fProvider->getObject(arg->GetName(), arg->ClassName());
5491 _owned = emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
5497 if (
strcmp(
r->GetName(), arg->GetName()) == 0 &&
strcmp(
r->get()->ClassName(), arg->ClassName()) == 0) {
5503 std::cout <<
GetName() <<
" taking over " << arg->ClassName() <<
"::" << arg->GetName() << std::endl;
5505 return _owned->emplace_back(std::make_shared<xRooNode>(arg->GetName(), arg, *
this))->fComp;
5547 throw std::runtime_error(
"Cannot SetXaxis of non-arg");
5550 _x->setBinning(binning,
a->
GetName());
5551 _x->getBinning(
a->GetName()).SetTitle(title);
5552 if (_x->getBinningNames().size() == 2) {
5554 _x->setBinning(_x->getBinning(
a->GetName()));
5559 if (_x->getMax() < high)
5561 if (_x->getMin() > low)
5567 _x->setAttribute(
"obs");
5570 a->setStringAttribute(
"xvar", _x->GetName());
5571 a->setStringAttribute(
"binning",
a->GetName());
5581 if (
ax->IsVariableBinSize()) {
5582 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXbins()->GetArray());
5584 return SetXaxis(
ax->GetName(),
ax->GetTitle(),
ax->GetNbins(),
ax->GetXmin(),
ax->GetXmax());
5590 return find(
name,
false) !=
nullptr;
5598 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5599 for (
auto &
child : *
this) {
5602 (!extra.empty() && ((extra +
"=" +
name) ==
child->GetName() ||
5615 for (
auto &
child2 :
x.browse()) {
5641 auto out = std::make_shared<xRooNode>(obj, *
this);
5656 std::string extra = (_s) ? _s->indexCat().GetName() :
"";
5658 for (
auto &
child : *
this) {
5670 for (
auto &
child2 :
x.browse()) {
5682 folderNode = std::make_shared<xRooNode>(
child->fFolder.c_str(),
nullptr, *
this);
5700 auto out = std::make_shared<xRooNode>(
partname.c_str(),
nullptr, *
this);
5703 out->SetName(
"!pdfs");
5706 return out->operator[](
name.substr(
partname.length() + 1));
5714 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5716 if (!
b || !
b->GetBrowserImp())
5723 if (!
b->GetBrowserImp())
5739 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5741 if (!
b || !
b->GetBrowserImp())
5748 if (
b->GetBrowserImp()) {
5766 a->setStringAttribute(
"alias",
name);
5767 for (
auto o : *
gROOT->GetListOfBrowsers()) {
5768 if (
auto b =
dynamic_cast<TBrowser *
>(o);
b) {
5793 auto findByObj = [&](
const std::shared_ptr<xRooNode> &
n) {
5794 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5795 for (
auto &
c :
nn) {
5796 if (
c->get() ==
n->get() &&
strcmp(
n->GetName(),
c->GetName()) == 0)
5799 return std::shared_ptr<xRooNode>(
nullptr);
5804 const std::vector<std::shared_ptr<xRooNode>> &
nn(
n);
5805 for (
auto &
c :
nn) {
5818 const std::vector<std::shared_ptr<xRooNode>> &
nn2(*
this);
5819 for (
auto &
c :
nn2) {
5820 if (
strlen(
c->GetName()) > 0 && (
c->GetName()[0] ==
'.')) {
5824 if (
strcmp(
c->GetName(),
"!.pars") == 0) {
5863 auto coef = std::make_shared<xRooNode>(
".coef", *
_coefs.at(0)->get(), *
this);
5876 emplace_back(std::make_shared<xRooNode>(
_coefs));
5888 for (
int i = 0; i < arg->numProxies(); i++) {
5889 auto _proxy = arg->getProxy(i);
5899 for (
auto &
child : *
this) {
5907 for (
auto a2 : *s) {
5908 auto c = std::make_shared<xRooNode>(*
a2, *
this);
5909 if (arg->numProxies() != 1) {
5910 c->fFolder = std::string(
"!.") +
5943 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory", std::make_shared<xRooHypoSpace>(
ir), *
this));
5956 auto hpn = emplace_back(std::make_shared<xRooNode>(
coordString,
hp.hypoTestResult,
hs));
5958 hpn->fBrowsables.emplace_back(std::make_shared<xRooNode>(
5964 std::vector<std::shared_ptr<xRooNode>> &
nn = *
this;
5965 for (
auto &
c :
nn) {
5988 std::make_shared<xRooNLLVar::xRooHypoPoint>(std::dynamic_pointer_cast<RooStats::HypoTestResult>(
fComp));
5989 fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
shp, *
this));
5995 if (
auto fit =
hp->ufit()) {
5996 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"ufit");
5998 if (
auto fit =
hp->cfit_null()) {
5999 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_null");
6001 if (
auto fit =
hp->cfit_alt()) {
6002 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"cfit_alt");
6004 if (
auto fit =
hp->gfit()) {
6005 fits.emplace_back(std::make_shared<xRooNode>(fit, *
this))->TNamed::SetName(
"gfit");
6007 if (
auto asi =
hp->asimov()) {
6008 auto asiP =
fits.emplace_back(std::make_shared<xRooNode>(
6009 asi->hypoTestResult ?
asi->hypoTestResult : std::make_shared<RooStats::HypoTestResult>(
asi->result()),
6011 asiP->TNamed::SetName(
"asimov");
6012 asiP->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".memory",
asi,
asiP));
6018 auto it = std::vector<std::shared_ptr<xRooNode>>
::begin();
6019 while (it != std::vector<std::shared_ptr<xRooNode>>
::end()) {
6020 if (it->get()->fTimes == 0) {
6021 for (
auto o : *
gROOT->GetListOfBrowsers()) {
6023 if (
b &&
b->GetBrowserImp()) {
6070 xRooNode out(
".obs", std::make_shared<RooArgList>(), *
this);
6072 for (
auto o :
vars()) {
6075 out.emplace_back(o);
6086 xRooNode out(
".globs", std::make_shared<RooArgList>(), *
this);
6088 for (
auto o :
obs()) {
6091 out.emplace_back(o);
6102 xRooNode out(
".robs", std::make_shared<RooArgList>(), *
this);
6104 for (
auto o :
obs()) {
6107 out.emplace_back(o);
6122 xRooNode out(
".pars", std::make_shared<RooArgList>(), *
this);
6124 for (
auto o :
vars()) {
6127 out.emplace_back(o);
6138 xRooNode out(
".consts", std::make_shared<RooArgList>(), *
this);
6140 for (
auto o :
pars()) {
6143 out.emplace_back(o);
6155 xRooNode out(
".floats", std::make_shared<RooArgList>(), *
this);
6157 for (
auto o :
pars()) {
6160 out.emplace_back(o);
6172 xRooNode out(
".poi", std::make_shared<RooArgList>(), *
this);
6174 for (
auto o :
pars()) {
6177 out.emplace_back(o);
6189 xRooNode out(
".np", std::make_shared<RooArgList>(), *
this);
6191 for (
auto o :
pars()) {
6193 (!o->get<
RooAbsArg>()->getAttribute(
"Constant") && !o->get<
RooAbsArg>()->getAttribute(
"poi") &&
6196 out.emplace_back(o);
6207 xRooNode out(
".pp", std::make_shared<RooArgList>(), *
this);
6209 for (
auto o :
pars()) {
6213 out.emplace_back(o);
6224 xRooNode out(
".vars", std::make_shared<RooArgList>(), *
this);
6227 for (
auto &
x : *
this) {
6228 for (
auto &
y :
x->vars()) {
6243 if (!
c->getAttribute(
"global")) {
6245 out.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6247 if (
c->getAttribute(
"global")) {
6248 _globs.emplace_back(std::make_shared<xRooNode>(*
c, *
this));
6249 _globs.back()->fFolder =
"!globs";
6250 }
else if (
c->getAttribute(
"obs")) {
6251 out.back()->fFolder =
"!robs";
6252 }
else if (
c->getAttribute(
"poi")) {
6253 out.back()->fFolder =
"!poi";
6254 }
else if (
c->getAttribute(
"np") ||
6256 out.back()->fFolder =
"!np";
6258 out.back()->fFolder =
"!floats";
6260 out.back()->fFolder =
"!pp";
6266 out.emplace_back(
g);
6269 for (
auto a : *
p2->get()) {
6270 a->setAttribute(
"obs");
6271 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6274 if (
auto _dglobs =
p2->getGlobalObservables()) {
6276 a->setAttribute(
"obs");
6277 a->setAttribute(
"global");
6278 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6283 a->setAttribute(
"obs");
6284 a->setAttribute(
"global");
6285 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6288 }
else if (
auto _ws =
ws(); _ws) {
6291 a->setAttribute(
"obs");
6292 a->setAttribute(
"global");
6293 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6297 for (
auto &
_g :
_gl->second) {
6298 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6299 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6301 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6310 auto _clone = std::shared_ptr<RooAbsArg>(
dynamic_cast<RooAbsArg *
>(
_g->Clone(
_g->GetName())));
6311 if (
auto v = std::dynamic_pointer_cast<RooAbsRealLValue>(
_clone);
v &&
_g->getStringAttribute(
"nominal"))
6313 out.emplace_back(std::make_shared<xRooNode>(
_clone, *
this));
6319 for (
auto a :
w->allVars()) {
6320 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6324 for (
auto a :
w->allCats()) {
6325 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6334 xRooNode out(
".components",
nullptr, *
this);
6339 for (
auto &o :
p->pdfList()) {
6342 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6360 for (
auto &o :
p2->funcList()) {
6363 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6367 for (
auto &o :
p3->list()) {
6368 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6371 for (
auto &
a : *
p4) {
6372 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6375 for (
auto &o :
p5->components()) {
6378 bool hasClients =
false;
6379 for (
auto &
c : o->clients()) {
6380 if (!
c->InheritsFrom(
"RooRealIntegral") &&
p5 ==
GETWS(
c)) {
6387 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6388 if (o->InheritsFrom(
"RooAbsPdf")) {
6389 out.back()->fFolder =
"!pdfs";
6391 out.back()->fFolder =
"!scratch";
6394 for (
auto &o :
p5->allGenericObjects()) {
6398 s = s(0, s.
Index(
';'));
6399 if (
auto _pdf = out.
find(s.
Data()); _pdf) {
6401 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, _pdf));
6408 out.emplace_back(std::make_shared<xRooNode>(fr->GetName(), *fr, *
this));
6410 out.back()->fFolder =
"!fits";
6412 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6414 out.back()->fFolder =
"!styles";
6415 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::HypoTestInverterResult") == 0) {
6416 out.back()->fFolder =
"!scans";
6417 }
else if (
strcmp(out.back()->get()->
ClassName(),
"RooStats::ModelConfig") == 0) {
6418 out.back()->fFolder =
"!models";
6420 out.back()->fFolder =
"!objects";
6427 if (k.find(
"CACHE_") == 0)
6429 out.emplace_back(std::make_shared<xRooNode>(k.c_str(),
v, *
this));
6430 out.back()->fFolder =
"!sets";
6434 std::unique_ptr<TIterator> iter(
snaps.MakeIterator());
6436 while ((
snap = iter->Next())) {
6437 out.emplace_back(std::make_shared<xRooNode>(*
snap, *
this));
6438 out.back()->fFolder =
"!snapshots";
6443 out.emplace_back(std::make_shared<xRooNode>(
".pdf", *
mc->GetPdf(), *
this));
6445 if (
mc->GetExternalConstraints()) {
6446 out.emplace_back(std::make_shared<xRooNode>(
".extCons", *
mc->GetExternalConstraints(), *
this));
6452 out.emplace_back(
c);
6459 out.emplace_back(
c);
6473 xRooNode out(
".bins",
nullptr, *
this);
6476 std::map<int, std::shared_ptr<xRooNode>> cats;
6477 for (
auto &
c :
p->indexCat()) {
6478 auto pp =
p->getPdf(
c.first.c_str());
6482 std::make_shared<xRooNode>(
TString::Format(
"%s=%s",
p->indexCat().GetName(),
c.first.c_str()), *
pp, *
this);
6484 for (
auto &[
_,
n] : cats)
6485 out.emplace_back(
n);
6488#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6491 auto &
pSet =
phf->paramList();
6493 for (
auto par :
pSet) {
6494 out.emplace_back(std::make_shared<xRooNode>(*par, *
this));
6495 out.back()->fBinNumber = i;
6499 for (
int i = 1; i <=
ax->GetNbins(); i++) {
6505 for (
auto &
ss :
f->bins()[i - 1]->factors())
6512 out.emplace_back(std::make_shared<xRooNode>(
6513 TString::Format(
"%g<=%s<%g",
ax->GetBinLowEdge(i),
ax->GetParent()->GetName(),
ax->GetBinLowEdge(i + 1)),
6519#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6525 out.back()->fBinNumber = i;
6550 std::make_shared<RooProduct>(
".recursiveCoefs",
6555 auto mem = out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this));
6556 mem->emplace_back(std::make_shared<xRooNode>(
ourCoefs));
6569 if (!parent->fComp) {
6570 while (!parent->fComp && parent->fParent) {
6571 parent = parent->fParent;
6574 parent = parent->fParent;
6580 for (
auto &o :
p->funcList()) {
6582 if (i >=
p->coefList().size()) {
6584 coefs.add(
p->coefList());
6586 coefs.add(*
p->coefList().at(i));
6593 if (
p2->coefList().empty()) {
6598 for (
auto &o :
p2->pdfList()) {
6600 if (i >=
p2->coefList().size()) {
6604 coefs.add(*
p2->coefList().at(i));
6618 : std::make_shared<RooAddition>((
isResidual) ?
".sumOfCoefs" :
".coefs",
6619 "Coefficients of",
coefs));
6620 xRooNode out(
".coef",
coefSum ? std::dynamic_pointer_cast<RooAbsArg>(std::make_shared<RooFormulaVar>(
6621 ".coef",
"1-sum(otherCoefs)",
"1. - @0", *
coefSum))
6624 out.emplace_back(std::make_shared<xRooNode>(
".memory",
nullptr, *
this))
6626 std::make_shared<xRooNode>(
".sumOfCoefs",
coefSum, out));
6628 if (!
coefs.empty()) {
6632 }
else if (
coefs.size() == 1) {
6634 if (!
coefs.empty()) {
6653 xRooNode out(
".factors",
nullptr, *
this);
6658 a->setStringAttribute(
"alias",
"samples");
6660 a2->setStringAttribute(
"alias",
"components");
6662 int _npdfs =
p->pdfList().size();
6663 for (
auto &o :
p->pdfList()) {
6664 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6665 if (
_npdfs > 5 && o !=
_main.get() && out.back()->robs().size() == 0)
6666 out.back()->fFolder =
"!constraints";
6669 for (
auto &o :
p2->components()) {
6670 if (o->InheritsFrom(
"RooProduct")) {
6672 auto x =
xRooNode(
"tmp", *o, *
this).factors();
6674 out.emplace_back(std::make_shared<xRooNode>(
n->GetName(),
n->fComp, *
this));
6677 out.emplace_back(std::make_shared<xRooNode>(*o, *
this));
6686 for (
auto a :
w->allFunctions()) {
6687 if (_obs.contains(*
a))
6690 for (
auto c :
a->clients()) {
6692 if (
c->InheritsFrom(
"RooProduct")) {
6698 out.emplace_back(std::make_shared<xRooNode>(*
a, *
this));
6742 xRooNode out(
".variations",
nullptr, *
this);
6755#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6756 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
p2->_nominal.arg(), *
this));
6758 out.emplace_back(std::make_shared<xRooNode>(
"nominal", *(
p2->nominalHist()), *
this));
6760 for (
size_t i = 0; i <
p2->paramList().
size(); i++) {
6762 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p2->paramList().at(i)->GetName()),
6763 *
p2->highList().at(i), *
this));
6764 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p2->paramList().at(i)->GetName()),
6765 *
p2->lowList().at(i), *
this));
6768#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
6769 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->_nominal), *
this));
6770 for (
size_t i = 0; i <
p3->_paramList.size(); i++) {
6771 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->_paramList.at(i)->GetName()),
6773 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->_paramList.at(i)->GetName()),
6777 out.emplace_back(std::make_shared<xRooNode>(
"nominal",
RooFit::RooConst(
p3->nominal()), *
this));
6778 for (
size_t i = 0; i <
p3->variables().
size(); i++) {
6779 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=1",
p3->variables().at(i)->GetName()),
6781 out.emplace_back(std::make_shared<xRooNode>(
TString::Format(
"%s=-1",
p3->variables().at(i)->GetName()),
6805 for (
auto &k : *
this) {
6814 xRooNode out(
".datasets()",
nullptr, *
this);
6820 for (
auto &
d : _ws->allData()) {
6821 out.emplace_back(std::make_shared<xRooNode>(*
d, *
this));
6822 out.back()->fFolder =
"!datasets";
6835 for (
auto _c :
coords()) {
6839 cut +=
TString::Format(
"%s==%d", _cat->GetName(), _cat->getCurrentIndex());
6848 _rv->GetName(),
_rv->getMax(
_rv->getStringAttribute(
"coordRange")));
6853 throw std::runtime_error(
"datasets(): Unsupported coordinate type");
6860 for (
auto cat : s->indexCat()) {
6861 if (!s->getPdf(cat.first.c_str())) {
6873 cutobs.add(s->indexCat());
6882 for (
auto &
child : *
this) {
6888 for (
auto &
d :
_wsNode.datasets()) {
6894 if (std::unique_ptr<RooAbsCollection>(
d->obs().argList().selectCommon(_obs))->size() == _obs.
size()) {
6901 out.emplace_back(std::make_shared<xRooNode>(
6906 out.back()->get<
RooAbsData>()->setGlobalObservables(*std::unique_ptr<RooAbsCollection>(
6908 if (
d->get()->TestBit(1 << 20))
6909 out.back()->get()->
SetBit(1 << 20);
6911 out.back()->fBrowsables.emplace_back(std::make_shared<xRooNode>(
".sourceds",
d->fComp, *
this));
6913 out.emplace_back(std::make_shared<xRooNode>(
d->fComp, *
this));
6955 for (
auto o : *
fromPad->GetListOfPrimitives()) {
6975 cat->numTypes(), 0, cat->numTypes());
6977 std::map<int, std::string> cats;
6978 for (
auto &
c : *cat) {
6979 cats[
c.second] =
c.first;
6981 for (
auto &[
_, label] : cats) {
6982 theHist->GetXaxis()->SetBinLabel(i++, label.c_str());
6985 auto _binning =
v->getBinningPtr(
nullptr);
6986 if (_binning->isUniform()) {
6990 v->numBins(), _binning->lowBound(), _binning->highBound());
6995 v->numBins(), _binning->array());
6999 throw std::runtime_error(
"Cannot draw dataset without parent PDF");
7012 auto nHist = std::unique_ptr<TH1>(
static_cast<TH1 *
>(
theHist->Clone(
"nEntries")));
7034 : (
theHist->GetXaxis()->IsAlphanumeric() ?
theHist->GetXaxis()->GetTimeFormatOnly()
7035 :
theHist->GetXaxis()->GetName()));
7054 int nevent =
theData->numEntries();
7055 for (
int i = 0; i < nevent; i++) {
7060 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
7066 if (!
rv->inRange(
theData->get()->getRealValue(
rv->GetName()),
rv->getStringAttribute(
"coordRange"))) {
7099 for (
int i = 0; i <
theHist->GetNbinsX(); i++) {
7101 double val =
theHist->GetBinContent(i + 1);
7104 (
xvar && val) ?
xPos->GetBinContent(i + 1) :
theHist->GetBinCenter(i + 1), val);
7107 double xErr =
xPos2->GetBinContent(i + 1) - pow(
xPos->GetBinContent(i + 1), 2);
7120 dataGraph->GetHistogram()->GetXaxis()->SetLimits(
theHist->GetXaxis()->GetXmin(),
theHist->GetXaxis()->GetXmax());
7124 for (
int i = 1; i <=
theHist->GetNbinsX(); i++)
7125 dataGraph->GetHistogram()->GetXaxis()->SetBinLabel(i,
theHist->GetXaxis()->GetBinLabel(i));
7159 throw std::runtime_error(
"Cannot build graph");
7165 if (
auto _w =
ws();
_w) {
7167 for (
auto o :
_w->allGenericObjects()) {
7169 _fr->ResetBit(1 << 20);
7172 res->SetBit(1 << 20);
7174 auto allVars =
_w->allVars();
7179 throw std::runtime_error(
"Not supported yet");
7193 throw std::runtime_error(
"Not a RooFitResult");
7204#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
7216 if (
sOpt ==
"prefit") {
7230 auto fr = std::make_shared<RooFitResult>(
"prefitResult",
"Prefit");
7231 fr->setFinalParList(*
_pars);
7232 for (
auto &
p : fr->floatParsFinal()) {
7236 if (
auto s =
_v->getStringAttribute(
"nominal"); s)
7239 std::shared_ptr<xRooNode>
pConstr;
7246 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
7247 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
7264 for (
auto &_d :
pConstr->vars()) {
7265 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
7289 if (!
_v->getStringAttribute(
"nominal"))
7301 _args.add(
_globs.argList());
7302 fr->setConstParList(_args);
7305 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7308 fr->setInitParList(*
_snap);
7313 if (
auto _w =
ws();
_w) {
7320 for (
auto p :
pars()) {
7323 if (
_fr->floatParsFinal().find(
p->GetName()) ||
7325 std::abs(
_fr->constPars().getRealValue(
p->GetName(), std::numeric_limits<double>::quiet_NaN()) -
7329 _fr->constPars().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7334 if (!
_fr->floatParsFinal().find(
p->GetName())) {
7337 std::abs(
_fr->floatParsFinal().getRealValue(
p->GetName(),
7338 std::numeric_limits<double>::quiet_NaN()) -
7342 _fr->floatParsFinal().getCatIndex(
p->GetName(), std::numeric_limits<int>().max()))) {
7358 for (
size_t i = 0; i <
newFloats.size(); i++) {
7374 auto fr = std::make_shared<RooFitResult>(
TString::Format(
"%s-dirty",
_fr->GetName()));
7377 fr->setCovarianceMatrix(
cov);
7378 fr->setInitParList(
_fr->floatParsInit());
7383 return xRooNode(*
_fr, std::make_shared<xRooNode>(*
_w, std::make_shared<xRooNode>()));
7388 for (
auto o :
_w->allGenericObjects()) {
7414 auto fr = std::make_shared<RooFitResult>(
TUUID().AsString());
7416 fr->setFinalParList(*
_pars);
7422 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
7423 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
7424 cov(i,
j) = (*prevCov)(i,
j);
7429 for (
auto &
p : fr->floatParsFinal()) {
7432 cov(i, i) = pow(
v->getError(), 2);
7440 fr->setCovarianceMatrix(
cov);
7447 _args.add(
_globs.argList());
7448 fr->setConstParList(_args);
7451 if (
auto atr =
p->getStringAttribute(
"initVal");
atr &&
dynamic_cast<RooRealVar *
>(
p))
7454 fr->setInitParList(*
_snap);
7484 o->setStringAttribute(
"range",
range);
7491 std::string &out =
fRange;
7492 if (
auto o =
get<RooAbsArg>(); o && o->getStringAttribute(
"range"))
7493 out = o->getStringAttribute(
"range");
7495 while (out.empty() && _parent) {
7496 if (
auto o = _parent->get<
RooAbsArg>(); o && o->getStringAttribute(
"range"))
7497 out = o->getStringAttribute(
"range");
7498 _parent = _parent->fParent;
7523 Info(
"nll",
"Overriding NLL Option: %s", o->GetName());
7529 return nll(_data,
l);
7547 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7548 "generate with (found at least %s and %s)",
7554 return mainModel->generate(fr, expected, seed);
7562 std::string selected;
7565 for (
auto c :
bins()) {
7576 if (!selected.empty())
7578 selected +=
cName.Data();
7587 if (
d->get()->TestBit(1 << 20)) {
7593 throw std::runtime_error(
7594 "Need at least one dataset selected (SetChecked) to use for deselected regions");
7626 std::unique_ptr<RooFitResult>
newFr;
7628 newFr = std::make_unique<RooFitResult>(*
_fr);
7640 for (
auto par :
_pars) {
7650 newFr = std::make_unique<RooFitResult>(*
_fr);
7651 for (
auto par :
_pars) {
7673 if (
mc->GetExternalConstraints()) {
7675 for (
auto o :
opts) {
7700 throw std::runtime_error(
TString::Format(
"Workspace has multiple models, you must specify which to "
7701 "build nll with (found at least %s and %s)",
7710 throw std::runtime_error(
TString::Format(
"Workspace has multiple pdfs, you must specify which to "
7711 "build nll with (found at least %s and %s)",
7722 std::string selected;
7724 for (
auto c :
bins()) {
7730 if (!selected.empty())
7745 _d = std::make_shared<xRooNode>(
asi.first, *
this);
7748 std::make_shared<xRooNode>(
".globs", std::const_pointer_cast<RooAbsCollection>(
asi.second), *_d));
7758 me.push_back(std::make_shared<xRooNode>(_data));
7775 for (
int i = 0; i <
opts.GetSize(); i++) {
7778 if (
strcmp(
opts.At(i)->GetName(),
"GlobalObservables") == 0) {
7789 std::dynamic_pointer_cast<RooAbsData>(_data.
fComp), *
_opts);
7899 for (
auto &
c :
bins()) {
7902 _cat.setLabel(
cName);
7909 if (_cat.hasRange(
p) && _cat.inRange(
p)) {
7923 std::vector<TObject *>
funcs;
7933 funcs.push_back(
c->get());
7937 if (!
funcs.empty()) {
7939 _pdf->setFloor(
false);
7965 auto _tmp = fr->reducedCovarianceMatrix(
_pars);
7967 fr->setCovarianceMatrix(
_tmp);
7969 const_cast<RooArgList &
>(fr->floatParsFinal())
7980 for (
auto c : *
this) {
7981 nobs += (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs");
7985 (
isVars &&
p ==
"x" && (
c->fFolder ==
"!robs" ||
c->fFolder ==
"!globs") &&
nobs == 1)) {
8089 return static_cast<RooAbsPdf *
>(intpdf.absArg())->expectedEvents(nset);
8098 return getProjection(&intobs, _normSet, (_normRange.Length() > 0 ? _normRange.Data() :
nullptr), code)->getVal();
8114 return rrv->getErrorHi();
8116 return rrv->getErrorLo();
8118 return rrv->getError();
8135 if (
rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8145 std::stringstream
errMsg;
8146 errMsg <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8147 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case."
8151 throw std::runtime_error(
errMsg.str());
8163 : fr.reducedCovarianceMatrix(*
_pars));
8167 double nomVal =
f.getVal(nset);
8217 for (std::size_t i = 0; i <
_pars->size(); i++) {
8218 errVec[i] = std::sqrt(V(i, i));
8219 for (std::size_t
j = i;
j <
_pars->size();
j++) {
8220 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8226 double sum = F * (
C *
F);
8242 fFunc(
"func",
"func",
this,
f),
8243 fCoef(
"coef",
"coef",
this),
8244 fExpPdf(
"expPdf",
"expPdf",
this)
8249 fCoef.setArg(*coef);
8253 }
else if (
auto _p =
dynamic_cast<RooAbsPdf *
>(&
f);
8265 fExpectedEventsMode(
other.fExpectedEventsMode)
8272 return fFunc->binBoundaries(obs, xlo, xhi);
8277 return (fExpectedEventsMode ? 1. : fFunc) *
8278 ((fExpPdf.absArg()) ?
static_cast<RooAbsPdf *
>(fExpPdf.absArg())->expectedEvents(_normSet) : 1.) *
8279 (fCoef.absArg() ? fCoef : 1.);
8290#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 28, 00)
8291 double oo = getPropagatedError(fr,
nset_in);
8292 if (std::isnan(
oo)) {
8311 rrvFitRes->getError() <= std::abs(
rrvFitRes->getVal()) * std::numeric_limits<double>::epsilon())
8321 std::stringstream
errMsg;
8323 <<
"RooAbsReal::getPropagatedError(): the parameters of the RooAbsReal don't have"
8324 <<
" the same values as in the fit result! The logic of getPropagatedError is broken in this case.";
8326 throw std::runtime_error(
errMsg.str());
8331 if (paramList.
empty())
8366#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8390 std::vector<double>
errVec(paramList.
size());
8391 for (std::size_t i = 0; i < paramList.
size(); i++) {
8392 errVec[i] = std::sqrt(V(i, i));
8393 for (std::size_t
j = i;
j < paramList.
size();
j++) {
8394 C(i,
j) = V(i,
j) / std::sqrt(V(i, i) * V(
j,
j));
8401 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8406 double sum = F * (C *
F);
8416 if (
frv->getError() > 1
e-20) {
8433 for (
Int_t i = 0; i <
fpf.size(); i++) {
8436 paramList.
add(*par);
8472 std::vector<double>
errVec(paramList.
size());
8473 for (
int i = 0; i < paramList.
size(); i++) {
8474 errVec[i] = sqrt(V(i, i));
8475 for (
int j = i;
j < paramList.
size();
j++) {
8476 C(i,
j) = V(i,
j) / sqrt(V(i, i) * V(
j,
j));
8483 for (
unsigned int j = 0;
j <
plusVar.size();
j++) {
8488 double sum = F * (C *
F);
8502 bool fExpectedEventsMode =
false;
8510 std::cout <<
"Got signal " <<
signum << std::endl;
8512 std::cout <<
"Keyboard interrupt while building histogram" << std::endl;
8525 for (
int i = 0; i < obj->numCaches(); i++) {
8531 p->setNormRange(
p->normRange());
8533#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
8538 p->setProxyNormSet(
nullptr);
8539 p->_lastNSet =
nullptr;
8542 obj->setValueDirty();
8546 for (
auto &
c :
w->components()) {
8566 for (
auto obj :
a->clients()) {
8573 }
while (
a->clients().size() !=
nClients);
8592 out.
fComp = std::shared_ptr<TH1>(
8593 BuildHistogram(
nullptr, !
content,
errors, -1, -1, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
false));
8594 }
else if (
vars.size() == 1) {
8596 out.
fComp = std::shared_ptr<TH1>(
8597 BuildHistogram(
v, !
content,
errors, 1, 0, fr,
errorsHi,
errorsLo,
nErrorToys,
nullptr, !stack,
true));
8599 throw std::runtime_error(
"multi-dim histo not yet supported");
8639 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8640 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8641 h->GetXaxis()->SetTimeFormat(
rar->GetName());
8653 if (
h->GetListOfFunctions())
8655 h->SetTitle(
rar->GetTitle());
8662 h =
new TH1D(
rar->GetName(),
rar->GetTitle(), 1, 0, 1);
8665 h->GetXaxis()->SetBinLabel(1,
rar->GetName());
8666 h->SetBinContent(1,
rar->getVal());
8667 if (
x->getError()) {
8668 h->SetBinError(1,
x->getError());
8669 h->SetFillStyle(3005);
8670 h->SetFillColor(
h->GetLineColor());
8672 h->SetMaximum(
x->hasMax() ?
x->getMax()
8673 : (
h->GetBinContent(1) + std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8674 h->SetMinimum(
x->hasMin() ?
x->getMin()
8675 : (
h->GetBinContent(1) - std::max(std::abs(
h->GetBinContent(1) * 0.1), 50.)));
8678 h->SetMarkerSize(0);
8679 h->SetMarkerStyle(0);
8684 TString binningName = (_ax && _ax->GetParent() ==
x) ? _ax->GetName() :
rar->getStringAttribute(
"binning");
8685 if (binningName ==
"")
8686 binningName =
rar->GetName();
8687 if (
x->hasBinning(binningName)) {
8688 if (
x->getBinning(binningName).isUniform()) {
8690 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName) <= 0 ? 100 :
x->numBins(binningName),
8691 x->getMin(binningName),
x->getMax(binningName));
8694 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
x->numBins(binningName),
x->getBinning(binningName).array());
8696 h->GetXaxis()->SetTitle(
x->getBinning(binningName).GetTitle());
8698 }
else if (
auto _boundaries =
8699 _or_func( (std::list<double> *)(
nullptr),
8700 rar->binBoundaries(*
x, -std::numeric_limits<double>::infinity(),
8701 std::numeric_limits<double>::infinity()));
8703 std::vector<double>
_bins;
8704 for (
auto &
b : *_boundaries) {
8711 }
else if (!
x->hasMax() || !
x->hasMin()) {
8714 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getVal() * 0.2,
x->getVal() * 5);
8717 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(),
x->getBinning().array());
8723 h =
new TH1D(
rar->GetName(),
rar->GetTitle(),
v->numBins(
rar->GetName()), 0,
v->numBins(
rar->GetName()));
8727 std::map<int, std::string> cats;
8728 for (
auto &
c : *cat) {
8729 cats[
c.second] =
c.first;
8731 for (
auto &[
_, label] : cats) {
8732 h->GetXaxis()->SetBinLabel(i++, label.c_str());
8738 h->GetXaxis()->SetTitle(o->GetTitle());
8742 if (
h->GetXaxis()->IsAlphanumeric()) {
8751 if (
auto s =
styles(
nullptr,
false); s) {
8757 if (
strlen(
h->GetXaxis()->GetTitle()) == 0)
8758 h->GetXaxis()->SetTitle(
vv->GetTitle());
8787 if (!
GETDMP(fr, _finalPars)) {
8800 for (
int i = 0; i <
prevCov->GetNcols(); i++) {
8801 for (
int j = 0;
j <
prevCov->GetNrows();
j++) {
8802 cov(i,
j) = (*prevCov)(i,
j);
8822 _pars.remove(*_p,
true);
8855 if (
x && (
p ||
_coefs.get() ||
rar->getAttribute(
"density"))) {
8873 for (
auto o : _obs) {
8875 rr->removeMin();
rr->removeMax();
8876 rr->setStringAttribute(
"coordRange",
nullptr);
8880 if (
auto rr =
dynamic_cast<RooRealVar *
>(
v);
rr &&
rr->hasRange(
"coordRange")) {
8881 rr->removeMin();
rr->removeMax();
8882 rr->setStringAttribute(
"coordRange",
nullptr);
8892 bool hasRange =
false;
8895 rr && (
rr->getStringAttribute(
"coordRange")) &&
strlen(
rr->getStringAttribute(
"coordRange"))) {
8905 for (
auto pdf :
bins()) {
8912 dynamic_cast<RooAbsPdf *
>(_pdf)->setNormRange(
"coordRange");
8914 newrar->addPdf(*_pdf, pdf->coords()[s->indexCat().GetName()]->get<
RooCategory>()->getLabel());
8918 rar =
p->createProjection(
8922 dynamic_cast<RooAbsPdf *
>(
rar)->setNormRange(
"coordRange");
8926 p->setNormRange(
"coordRange");
8931 rar = std::unique_ptr<RooAbsReal>{
rar->createIntegral(
8937 std::unique_ptr<RooAbsReal>{
rar->createIntegral(*_obs.get<
RooArgList>() )}
8955 std::unique_ptr<RooArgSet>
snap(
normSet.snapshot());
8977 h->GetNbinsX() == 1 ||
rar->getAttribute(
"BinnedLikelihood") ||
8980 -std::numeric_limits<double>::infinity(),
8981 std::numeric_limits<double>::infinity()))))
8994 if (!(s->get() &&
_clName.Contains(
"Hist"))) {
9012 auto l =
static_cast<TH1 *
>(
h->Clone(
"nominal"));
9015 h->GetListOfFunctions()->Add(
l, (
setInterp) ?
"lsame" :
"histsame");
9019 h->SetMarkerSize(0);
9020 h->SetFillStyle(3005);
9021 h->SetFillColor(
h->GetLineColor());
9037 auto l =
static_cast<TH1 *
>(
h->Clone(
"toys"));
9040 h->GetListOfFunctions()->Add(
9054 static_cast<TH1 *
>(
main_h->GetListOfFunctions()->FindObject(
"toys"))->GetListOfFunctions()->
Add(
h);
9063 if (
_vv->getError() == 0)
9068 for (
int i = std::max(1,
binStart); i <= std::min(
h->GetNbinsX(),
binEnd); i++) {
9071 x->setVal(
h->GetBinCenter(i));
9073 cat->setLabel(
h->GetXaxis()->GetBinLabel(i));
9077 if (
x && !
x->inRange(
"coordRange"))
9081 if (!empty ||
toy > 0) {
9083#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9092 r *=
h->GetBinWidth(i);
9100 h->SetBinContent(i,
r);
9117#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9119 p->_normSet =
nullptr;
9137 res *=
h->GetBinWidth(i);
9139 h->SetBinError(i, res);
9155 res *=
h->GetBinWidth(i);
9160 h->SetBinContent(i,
h->GetBinContent(i) + (res -
h->GetBinError(i)) * 0.5);
9161 h->SetBinError(i, (res +
h->GetBinError(i)) * 0.5);
9173 Warning(
"BuildHistogram",
"Building this histogram will take until %s",
t2.AsString());
9183 Warning(
"BuildHistogram",
"Skipping errors for remaining bins");
9209 auto nomHist =
static_cast<TH1 *
>(
h->FindObject(
"nominal"));
9212 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9213 std::vector<double> vals;
9221 std::sort(vals.begin(), vals.end());
9230 upVal =
h->GetBinContent(i) + err;
9231 downVal =
h->GetBinContent(i) - err;
9239 std::vector<RooAbsArg *> extra;
9242 for (
auto _pdf : s->servers()) {
9244 extra.push_back(_pdf);
9247 extra.push_back(
rar);
9250 for (
auto a : extra)
9257 h->GetYaxis()->SetTitle(
rar->getStringAttribute(
"units"));
9259 h->GetYaxis()->SetTitle(
"Events");
9261 h->GetYaxis()->SetTitle(
"Probability Mass");
9263 h->GetYaxis()->SetMaxDigits(3);
9272 auto hCopy =
static_cast<TH1 *
>(
h->Clone(
"copy"));
9276 hCopy->SetStats(
false);
9277 h->GetListOfFunctions()->Add(
hCopy,
TString(
h->GetOption()) +
"same");
9278 h->GetListOfFunctions()->Add(
hCopy,
"axissame");
9296 std::vector<TH1 *>
hhs;
9304 if (!
rarNode->components().empty()) {
9307 if (
c->fFolder ==
"!.coeffs" ||
c->fFolder ==
"!.coeffpars")
9313 std::shared_ptr<TH1>
prevHist(
static_cast<TH1 *
>(
h->Clone()));
9320 std::unique_ptr<RooAbsReal>
forig(
9321 dynamic_cast<RooAbsReal *
>(
rarNode->components()[0]->get()->Clone(
"tmpCopy0")));
9325 zero.setAttribute(
Form(
"ORIGNAME:%s",
c->GetName()));
9327 std::unique_ptr<RooAbsReal>
f(
dynamic_cast<RooAbsReal *
>(
forig->Clone(
"tmpCopy")));
9332 hh->SetName(
c->GetName());
9334 hh->Scale(
sf->getVal());
9336 hh->SetTitle(
c->GetName());
9343 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9348 std::shared_ptr<TH1>
nextHist(
static_cast<TH1 *
>(
hh->Clone()));
9352 hh->TH1::Reset(
"ICE");
9367 auto hh =
static_cast<TH1 *
>(
h->Clone(
samp->GetName()));
9369 hh->SetTitle(
samp->GetTitle());
9371 hh->SetTitle(
samp->GetName());
9373 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9377 .ReplaceAll(
TString(
chan->get()->GetName()) +
"_",
9381 hh->SetBinContent(
hh->GetXaxis()->FindFixBin(
chanName),
samp->GetContent());
9387 auto hh =
samp->BuildHistogram(
9388 v, empty,
false ,
binStart,
binEnd,
_fr,
false,
false, 0,
h,
true,
9390 hh->SetName(
samp->GetName());
9392 hh->Scale(
sf->getVal());
9395 hh->SetTitle(
samp->GetName());
9397 }
else if (
strcmp(
hh->GetName(),
hh->GetTitle()) == 0) {
9411 for (
auto &
hh :
hhs) {
9462 if (
titlesMap[s.substr(0,
jj)] == 1 && (
jj >= s.length() || s.at(
jj) ==
' ' || s.at(
jj) ==
'_')) {
9477 (*ritr)->SetTitle(
_title.c_str());
9481 for (
auto &
hh :
hhs) {
9492 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
9513 h->GetListOfFunctions()->AddFirst(stack,
"noclear same");
9522 if (
ll &&
ll->GetEntries()) {
9525 for (
auto ho : *
ll) {
9533 hh->SetFillStyle(1001);
9537 if (!
gROOT->GetColor(
hh->GetFillColor())) {
9539 hh->SetFillColor(0);
9543 for (
auto ho2 : *
ll) {
9564 if (
hh->GetFillColor() ==
kWhite &&
hh->GetFillStyle() != 0) {
9567 hh->SetFillColor(10);
9580 push_back(std::make_shared<xRooNode>(
data));
9588 return std::numeric_limits<double>::quiet_NaN();
9589 return node->GetBinContent(bin);
9600 std::vector<double> out;
9612 for (
int i = 0; i <
g->GetN(); i++)
9613 integral +=
g->GetPointY(i);
9614 out.push_back(integral);
9619 out.push_back(
g->GetPointY(i));
9640 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
9641 tot +=
h->GetBinContent(i);
9646 out.push_back(
h->GetBinContent(i));
9657 for (
auto &
l :
a->servers()) {
9677 if (
auto o =
get(); o) {
9686#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
9690 for (
int i = 0; i <
p->fCGnx; i++) {
9691 for (
int j = 0;
j <
p->fCGny;
j++) {
9692 p->fCollideGrid[i +
j *
p->fCGnx] =
true;
9695 p->FillCollideGrid(o);
9704 if (
p->Collide(i,
j,
iw,
ih)) {
9715 return p->PlaceBox(o,
w,
h,
xl,
yb,
"trw");
9723 gPad->PaintModified();
9729 auto l =
new TPaveText(
gPad->GetLeftMargin() + 0.02, 1. -
gPad->GetTopMargin() - 0.08, 0.6,
9730 1. -
gPad->GetTopMargin() - 0.08);
9731 l->SetBorderSize(0);
9732 if (
l->GetTextSize() == 0)
9740 l->ConvertNDCtoPad();
9746 if (
auto p =
dynamic_cast<TLegend *
>(
gPad->GetPrimitive(
"legend"));
p) {
9749 double w =
p->GetX2NDC() -
p->GetX1NDC();
9750 double h =
p->GetY2NDC() -
p->GetY1NDC();
9752 gPad->PaintModified();
9756 x = std::max(
x, (
gPad->GetLeftMargin() + 0.02));
9757 y = std::max(
y, (
gPad->GetBottomMargin() + 0.02));
9758 x = std::min(
x, (1. -
gPad->GetRightMargin() - 0.02) -
w);
9759 y = std::min(
y, (1. -
gPad->GetTopMargin() - 0.02) -
h);
9760 h = std::min(
h, (1. -
gPad->GetTopMargin() - 0.02) -
y);
9761 w = std::min(
w, (1. -
gPad->GetRightMargin() - 0.02) -
x);
9773 while ((
p !=
p->GetMother()) && (
p =
p->GetMother())) {
9774 if (
auto q =
dynamic_cast<TVirtualPad *
>(
p->GetPrimitive(
"legend"));
q) {
9782 if (
p &&
strcmp(
p->GetName(),
"legend") == 0) {
9783 if (
l =
dynamic_cast<TLegend *
>(
p->GetPrimitive(
"legend"));
l || !create)
9787 gPad->GetBottomMargin());
9788 l->SetBorderSize(1);
9792 l =
new TLegend(0.6, 1. -
gPad->GetTopMargin() - 0.08, 0.75, 1. -
gPad->GetTopMargin() - 0.08);
9793 l->SetBorderSize(0);
9795 if (
l->GetTextSize() == 0) {
9803 l->SetName(
"legend");
9805 l->ConvertNDCtoPad();
9812 auto i = s.find(
"\n");
9813 if (i == std::string::npos) {
9816 return std::string(
"#splitline{") + s.substr(0, i) +
"}{" +
formatLegendString(s.substr(i + 1)) +
"}";
9825 for (
auto a : *
l->GetListOfPrimitives()) {
9829 if (
l->GetListOfPrimitives()->GetEntries() > 20)
9834 l->GetListOfPrimitives()->RemoveLast();
9835 l->GetListOfPrimitives()->AddFirst(
e);
9836 if (
auto nObj =
l->GetListOfPrimitives()->GetEntries();
nObj > 0) {
9838 int nn =
l->GetNColumns();
9841 l->SetNColumns(
l->GetNColumns() + 1);
9842 if (
l->GetBorderSize() == 0) {
9843 l->SetX1NDC(
l->GetX2NDC() - 0.15 *
l->GetNColumns());
9846 if (
l->GetBorderSize() == 0) {
9847 l->SetY1NDC(
l->GetY2NDC() - 0.05 *
gPad->GetHNDC() * std::ceil((
double(
nObj) /
l->GetNColumns())));
9865#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
9881 if (
gROOT->FromPopUp()) {
9882 gROOT->SetFromPopUp(
false);
9885 }
catch (
const std::exception &
e) {
9888 (
gROOT->GetListOfBrowsers()->At(0))
9891 "Exception",
e.what(),
9894 gROOT->SetFromPopUp(
true);
9926 if (
d->get()->TestBit(1 << 20)) {
9932 hs.limits(
"cls visualize");
9944 [](
double a,
double b,
double) {
9947 if (
b == 0 &&
a == 0)
9954 [](
double n,
double b,
double sigma) {
9958 t0 = 2. * (((
n == 0) ? 0 :
n * log(
n /
b)) - (
n -
b));
9968 return (
n >=
b) ? sqrt(
t0) : -sqrt(
t0);
9977 if (
sOpt2.Contains(
"x=")) {
9979 int _idx =
sOpt2.Index(
"x=");
9995 }
else if (
ii == 1) {
9997 }
else if (
ii == 2) {
10005 for (
double x = min;
x <= max;
x += (max - min) / (nBins - 1)) {
10008 }
else if (nBins == 1)
10009 xPoints.push_back((min + max) / 2.);
10018 for (
int i = 0; i <
v->numBins(
GetName()); i++) {
10028 if (
sOpt2.Contains(
"force")) {
10042 Error(
"Draw",
"Can only compute forces with PDFs");
10054 if (
sOpt2.Contains(
"ratio") && !
sOpt2.Contains(
"auxratio"))
10055 sOpt +=
"auxRatio";
10056 if (
sOpt2.Contains(
"significance") && !
sOpt2.Contains(
"auxsignif"))
10057 sOpt +=
"auxSignif";
10068 sOpt.ReplaceAll(
"ratio",
"");
10069 sOpt.ReplaceAll(
"significance",
"");
10071 sOpt.ReplaceAll(
"nostack",
"");
10073 sOpt.ReplaceAll(
"same",
"");
10075 sOpt.ReplaceAll(
"goff",
"");
10077 sOpt.ReplaceAll(
"pull",
"");
10081 sOpt.ReplaceAll(
"e",
"");
10083 sOpt.ReplaceAll(
"txt",
"texte");
10085 sOpt.ReplaceAll(
"txt",
"text");
10098 if (
gPad->GetNumber() == 0) {
10118 hAxis =
dynamic_cast<TH1 *
>(
pad->GetPrimitive(
"axis"));
10120 for (
auto o : *
pad->GetListOfPrimitives()) {
10127 :
hAxis->GetXaxis()->GetName())
10149 double ymin =
hh->GetMinimum();
10150 double ymax =
hh->GetMaximum();
10151 if (
hh->GetMaximumStored() == -1111)
10153 if (
hh->GetMinimumStored() == -1111) {
10156 }
else if (
ymin < 0) {
10164 if (
hh->GetSumw2()) {
10166 double smallestErrUp3 = std::numeric_limits<double>::infinity();
10167 for (
int i = 1; i <=
hh->GetNbinsX(); i++) {
10174 bool change =
false;
10187 double up =
ymax -
hh->GetBinContent(1);
10212 double ymax = -std::numeric_limits<double>::infinity();
10213 double ymin = std::numeric_limits<double>::infinity();
10214 for (
int i = 0; i <
gr->
GetN(); i++) {
10218 return std::make_pair(
ymin,
ymax);
10248 pad->Divide(1, 2, 1
e-9, 1
e-9);
10249 pad->GetPad(1)->SetPad(0, 0.2, 1, 1);
10250 pad->GetPad(2)->SetPad(0, 0, 1, 0.2);
10252 optNoFR.ReplaceAll(
"pull",
"");
10262 gPad->GetFrame()->SetFillStyle(1001);
10263 gPad->SetTopMargin(0);
10264 gPad->SetBottomMargin(0);
10265 gPad->SetName(
"pull");
10269 Error(
"Draw",
"Couldn't find pull graph");
10278 throw std::runtime_error(
"Could not find scales in fit result");
10280 for (
auto i = 0; i <
pullGraph->GetN(); i++) {
10285 Warning(
"Draw",
"Found a non-var in the floatParsFinal list: %s - this shouldn't happen",
g->GetName());
10289 "%s=%g +/- %s [%g,%g]",
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName(), _p->getVal(),
10290 _p->hasAsymError() ?
TString::Format(
"(%g,%g)", _p->getAsymErrorHi(), _p->getAsymErrorLo()).Data()
10294 g->SetPointEYhigh(0,
pullGraph->GetErrorYhigh(i));
10295 g->SetPointEYlow(0,
pullGraph->GetErrorYlow(i));
10296 g->SetEditable(
true);
10297 g->SetHighlight(
true);
10298 g->SetMarkerStyle(20);
10299 g->SetMarkerSize(0.5);
10325 if (!
_v->IsHidden())
10334 pad->SetBorderSize(0);
10360 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10363 auto _pad =
pad->GetPad(_size);
10364 _pad->SetName(
"legend");
10366 _pad->SetPad(
_pad->GetXlowNDC(),
_pad->GetYlowNDC(), 1.0,
_pad->GetYlowNDC() +
_pad->GetHNDC());
10369 while (
pad->GetPad(
x + 1)) {
10370 pad->GetPad(
x + 1)->SetFillStyle(0);
10380 if (_range &&
strlen(_range)) {
10387 if (
_v->IsHidden())
10404 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10419 for (
auto &
_v : *
this) {
10420 if (
_v->IsHidden())
10426 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10429 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10439 pad->SetBorderSize(0);
10440 dynamic_cast<TPad *
>(
pad)->DivideSquare(_size, 1
e-9, 1
e-9);
10443 for (
auto &
_v : *
this) {
10444 if (
_v->IsHidden())
10450 if (
strcmp(
_v->get()->GetName(),
"1") == 0 ||
strcmp(
_v->get()->GetName(),
"ONE") == 0 ||
10453 if (
_v->get()->InheritsFrom(
"RooConstVar"))
10462 gPad->SetLeftMargin(std::min(
gPad->GetLeftMargin() * (1. /
gPad->GetWNDC()), 0.3));
10484 if (
sOpt.Contains(
"corr")) {
10491 TH2 *hist =
nullptr;
10494 std::set<std::pair<double, size_t>>
maxCorrs;
10504 std::vector<size_t>
topN;
10514 for (
size_t i = 0; i <
topN.size(); i++) {
10517 for (
size_t j = 0;
j <
topN.size();
j++) {
10540 gPad->SetGrid(1, 1);
10546 if (
sOpt.Contains(
"brakdown")) {
10552 if (
sOpt.Contains(
"brakdown:")) {
10556 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10557 if (_poi->empty()) {
10558 throw std::runtime_error(
"No floating poi in the fit");
10559 }
else if (_poi->size() != 1) {
10560 throw std::runtime_error(
"Multiple poi in the fit");
10562 poiName = _poi->first()->GetName();
10568 std::set<std::string>
groups;
10572 }
else if (
p->getStringAttribute(
"group")) {
10573 groups.insert(
p->getStringAttribute(
"group"));
10575 groups.insert(
p->GetTitle());
10600 }
else if ((
p->getStringAttribute(
"group") &&
group ==
p->getStringAttribute(
"group")) ||
10601 (!
p->getStringAttribute(
"group") &&
group ==
p->GetTitle())) {
10609 Warning(
"Draw",
"breakdown group %s variance bigger than preceding?",
group.c_str());
10610 pie->SetEntryVal(i, 0);
10619 pie->SetEntryLabel(i,
group.c_str());
10634 pie->SetRadius(0.17);
10643 out->
SetTitle(
"Fit Result Pulls");
10647 ugraph->SetTitle(
"Fit Result Pulls");
10649 std::map<std::string, double>
scale;
10650 std::map<std::string, double>
offset;
10656 if (std::isnan(
_v->getErrorHi()) || std::isnan(
_v->getErrorLo())) {
10657 Warning(
"Draw",
"%s error is invalid",
_v->GetName());
10671 std::shared_ptr<xRooNode>
pConstr;
10674 if (
_vv->hasRange(
"pullScale")) {
10684 for (
auto s :
c->get<
RooAbsArg>()->servers()) {
10685 if (
strcmp(s->GetName(),
p->GetName()) == 0) {
10707 std::string
xName =
pConstr->find(
".x")->get()->GetName();
10709 for (
auto &_d :
pConstr->vars()) {
10710 if (
strcmp(
p->GetName(), _d->get()->GetName()) == 0)
10712 if (
xName == _d->get()->GetName())
10748 Warning(
"Draw",
"failed to determine prefit error of %s, using post-fit error",
p->GetName());
10763 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10782 prefitError = (std::max({
_v->getMax() -
_v->getVal(),
_v->getVal() -
_v->getMin(), 4.}) / 4);
10795 for (
int i = 0; i <
ugraph->GetN(); i++)
10796 ugraph->SetPointX(i, i + graph->GetN());
10809 graph->SetMarkerStyle(20);
10810 graph->SetMarkerSize(0.5);
10812 graph->SetMaximum(4);
10813 graph->SetMinimum(-4);
10816 (!
sOpt.Contains(
"impact") &&
sOpt.Contains(
"v")) || (
sOpt.Contains(
"impact") && !
sOpt.Contains(
"himpact"));
10818 std::vector<std::pair<double, std::string>>
covariances;
10821 if (
sOpt.Contains(
"impact")) {
10822 if (
sOpt.Contains(
"impact:")) {
10826 std::unique_ptr<RooAbsCollection> _poi(fr->
floatParsFinal().selectByAttrib(
"poi",
true));
10827 if (_poi->empty()) {
10828 throw std::runtime_error(
"No floating poi in the fit");
10829 }
else if (_poi->size() != 1) {
10830 throw std::runtime_error(
"Multiple poi in the fit");
10832 poiName = _poi->first()->GetName();
10853 [&](std::pair<double, std::string> i, std::pair<double, std::string>
j) {
10854 return doHorizontal ? (std::abs(i.first) < std::abs(j.first))
10855 : (std::abs(i.first) > std::abs(j.first));
10876 sortedGraph.SetPointError(
sortedGraph.GetN() - 1, 0, 0, graph->GetErrorYlow(i), graph->GetErrorYhigh(i));
10885 graph->SetTitle(
"Fit Result Impact");
10892 std::max(graph->GetN(), 1) - 0.5);
10901 hist =
new TH2D(
GetName(), fr->
GetTitle(), std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5,
10921 graph->GetHistogram()->GetXaxis()->Set(std::max(graph->GetN(), 1), -0.5, std::max(graph->GetN(), 1) - 0.5);
10922 for (
int ii = 1;
ii <=
_axis->GetNbins();
ii++) {
10923 graph->GetHistogram()->GetXaxis()->SetBinLabel(
ii,
_axis->GetBinLabel(
ii));
10938 gPad->Divide(1, 1, 1
e-9, 1
e-9);
10942 gPad->SetLeftMargin(0.4);
10944 gPad->SetBottomMargin(0.4);
10947 auto pNamesHist =
dynamic_cast<TH1F *
>(graph->GetHistogram()->Clone(
"scales"));
10951 for (
int ii = 1;
ii <= graph->GetN();
ii++) {
10955 _axis->SetBinLabel(
ii,
strlen(_p->GetTitle()) ? _p->GetTitle() : _p->GetName());
10960 if (!
sOpt.Contains(
"impact")) {
10961 for (
int ii = 2;
ii >= 1;
ii--) {
10996 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->GetTopMargin(), 1. -
gPad->GetRightMargin(), 0.98,
"NDCNB");
10997 pave->SetFillStyle(0);
10998 pave->SetBorderSize(0);
10999 pave->SetMargin(0.);
11000 pave->SetName(
"status");
11001 pave->SetTextAlign(31);
11007 case 0:
covQualTxt =
"Not calculated";
break;
11009 case 2:
covQualTxt =
"Forced Positive-Definite";
break;
11024 gPad->SetTicks(0, 0);
11028 if (
int(
gPad->GetCanvas()->GetWh()) <
pNamesHist->GetNbinsX() * 15) {
11029 gPad->GetCanvas()->SetCanvasSize(
gPad->GetCanvas()->GetWw(),
pNamesHist->GetNbinsX() * 15);
11033 double factor = 475. /
gPad->GetCanvas()->GetWh();
11062 for (
int tt = 0;
tt < 2;
tt++) {
11063 auto impact =
static_cast<TH1 *
>(
11064 graph->GetHistogram()->Clone(
TString::Format(
"%s_impact+",
tt == 0 ?
"prefit" :
"postfit")));
11067 impact->SetBarWidth(0.9);
11068 impact->SetBarOffset(0.05);
11069 impact->SetLineColor(
kBlack);
11070 impact->SetFillColor(
kAzure - 4);
11071 impact->SetFillStyle(
tt == 0 ? 3013 : 1001);
11073 static_cast<TH1 *
>(impact->Clone(
TString::Format(
"%s_impact-",
tt == 0 ?
"prefit" :
"postfit")));
11074 impact2->SetDirectory(
nullptr);
11082 impact->SetBinContent(
ii, ((
tt == 0 && !
vv_init->hasError()) || !
vv->hasError())
11084 :
c.first *
vv->getError() /
vv->getErrorHi() *
11085 (
tt == 0 ? (
vv_init->getErrorHi() /
vv->getErrorHi()) : 1.));
11088 :
c.first *
vv->getError() /
vv->getErrorLo() *
11089 (
tt == 0 ? (
vv_init->getErrorLo() /
vv->getErrorLo()) : 1.));
11096 for (
int ii = -1;
ii <= 1;
ii++) {
11109 leg1->SetFillStyle(0);
11110 leg1->SetBorderSize(0);
11111 leg1->SetMargin(0.25);
11112 leg1->SetNColumns(2);
11114 leg1->SetTextSize(
_axis->GetLabelSize());
11115 leg1->SetTextFont(
_axis->GetLabelFont());
11116 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Pre-fit",
"");
11117 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11118 leg1->AddEntry(hist->
FindObject(
"prefit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11119 leg1->AddEntry(hist->
FindObject(
"prefit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11120 leg1->AddEntry((
TObject *)
nullptr,
"Hessian Post-fit",
"");
11121 leg1->AddEntry((
TObject *)
nullptr,
"Impact:",
"");
11122 leg1->AddEntry(hist->
FindObject(
"postfit_impact+"),
"#theta = #hat{#theta}+#Delta#theta",
"f");
11123 leg1->AddEntry(hist->
FindObject(
"postfit_impact-"),
"#theta = #hat{#theta}-#Delta#theta",
"f");
11129 new TPaveText(
gPad->GetLeftMargin(), 1. -
gPad->AbsPixeltoY(14), 1. -
gPad->GetRightMargin(), 1.,
"NDC");
11136 : ((
gPad->AbsPixeltoY(0) -
gPad->AbsPixeltoY(10 / factor)) / (
gPad->GetY2() -
gPad->GetY1())));
11144 graph->SetEditable(
false);
11148 graph->GetListOfFunctions()->Add(
pNamesHist,
"same");
11152 for (
int p = 0;
p < graph->GetN();
p++) {
11153 graph->SetPoint(
p, graph->GetPointY(
p), graph->GetPointX(
p));
11154 graph->SetPointError(
p, graph->GetErrorYlow(
p), graph->GetErrorYhigh(
p), graph->GetErrorXlow(
p),
11155 graph->GetErrorXhigh(
p));
11158 if (
f->InheritsFrom(
"TH1")) {
11167 else if (
auto g =
dynamic_cast<TGraph *
>(
f)) {
11168 for (
int p = 0;
p <
g->GetN();
p++) {
11169 g->SetPoint(
p,
g->GetPointY(
p),
g->GetPointX(
p));
11172 }
else if (
auto l =
dynamic_cast<TLine *
>(
f)) {
11182 if (!
sOpt.Contains(
"impact")) {
11189 auto x = graph->GetPointX(graph->GetN() -
ugraphLabels.size() + i);
11190 auto y = graph->GetPointY(graph->GetN() -
ugraphLabels.size() + i) +
11191 graph->GetErrorYhigh(graph->GetN() -
ugraphLabels.size() + i);
11195 t->SetTextSize(0.025);
11196 t->SetTextAngle(90);
11197 graph->GetListOfFunctions()->Add(t);
11201 graph->SetName(
"pulls");
11210 hist->
Draw(
"same");
11222 auto hh =
dynamic_cast<TH1 *
>(
histCopy->Clone(
".axiscopy"));
11223 hh->SetDirectory(
nullptr);
11241 for (
auto c : s->bins()) {
11242 auto _pad =
dynamic_cast<TPad *
>(
gPad->GetPrimitive(
c->GetName()));
11247 c->push_back(std::make_shared<xRooNode>(*
this));
11249 c->resize(
c->size() - 1);
11251 std::cout <<
" no ds " <<
GetName() <<
" - this should never happen!" << std::endl;
11270 for (
auto o : *
gPad->GetListOfPrimitives()) {
11295 for (
int i = 0; i <
dataGraph->GetN(); i++)
11312 for (
auto o : *
gPad->GetListOfPrimitives()) {
11313 if (
auto h =
dynamic_cast<TH1 *
>(o);
11323 if (
auto h =
dynamic_cast<TH1 *
>(
_pad->GetPrimitive(
"auxHist"));
h) {
11326 histName = histName(0, histName.
Index(
'|'));
11327 if (
auto mainHist =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
11333 for (
int i = 0; i <
ratioGraph->GetN(); i++) {
11345 if (!std::isnan(
yval)) {
11347 if (!std::isnan(yup))
11349 if (!std::isnan(
ydown))
11416 if (!
d->get()->TestBit(1 << 20))
11420 auto _obs =
d->obs();
11422 auto _nll =
nll(
d);
11424 int nevent =
theData->numEntries();
11425 for (
int i = 0; i < nevent; i++) {
11427 bool _skip =
false;
11428 for (
const auto &_c :
_coords) {
11430 if (cat->getIndex() !=
theData->get()->getCatIndex(cat->GetName())) {
11440 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11443 auto nllVal = _nll.getEntryVal(i);
11444 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11445 auto nllVal2 = _nll.getEntryVal(i);
11446 _nll.pars()->setRealValue(
initPar->GetName(), val);
11452 auto val = _nll.pars()->getRealValue(
initPar->GetName());
11455 auto _extTerm = _nll.extendedTermVal();
11456 _nll.pars()->setRealValue(
initPar->GetName(),
initPar->getVal());
11457 auto _extTerm2 = _nll.extendedTermVal();
11458 _nll.pars()->setRealValue(
initPar->GetName(), val);
11459 for (
int i = 1; i <=
emptyHist->GetNbinsX(); i++) {
11464 emptyHist->GetYaxis()->SetTitle(
"log (L(#theta)/L(#theta_{0}))");
11470 }
else if (
ii == 3) {
11496 (
rarNode->get()->InheritsFrom(
"RooRealSumPdf") ||
rarNode->get()->InheritsFrom(
"RooAddPdf") ||
11497 (
v &&
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11505 auto h =
BuildHistogram(
v,
false,
hasErrorOpt, 1, 0,
"",
false,
false, 0,
nullptr,
nostack,
true );
11517 :
h->GetXaxis()->GetName())
11520 if (
h->GetXaxis()->IsAlphanumeric()) {
11528 if (
rar->InheritsFrom(
"RooAbsPdf") && !(
rar->InheritsFrom(
"RooRealSumPdf") ||
rar->InheritsFrom(
"RooAddPdf") ||
11529 rar->InheritsFrom(
"RooSimultaneous"))) {
11532 rar->leafNodeServerList(&s);
11539 for (
auto _p : s) {
11547 if (
_v->hasError()) {
11558 gPad->SetGrid(0, 0);
11560 gPad->SetGrid(1, 1);
11565 h->SetFillStyle(0);
11614 gROOT->SetEditHistograms(
true);
11616 gROOT->SetEditHistograms(
false);
11625 if (
dOpt.Contains(
"TEXT") ||
sOpt.Contains(
"text")) {
11630 bool hasError(
false);
11631 for (
int i = 0; i <
h->GetSumw2N(); i++) {
11632 if (
h->GetSumw2()->At(i)) {
11643 if (!
hasSame &&
h->GetYaxis()->GetTitleFont() % 10 == 2) {
11644 h->GetYaxis()->SetTitleOffset(1.);
11652 if(
rar->getAttribute(
"Logy")) {
11666 hCopy->SetDirectory(
nullptr);
11668 _hist->GetListOfFunctions()->Add(node);
11669 _hist->GetListOfFunctions()->Add(
new TExec(
11672 "gROOT->SetEditHistograms(true);auto h = dynamic_cast<TH1*>(gPad->GetPrimitive(\"%s\")); if(h) { double "
11673 "range= h->GetMaximum()-h->GetMinimum(); if(auto n "
11674 "= dynamic_cast<xRooNode*>(h->GetListOfFunctions()->FindObject(\"%s\")); n && "
11675 "n->TestBit(TObject::kNotDeleted) && n->get<RooRealVar>()->getVal() != h->GetBinContent(1)) {"
11676 "h->SetBinContent(1, "
11677 "TString::Format(\"%%.2g\",int(h->GetBinContent(1)/(range*0.01))*range*0.01).Atof());n->SetContent( "
11678 "h->GetBinContent(1) ); for(auto pp : *h->GetListOfFunctions()) if(auto hh = "
11679 "dynamic_cast<TH1*>(pp))hh->SetBinContent(1,h->GetBinContent(1));} if(h->GetBinContent(1)==0.) "
11680 "h->SetBinContent(1,range*0.005); gPad->Modified();gPad->Update(); }",
11681 _hist->GetName(), node->GetName())));
11683 errHist->GetListOfFunctions()->Add(
h,
"TEXT HIST same");
11684 errHist->SetFillColor(
h->GetLineColor());
11687 hCopy->SetFillStyle(0);
11688 _hist->GetListOfFunctions()->Add(
hCopy,
"TEXT HIST same");
11691 _hist->SetStats(
false);
11748 errHist->SetFillColor(
h->GetLineColor());
11765 (
rarNode->get()->InheritsFrom(
"RooSimultaneous") &&
11767 if (
auto stack =
dynamic_cast<THStack *
>(
h->FindObject(
"stack"))) {
11773 auto hhMin = (
hh->GetMinimum() == 0) ?
hh->GetMinimum(1
e-9) :
hh->GetMinimum();
11774 if (
lnk == stack->GetHists()->FirstLink() &&
h->GetMinimum() >
hhMin) {
12060 dOpt.ReplaceAll(
"TEXT",
"");
12062 double ymax = -std::numeric_limits<double>::infinity();
12063 double ymin = std::numeric_limits<double>::infinity();
12064 for (
int i = 1; i <=
errHist->GetNbinsX(); i++) {
12093 ratioHist->GetYaxis()->SetNdivisions(5, 0, 0);
12102 for (
int i = 1; i <=
ratioHist->GetNbinsX(); i++) {
12103 double val =
ratioHist->GetBinContent(i);
12104 double err =
ratioHist->GetBinError(i);
12111 if (
ratioHist->GetYaxis()->GetTitleFont() % 10 == 2) {
12118#if ROOT_VERSION_CODE < ROOT_VERSION(6, 26, 00)
12127 auto _h =
dynamic_cast<TH1 *
>(
ratioHist->Clone(
"auxHist_clone"));
12128 _h->SetDirectory(
nullptr);
12129 _h->SetFillColor(0);
12130 ratioHist->GetListOfFunctions()->Add(
_h,
"histsame");
12135 TString::Format(
"auto h1 = (TH1*)%p; auto h2 = (TH1*)%p; if(h2->GetXaxis()->GetFirst() != "
12136 "h1->GetXaxis()->GetFirst() || h1->GetXaxis()->GetLast()!=h2->GetXaxis()->GetLast()) "
12137 "{h2->GetXaxis()->SetRange(h1->GetXaxis()->GetFirst(),h1->GetXaxis()->GetLast());if(gPad) "
12138 "{gPad->GetCanvas()->Paint();gPad->GetCanvas()->Update();}}",
12148 if (
auto hr =
dynamic_cast<TH1 *
>(
ratioPad->GetPrimitive(
"auxHist"));
12152 histName = histName(0, histName.
Index(
'|'));
12154 if (
auto hnom =
dynamic_cast<TH1 *
>(
gPad->GetPrimitive(histName));
hnom) {
12155 h =
dynamic_cast<TH1 *
>(
h->Clone(
h->GetName()));
12158 for (
int i = 1; i <=
hnom->GetNbinsX(); i++) {
12159 double val =
h->GetBinContent(i);
12160 double err =
h->GetBinError(i);
12161 h->SetBinContent(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12162 h->GetBinContent(i),
hnom->GetBinContent(i),
hnom->GetBinError(i)));
12163 h->SetBinError(i, std::get<0>(
auxFunctions[
hr->GetYaxis()->GetTitle()])(
12164 val + err,
hnom->GetBinContent(i),
hnom->GetBinError(i)) -
12165 h->GetBinContent(i));
12182 double ymax = -std::numeric_limits<double>::infinity();
12183 double ymin = std::numeric_limits<double>::infinity();
12184 for (
int i = 1; i <=
h->GetNbinsX(); i++) {
12185 ymax = std::max(
ymax,
h->GetBinContent(i) +
h->GetBinError(i));
12186 ymin = std::min(
ymin,
h->GetBinContent(i) -
h->GetBinError(i));
12220 if (
d->get()->TestBit(1 << 20)) {
12268 w->import(*
gROOT->GetListOfColors(),
true);
12271#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
12275 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12280 Error(
"SaveAs",
"json format workspaces only in ROOT 6.26 onwards");
12285#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12289 for (
auto &
c :
w->components()) {
12290 c->_eocache =
nullptr;
12294#if ROOT_VERSION_CODE < ROOT_VERSION(6, 38, 00)
12299 Info(
"SaveAs",
"%s saved to %s",
w->GetName(),
sFilename.Data());
12305 auto dir =
dest->GetDirectory(
source->GetName());
12309 for (
auto k : *
source->GetListOfKeys()) {
12310 auto key =
dynamic_cast<TKey *
>(k);
12311 const char *classname = key->GetClassName();
12320 if (dir->FindKey(key->GetName()))
12323 if (
strcmp(classname,
"ROOT::Fit::FitConfig") == 0) {
12325 dir->WriteObject(
fc, key->GetName());
12328 TObject *obj = key->ReadObj();
12330 dir->WriteTObject(obj, key->
GetName());
12337 if (
gROOT->GetListOfFiles()) {
12338 for (
auto key : *
gROOT->GetListOfFiles()) {
12349#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12351 for (
auto &
c :
w->components()) {
12352 c->setExpensiveObjectCache(
w->expensiveObjectCache());
12362 return std::numeric_limits<double>::quiet_NaN();
12368 std::vector<double> out;
12369 out.reserve(
size());
12370 for (
auto child : *
this) {
12371 out.push_back(
child->GetContent());
12385 auto rho =
_fr->correlationMatrix();
12394 for (
int m = 0;
m < rho.GetNrows();
m++) {
12401 auto tmp = _p->getVal();
12402 _p->setVal(
p_m->getVal() +
p_m->getErrorHi());
12404 _p->setVal(
p_m->getVal() +
p_m->getErrorLo());
12407 for (
int n = 0;
n < rho.GetNrows();
n++) {
12415 _p2->setVal(
p_n->getVal() +
p_n->getErrorHi());
12417 _p2->setVal(
p_n->getVal() +
p_n->getErrorLo());
12420 for (
int i = 0; i < out.
GetNrows(); i++) {
12430std::pair<double, double>
12434 double err = std::numeric_limits<double>::quiet_NaN();
12436 std::unique_ptr<RooAbsCollection>
_snap;
12449 out =
c->getVal(
sobs);
12456#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 27, 00)
12459 out *=
p->expectedEvents(*_obs.get<
RooArgList>());
12460#if ROOT_VERSION_CODE < ROOT_VERSION(6, 27, 00)
12462 p->_normSet =
nullptr;
12466 p->setNormRange(
nullptr);
12469 auto f = std::shared_ptr<RooAbsReal>(
12470 p2->createIntegral(*std::unique_ptr<RooArgSet>(
p2->getObservables(*_obs.get<
RooArgList>())),
12474 out *=
f->getVal();
12484 for (
auto &
v : vals) {
12496 out = std::numeric_limits<double>::quiet_NaN();
12499 _pars.RooAbsCollection::operator=(*_snap);
12501 return std::make_pair(out, err);
12520 std::vector<double> out;
12526 binEnd = _hist->GetNbinsX();
12533 _hist->GetBinError(bin));
12658std::string cling::printValue(
const xRooNode *
v)
12661 return "nullptr\n";
12664 size_t left =
v->size();
12665 for (
auto n : *
v) {
12671 out +=
n->GetName();
12672 if (out.length() > 100 && left > 0) {
12678 out = std::string(
Form(
"<%s> %s",
v->get() ?
v->get()->ClassName() :
"nullptr",
v->
GetName())) + out;
12683 return "<nullptr>";
12685 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
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
const char Option_t
Option string (const char)
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void funcs
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
double GetBinLowEdge(Int_t bin) const override
Return low edge of bin.
double GetBinUpEdge(Int_t bin) const override
Return up edge of bin.
Int_t FindFixBin(double x) const override
Find bin number corresponding to abscissa x
void Set(Int_t nbins, const double *xbins) override
Initialize axis with variable bins.
RooAbsRealLValue * rvar() const
void SetTitle(const char *title) override
Set the title of the TNamed.
void Set(Int_t nbins, double xmin, double xmax) override
Initialize axis with fix bins.
Int_t FindFixBin(const char *label) const override
Find bin number with label.
RooAbsLValue * var() const
const RooAbsBinning * binning() const
void Set(Int_t nbins, const float *xbins) override
Initialize axis with variable bins.
const char * GetTitle() const override
Returns title of object.
double GetBinWidth(Int_t bin) const override
Return bin width.
PadRefresher(TVirtualPad *p)
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
bool isBinnedDistribution(const RooArgSet &obs) const override
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
bool selfNormalized() const override
Shows if a PDF is self-normalized, which means that no attempt is made to add a normalization term.
double getSimplePropagatedError(const RooFitResult &fr, const RooArgSet &nset_in) const
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
TObject * clone(const char *newname) const override
std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const override
Retrieve bin boundaries if this distribution is binned in obs.
PdfWrapper(const PdfWrapper &other, const char *name=nullptr)
PdfWrapper(RooAbsReal &f, RooAbsReal *coef, bool expEvMode=false, RooAbsPdf *expPdf=nullptr)
The PiecewiseInterpolation is a class that can morph distributions into each other,...
static std::shared_ptr< RooLinkedList > createNLLOptions()
static std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > generateFrom(RooAbsPdf &pdf, const RooFitResult &fr, bool expected=false, int seed=0)
static xRooNLLVar createNLL(const std::shared_ptr< RooAbsPdf > pdf, const std::shared_ptr< RooAbsData > data, const RooLinkedList &nllOpts)
static std::pair< double, double > matchPrecision(const std::pair< double, double > &in)
void Draw(Option_t *opt="") override
Default Draw method for all objects.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
This xRooNLLVar object has several special methods, e.g.
xRooHypoSpace hypoSpace(const char *parName, int nPoints, double low, double high, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown, int tsType=0)
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
void _Add_(const char *name, const char *opt)
TH1 * BuildHistogram(RooAbsLValue *v=nullptr, bool empty=false, bool errors=false, int binStart=1, int binEnd=0, const xRooNode &fr="", bool errorsHi=false, bool errorsLo=false, int nErrorToys=0, TH1 *templateHist=nullptr, bool nostack=true, bool setInterp=false) const
xRooNode filter(const xRooNode &range) const
std::vector< std::shared_ptr< xRooNode > > fBrowsables
xRooNLLVar nll(const xRooNode &_data, std::initializer_list< RooCmdArg > nllOpts) const
xRooNode poi() const
List of parameters of interest: parameters marked as "of interest" These parameters have the "poi" at...
void SetName(const char *name) override
Set the name of the TNamed.
TGListTreeItem * GetTreeItem(TBrowser *b) const
void SetTitle(const char *title) override
Set the title of the TNamed.
xRooNode Multiply(const xRooNode &child, Option_t *opt="")
xRooNode Replace(const xRooNode &node)
bool SetData(const TObject &obj, const xRooNode &data="obsData")
xRooNode datasets() const
xRooNode Remove(const xRooNode &child)
xRooNode globs() const
List of global observables of this node.
xRooNode Add(const xRooNode &child, Option_t *opt="")
xRooNode(const char *type, const char *name, const char *title="")
const char * GetIconName() const override
Returns mime type name of object.
void Draw(Option_t *opt="") override
Default Draw method for all objects.
bool _IsShowVars_() const
TGraph * BuildGraph(RooAbsLValue *v=nullptr, bool includeZeros=false, TVirtualPad *fromPad=nullptr) const
const std::shared_ptr< xRooNode > & at(size_t idx, bool browseResult=true) const
std::string fRange
! only here so can have char* GetRange return so can return nullptr for no range set !...
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 reduced(const std::string &range="", bool invert=false) const
xRooNode variations() const
std::string GetPath() const
std::vector< double > GetBinErrors(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
auto begin() const -> xRooNodeIterator
std::shared_ptr< xRooNode > parentPdf() const
bool SetContent(double value)
void _scan_(const char *what="plr", double nToys=0, const char *xvar="", int nPointsX=0, double lowX=0, double highX=0, const char *constParValues="", const char *options="")
std::shared_ptr< xRooNode > fParent
!
xRooNode robs() const
List of regular observables of this node.
TClass * IsA() const override
xRooNode & operator=(const TObject &o)
auto end() const -> xRooNodeIterator
xRooNode consts() const
List of parameters that are currently constant.
void _SetBinContent_(int bin, double value, const char *par="", double parVal=1)
std::shared_ptr< TObject > acquire(const std::shared_ptr< TObject > &arg, bool checkFactory=false, bool mustBeNew=false)
std::function< xRooNode(xRooNode *) fBrowseOperation)
void _SetAttribute_(const char *name, const char *value=nullptr)
xRooNode histo(const xRooNode &vars="x", const xRooNode &fr="", bool content=true, bool errors=true, bool stack=true, bool errorsHi=false, bool errorsLo=false, int nErrorToys=0) const
void Browse(TBrowser *b=nullptr) override
Browse object. May be overridden for another default action.
xRooNode obs() const
List of observables (global and regular) of this node.
void SetRange(const char *range, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN())
static void SetAuxFunction(const char *title, const std::function< double(double, double, double)> &func, bool symmetrize=false)
std::shared_ptr< TObject > convertForAcquisition(xRooNode &acquirer, const char *opt="") const
xRooNode vars() const
List of variables (observables and parameters) of this node.
const char * GetRange() const
TMatrixDSym covariances(const xRooNode &fr="") const
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
bool dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=nullptr, bool valueOnly=false) const
Test whether we depend on (ie, are served by) any object in the specified collection.
void setStringAttribute(const Text_t *key, const Text_t *value)
Associate string 'value' to this object under key 'key'.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
void SetName(const char *name) override
Set the name of the TNamed.
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Abstract base class for RooRealVar binning definitions.
virtual double highBound() const =0
virtual double lowBound() const =0
Abstract base class for objects that represent a discrete value that can be set from the outside,...
A space to attach TBranches.
const char * getLabel() const
Retrieve current label. Use getCurrentLabel() for more clarity.
Abstract container object that can hold multiple RooAbsArg objects.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
std::string contentsString() const
Return comma separated list of contained object names as STL string.
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 Clear(Option_t *option="") override
Remove all objects from the list.
void Add(TObject *obj) override
A TMemFile is like a normal TFile except that it reads and writes only from memory.
A TMultiGraph is a collection of TGraph (or derived) objects.
virtual void Add(TGraph *graph, Option_t *chopt="")
Add a new graph to the list of graphs.
void Draw(Option_t *chopt="") override
Draw this multigraph with its current attributes.
The TNamed class is the base class for all named ROOT classes.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Wrapper around a TObject so it can be stored in a TList.
Mother of all ROOT objects.
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
virtual const char * GetName() const
Returns name of object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
virtual void Delete(Option_t *option="")
Delete this object.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
@ kCanDelete
if object in a list can be deleted
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
The most important graphics class in the ROOT system.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void SetY1NDC(Double_t y1)
virtual void ConvertNDCtoPad()
Convert pave coordinates from NDC to Pad coordinates.
virtual void SetBorderSize(Int_t bordersize=4)
Sets the border size of the TPave box and shadow.
virtual void SetY2NDC(Double_t y2)
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Regular expression class.
This class creates a ROOT object browser, constituted by three main tabs.
Sequenceable collection abstract base class.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
Bool_t IsDec() const
Returns true if all characters in string are decimal digits (0-9).
Int_t Atoi() const
Return integer value of string.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Double_t Atof() const
Return floating-point value contained in string.
Bool_t IsFloat() const
Returns kTRUE if string contains a floating point or integer number.
const char * Data() const
Bool_t IsAlpha() const
Returns true if all characters in string are alphabetic.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TStyle objects may be created to define special styles.
void SetPaintTextFormat(const char *format="g")
Int_t GetOptTitle() const
Float_t GetLabelSize(Option_t *axis="X") const
Return label size.
Float_t GetPadRightMargin() const
Style_t GetTitleFont(Option_t *axis="X") const
Return title font.
Bool_t GetHistMinimumZero() const
Float_t GetPadLeftMargin() const
Float_t GetTitleYSize() const
Double_t GetHistTopMargin() const
Float_t GetPadBottomMargin() const
const char * GetPaintTextFormat() const
Float_t GetPadTopMargin() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
The TTimeStamp encapsulates seconds and ns since EPOCH.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
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.
constexpr Double_t C()
Velocity of light in .
Double_t Prob(Double_t chi2, Int_t ndf)
Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf...
Double_t ChisquareQuantile(Double_t p, Double_t ndf)
Evaluate the quantiles of the chi-squared probability distribution function.
Double_t StdDev(Long64_t n, const T *a, const Double_t *w=nullptr)
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE
bool isNaNWithPayload() const
Test if this struct has a float packed into its mantissa.
static float unpackNaN(double val)
If val is NaN and a this NaN has been tagged as containing a payload, unpack the float from the manti...
static uint64_t sum(uint64_t i)
void(* gOldHandlerr)(int)
void addLegendEntry(TObject *o, const char *title, const char *opt)
void buildHistogramInterrupt(int signum)
auto GETACTBROWSER(TRootBrowser *b)
auto & GETWSSNAPSHOTS(RooWorkspace *w)
bool TopRightPlaceBox(TPad *p, TObject *o, double w, double h, double &xl, double &yb)
TPaveText * getPave(const char *name="labels", bool create=true, bool doPaint=false)
std::string formatLegendString(const std::string &s)
auto GETROOTDIR(TGFileBrowser *b)
const xRooNode * runningNode
auto GETLISTTREE(TGFileBrowser *b)
const T & _or_func(const T &a, const T &b)
double new_getPropagatedError(const RooAbsReal &f, const RooFitResult &fr, const RooArgSet &nset={}, RooArgList **pars=nullptr, bool asymHi=false, bool asymLo=false)
TLegend * getLegend(bool create=true, bool doPaint=false)