42xRooNLLVar::xRooHypoSpace::xRooHypoSpace(
const char *
name,
const char *title)
74 ssize /= (
v->getMax() -
v->getMin());
82 for (
auto &
p : *
this) {
83 for (
auto a : *
p.coords) {
84 if (!
fPars->find(
a->GetName()))
101 std::shared_ptr<xRooNode> out =
nullptr;
103 for (
auto &[_range, _pdf] : fPdfs) {
107 for (
auto &
_lhs : *_range) {
113 if (!(
v->getMin() <=
v2->getMax() &&
v2->getMin() <=
v->getMax())) {
118 if (!(
v->getMin() <=
c2->getVal() &&
c2->getVal() <=
v->getMax())) {
125 if (!(
c->getVal() <=
v2->getMax() &&
v2->getMin() <=
c->getVal())) {
130 if (!(
c->getVal() ==
c2->getVal())) {
139 throw std::runtime_error(
"Multiple pdf possibilities");
157 auto _idx = s.
Index(
'=');
163 if (
_val.IsFloat()) {
165 }
else if (
_val.BeginsWith(
'[')) {
166 _idx =
_val.Index(
',');
185 throw std::runtime_error(
"Unknown parameter");
186 _par->setAttribute(
"axis");
189 _par->setVal((high + low) * 0.5);
194 double step = (high - low) / (
nPoints - 1);
196 throw std::runtime_error(
"Invalid steps");
198 for (
size_t i = 0; i <
nPoints; i++) {
199 _par->setVal((i ==
nPoints - 1) ? high : (low + step * i));
207 if (axes().empty()) {
210 throw std::runtime_error(
"No POI to scan");
212 poi().first()->setAttribute(
"axis");
218 poi().setAttribAll(
"poi",
false);
219 axes().setAttribAll(
"poi");
231 if (
sType.Contains(
"cls") && !
sType.Contains(
"pcls"))
232 sType.ReplaceAll(
"cls",
"pcls");
233 if (!
sType.Contains(
"pcls") && !
sType.Contains(
"ts") && !
sType.Contains(
"pnull") && !
sType.Contains(
"plr")) {
234 throw std::runtime_error(
"scan type must be equal to one of: plr, cls, ts, pnull");
238 if (axes().empty()) {
241 throw std::runtime_error(
"No POI to scan");
243 poi().first()->setAttribute(
"axis");
248 poi().setAttribAll(
"poi",
false);
249 axes().setAttribAll(
"poi");
251 auto p =
dynamic_cast<RooRealVar *
>(axes().first());
253 throw std::runtime_error(
TString::Format(
"%s not scannable", axes().first()->GetName()));
256 if (
sType.Contains(
"cls")) {
257 if (empty() &&
relUncert == std::numeric_limits<double>::infinity()) {
259 ::Info(
"xRooHypoSpace::scan",
"Using default precision of 10%% for auto-scan");
262 for (
auto a : axes()) {
263 if (!
a->hasRange(
"physical")) {
264 ::Info(
"xRooHypoSpace::scan",
"No physical range set for %s, setting to [0,inf]",
p->GetName());
265 dynamic_cast<RooRealVar *
>(
a)->setRange(
"physical", 0, std::numeric_limits<double>::infinity());
267 if (!
a->getStringAttribute(
"altVal") || !
strlen(
p->getStringAttribute(
"altVal"))) {
268 ::Info(
"xRooHypoSpace::scan",
"No altVal set for %s, setting to 0",
a->GetName());
269 a->setStringAttribute(
"altVal",
"0");
275 ::Info(
"xRooHypoSpace::scan",
"range of POI does not straddle alt value, adjusting minimum to %g",
280 ::Info(
"xRooHypoSpace::scan",
"range of POI does not straddle alt value, adjusting maximum to %g",
284 for (
auto &[
pdf, nll] : fNlls) {
285 if (
auto _v =
dynamic_cast<RooRealVar *
>(nll->pars()->find(*
a))) {
286 _v->setRange(
v->getMin(),
v->getMax());
290 }
else if (
sType.Contains(
"plr")) {
293 sType.ReplaceAll(
"plr",
"ts");
296 if (high < low || (high == low &&
nPoints != 1)) {
298 low =
p->getMin(
"scan");
299 high =
p->getMax(
"scan");
301 if (!std::isnan(low) && !std::isnan(high) && !(std::isinf(low) && std::isinf(high))) {
302 p->setRange(
"scan", low, high);
304 if (
p->hasRange(
"scan")) {
305 ::Info(
"xRooHypoSpace::scan",
"Using %s scan range: %g - %g",
p->GetName(),
p->getMin(
"scan"),
p->getMax(
"scan"));
319 relUncert = std::numeric_limits<double>::infinity();
328#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
348 for (
auto file : *
gROOT->GetListOfFiles()) {
349 if (
auto f =
dynamic_cast<TMemFile *
>(file)) {
355 new TMemFile(
"fitDatabase",
"RECREATE");
363 if (
sType.Contains(
"cls")) {
374 if (std::isnan(res.first) || std::isnan(res.second)) {
376 }
else if (std::isinf(res.second)) {
381 throw std::runtime_error(
TString::Format(
"Automatic scanning not yet supported for %s",
type));
386 AddPoint(
TString::Format(
"%s=%g", poi().first()->GetName(), (high + low) / 2.));
389 double step = (high - low) / (
nPoints - 1);
390 for (
size_t i = 0; i <
nPoints; i++) {
391 AddPoint(
TString::Format(
"%s=%g", poi().first()->GetName(), low + step * i));
403std::map<std::string, xRooNLLVar::xValueWithError>
410 relUncert = std::numeric_limits<double>::infinity();
415 std::map<std::string, xRooNLLVar::xValueWithError> out;
437 auto _idx = s.
Index(
'=');
442 auto _v =
dynamic_cast<RooRealVar *
>(fPars->find(_name));
446 if (
_val.IsFloat()) {
455 throw std::runtime_error(
"no model at coordinates");
462 if (fNlls.find(_pdf) == fNlls.end()) {
463 fNlls[_pdf] = std::make_shared<xRooNLLVar>(_pdf->nll(
"" , {}));
468 out.nllVar = fNlls[_pdf];
469 out.fData = fNlls[_pdf]->getData();
470 out.isExpected =
dynamic_cast<RooDataSet *
>(out.fData.first.get()) &&
471 dynamic_cast<RooDataSet *
>(out.fData.first.get())->weightVar()->getAttribute(
"expected");
474 out.coords.reset(fPars->snapshot());
476 out.poi().setAttribAll(
"Constant");
483 ->remove(*std::unique_ptr<RooAbsCollection>(out.coords->selectByAttrib(
"Constant",
false)),
true,
true);
485 double value = out.fNullVal();
488 auto _type = fTestStatType;
500 out.fPllType = _type;
503 for (
auto &
p : *
this) {
504 if (
p.nllVar != out.nllVar)
506 if (
p.fData != out.fData)
508 if (!
p.alt_poi().equals(out.alt_poi()))
511 for (
auto c :
p.alt_poi()) {
513 v && std::abs(
v->getVal() - out.alt_poi().getRealValue(
v->GetName())) > 1
e-12) {
518 out.alt_poi().getCatIndex(cat->GetName(), std::numeric_limits<int>().max())) {
525 if (!
p.coords->equals(*out.coords))
527 for (
auto c : *
p.coords) {
528 if (
c->getAttribute(
"poi")) {
532 v && std::abs(
v->getVal() - out.coords->getRealValue(
v->GetName())) > 1
e-12) {
537 out.alt_poi().getCatIndex(cat->GetName(), std::numeric_limits<int>().max())) {
546 if (
auto cfit =
p.cfit_alt(
true)) {
547 out.fAlt_cfit = cfit;
549 if (
p.asimov(
true) &&
p.asimov(
true)->fData.first && (!out.asimov(
true) || !out.asimov(
true)->fData.first)) {
550 out.asimov()->fData =
p.asimov(
true)->fData;
552 if (!
p.poi().equals(out.poi()))
554 for (
auto c :
p.poi()) {
556 v && std::abs(
v->getVal() - out.poi().getRealValue(
v->GetName())) > 1
e-12) {
568 for (
auto a : axes()) {
575 return emplace_back(out);
582 throw std::runtime_error(
"Not a pdf");
594 throw std::runtime_error(std::string(
"Clashing model: ") +
existing->GetName());
600 pars.remove(*fPars,
true,
true);
602 fPars->addClone(
pars);
604 fPdfs.insert(std::make_pair(
myPars, std::make_shared<xRooNode>(_pdf)));
615 out.add(*std::unique_ptr<RooAbsCollection>(
616 fPars->selectByAttrib(
"axis",
true)));
622 std::set<std::vector<double>> coords;
623 for (
auto &
p : *
this) {
626 auto _v =
dynamic_cast<RooRealVar *
>(
p.coords->find(o->GetName()));
628 (
_v &&
_v->isConstant())
630 : std::numeric_limits<double>::infinity());
633 if (coords.find(
p_coords) != coords.end()) {
642 std::map<std::string, std::unordered_set<double>> values;
643 for (
auto &par : *
pars()) {
646 for (
auto p : *
this) {
647 auto _v =
dynamic_cast<RooRealVar *
>(
p.coords->find(par->GetName()));
648 values[par->GetName()].insert(
649 (
_v &&
_v->isConstant())
651 : std::numeric_limits<double>::infinity());
660 for (
auto &[k,
v] : values) {
663 isPOI =
pars()->find(k.c_str())->getAttribute(
"poi");
676 std::unique_ptr<RooAbsCollection> poi(out.selectByAttrib(
"poi",
true));
687 out.add(*std::unique_ptr<RooAbsCollection>(
pars()->selectByAttrib(
"poi",
true)));
711 Error(
"LoadFits",
"Path not found %s",
apath);
721 std::map<std::set<std::tuple<std::string, double, std::string>>, std::set<std::set<std::string>>>
cfits;
727 std::cout <<
"Processing " << _dir->GetName() << std::endl;
728 if (
auto keys = _dir->GetListOfKeys(); keys) {
732 for (
auto &&k : *keys) {
733 TKey *key =
dynamic_cast<TKey *
>(k);
740 for (
auto &&k : *keys) {
741 if (
auto subdir = _dir->GetDirectory(k->GetName());
subdir) {
743 LoadFits(
subdir->GetPath());
750 if (cl->InheritsFrom(
"RooFitResult")) {
755 std::unique_ptr<RooAbsCollection>
snap(
cachedFit->floatParsFinal().snapshot());
756 snap->remove(*fPars,
true,
true);
757 fPars->addClone(*
snap);
760 if (
p->getAttribute(
"global"))
766 if (!fPars->contains(*
v))
777 std::set<std::tuple<std::string, double, std::string>> constPars;
779 if (
p->getAttribute(
"global"))
786 std::make_tuple(
v->GetName(),
v->getVal(),
787 v->getStringAttribute(
"altVal") ?
v->getStringAttribute(
"altVal") :
""));
791 if (constPars == key)
793 if (std::includes(constPars.begin(), constPars.end(), key.begin(), key.end())) {
797 std::set<std::string>
pois;
798 for (
auto &&par : constPars) {
799 if (key.find(par) == key.end()) {
800 pois.insert(std::get<0>(par));
801 allpois.insert(std::get<0>(par));
840 ::Info(
"xRooHypoSpace::xRooHypoSpace",
"%s - Loaded %d fits",
apath,
nFits);
845 auto nll = std::make_shared<xRooNLLVar>(
nullptr,
nullptr);
846 auto dummyNll = std::make_shared<RooRealVar>(
apath,
"Dummy NLL", std::numeric_limits<double>::quiet_NaN());
851 for (
auto &&
p : *fPars) {
857 fPars->find(
p.c_str())->setAttribute(
"poi",
true);
865 auto _coords = std::make_shared<RooArgSet>();
866 for (
auto &k : key) {
867 auto v =
_coords->addClone(
RooRealVar(std::get<0>(k).c_str(), std::get<0>(k).c_str(), std::get<1>(k)));
869 if (!std::get<2>(k).empty()) {
870 v->setStringAttribute(
"altVal", std::get<2>(k).c_str());
885 if (std::isnan(
hp.fAltVal())) {
887 }
else if (
hp.fNullVal() >=
hp.fAltVal()) {
896 }
else if (
nFits > 0) {
897 std::cout <<
"possible POI: ";
899 std::cout <<
p <<
",";
900 std::cout << std::endl;
911 for (
size_t i = 0; i <
size(); i++) {
912 std::cout << i <<
") ";
916 std::cout <<
a->GetName() <<
"="
917 << at(i).coords->getRealValue(
a->GetName(), std::numeric_limits<double>::quiet_NaN());
919 std::cout <<
" status=[ufit:";
924 std::cout << ufit->
status();
927 std::cout <<
",cfit_null:";
928 auto cfit =
const_cast<xRooHypoPoint &
>(at(i)).cfit_null(
true);
932 std::cout << cfit->
status();
935 std::cout <<
",cfit_alt:";
940 std::cout <<
afit->status();
944 std::cout <<
",asimov.ufit:";
952 std::cout <<
",asimov.cfit_null:";
962 auto sigma_mu =
const_cast<xRooHypoPoint &
>(at(i)).sigma_mu(
true);
963 if (!std::isnan(sigma_mu.first)) {
964 std::cout <<
" sigma_mu=" << sigma_mu.first;
966 std::cout <<
" +/- " << sigma_mu.second;
968 std::cout << std::endl;
970 std::cout <<
"--------------------------" << std::endl;
971 std::cout <<
"Number of bad fits: " <<
badFits << std::endl;
975 const char *opt )
const
986 (
sOpt.Contains(
"exp"))
990 : std::numeric_limits<double>::quiet_NaN();
995 if (
_axes.size() != 1)
998 auto out = std::make_shared<TGraphErrors>();
999 out->SetName(GetName());
1000 out->SetEditable(
false);
1001 const char *
sCL = (
doCLs) ?
"CLs" :
"null";
1013 if (std::isnan(
nSigma)) {
1015 out->SetMarkerStyle(20);
1016 out->SetMarkerSize(0.5);
1017 if (
sOpt.Contains(
"ts")) {
1019 (empty() ?
"" : front().tsTitle(
true).Data())));
1023 out->SetMarkerStyle(0);
1024 out->SetMarkerSize(0);
1025 out->SetLineStyle(2 +
int(
nSigma));
1029 out->SetLineStyle(0);
1030 out->SetLineWidth(0);
1031 auto x = out->Clone(
"up");
1035 out->GetListOfFunctions()->Add(
x,
"F");
1036 x = out->Clone(
"down");
1040 out->GetListOfFunctions()->Add(
x,
"F");
1042 if (
sOpt.Contains(
"ts")) {
1049 auto badPoints2 =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"badPoints"));
1057 out->GetListOfFunctions()->Add(
badPoints2,
"P");
1066 for (
auto &
p : *
this) {
1071 if (
gra &&
gra->GetN()) {
1073 gROOT->GetSelectedPad()->cd();
1077#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1078 if (
auto pad =
gROOT->GetSelectedPad()) {
1079 pad->GetCanvas()->ResetUpdated();
1085 ::Info(
"xRooHypoSpace::graph",
"Completed %d/%d points for %s",
int(
nDone),
int(
size()),
sOpt.Data());
1091 double _x =
p.coords->getRealValue(
_axes.at(0)->GetName(), std::numeric_limits<double>::quiet_NaN());
1095 if (std::isnan(pval.first)) {
1096 if (
p.status() != 0) {
1100 out->InsertPointBefore(idx, _x, pval.first);
1101 out->SetPointError(idx, 0, pval.second);
1106 sOpt2.ReplaceAll(
"exp",
"exp-");
1108 if (std::isnan(pval.first)) {
1109 if (
p.status() != 0) {
1113 out->InsertPointBefore(idx + 1, _x, pval.first);
1114 out->SetPointError(idx + 1, 0, pval.second);
1116 if (out->GetPointY(idx) < pval.first)
1123 if (out->GetN() == 0)
1128 if (out->GetListOfFunctions()->FindObject(
"badPoints")) {
1130 for (
int i = 0; i <
badPoints()->GetN(); i++) {
1139 auto up =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"up"));
1140 auto down =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"down"));
1142 for (
int i = 0; i < out->GetN(); i++) {
1144 up->SetPoint(
up->GetN(), out->GetPointX(i), out->GetPointY(i) + out->GetErrorY(i) * (
above ? 1. : -1.));
1145 down->SetPoint(
down->GetN(), out->GetPointX(i), out->GetPointY(i) - out->GetErrorY(i) * (
above ? 1. : -1.));
1147 up->SetPoint(
up->GetN(), out->GetPointX(i), out->GetPointY(i) - out->GetErrorY(i) * (
above ? 1. : -1.));
1148 down->SetPoint(
down->GetN(), out->GetPointX(i), out->GetPointY(i) + out->GetErrorY(i) * (
above ? 1. : -1.));
1156 gROOT->GetSelectedPad()->cd();
1160#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1161 if (
auto pad =
gROOT->GetSelectedPad()) {
1162 pad->GetCanvas()->ResetUpdated();
1175 std::shared_ptr<TMultiGraph> out;
1176 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull") ||
sOpt.Contains(
"ts")) {
1179 sOpt.ReplaceAll(
"visualize",
"");
1188 out = std::make_shared<TMultiGraph>(GetName(), GetTitle());
1189 if (exp2 && exp2->GetN() > 1)
1190 out->Add(
static_cast<TGraph *
>(exp2->Clone()),
"FP");
1192 out->Add(
static_cast<TGraph *
>(
exp1->Clone()),
"FP");
1193 if (exp && exp->GetN() > 1)
1194 out->Add(
static_cast<TGraph *
>(exp->Clone()),
"LP");
1195 if (obs && obs->GetN() > 1)
1196 out->Add(
static_cast<TGraph *
>(obs->Clone()),
"LP");
1198 if (!out->GetListOfGraphs()) {
1203 if (
sOpt.Contains(
"pcls")) {
1205 line->SetName(
"alpha");
1207 line->SetEditable(
false);
1208 line->SetPoint(
line->GetN(), out->GetHistogram()->GetXaxis()->GetXmin() - 10, 0.05);
1215 for (
int i = 0; i < exp->GetN(); i++) {
1219 line->SetPoint(
line->GetN(), out->GetHistogram()->GetXaxis()->GetXmax() + 10, 0.05);
1221 out->GetListOfFunctions()->Add(
line,
"L");
1224 out->GetHistogram()->GetXaxis()->SetTitle(exp->GetHistogram()->GetXaxis()->GetTitle());
1225 out->GetHistogram()->GetYaxis()->SetTitle(exp->GetHistogram()->GetYaxis()->GetTitle());
1229 leg->SetName(
"legend");
1232 out->GetListOfFunctions()->Add(
leg);
1235 for (
auto g : *out->GetListOfGraphs()) {
1237 leg->AddEntry(o,
"",
"F");
1239 leg->AddEntry(
g,
"",
"LPE");
1243 if (
sOpt.Contains(
"pcls")) {
1245 if (exp2 && exp2->GetN() > 1) {
1253 if (exp && exp->GetN() > 1) {
1261 if (exp2 && exp2->GetN() > 1) {
1265 if (obs && obs->GetN() > 1) {
1275 gROOT->GetSelectedPad()->cd();
1280 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull")) {
1281 gra2->GetHistogram()->SetMinimum(1
e-6);
1285 gPad->GetCanvas()->Paint();
1286 gPad->GetCanvas()->Update();
1287#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1288 gPad->GetCanvas()->ResetUpdated();
1301 if (std::isnan(
target)) {
1305 auto gr = std::make_shared<TGraph>(
pValues);
1326 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1329 double alpha = log(
target);
1343 return std::pair(
lim, err);
1358 return std::pair(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity());
1359 return std::pair((alpha -
y1) /
m +
x1, std::numeric_limits<double>::infinity());
1366 return std::pair(-std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity());
1367 return std::pair((alpha -
y1) /
m +
x1, -std::numeric_limits<double>::infinity());
1374 if (std::isnan(
nSigma)) {
1379 return GetLimit(*
graph(
sOpt +
" readonly"));
1387 sOpt.ReplaceAll(
"visualize",
"");
1388 std::shared_ptr<TGraphErrors>
gr =
graph(
sOpt +
" readonly");
1390 auto gra = graphs(
sOpt.Contains(
"toys") ?
"pcls readonly toys" :
"pcls readonly");
1397 gra->GetHistogram()->SetMinimum(1
e-9);
1398 gra->GetHistogram()->GetYaxis()->SetRangeUser(1
e-9, 1);
1400#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1401 gPad->GetCanvas()->ResetUpdated();
1408 for (
auto p : axes()) {
1409 for (
auto &[
pdf, nll] : fNlls) {
1410 if (
auto _v =
dynamic_cast<RooRealVar *
>(nll->pars()->find(*
p))) {
1417 auto v = (axes().empty()) ?
nullptr :
dynamic_cast<RooRealVar *
>(*axes().rbegin());
1419 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1420 double muMax = std::min(std::min(
v->getMax(
"physical"),
v->getMax()),
v->getMax(
"scan"));
1421 double muMin = std::max(std::max(
v->getMin(
"physical"),
v->getMin()),
v->getMin(
"scan"));
1425 Error(
"findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
muMin);
1426 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1439 if (
sOpt.Contains(
"obs")) {
1441 sOpt2.ReplaceAll(
"obs",
"exp");
1442 auto expLim = findlimit(
sOpt2, std::numeric_limits<double>::infinity(), 0);
1448 (
sOpt.Contains(
"exp")) ? back().asimov() : std::shared_ptr<xRooHypoPoint>(&back(), [](
xRooHypoPoint *) {});
1450 if (point && point->ufit()) {
1461 Error(
"findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
nextPoint);
1462 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1468 auto lim = GetLimit(*
gr);
1470 if (std::isnan(
lim.first)) {
1474 auto v =
dynamic_cast<RooRealVar *
>(*axes().rbegin());
1475 double maxMu = std::min(std::min(
v->getMax(
"physical"),
v->getMax()),
v->getMax(
"scan"));
1476 double minMu = std::max(std::max(
v->getMin(
"physical"),
v->getMin()),
v->getMin(
"scan"));
1479 if (
lim.first > -std::numeric_limits<double>::infinity() &&
lim.first < std::numeric_limits<double>::infinity() &&
1485 if (
lim.second == std::numeric_limits<double>::infinity()) {
1495 (
sOpt.Contains(
"exp")) ? back().asimov() : std::shared_ptr<xRooHypoPoint>(&back(), [](
xRooHypoPoint *) {});
1497 if (point && point->ufit()) {
1509 }
else if (
lim.second == -std::numeric_limits<double>::infinity()) {
1523 ::Info(
"xRooHypoSpace::findlimit",
"%s -- Testing new point @ %s=%g (delta=%g)",
sOpt.Data(),
v->GetName(),
1527 Warning(
"findlimit",
"Reached max number of point evaluations");
1529 Error(
"findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
nextPoint);
1543 if ((
sOpt ==
"" ||
sOpt ==
"same") && !empty()) {
1546 for (
auto &
hp : *
this) {
1547 if (!
hp.nullToys.empty() || !
hp.altToys.empty()) {
1558 auto _axes = axes();
1562 if (
sOpt ==
"status") {
1564 if (
_axes.size() <= 2) {
1567 out->SetName(
"points");
1568 out->SetMarkerSize(0.5);
1577 expAvail->SetMarkerSize(out->GetMarkerSize() * 1.5);
1583 badPoints->SetMarkerSize(out->GetMarkerSize());
1589 badPoints2->SetMarkerSize(out->GetMarkerSize());
1592 (
_axes.size() == 1) ?
"" :
_axes.at(1)->GetTitle()));
1593 for (
auto &
p : *
this) {
1594 bool _readOnly =
p.nllVar ?
p.nllVar->get()->getAttribute(
"readOnly") :
false;
1596 p.nllVar->get()->setAttribute(
"readOnly",
true);
1597 double x =
p.coords->getRealValue(
_axes.at(0)->GetName());
1598 double y =
_axes.size() == 1 ?
p.ts_asymp().first :
p.coords->getRealValue(
_axes.at(1)->GetName());
1599 out->SetPoint(out->GetN(),
x,
y);
1600 if (!std::isnan(
p.ts_asymp().first)) {
1601 if (
_axes.size() == 1)
1602 out->SetPointError(out->GetN() - 1, 0,
p.ts_asymp().second);
1604 }
else if (
p.fUfit && (std::isnan(
p.fUfit->minNll()) ||
1608 }
else if (
p.fNull_cfit && (std::isnan(
p.fNull_cfit->minNll()) ||
1613 if (!std::isnan(
p.ts_asymp(0).first)) {
1615 }
else if (
p.asimov() &&
p.asimov()->fUfit &&
1616 (std::isnan(
p.asimov()->fUfit->minNll()) ||
1620 }
else if (
p.asimov() &&
p.asimov()->fNull_cfit &&
1621 (std::isnan(
p.asimov()->fNull_cfit->minNll()) ||
1626 p.nllVar->get()->setAttribute(
"readOnly",
_readOnly);
1629 if (
_axes.size() == 1) {
1631 for (
int i = 0; i < out->GetN(); i++) {
1632 if (!std::isnan(out->GetPointY(i)))
1633 tmp.SetPoint(tmp.GetN(), out->GetPointX(i), out->GetPointY(i));
1636 for (
int i = 0; i <
g->GetN(); i++) {
1637 if (std::isnan(
g->GetPointY(i)))
1638 g->SetPointY(i, std::isnan(tmp.Eval(
g->GetPointX(i))) ? 0. : tmp.Eval(
g->GetPointX(i)));
1648 out->SetMarkerStyle(4);
1650 auto leg =
new TLegend(1. -
gPad->GetRightMargin() - 0.3, 1. -
gPad->GetTopMargin() - 0.35,
1651 1. -
gPad->GetRightMargin() - 0.05, 1. -
gPad->GetTopMargin() - 0.05);
1652 leg->SetName(
"legend");
1653 leg->AddEntry(out,
"Uncomputed",
"P");
1656 out->GetListOfFunctions()->Add(
tsAvail,
"P");
1662 out->GetListOfFunctions()->Add(
expAvail,
"P");
1663 leg->AddEntry(
expAvail,
"Expected computed",
"P");
1668 out->GetListOfFunctions()->Add(
badPoints,
"P");
1674 out->GetListOfFunctions()->Add(
badPoints2,
"P");
1683 if (
_axes.size() == 1)
1684 gPad->SetLogy(
false);
1692 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull") ||
sOpt.Contains(
"ts")) {
1693 auto gra = graphs(
sOpt +
" readonly");
1695 gROOT->GetSelectedPad()->cd();
1696 if (!
sOpt.Contains(
"same") &&
gPad) {
1702 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull")) {
1703 gra2->GetHistogram()->SetMinimum(1
e-6);
1707 gPad->GetCanvas()->Paint();
1708 gPad->GetCanvas()->Update();
1709#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1710 gPad->GetCanvas()->ResetUpdated();
1715 if (!
sOpt.Contains(
"same") &&
gPad) {
1731 out->SetName(GetName());
1736 if (!empty() && axes().
size() == 1) {
1737 for (
auto &
p : *
this) {
1743 title += front().tsTitle(
true);
1746 out->SetTitle(title);
1747 *
dynamic_cast<TAttFill *
>(out) = *
this;
1748 *
dynamic_cast<TAttLine *
>(out) = *
this;
1755 if (!
sOpt.Contains(
"same"))
1759 if (
sOpt.Contains(
"fits")) {
1761 sOpt.ReplaceAll(
"fits",
"");
1766 out->SetEditable(
false);
1771 gPad->SetBottomMargin(
gPad->GetBottomMargin() * 2.);
1781 std::pair<double, double>
minMax(std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity());
1782 for (
auto &
p : *
this) {
1785 auto val =
p.pll(
true).first;
1786 if (std::isnan(val))
1791 if (
minMax.first < std::numeric_limits<double>::infinity())
1792 out->GetHistogram()->SetMinimum(
minMax.first);
1793 if (
minMax.second > -std::numeric_limits<double>::infinity())
1794 out->GetHistogram()->SetMaximum(
minMax.second);
1800 std::shared_ptr<const RooFitResult>
ufr;
1801 for (
auto &
p : *
this) {
1804 auto val =
p.pll().first;
1807 if (out->GetN() == 0 &&
ufr &&
ufr->status() == 0) {
1808 out->SetPoint(out->GetN(),
1809 ufr->floatParsFinal().getRealValue(axes().first()->GetName(),
1810 ufr->constPars().getRealValue(axes().first()->GetName())),
1812 out->SetPointError(out->GetN() - 1, 0,
ufr->edm());
1814 if (
auto fr =
p.fNull_cfit;
1819 new TPad(fr->GetName(),
TString::Format(
"%s = %g", poi().first()->GetTitle(),
p.fNullVal()), 0, 0, 1., 1);
1820 pad->SetNumber(out->GetN() + 1);
1827 if (std::isnan(val) &&
p.status() != 0) {
1835 out->GetListOfFunctions()->Add(
badPoints,
"P");
1839 }
else if (!std::isnan(val)) {
1840 out->SetPoint(out->GetN(),
p.coords->getRealValue(axes().first()->GetName()),
p.pll().first);
1841 out->SetPointError(out->GetN() - 1, 0,
p.pll().second);
1846 for (
int i = 0; i <
badPoints->GetN(); i++)
1853 basePad->GetCanvas()->Paint();
1854 basePad->GetCanvas()->Update();
1861 basePad->GetCanvas()->Paint();
1862 basePad->GetCanvas()->Update();
1863#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1864 basePad->GetCanvas()->ResetUpdated();
1871 auto pad =
new TPad(
ufr->GetName(),
"unconditional fit", 0, 0, 1., 1.);
1879 pad =
new TPad(
"selected",
"selected", 0, 0, 1, 1);
1882 basePad->GetPad(2)->GetPad(-1)->AppendPad();
1894 gPad->GetCanvas()->
Connect(
"Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)",
"xRooNode::InteractiveObject",
1906 auto _axes = axes();
1911 out->SetTitle(GetTitle());
1913 for (
auto &
p : *
this) {
1914 double _x =
p.coords->getRealValue(
_axes.at(0)->GetName(), std::numeric_limits<double>::quiet_NaN());
1915 out->Add(_x,
p.result());
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetFillStyle
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 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 target
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 value
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char y1
R__EXTERN TStyle * gStyle
R__EXTERN TSystem * gSystem
static std::pair< double, double > matchPrecision(const std::pair< double, double > &in)
static std::set< int > allowedStatusCodes
xValueWithError limit(const char *type="cls", double nSigma=std::numeric_limits< double >::quiet_NaN()) const
xRooHypoPoint & point(size_t i)
RooStats::HypoTestInverterResult * result()
static xValueWithError GetLimit(const TGraph &pValues, double target=std::numeric_limits< double >::quiet_NaN())
std::map< std::string, xValueWithError > limits(const char *opt="cls", const std::vector< double > &nSigmas={0, 1, 2, -1, -2, std::numeric_limits< double >::quiet_NaN()}, double relUncert=std::numeric_limits< double >::infinity())
bool AddModel(const xRooNode &pdf, const char *validity="")
std::shared_ptr< TMultiGraph > graphs(const char *opt)
static RooArgList toArgs(const char *str)
xValueWithError findlimit(const char *opt, double relUncert=std::numeric_limits< double >::infinity(), unsigned int maxTries=20)
int AddPoints(const char *parName, size_t nPoints, double low, double high)
std::shared_ptr< TGraphErrors > graph(const char *opt) const
std::shared_ptr< RooArgSet > fPars
void Print(Option_t *opt="") const override
Print TNamed name and title.
xRooHypoSpace(const char *name="", const char *title="")
xRooHypoPoint & AddPoint(double value)
int scan(const char *type, size_t nPoints, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN(), const std::vector< double > &nSigmas={0, 1, 2, -1, -2, std::numeric_limits< double >::quiet_NaN()}, double relUncert=0.1)
std::shared_ptr< xRooNode > pdf(const RooAbsCollection &parValues) const
void Draw(Option_t *opt="") override
Default Draw method for all objects.
void LoadFits(const char *apath)
std::shared_ptr< RooAbsPdf > pdf() const
std::shared_ptr< RooArgSet > pars(bool stripGlobalObs=true) const
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
void Draw(Option_t *opt="") override
Default Draw method for all objects.
RooArgList argList() const
static InteractiveObject * gIntObj
xRooNode pars() const
List of parameters (non-observables) of this node.
const_iterator begin() const
const_iterator end() const
A space to attach TBranches.
virtual value_type getCurrentIndex() const
Return index number of current state.
Abstract container object that can hold multiple RooAbsArg objects.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Represents a constant real-valued object.
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Variable that can be changed from the outside.
HypoTestInverterResult class holds the array of hypothesis test results and compute a confidence inte...
HypoTestResult * GetResult(int index) const
return a pointer to the i^th result object
int ArraySize() const
number of entries in the results array
double GetXValue(int index) const
function to return the value of the parameter of interest for the i^th entry in the results
RooArgSet * GetParameters() const override
return a cloned list with the parameter of interest
Fill Area Attributes class.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
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.
Describe directory structure in memory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TGraphErrors is a TGraph with error bars.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual Double_t GetPointX(Int_t i) const
Get x value for point i.
static Bool_t CompareX(const TGraph *gr, Int_t left, Int_t right)
Return kTRUE if fX[left] > fX[right]. Can be used by Sort.
virtual void Sort(Bool_t(*greater)(const TGraph *, Int_t, Int_t)=&TGraph::CompareX, Bool_t ascending=kTRUE, Int_t low=0, Int_t high=-1111)
Sorts the points of this TGraph using in-place quicksort (see e.g.
TList * GetListOfFunctions() const
virtual Int_t RemovePoint()
Delete point close to the mouse position Returns index of removed point (or -1 if nothing was changed...
virtual Double_t GetPointY(Int_t i) const
Get y value for point i.
virtual void SetPointY(Int_t i, Double_t y)
Set y value for point i.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
virtual const char * GetClassName() const
This class displays a legend box (TPaveText) containing several legend entries.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
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.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Mother of all ROOT objects.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
The most important graphics class in the ROOT system.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Continue()
Resume a stopped stopwatch.
Provides iteration through tokens of a given string.
Bool_t NextToken()
Get the next token, it is stored in this TString.
Double_t Atof() const
Return floating-point value contained in string.
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
Float_t GetPadRightMargin() const
Float_t GetPadTopMargin() const
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
TVirtualPad is an abstract base class for the Pad and Canvas classes.
double gaussian_quantile(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the lower tail of the normal (Gaussian) distri...
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE