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 Warning(
"AddPoints",
"low edge of hypoSpace %g below lower bound of parameter: %g. Changing to lower bound", low,
191 low = _par->getMin();
193 if (high > _par->getMax()) {
194 Warning(
"AddPoints",
"high edge of hypoSpace %g above upper bound of parameter: %g. Changing to upper bound",
195 high, _par->getMax());
196 high = _par->getMax();
200 _par->setVal((high + low) * 0.5);
205 double step = (high - low) / (
nPoints - 1);
207 throw std::runtime_error(
"Invalid steps");
209 for (
size_t i = 0; i <
nPoints; i++) {
210 _par->setVal((i ==
nPoints - 1) ? high : (low + step * i));
218 if (axes().empty()) {
221 throw std::runtime_error(
"No POI to scan");
223 poi().first()->setAttribute(
"axis");
229 poi().setAttribAll(
"poi",
false);
230 axes().setAttribAll(
"poi");
242 if (
sType.Contains(
"cls") && !
sType.Contains(
"pcls"))
243 sType.ReplaceAll(
"cls",
"pcls");
244 if (!
sType.Contains(
"pcls") && !
sType.Contains(
"ts") && !
sType.Contains(
"pnull") && !
sType.Contains(
"plr")) {
245 throw std::runtime_error(
"scan type must be equal to one of: plr, cls, ts, pnull");
249 if (axes().empty()) {
252 throw std::runtime_error(
"No POI to scan");
254 poi().first()->setAttribute(
"axis");
259 poi().setAttribAll(
"poi",
false);
260 axes().setAttribAll(
"poi");
262 auto p =
dynamic_cast<RooRealVar *
>(axes().first());
264 throw std::runtime_error(
TString::Format(
"%s not scannable", axes().first()->GetName()));
267 if (
sType.Contains(
"cls")) {
268 if (empty() &&
relUncert == std::numeric_limits<double>::infinity()) {
270 ::Info(
"xRooHypoSpace::scan",
"Using default precision of 10%% for auto-scan");
273 for (
auto a : axes()) {
274 if (!
a->hasRange(
"physical")) {
275 ::Info(
"xRooHypoSpace::scan",
"No physical range set for %s, setting to [0,inf]",
p->GetName());
276 dynamic_cast<RooRealVar *
>(
a)->setRange(
"physical", 0, std::numeric_limits<double>::infinity());
278 if (!
a->getStringAttribute(
"altVal") || !
strlen(
p->getStringAttribute(
"altVal"))) {
279 ::Info(
"xRooHypoSpace::scan",
"No altVal set for %s, setting to 0",
a->GetName());
280 a->setStringAttribute(
"altVal",
"0");
286 ::Info(
"xRooHypoSpace::scan",
"range of POI does not straddle alt value, adjusting minimum to %g",
291 ::Info(
"xRooHypoSpace::scan",
"range of POI does not straddle alt value, adjusting maximum to %g",
295 for (
auto &[
pdf, nll] : fNlls) {
296 if (
auto _v =
dynamic_cast<RooRealVar *
>(nll->pars()->find(*
a))) {
297 _v->setRange(
v->getMin(),
v->getMax());
301 }
else if (
sType.Contains(
"plr")) {
304 sType.ReplaceAll(
"plr",
"ts");
310 for (
auto a : axes()) {
311 if (!
a->getStringAttribute(
"altVal") || !
strlen(
p->getStringAttribute(
"altVal"))) {
312 ::Info(
"xRooHypoSpace::scan",
"No altVal set for %s, setting to 1",
a->GetName());
313 a->setStringAttribute(
"altVal",
"1");
318 if ( (high == low &&
nPoints != 1)) {
320 low =
p->getMin(
"scan");
321 high =
p->getMax(
"scan");
323 if (!std::isnan(low) && !std::isnan(high) && !(std::isinf(low) && std::isinf(high))) {
324 p->setRange(
"scan", std::min(low, high), std::max(low, high));
326 if (
p->hasRange(
"scan")) {
327 ::Info(
"xRooHypoSpace::scan",
"Using %s scan range: %g - %g",
p->GetName(),
p->getMin(
"scan"),
p->getMax(
"scan"));
341 relUncert = std::numeric_limits<double>::infinity();
350#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 26, 00)
370 if (
auto myDb =
dynamic_cast<TMemFile *
>(fFitDb.get())) {
372 myDb->SetWritable(
true);
388 fFitDb = std::shared_ptr<TDirectory>(
400 if (!
gROOT->IsBatch() && !
sType.Contains(
"visualize"))
401 sType +=
" visualize";
405 if (
sType.Contains(
"cls")) {
416 if (std::isnan(res.first) || std::isnan(res.second)) {
418 }
else if (std::isinf(res.second)) {
423 throw std::runtime_error(
TString::Format(
"Automatic scanning not yet supported for %s",
type));
428 AddPoint(
TString::Format(
"%s=%g", poi().first()->GetName(), (high + low) / 2.));
430 if (back().status() != 0)
433 double step = (high - low) / (
nPoints - 1);
434 for (
size_t i = 0; i <
nPoints; i++) {
435 AddPoint(
TString::Format(
"%s=%g", poi().first()->GetName(), low + step * i));
437 if (back().status() != 0)
446 if (
auto myDb =
dynamic_cast<TMemFile *
>(fFitDb.get())) {
448 myDb->SetWritable(
false);
453std::map<std::string, xRooNLLVar::xValueWithError>
460 relUncert = std::numeric_limits<double>::infinity();
465 std::map<std::string, xRooNLLVar::xValueWithError> out;
487 auto _idx = s.
Index(
'=');
492 auto _v =
dynamic_cast<RooRealVar *
>(fPars->find(_name));
496 if (
_val.IsFloat()) {
505 throw std::runtime_error(
"no model at coordinates");
512 if (fNlls.find(_pdf) == fNlls.end()) {
513 fNlls[_pdf] = std::make_shared<xRooNLLVar>(_pdf->nll(
"" , {}));
519 out.
fData = fNlls[_pdf]->getData();
521 dynamic_cast<RooDataSet *
>(out.
fData.first.get())->weightVar()->getAttribute(
"expected");
524 out.
coords.reset(fPars->snapshot());
533 ->remove(*std::unique_ptr<RooAbsCollection>(out.
coords->selectByAttrib(
"Constant",
false)),
true,
true);
538 auto _type = fTestStatType;
553 for (
auto &
p : *
this) {
558 if (!
p.alt_poi().equals(out.
alt_poi()))
561 for (
auto c :
p.alt_poi()) {
575 if (!
p.coords->equals(*out.
coords))
577 for (
auto c : *
p.coords) {
578 if (
c->getAttribute(
"poi")) {
582 v && std::abs(
v->getVal() - out.
coords->getRealValue(
v->GetName())) > 1
e-12) {
596 if (
auto cfit =
p.cfit_alt(
true)) {
599 if (
p.asimov(
true) &&
p.asimov(
true)->fData.first && (!out.
asimov(
true) || !out.
asimov(
true)->fData.first)) {
600 out.
asimov()->fData =
p.asimov(
true)->fData;
602 if (!
p.poi().equals(out.
poi()))
604 for (
auto c :
p.poi()) {
618 for (
auto a : axes()) {
625 return emplace_back(out);
632 throw std::runtime_error(
"Not a pdf");
644 throw std::runtime_error(std::string(
"Clashing model: ") +
existing->GetName());
650 pars.remove(*fPars,
true,
true);
652 fPars->addClone(
pars);
654 fPdfs.insert(std::make_pair(
myPars, std::make_shared<xRooNode>(_pdf)));
665 out.
add(*std::unique_ptr<RooAbsCollection>(
666 fPars->selectByAttrib(
"axis",
true)));
672 std::set<std::vector<double>> coords;
673 for (
auto &
p : *
this) {
676 auto _v =
dynamic_cast<RooRealVar *
>(
p.coords->find(o->GetName()));
678 (
_v &&
_v->isConstant())
680 : std::numeric_limits<double>::infinity());
683 if (coords.find(
p_coords) != coords.end()) {
692 std::map<std::string, std::unordered_set<double>> values;
693 for (
auto &par : *
pars()) {
696 for (
auto p : *
this) {
697 auto _v =
dynamic_cast<RooRealVar *
>(
p.coords->find(par->GetName()));
698 values[par->GetName()].insert(
699 (
_v &&
_v->isConstant())
701 : std::numeric_limits<double>::infinity());
710 for (
auto &[k,
v] : values) {
713 isPOI =
pars()->find(k.c_str())->getAttribute(
"poi");
726 std::unique_ptr<RooAbsCollection> poi(out.
selectByAttrib(
"poi",
true));
737 out.
add(*std::unique_ptr<RooAbsCollection>(
pars()->selectByAttrib(
"poi",
true)));
748 for (
size_t i = 0; i <
size(); i++) {
749 std::cout << i <<
") ";
753 std::cout <<
a->GetName() <<
"="
754 << at(i).coords->getRealValue(
a->GetName(), std::numeric_limits<double>::quiet_NaN());
756 std::cout <<
" status=[ufit:";
761 std::cout << ufit->
status();
764 std::cout <<
",cfit_null:";
765 auto cfit =
const_cast<xRooHypoPoint &
>(at(i)).cfit_null(
true);
769 std::cout << cfit->
status();
772 std::cout <<
",cfit_alt:";
777 std::cout <<
afit->status();
781 std::cout <<
",asimov.ufit:";
789 std::cout <<
",asimov.cfit_null:";
797 auto cfit_lbound =
const_cast<xRooHypoPoint &
>(at(i)).cfit_lbound(
true);
800 std::cout <<
",cfit_lbound:" << cfit_lbound->
status();
805 auto sigma_mu =
const_cast<xRooHypoPoint &
>(at(i)).sigma_mu(
true);
806 if (!std::isnan(sigma_mu.first)) {
807 std::cout <<
" sigma_mu=" << sigma_mu.first;
809 std::cout <<
" +/- " << sigma_mu.second;
811 std::cout << std::endl;
813 std::cout <<
"--------------------------" << std::endl;
814 std::cout <<
"Number of bad fits: " <<
badFits << std::endl;
818 const char *opt )
const
829 (
sOpt.Contains(
"exp"))
833 : std::numeric_limits<double>::quiet_NaN();
838 if (
_axes.size() != 1)
841 auto out = std::make_shared<TGraphErrors>();
842 out->SetName(GetName());
843 out->SetEditable(
false);
844 const char *
sCL = (
doCLs) ?
"CLs" :
"null";
858 out->SetMarkerStyle(20);
859 out->SetMarkerSize(0.5);
860 if (
sOpt.Contains(
"ts")) {
862 (empty() ?
"" : front().tsTitle(
true).Data())));
866 out->SetMarkerStyle(0);
867 out->SetMarkerSize(0);
868 out->SetLineStyle(2 +
int(
nSigma));
872 out->SetLineStyle(0);
873 out->SetLineWidth(0);
874 auto x = out->Clone(
"up");
878 out->GetListOfFunctions()->Add(
x,
"F");
879 x = out->Clone(
"down");
883 out->GetListOfFunctions()->Add(
x,
"F");
885 if (
sOpt.Contains(
"ts")) {
892 auto badPoints2 =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"badPoints"));
900 out->GetListOfFunctions()->Add(
badPoints2,
"P");
909 for (
auto &
p : *
this) {
913 auto gra = graph(
sOpt +
" readOnly");
916 gROOT->GetSelectedPad()->cd();
920#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
921 if (
auto pad =
gROOT->GetSelectedPad()) {
922 pad->GetCanvas()->ResetUpdated();
928 ::Info(
"xRooHypoSpace::graph",
"Completed %d/%d points for %s",
int(
nDone),
int(
size()),
sOpt.Data());
934 double _x =
p.coords->getRealValue(
_axes.at(0)->GetName(), std::numeric_limits<double>::quiet_NaN());
938 if (std::isnan(
pval.first)) {
939 if (
p.status() != 0) {
943 out->InsertPointBefore(idx, _x,
pval.first);
944 out->SetPointError(idx, 0,
pval.second);
949 sOpt2.ReplaceAll(
"exp",
"exp-");
951 if (std::isnan(
pval.first)) {
952 if (
p.status() != 0) {
956 out->InsertPointBefore(idx + 1, _x,
pval.first);
957 out->SetPointError(idx + 1, 0,
pval.second);
959 if (out->GetPointY(idx) <
pval.first)
966 if (out->GetN() == 0)
971 if (out->GetListOfFunctions()->FindObject(
"badPoints")) {
973 for (
int i = 0; i <
badPoints()->GetN(); i++) {
982 auto up =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"up"));
983 auto down =
dynamic_cast<TGraph *
>(out->GetListOfFunctions()->FindObject(
"down"));
985 for (
int i = 0; i < out->GetN(); i++) {
987 up->SetPoint(
up->GetN(), out->GetPointX(i), out->GetPointY(i) + out->GetErrorY(i) * (
above ? 1. : -1.));
988 down->SetPoint(
down->GetN(), out->GetPointX(i), out->GetPointY(i) - out->GetErrorY(i) * (
above ? 1. : -1.));
990 up->SetPoint(
up->GetN(), out->GetPointX(i), out->GetPointY(i) - out->GetErrorY(i) * (
above ? 1. : -1.));
991 down->SetPoint(
down->GetN(), out->GetPointX(i), out->GetPointY(i) + out->GetErrorY(i) * (
above ? 1. : -1.));
999 gROOT->GetSelectedPad()->cd();
1003#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1004 if (
auto pad =
gROOT->GetSelectedPad()) {
1005 pad->GetCanvas()->ResetUpdated();
1018 std::shared_ptr<TMultiGraph> out;
1019 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull") ||
sOpt.Contains(
"ts")) {
1022 sOpt.ReplaceAll(
"visualize",
"");
1024 auto exp2 = graph(
sOpt +
" exp2");
1026 auto exp = graph(
sOpt +
" exp");
1029 auto obs = (
doObs) ? graph(
sOpt) :
nullptr;
1031 out = std::make_shared<TMultiGraph>(GetName(), GetTitle());
1032 if (exp2 && exp2->GetN() > 1)
1033 out->Add(
static_cast<TGraph *
>(exp2->Clone()),
"FP");
1035 out->Add(
static_cast<TGraph *
>(
exp1->Clone()),
"FP");
1036 if (exp && exp->GetN() > 1)
1037 out->Add(
static_cast<TGraph *
>(exp->Clone()),
"LP");
1038 if (obs && obs->GetN() > 1)
1039 out->Add(
static_cast<TGraph *
>(obs->Clone()),
"LP");
1041 if (!out->GetListOfGraphs()) {
1046 if (
sOpt.Contains(
"pcls")) {
1048 line->SetName(
"alpha");
1050 line->SetEditable(
false);
1051 line->SetPoint(
line->GetN(), out->GetHistogram()->GetXaxis()->GetXmin() - 10, 0.05);
1058 for (
int i = 0; i < exp->GetN(); i++) {
1062 line->SetPoint(
line->GetN(), out->GetHistogram()->GetXaxis()->GetXmax() + 10, 0.05);
1064 out->GetListOfFunctions()->Add(
line,
"L");
1067 out->GetHistogram()->GetXaxis()->SetTitle(exp->GetHistogram()->GetXaxis()->GetTitle());
1068 out->GetHistogram()->GetYaxis()->SetTitle(exp->GetHistogram()->GetYaxis()->GetTitle());
1071 if (out->GetListOfGraphs()->GetEntries() > 1) {
1074 leg->SetName(
"legend");
1077 out->GetListOfFunctions()->Add(
leg);
1080 for (
auto g : *out->GetListOfGraphs()) {
1082 leg->AddEntry(o,
"",
"F");
1084 leg->AddEntry(
g,
"",
"LPE");
1089 auto addToLegend = [](
TLegend *
l,
const char *label,
const std::pair<double, double> val) {
1092 TString::Format(
"%s%s: %g #pm %g%s", std::isfinite(val.second) ?
"" :
"#color[2]{", label,
1093 val.first, val.second, std::isfinite(val.second) ?
"" :
"}"),
1098 if (
sOpt.Contains(
"pcls")) {
1100 if (exp2 && exp2->GetN() > 1) {
1108 if (exp && exp->GetN() > 1) {
1116 if (exp2 && exp2->GetN() > 1) {
1120 if (obs && obs->GetN() > 1) {
1130 gROOT->GetSelectedPad()->cd();
1135 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull")) {
1136 gra2->GetHistogram()->SetMinimum(1
e-6);
1140 gPad->GetCanvas()->Paint();
1141 gPad->GetCanvas()->Update();
1142#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1143 gPad->GetCanvas()->ResetUpdated();
1156 if (std::isnan(
target)) {
1160 auto gr = std::make_shared<TGraph>(
pValues);
1181 return std::pair<double, double>(std::numeric_limits<double>::quiet_NaN(), 0);
1184 double alpha = log(
target);
1198 return std::pair(
lim, err);
1213 return std::pair(std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity());
1214 return std::pair((alpha -
y1) /
m +
x1, std::numeric_limits<double>::infinity());
1221 return std::pair(-std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity());
1222 return std::pair((alpha -
y1) /
m +
x1, -std::numeric_limits<double>::infinity());
1229 if (std::isnan(
nSigma)) {
1234 return GetLimit(*graph(
sOpt +
" readonly"));
1242 sOpt.ReplaceAll(
"visualize",
"");
1243 std::shared_ptr<TGraphErrors>
gr = graph(
sOpt +
" readonly");
1245 auto gra = graphs(
sOpt.Contains(
"toys") ?
"pcls readonly toys" :
"pcls readonly");
1252 gra->GetHistogram()->SetMinimum(1
e-9);
1253 gra->GetHistogram()->GetYaxis()->SetRangeUser(1
e-9, 1);
1255#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1256 gPad->GetCanvas()->ResetUpdated();
1263 for (
auto p : axes()) {
1264 for (
auto &[
pdf, nll] : fNlls) {
1265 if (
auto _v =
dynamic_cast<RooRealVar *
>(nll->pars()->find(*
p))) {
1272 auto v = (axes().empty()) ?
nullptr :
dynamic_cast<RooRealVar *
>(*axes().rbegin());
1274 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1275 double muMax = std::min(std::min(
v->getMax(
"physical"),
v->getMax()),
v->getMax(
"scan"));
1276 double muMin = std::max(std::max(
v->getMin(
"physical"),
v->getMin()),
v->getMin(
"scan"));
1280 ::Error(
"findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
muMin);
1281 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1294 if (
sOpt.Contains(
"obs")) {
1296 sOpt2.ReplaceAll(
"obs",
"exp");
1297 auto expLim = findlimit(
sOpt2, std::numeric_limits<double>::infinity(), 0);
1303 (
sOpt.Contains(
"exp")) ? back().asimov() : std::shared_ptr<xRooHypoPoint>(&back(), [](
xRooHypoPoint *) {});
1305 if (point && point->ufit()) {
1316 ::Error(
"xRooHypoSpace::findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
nextPoint);
1317 return std::pair(std::numeric_limits<double>::quiet_NaN(), 0.);
1323 auto lim = GetLimit(*
gr);
1325 if (std::isnan(
lim.first)) {
1329 auto v =
dynamic_cast<RooRealVar *
>(*axes().rbegin());
1330 double maxMu = std::min(std::min(
v->getMax(
"physical"),
v->getMax()),
v->getMax(
"scan"));
1331 double minMu = std::max(std::max(
v->getMin(
"physical"),
v->getMin()),
v->getMin(
"scan"));
1334 if (
lim.first > -std::numeric_limits<double>::infinity() &&
lim.first < std::numeric_limits<double>::infinity() &&
1340 if (
lim.second == std::numeric_limits<double>::infinity()) {
1350 (
sOpt.Contains(
"exp")) ? back().asimov() : std::shared_ptr<xRooHypoPoint>(&back(), [](
xRooHypoPoint *) {});
1352 if (point && point->ufit()) {
1364 }
else if (
lim.second == -std::numeric_limits<double>::infinity()) {
1378 ::Info(
"xRooHypoSpace::findlimit",
"%s -- Testing new point @ %s=%g (delta=%g)",
sOpt.Data(),
v->GetName(),
1382 ::Warning(
"xRooHypoSpace::findlimit",
"Reached max number of point evaluations");
1384 ::Error(
"xRooHypoSpace::findlimit",
"Problem evaluating %s @ %s=%g",
sOpt.Data(),
v->GetName(),
nextPoint);
1398 if ((
sOpt ==
"" ||
sOpt ==
"same") && !empty()) {
1401 for (
auto &
hp : *
this) {
1402 if (!
hp.nullToys.empty() || !
hp.altToys.empty()) {
1413 auto _axes = axes();
1417 if (
sOpt ==
"status") {
1419 if (
_axes.size() <= 2) {
1447 (
_axes.size() == 1) ?
"" :
_axes.at(1)->GetTitle()));
1448 for (
auto &
p : *
this) {
1449 bool _readOnly =
p.nllVar ?
p.nllVar->get()->getAttribute(
"readOnly") :
false;
1451 p.nllVar->get()->setAttribute(
"readOnly",
true);
1452 double x =
p.coords->getRealValue(
_axes.at(0)->GetName());
1453 double y =
_axes.size() == 1 ?
p.ts_asymp().first :
p.coords->getRealValue(
_axes.at(1)->GetName());
1455 if (!std::isnan(
p.ts_asymp().first)) {
1456 if (
_axes.size() == 1)
1459 }
else if (
p.fUfit && (std::isnan(
p.fUfit->minNll()) ||
1463 }
else if (
p.fNull_cfit && (std::isnan(
p.fNull_cfit->minNll()) ||
1468 if (!std::isnan(
p.ts_asymp(0).first)) {
1470 }
else if (
p.asimov() &&
p.asimov()->fUfit &&
1471 (std::isnan(
p.asimov()->fUfit->minNll()) ||
1475 }
else if (
p.asimov() &&
p.asimov()->fNull_cfit &&
1476 (std::isnan(
p.asimov()->fNull_cfit->minNll()) ||
1481 p.nllVar->get()->setAttribute(
"readOnly",
_readOnly);
1484 if (
_axes.size() == 1) {
1486 for (
int i = 0; i < out->
GetN(); i++) {
1491 for (
int i = 0; i <
g->GetN(); i++) {
1492 if (std::isnan(
g->GetPointY(i)))
1493 g->SetPointY(i, std::isnan(
tmp.Eval(
g->GetPointX(i))) ? 0. :
tmp.Eval(
g->GetPointX(i)));
1505 auto leg =
new TLegend(1. -
gPad->GetRightMargin() - 0.3, 1. -
gPad->GetTopMargin() - 0.35,
1506 1. -
gPad->GetRightMargin() - 0.05, 1. -
gPad->GetTopMargin() - 0.05);
1507 leg->SetName(
"legend");
1508 leg->AddEntry(out,
"Uncomputed",
"P");
1518 leg->AddEntry(
expAvail,
"Expected computed",
"P");
1538 if (
_axes.size() == 1)
1539 gPad->SetLogy(
false);
1547 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull") ||
sOpt.Contains(
"ts")) {
1548 auto gra = graphs(
sOpt +
" readonly");
1550 gROOT->GetSelectedPad()->cd();
1551 if (!
sOpt.Contains(
"same") &&
gPad) {
1559 if (
sOpt.Contains(
"pcls") ||
sOpt.Contains(
"pnull")) {
1560 gra2->GetHistogram()->SetMinimum(1
e-6);
1564 gPad->GetCanvas()->Paint();
1565 gPad->GetCanvas()->Update();
1566#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1567 gPad->GetCanvas()->ResetUpdated();
1572 if (!
sOpt.Contains(
"same") &&
gPad) {
1593 if (!empty() && axes().
size() == 1) {
1594 for (
auto &
p : *
this) {
1600 title += front().tsTitle(
true);
1604 *
dynamic_cast<TAttFill *
>(out) = *
this;
1605 *
dynamic_cast<TAttLine *
>(out) = *
this;
1612 if (!
sOpt.Contains(
"same"))
1616 if (
sOpt.Contains(
"fits")) {
1618 sOpt.ReplaceAll(
"fits",
"");
1628 gPad->SetBottomMargin(
gPad->GetBottomMargin() * 2.);
1638 std::pair<double, double>
minMax(std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity());
1639 for (
auto &
p : *
this) {
1642 auto val =
p.pll(
true).first;
1643 if (std::isnan(val))
1648 if (
minMax.first < std::numeric_limits<double>::infinity())
1650 if (
minMax.second > -std::numeric_limits<double>::infinity())
1657 std::shared_ptr<const RooFitResult>
ufr;
1658 for (
auto &
p : *
this) {
1661 auto val =
p.pll().first;
1664 if (out->
GetN() == 0 &&
ufr &&
ufr->status() == 0) {
1666 ufr->floatParsFinal().getRealValue(axes().first()->GetName(),
1667 ufr->constPars().getRealValue(axes().first()->GetName())),
1671 if (
auto fr =
p.fNull_cfit;
1676 new TPad(fr->GetName(),
TString::Format(
"%s = %g", poi().first()->GetTitle(),
p.fNullVal()), 0, 0, 1., 1);
1677 pad->SetNumber(out->
GetN() + 1);
1684 if (std::isnan(val) &&
p.status() != 0) {
1696 }
else if (!std::isnan(val)) {
1697 out->
SetPoint(out->
GetN(),
p.coords->getRealValue(axes().first()->GetName()),
p.pll().first);
1703 for (
int i = 0; i <
badPoints->GetN(); i++)
1710 basePad->GetCanvas()->Paint();
1711 basePad->GetCanvas()->Update();
1718 basePad->GetCanvas()->Paint();
1719 basePad->GetCanvas()->Update();
1720#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 30, 00)
1721 basePad->GetCanvas()->ResetUpdated();
1728 auto pad =
new TPad(
ufr->GetName(),
"unconditional fit", 0, 0, 1., 1.);
1736 pad =
new TPad(
"selected",
"selected", 0, 0, 1, 1);
1739 basePad->GetPad(2)->GetPad(-1)->AppendPad();
1751 gPad->GetCanvas()->
Connect(
"Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)",
"xRooNode::InteractiveObject",
1763 auto _axes = axes();
1770 for (
auto &
p : *
this) {
1771 double _x =
p.coords->getRealValue(
_axes.at(0)->GetName(), std::numeric_limits<double>::quiet_NaN());
1772 out->
Add(_x,
p.result());
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
const char Option_t
Option string (const char)
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)
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > fData
std::shared_ptr< const RooAbsCollection > coords
std::shared_ptr< xRooNLLVar > nllVar
xRooFit::Asymptotics::PLLType fPllType
std::shared_ptr< xRooHypoPoint > asimov(bool readOnly=false)
RooArgList alt_poi() const
std::shared_ptr< const RooFitResult > fAlt_cfit
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.
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 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.
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
Int_t getCatIndex(const char *name, Int_t defVal=0, bool verbose=false) const
Get index value of a RooAbsCategory stored in set with given name.
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.
void setAttribAll(const Text_t *name, bool value=true)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
void setName(const char *name)
RooAbsArg * find(const char *name) const
Find object with given name in list.
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.
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
bool Add(const HypoTestInverterResult &otherResult)
merge with the content of another HypoTestInverterResult object
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.
virtual Size_t GetMarkerSize() const
Return the marker size.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Describe directory structure in memory.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
A TGraphErrors is a TGraph with error bars.
virtual void SetPointError(Double_t ex, Double_t ey)
Set ex and ey values for point pointed by the mouse.
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.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number 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 Double_t Eval(Double_t x, TSpline *spline=nullptr, Option_t *option="") const
Interpolate points in this graph at x using a TSpline.
virtual Int_t RemovePoint()
Delete point close to the mouse position Returns index of removed point (or -1 if nothing was changed...
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.
virtual void SetPointY(Int_t i, Double_t y)
Set y value for point i.
virtual void SetEditable(Bool_t editable=kTRUE)
if editable=kFALSE, the graph cannot be modified with the mouse by default a TGraph is editable
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.
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.
The TNamed class is the base class for all named ROOT classes.
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).
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.
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