5 #pragma GCC diagnostic ignored "-Wfloat-conversion"
6 #pragma GCC diagnostic ignored "-Wconversion"
21 constexpr Color_t
Colours[
NVars] = {kRed, kGreen+1, kBlack, kBlue+1, kOrange+1};
22 constexpr ELineStyle
Style[
NVars] = {kDotted, kDashed, kSolid, kDashDotted, kDashDotted};
28 void FindKnot(std::vector<double>& SigmaValues,
29 const std::string& dirname,
30 const std::string& subdirname,
31 const std::string& ProjName,
32 std::string histname) {
33 auto StripPrefix = [](std::string& str,
const std::string& prefix) {
34 if (str.find(prefix +
"_") == 0) {
35 str.erase(0, prefix.length() + 1);
36 if (str.find(prefix) == 0) {
37 MACH3LOG_ERROR(
"Failed to strip prefix '{}' from string '{}'", prefix, str);
41 MACH3LOG_ERROR(
"String '{}' does not start with expected prefix '{}'", str, prefix);
47 StripPrefix(histname, subdirname);
48 StripPrefix(histname, ProjName);
49 StripPrefix(histname, dirname);
55 size_t sig_pos = histname.find(
"_sig_");
58 std::string sigma_part = histname.substr(sig_pos + 5);
61 if (histname.find(
"nom_") != std::string::npos) {
63 PriorKnot =
static_cast<int>(SigmaValues.size());
65 }
else if (sigma_part.size() > 0 && sigma_part[0] ==
'n') {
66 sigma = -std::stod(sigma_part.substr(1));
67 }
else if (sigma_part.size() > 0 && sigma_part[0] ==
'p') {
68 sigma = std::stod(sigma_part.substr(1));
75 SigmaValues.push_back(sigma);
78 std::unique_ptr<TLegend>
MakeLegend(
double x1,
double y1,
double x2,
double y2,
79 double textSize = 0.04)
81 auto leg = std::make_unique<TLegend>(x1, y1, x2, y2);
82 leg->SetTextSize(textSize);
87 leg->SetBorderSize(0);
93 void ScanInput(std::vector<std::string>& DialNameVecr,
94 std::vector<std::string>& SampleNameVec,
95 std::vector<int>& SampleDimVec,
96 std::vector<double>& SigmaValues,
97 const std::string& filename)
100 TFile *infile =
M3::Open(filename,
"OPEN", __FILE__, __LINE__);
101 TDirectoryFile *SigmaDir = infile->Get<TDirectoryFile>(
"SigmaVar");
104 TIter next(SigmaDir->GetListOfKeys());
108 while ((key =
static_cast<TKey*
>(next()))) {
110 auto classname = std::string(key->GetClassName());
111 auto dirname = std::string(key->GetName());
113 if (classname !=
"TDirectoryFile")
continue;
114 dirname = std::string(key->GetName());
116 SigmaDir->cd(dirname.c_str());
117 TIter nextsub(gDirectory->GetListOfKeys());
118 TKey *subkey =
nullptr;
120 DialNameVecr.push_back(dirname);
123 if(SampleNameVec.size() != 0)
continue;
125 while ((subkey =
static_cast<TKey*
>(nextsub())))
127 auto subdirname = std::string(subkey->GetName());
128 SampleNameVec.push_back(subdirname);
129 SampleDimVec.push_back(0);
131 SigmaDir->cd((dirname +
"/" + subdirname).c_str());
133 TKey *subsubkey =
nullptr;
134 TIter nextsubsub(gDirectory->GetListOfKeys());
137 bool FillSigma =
false;
138 if(SigmaValues.size() == 0) FillSigma =
true;
140 while ((subsubkey =
static_cast<TKey*
>(nextsubsub())))
142 auto subsubdirname = std::string(subsubkey->GetTitle());
144 std::string histname = subsubdirname;
146 classname = std::string(subsubkey->GetClassName());
148 if (classname !=
"TH1D")
continue;
150 size_t proj_pos = histname.find(
"_1DProj");
151 int proj_number = -1;
153 if (proj_pos != std::string::npos) {
154 size_t number_start = proj_pos + 7;
155 size_t number_end = histname.find_first_not_of(
"0123456789", number_start);
156 proj_number = std::stoi(histname.substr(number_start, number_end - number_start));
158 SampleDimVec.back() = std::max(proj_number, SampleDimVec.back());
163 if(FillSigma && proj_number == 0)
FindKnot(SigmaValues, dirname, subdirname,
"1DProj" + std::to_string(proj_number), histname);
169 MACH3LOG_ERROR(
"Didn't find prior knot, something is not right...");
178 if(SampleNameVec.size() != SampleDimVec.size()) {
179 MACH3LOG_ERROR(
"Sample name vec ({}) and sample dimension vec ({}) have different sizes, something is not right");
188 bool SkipDirectory(
const std::vector<std::string>& ExcludeString,
const std::vector<std::string>& IncludeString,
const std::string& dirname)
191 for(
unsigned int i = 0; i < ExcludeString.size(); i++)
193 if (dirname.find(ExcludeString[i]) != std::string::npos){ Skip =
true;
break; }
195 for(
unsigned int i = 0; i < IncludeString.size(); i++)
197 if (!(dirname.find(IncludeString[i]) != std::string::npos)){ Skip =
true;
break; }
203 std::vector<double>
GetDialValues(
const std::vector<std::unique_ptr<TH1D>>& Poly) {
204 std::vector<double> values;
205 for (
const auto& hist : Poly) {
206 std::string title = hist->GetTitle();
207 auto pos = title.rfind(
"_val_");
208 if (pos != std::string::npos) {
209 std::string val_str = title.substr(pos + 5);
210 double val = std::stod(val_str);
211 values.push_back(val);
212 MACH3LOG_DEBUG(
"Extracted dial value {} from title '{}'", val, title);
214 MACH3LOG_DEBUG(
"Failed to extract dial value from title '{}'", title);
222 void InitializePads(TCanvas* canv, TPad*& pad1, TPad*& pad2,
double Pad1Bottom = 0.25,
double Pad2Top = 0.25)
225 if (pad1)
delete pad1;
226 if (pad2)
delete pad2;
229 pad1 =
new TPad(
"pad1",
"pad1", 0., Pad2Top, 1., 1.0);
230 pad2 =
new TPad(
"pad2",
"pad2", 0., 0., 1., Pad1Bottom);
237 pad1->SetLeftMargin(canv->GetLeftMargin());
238 pad1->SetRightMargin(canv->GetRightMargin());
239 pad1->SetTopMargin(canv->GetTopMargin());
240 pad1->SetBottomMargin(0);
243 pad2->SetLeftMargin(canv->GetLeftMargin());
244 pad2->SetRightMargin(canv->GetRightMargin());
245 pad2->SetTopMargin(0);
246 pad2->SetBottomMargin(0.30);
253 void MakeRatio(
const std::vector<std::unique_ptr<TH1D>>& Poly,
254 std::vector<std::unique_ptr<TH1D>>& Ratio) {
255 size_t ratio_index = 0;
256 for (
int i = 0; i < static_cast<int>(Poly.size()); ++i) {
258 Ratio[ratio_index] =
M3::Clone(Poly[i].get());
259 Ratio[ratio_index]->Divide(Poly[
PriorKnot].get());
263 Ratio[0]->GetYaxis()->SetTitle(
"Ratio to Prior");
264 Ratio[0]->SetBit(TH1D::kNoTitle);
269 void PlotRatio(
const std::vector<std::unique_ptr<TH1D>>& Poly,
270 const std::unique_ptr<TCanvas>& canv,
271 const std::string& Title,
272 const std::string& outfilename)
275 gStyle->SetDrawBorder(0);
276 gStyle->SetTitleBorderSize(2);
277 gStyle->SetOptStat(0);
279 canv->SetTopMargin(0.10);
280 canv->SetBottomMargin(0.08);
281 canv->SetRightMargin(0.05);
282 canv->SetLeftMargin(0.12);
284 TPad* pad1 =
nullptr;
285 TPad* pad2 =
nullptr;
292 for(
int ik = 0; ik < static_cast<int>(
sigmaArray.size()); ++ik)
294 Poly[ik]->SetLineWidth(2.);
295 Poly[ik]->SetLineColor(
Colours[ik]);
296 Poly[ik]->SetLineStyle(
Style[ik]);
299 Poly[ik]->GetYaxis()->SetTitle(fmt::format(
"Events/{:.0f}", BinWidthScale).c_str());
301 max = std::max(max, Poly[ik]->GetMaximum());
303 Poly[0]->SetTitle(Title.c_str());
304 Poly[0]->SetMaximum(max*1.2);
305 Poly[0]->Draw(
"HIST");
306 for(
int ik = 1; ik < static_cast<int>(
sigmaArray.size()); ++ik)
308 Poly[ik]->Draw(
"HIST SAME");
311 std::vector<double> Integral(
sigmaArray.size());
312 for(
int ik = 0; ik < static_cast<int>(
sigmaArray.size()); ++ik)
313 Integral[ik] = Poly[ik]->Integral();
315 auto leg =
MakeLegend(0.55, 0.55, 0.8, 0.88, 0.04);
316 leg->SetTextSize(0.04);
317 for (
int j = 0; j < static_cast<int>(
sigmaArray.size()); j++)
320 leg->AddEntry(Poly[j].get(), Form(
"Prior (%.2f), #int=%.2f", DialValues[j], Integral[j]),
"l");
322 leg->AddEntry(Poly[j].get(), Form(
"%.0f#sigma (%.2f), #int=%.2f",
sigmaArray[j], DialValues[j], Integral[j]),
"l");
329 TLine line(Poly[0]->GetXaxis()->GetBinLowEdge(Poly[0]->GetXaxis()->GetFirst()),
330 1.0, Poly[0]->GetXaxis()->GetBinUpEdge(Poly[0]->GetXaxis()->GetLast()), 1.0);
331 std::vector<std::unique_ptr<TH1D>> Ratio(
sigmaArray.size()-1);
337 Ratio[0]->GetXaxis()->SetTitle(PrettyX.c_str());
338 Ratio[0]->GetXaxis()->SetTitleSize(0.12);
339 Ratio[0]->GetYaxis()->SetTitleOffset(0.4);
340 Ratio[0]->GetYaxis()->SetTitleSize(0.10);
342 Ratio[0]->GetXaxis()->SetLabelSize(0.10);
343 Ratio[0]->GetYaxis()->SetLabelSize(0.10);
344 Ratio[0]->Draw(
"HIST");
345 for(
int ik = 1; ik < static_cast<int>(
sigmaArray.size())-1; ++ik)
347 Ratio[ik]->Draw(
"HIST SAME");
350 line.SetLineWidth(2);
351 line.SetLineColor(kBlack);
354 canv->Print((outfilename).c_str());
363 auto canvas = std::make_unique<TCanvas>(
"canv",
"canv", 1080, 1080);
364 TFile *infile =
M3::Open(filename,
"OPEN", __FILE__, __LINE__);
365 TDirectoryFile *SigmaDir = infile->Get<TDirectoryFile>(
"SigmaVar");
367 std::string outfilename = filename.substr(0, filename.find(
".root"));
368 outfilename = outfilename +
"_RatioPlots1d.pdf";
369 gErrorIgnoreLevel = kWarning;
370 canvas->Print((outfilename+
"[").c_str());
372 auto IncludeString = GetFromManager<std::vector<std::string>>(Settings[
"IncludeString"], {}, __FILE__ , __LINE__);
373 auto ExcludeString = GetFromManager<std::vector<std::string>>(Settings[
"ExcludeString"], {}, __FILE__ , __LINE__);
374 TDirectory *dir =
nullptr;
392 std::vector<std::unique_ptr<TH1D>> Projection;
393 TIter nextsub(dir->GetListOfKeys());
394 TKey *subsubkey =
nullptr;
397 while ((subsubkey =
static_cast<TKey*
>(nextsub())))
399 auto name = std::string(subsubkey->GetName());
400 auto classname = std::string(subsubkey->GetClassName());
402 const std::string ProjectionName =
"_1DProj" + std::to_string(iDim);
403 const bool IsProjection = (name.find(ProjectionName) != std::string::npos);
404 if (classname ==
"TH1D" && IsProjection)
407 Projection.emplace_back(
M3::Clone(SigmaDir->Get<TH1D>(name.c_str())));
413 PlotRatio(Projection, canvas, Title, outfilename);
414 gDirectory->cd(
"..");
419 canvas->Print((outfilename+
"]").c_str());
425 const std::unique_ptr<TCanvas>& canv,
426 const std::string& Title,
427 const std::string& outfilename)
430 gStyle->SetDrawBorder(0);
431 gStyle->SetTitleBorderSize(2);
432 gStyle->SetOptStat(0);
434 canv->SetTopMargin(0.10);
435 canv->SetBottomMargin(0.10);
436 canv->SetLeftMargin(0.12);
437 canv->SetRightMargin(0.20);
439 constexpr
int NRGBs = 5;
440 TColor::InitializeColors();
441 Double_t stops[NRGBs] = { 0.00, 0.25, 0.50, 0.75, 1.00 };
442 Double_t red[NRGBs] = { 0.00, 0.25, 1.00, 1.00, 0.50 };
443 Double_t green[NRGBs] = { 0.00, 0.25, 1.00, 0.25, 0.00 };
444 Double_t blue[NRGBs] = { 0.50, 1.00, 1.00, 0.25, 0.00 };
445 TColor::CreateGradientColorTable(5, stops, red, green, blue, 255);
446 gStyle->SetNumberContours(255);
448 for (
int i = 0; i < static_cast<int>(Poly.size()); ++i) {
450 std::unique_ptr<TH2> Ratio =
M3::Clone(Poly[i].get());
452 Ratio->SetTitle((Title +
" " + std::to_string(
static_cast<int>(
sigmaArray[i])) +
"sigma").c_str());
454 const double maxz = Ratio->GetMaximum();
455 const double minz = Ratio->GetMinimum();
456 if (std::fabs(1-maxz) > std::fabs(1-minz))
457 Ratio->GetZaxis()->SetRangeUser(1-std::fabs(1-maxz),1+std::fabs(1-maxz));
459 Ratio->GetZaxis()->SetRangeUser(1-std::fabs(1-minz),1+std::fabs(1-minz));
460 Ratio->GetXaxis()->SetTitleOffset(1.1);
461 Ratio->GetYaxis()->SetTitleOffset(1.1);
462 Ratio->GetZaxis()->SetTitleOffset(1.5);
463 Ratio->GetZaxis()->SetTitle(
"Ratio to Prior");
466 Ratio->GetXaxis()->SetTitle(PrettyX.c_str());
468 Ratio->GetYaxis()->SetTitle(PrettyY.c_str());
471 canv->Print((outfilename).c_str());
478 auto canvas = std::make_unique<TCanvas>(
"canv",
"canv", 1080, 1080);
479 TFile *infile =
M3::Open(filename,
"OPEN", __FILE__, __LINE__);
480 TDirectoryFile *SigmaDir = infile->Get<TDirectoryFile>(
"SigmaVar");
482 std::string outfilename = filename.substr(0, filename.find(
".root"));
483 outfilename = outfilename +
"_RatioPlots2d.pdf";
484 gErrorIgnoreLevel = kWarning;
485 canvas->Print((outfilename+
"[").c_str());
487 auto IncludeString = GetFromManager<std::vector<std::string>>(Settings[
"IncludeString"], {}, __FILE__ , __LINE__);
488 auto ExcludeString = GetFromManager<std::vector<std::string>>(Settings[
"ExcludeString"], {}, __FILE__ , __LINE__);
489 TDirectory *dir =
nullptr;
504 TIter nextsub(dir->GetListOfKeys());
505 TKey *subsubkey =
nullptr;
508 for (
int iDim1 = 0; iDim1 <= nDim; ++iDim1) {
509 for (
int iDim2 = iDim1 + 1; iDim2 <= nDim; ++iDim2) {
513 std::vector<std::unique_ptr<TH2>> Projection;
516 while ((subsubkey =
static_cast<TKey*
>(nextsub())))
518 auto name = std::string(subsubkey->GetName());
519 auto classname = std::string(subsubkey->GetClassName());
521 const std::string ProjectionName =
"_2DProj_" + std::to_string(iDim1) +
"_vs_" + std::to_string(iDim2);
522 const bool IsProjection = (name.find(ProjectionName) != std::string::npos);
523 if ((classname ==
"TH2D" || classname ==
"TH2Poly")&& IsProjection)
526 Projection.emplace_back(
M3::Clone(SigmaDir->Get<TH2>(name.c_str())));
535 gDirectory->cd(
"..");
538 canvas->Print((outfilename+
"]").c_str());
544 void PlotEventRate(
const std::vector<std::vector<std::unique_ptr<TH1D>>>& Poly,
545 const std::unique_ptr<TCanvas>& canv,
546 const std::string& Title,
547 const std::string& outfilename)
549 std::vector<std::unique_ptr<TH1D>> EvenRates(
sigmaArray.size());
550 for(
int ih = 0; ih < static_cast<int>(
sigmaArray.size()); ih++)
553 EvenRates[ih]->SetDirectory(
nullptr);
554 EvenRates[ih]->GetYaxis()->SetTitleOffset(1.4);
555 EvenRates[ih]->GetYaxis()->SetTitle(
"Events");
556 EvenRates[ih]->SetLineWidth(2.);
557 EvenRates[ih]->SetLineStyle(
Style[ih]);
558 EvenRates[ih]->SetLineColor(
Colours[ih]);
561 EvenRates[ih]->SetBinContent(iSample+1, Poly[iSample][ih]->Integral());
564 EvenRates[ih]->GetXaxis()->SetBinLabel(iSample+1, SamName.c_str());
568 TPad* pad1 =
nullptr;
569 TPad* pad2 =
nullptr;
571 pad2->SetBottomMargin(0.60);
575 for(
int ik = 0; ik < static_cast<int>(
sigmaArray.size()); ++ik) {
576 max = std::max(max, EvenRates[ik]->GetMaximum());
578 EvenRates[0]->SetTitle(Title.c_str());
579 EvenRates[0]->SetMaximum(max*1.2);
580 EvenRates[0]->Draw(
"HIST");
581 for(
int ik = 1; ik < static_cast<int>(
sigmaArray.size()); ++ik)
583 EvenRates[ik]->Draw(
"HIST SAME");
587 auto leg =
MakeLegend(0.55, 0.55, 0.8, 0.88, 0.04);
588 for (
int j = 0; j < static_cast<int>(
sigmaArray.size()); j++)
591 leg->AddEntry(EvenRates[j].get(), Form(
"Prior (%.2f)", DialValues[j]),
"l");
593 leg->AddEntry(EvenRates[j].get(), Form(
"%.0f#sigma (%.2f)",
sigmaArray[j], DialValues[j]),
"l");
599 TLine line(EvenRates[0]->GetXaxis()->GetBinLowEdge(EvenRates[0]->GetXaxis()->GetFirst()),
600 1.0, EvenRates[0]->GetXaxis()->GetBinUpEdge(EvenRates[0]->GetXaxis()->GetLast()), 1.0);
601 std::vector<std::unique_ptr<TH1D>> Ratio(
sigmaArray.size()-1);
603 Ratio[0]->GetXaxis()->SetTitleSize(0.08);
604 Ratio[0]->GetYaxis()->SetTitleOffset(0.4);
605 Ratio[0]->GetYaxis()->SetTitleSize(0.06);
607 Ratio[0]->GetXaxis()->SetLabelSize(0.08);
608 Ratio[0]->GetYaxis()->SetLabelSize(0.04);
609 Ratio[0]->GetXaxis()->LabelsOption(
"v");
610 Ratio[0]->Draw(
"HIST");
612 for(
int ik = 1; ik < static_cast<int>(
sigmaArray.size())-1; ++ik)
614 Ratio[ik]->Draw(
"HIST SAME");
617 line.SetLineWidth(2);
618 line.SetLineColor(kBlack);
621 canv->Print((outfilename).c_str());
631 auto canvas = std::make_unique<TCanvas>(
"canv",
"canv", 1080, 1080);
632 canvas->SetRightMargin(0.05);
633 TFile *infile =
M3::Open(filename,
"OPEN", __FILE__, __LINE__);
634 TDirectoryFile *SigmaDir = infile->Get<TDirectoryFile>(
"SigmaVar");
636 std::string outfilename = filename.substr(0, filename.find(
".root"));
637 outfilename = outfilename +
"_EventRate.pdf";
638 gErrorIgnoreLevel = kWarning;
639 canvas->Print((outfilename+
"[").c_str());
641 TDirectory *dir =
nullptr;
644 std::vector<std::vector<std::unique_ptr<TH1D>>> Projection(
SampleNameVector.size());
654 TIter nextsub(dir->GetListOfKeys());
655 TKey *subsubkey =
nullptr;
658 while ((subsubkey =
static_cast<TKey*
>(nextsub())))
660 auto name = std::string(subsubkey->GetName());
661 auto classname = std::string(subsubkey->GetClassName());
663 const std::string ProjectionName =
"_1DProj0";
664 const bool IsProjection = (name.find(ProjectionName) != std::string::npos);
665 if (classname ==
"TH1D" && IsProjection)
668 Projection[is].emplace_back(
M3::Clone(SigmaDir->Get<TH1D>(name.c_str())));
672 gDirectory->cd(
"..");
678 canvas->Print((outfilename+
"]").c_str());
683 void PlotSigVar1D(
const std::vector<std::vector<std::unique_ptr<TH1D>>>& Projection,
684 const std::unique_ptr<TCanvas>& canv,
685 const std::string& Title,
686 const std::string& outfilename,
687 const std::vector<std::string>& ParamNames,
688 const std::vector<int>& ParamColour)
691 gStyle->SetDrawBorder(0);
692 gStyle->SetTitleBorderSize(2);
693 gStyle->SetOptStat(0);
695 canv->SetTopMargin(0.10);
696 canv->SetBottomMargin(0.08);
697 canv->SetRightMargin(0.05);
698 canv->SetLeftMargin(0.12);
700 auto PriorHist = Projection[0][
PriorKnot].get();
701 PriorHist->SetTitle(Title.c_str());
704 PriorHist->GetYaxis()->SetTitle(fmt::format(
"Events/{:.0f}", BinWidthScale).c_str());
705 PriorHist->Draw(
"HIST");
706 PriorHist->SetLineWidth(2.);
707 PriorHist->SetLineColor(kBlack);
712 PriorHist->GetXaxis()->SetTitle(PrettyX.c_str());
713 for(
int ik = 0; ik < static_cast<int>(
sigmaArray.size()); ++ik)
718 for(
size_t nParam = 0; nParam < Projection.size(); nParam++) {
719 Projection[nParam][ik]->SetLineWidth(2.);
720 Projection[nParam][ik]->SetLineColor(ParamColour[nParam]);
721 Projection[nParam][ik]->SetLineStyle(kDotted);
722 Projection[nParam][ik]->GetYaxis()->SetTitle(fmt::format(
"Events/{:.0f}", BinWidthScale).c_str());
724 max = std::max(max, Projection[nParam][ik]->GetMaximum());
726 PriorHist->SetMaximum(max*1.2);
728 PriorHist->Draw(
"HIST");
729 for(
size_t nParam = 0; nParam < Projection.size(); nParam++) {
730 Projection[nParam][ik]->Draw(
"HIST SAME");
732 auto leg =
MakeLegend(0.50, 0.55, 0.70, 0.75, 0.035);
733 leg->AddEntry(PriorHist,
"Prior",
"l");
734 for(
size_t nParam = 0; nParam < Projection.size(); nParam++) {
735 leg->AddEntry(Projection[nParam][ik].get(), Form(
"%s (%.0f#sigma)", ParamNames[nParam].c_str(),
sigmaArray[ik]),
"l");
739 canv->Print((outfilename).c_str());
746 auto ParamNames = GetFromManager<std::vector<std::string>>(Settings[
"ParamNames"], {}, __FILE__ , __LINE__);
747 auto SigColours = GetFromManager<std::vector<int>>(Settings[
"Coulour"], {}, __FILE__ , __LINE__);
749 if(ParamNames.size() == 0)
return;
751 if(ParamNames.size() != SigColours.size()){
757 auto canvas = std::make_unique<TCanvas>(
"canv",
"canv", 1080, 1080);
758 TFile *infile =
M3::Open(filename,
"OPEN", __FILE__, __LINE__);
759 TDirectoryFile *SigmaDir = infile->Get<TDirectoryFile>(
"SigmaVar");
761 std::string outfilename = filename.substr(0, filename.find(
".root"));
762 outfilename = outfilename +
"_Overlay1d.pdf";
763 gErrorIgnoreLevel = kWarning;
764 canvas->Print((outfilename+
"[").c_str());
766 TDirectory *dir =
nullptr;
773 std::vector<std::vector<std::unique_ptr<TH1D>>> Projection(ParamNames.size());
774 for(
size_t id = 0;
id < ParamNames.size();
id++)
782 TIter nextsub(dir->GetListOfKeys());
783 TKey *subsubkey =
nullptr;
786 while ((subsubkey =
static_cast<TKey*
>(nextsub())))
788 auto name = std::string(subsubkey->GetName());
789 auto classname = std::string(subsubkey->GetClassName());
791 const std::string ProjectionName =
"_1DProj" + std::to_string(iDim);
792 const bool IsProjection = (name.find(ProjectionName) != std::string::npos);
793 if (classname ==
"TH1D" && IsProjection)
796 Projection[id].emplace_back(
M3::Clone(SigmaDir->Get<TH1D>(name.c_str())));
802 PlotSigVar1D(Projection, canvas, Title, outfilename, ParamNames, SigColours);
803 gDirectory->cd(
"..");
807 canvas->Print((outfilename+
"]").c_str());
812 int main(
int argc,
char **argv)
817 MACH3LOG_ERROR(
"Need two inputs: output of sigma var and config");
820 std::string filename = argv[1];
821 std::string ConfigName = argv[2];
822 MACH3LOG_INFO(
"Running {} with {} {}", argv[0], filename, ConfigName);
827 YAML::Node settings = Config[
"PlotSigmaVariation"];
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
void PlotRatio(const std::vector< std::unique_ptr< TH1D >> &Poly, const std::unique_ptr< TCanvas > &canv, const std::string &Title, const std::string &outfilename)
void CompareSigVar2D(const std::string &filename, const YAML::Node &Settings)
constexpr ELineStyle Style[NVars]
int main(int argc, char **argv)
void PlotRatio2D(const std::vector< std::unique_ptr< TH2 >> &Poly, const std::unique_ptr< TCanvas > &canv, const std::string &Title, const std::string &outfilename)
void OverlaySigVar1D(const std::string &filename, const YAML::Node &Settings)
constexpr Color_t Colours[NVars]
std::vector< double > GetDialValues(const std::vector< std::unique_ptr< TH1D >> &Poly)
Extracts dial value for from histogram title.
void PlotEventRate(const std::vector< std::vector< std::unique_ptr< TH1D >>> &Poly, const std::unique_ptr< TCanvas > &canv, const std::string &Title, const std::string &outfilename)
void CompareSigVar1D(const std::string &filename, const YAML::Node &Settings)
void PlotSigVar1D(const std::vector< std::vector< std::unique_ptr< TH1D >>> &Projection, const std::unique_ptr< TCanvas > &canv, const std::string &Title, const std::string &outfilename, const std::vector< std::string > &ParamNames, const std::vector< int > &ParamColour)
std::unique_ptr< TLegend > MakeLegend(double x1, double y1, double x2, double y2, double textSize=0.04)
std::vector< int > SampleMaxDim
void ScanInput(std::vector< std::string > &DialNameVecr, std::vector< std::string > &SampleNameVec, std::vector< int > &SampleDimVec, std::vector< double > &SigmaValues, const std::string &filename)
Scan inputs to figure out dial name and used sample names.
std::vector< std::string > DialNameVector
void FindKnot(std::vector< double > &SigmaValues, const std::string &dirname, const std::string &subdirname, const std::string &ProjName, std::string histname)
Histograms have name like ND_CC0pi_1DProj0_Norm_Param_0_sig_n3.00_val_0.25. This code is trying to ex...
std::vector< std::string > SampleNameVector
std::vector< double > sigmaArray
void InitializePads(TCanvas *canv, TPad *&pad1, TPad *&pad2, double Pad1Bottom=0.25, double Pad2Top=0.25)
constexpr const int NVars
void MakeRatio(const std::vector< std::unique_ptr< TH1D >> &Poly, std::vector< std::unique_ptr< TH1D >> &Ratio)
void MakeEventRatePlot(const std::string &filename, const YAML::Node &Settings)
M3::Plotting::PlottingManager * PlotMan
bool SkipDirectory(const std::vector< std::string > &ExcludeString, const std::vector< std::string > &IncludeString, const std::string &dirname)
Check whether to skip directory or not based on defined strings.
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
The main class to be used in plotting scripts.
void initialise()
initalise this PlottingManager.
const StyleManager & style() const
Get the StyleManager contained within this PlottingManager, for doing style related things.
void setTH1XRange(TH1 *hist) const
Set plotting range for histogram.
double getBinWidthScale(const std::string &Name) const
Get bin-width scaling factor for a given kinematic variable.
std::string prettifySampleName(const std::string &origName) const
Convert hideous and vulgar internal sample name into a beautiful presentable name.
std::string prettifyKinematicName(const std::string &origName) const
Convert hideous and vulgar internal kinematics name into a beautiful presentable name.
std::string prettifyParamName(const std::string &origName) const
Convert hideous and vulgar internal parameter name into a beautiful presentable name.
Custom exception class used throughout MaCh3.
void SetSymmetricRatioRange(const std::vector< std::unique_ptr< TH1D >> &RatioPlot)
Set a symmetric Y-axis range around 1 for ratio plots.
std::unique_ptr< ObjectType > Clone(const ObjectType *obj, const std::string &name="")
KS: Creates a copy of a ROOT-like object and wraps it in a smart pointer.
void ScaleHistogram(TH1 *Sample_Hist, const double scale)
Scale histogram to get divided by bin width.
TFile * Open(const std::string &Name, const std::string &Type, const std::string &File, const int Line)
Opens a ROOT file with the given name and mode.
constexpr static const int _BAD_INT_
Default value used for int initialisation.