58 int nBins_sin2th23 = 100;
59 int nBins_sin2th13 = 100;
60 int nBins_sin2th12 = 100;
61 int nBins_delm23 = 3000;
62 int nBins_delm12 = 100;
65 double sin2th23_min = 0.45;
66 double sin2th23_max = 0.57;
67 double sin2th13_min = 0.015;
68 double sin2th13_max = 0.03;
69 double sin2th12_min = 0.24;
70 double sin2th12_max = 0.36;
71 double delm23_no_min = 0.00245;
72 double delm23_no_max = 0.0026;
73 double delm23_io_min = -delm23_no_max;
74 double delm23_io_max = -delm23_no_min;
75 double delm12_min = 6.5e-5;
76 double delm12_max = 8.5e-5;
78 auto normalizeHist = [&](TH1 *h) {
80 double integral = h->Integral();
81 if (integral > 0.0) h->Scale(1.0 / integral);
84 auto printHistStats = [&](
const std::string &label, TH1 *h) {
86 std::cout <<
"[DEBUG] " << label <<
" : histogram is null" << std::endl;
89 std::cout << std::fixed << std::setprecision(6)
90 <<
"[DEBUG] " << label
91 <<
" entries=" << h->GetEntries()
92 <<
" effEntries=" << h->GetEffectiveEntries()
93 <<
" integral=" << h->Integral()
94 <<
" mean=" << h->GetMean()
95 <<
" rms=" << h->GetRMS()
99 TFile *f = TFile::Open(InputFile.c_str());
107 bool use_reference_chain =
false;
108 bool use_reference_LLH_scan =
true;
110 double asimovSin2th12 = std::numeric_limits<double>::quiet_NaN();
111 double asimovSin2th23 = std::numeric_limits<double>::quiet_NaN();
112 double asimovSin2th13 = std::numeric_limits<double>::quiet_NaN();
113 double asimovDelm12 = std::numeric_limits<double>::quiet_NaN();
114 double asimovDelm23 = std::numeric_limits<double>::quiet_NaN();
115 double asimovDcp = std::numeric_limits<double>::quiet_NaN();
116 double asimovBaseline = std::numeric_limits<double>::quiet_NaN();
117 double asimovElectronDensity = std::numeric_limits<double>::quiet_NaN();
120 std::string referenceFile =
"";
121 std::string referenceTreeName =
"";
123 if(use_reference_chain) {
124 referenceFile =
"/home/driley/projects/def-blairt2k/driley/T2K_outputs/umbrella_testing/fixing_params/allfixed/all_oscParams_fixed_hadded.root";
125 referenceTreeName =
"posteriors";
129 std::string referenceLLHScanFile =
"";
130 std::string referenceLLHScanDcpHistName =
"";
131 std::string referenceLLHScanDcp_NO_histName =
"";
132 std::string referenceLLHScanDcp_IO_histName =
"";
134 if(use_reference_LLH_scan) {
135 referenceLLHScanFile =
"/home/driley/Projects-T2K-MaCh3/umbrella_t2k/mcm_utils/target_1D_histos.root";
136 referenceLLHScanDcpHistName =
"dcp";
137 referenceLLHScanDcp_NO_histName =
"dcp_NO";
138 referenceLLHScanDcp_IO_histName =
"dcp_IO";
142 if (!f || f->IsZombie()) {
143 std::cerr <<
"Error: Cannot open file!" << std::endl;
148 TTree *tree = (TTree*)f->Get(
"posteriors");
150 std::cerr <<
"Error: Cannot find tree!" << std::endl;
156 bool isAsimovChain =
false;
158 auto calculateJarlskog = [&](
double sin2th12,
double sin2th23,
double sin2th13,
double dcp) {
159 if (!std::isfinite(sin2th12) || !std::isfinite(sin2th23) || !std::isfinite(sin2th13) || !std::isfinite(dcp)) {
160 return std::numeric_limits<double>::quiet_NaN();
162 return std::sqrt(std::max(0.0, sin2th12) * std::max(0.0, 1.0 - sin2th12) *
163 std::max(0.0, sin2th23) * std::max(0.0, 1.0 - sin2th23)) *
164 std::max(0.0, 1.0 - sin2th13) * std::sqrt(std::max(0.0, sin2th13)) *
168 const double asimovJarlskog = calculateJarlskog(asimovSin2th12, asimovSin2th23, asimovSin2th13, asimovDcp);
170 auto drawAsimovLineWithLegend = [&](
double xValue, TLegend *existingLegend =
nullptr) {
171 if (!isAsimovChain || !std::isfinite(xValue) || !gPad)
return;
173 const double yMin = gPad->GetUymin();
174 const double yMax = gPad->GetUymax();
175 TLine *asimovLine =
new TLine(xValue, yMin, xValue, yMax);
176 asimovLine->SetLineColor(kBlack);
177 asimovLine->SetLineStyle(3);
178 asimovLine->SetLineWidth(2);
179 asimovLine->Draw(
"SAME");
181 if (existingLegend) {
182 existingLegend->AddEntry(asimovLine,
"Asimov point",
"l");
183 existingLegend->Draw();
185 TLegend *asimovLegend =
new TLegend(0.14, 0.83, 0.34, 0.91);
186 asimovLegend->SetBorderSize(0);
187 asimovLegend->SetFillStyle(0);
188 asimovLegend->AddEntry(asimovLine,
"Asimov point",
"l");
189 asimovLegend->Draw();
193 auto drawAsimovMarkerWithLegend = [&](
double xValue,
double yValue, TLegend *existingLegend =
nullptr) {
194 if (!isAsimovChain || !std::isfinite(xValue) || !std::isfinite(yValue) || !gPad)
return;
197 const double xMin = gPad->GetUxmin();
198 const double xMax = gPad->GetUxmax();
199 const double yMin = gPad->GetUymin();
200 const double yMax = gPad->GetUymax();
201 const double dx = 0.012 * (xMax - xMin);
202 const double dy = 0.012 * (yMax - yMin);
204 TLine *l1 =
new TLine(xValue - dx, yValue - dy, xValue + dx, yValue + dy);
205 l1->SetLineColor(kRed);
209 TLine *l2 =
new TLine(xValue - dx, yValue + dy, xValue + dx, yValue - dy);
210 l2->SetLineColor(kRed);
214 if (existingLegend) {
215 existingLegend->AddEntry(l1,
"Asimov point",
"l");
216 existingLegend->Draw();
218 TLegend *lm =
new TLegend(0.14, 0.83, 0.34, 0.91);
219 lm->SetBorderSize(0);
221 lm->AddEntry(l1,
"Asimov point",
"l");
228 bool hasReferenceDcp =
false;
229 bool hasReferenceSin2Th23 =
false;
230 bool hasReferenceDelm23 =
false;
231 TH1D *hRefDcpShape =
nullptr;
232 TH1D *hRefSin2Th23Shape =
nullptr;
233 TH1D *hRefDelm23Shape =
nullptr;
234 TFile *fRef = TFile::Open(referenceFile.c_str());
235 if (!fRef || fRef->IsZombie()) {
236 std::cerr <<
"Warning: Cannot open reference file: " << referenceFile << std::endl;
238 TTree *refTree = (TTree*)fRef->Get(referenceTreeName.c_str());
240 std::cerr <<
"Warning: Cannot find reference tree: " << referenceTreeName << std::endl;
241 }
else if (!refTree->GetBranch(
"dcp") && !refTree->GetBranch(
"delta_cp")) {
242 std::cerr <<
"Warning: dcp branch not found in reference tree." << std::endl;
243 }
else if (refTree->GetBranch(
"delta_cp")) {
244 hRefDcpShape =
new TH1D(
"hRefDcpShape",
"", nBins_dcp, -3.1415, 3.1415);
245 refTree->Draw(
"delta_cp>>hRefDcpShape",
"",
"goff");
246 hRefDcpShape->SetDirectory(0);
247 hasReferenceDcp =
true;
248 std::cout <<
"Loaded reference dcp histogram from " << referenceTreeName << std::endl;
250 hRefDcpShape =
new TH1D(
"hRefDcpShape",
"", nBins_dcp, -3.1415, 3.1415);
251 refTree->Draw(
"dcp>>hRefDcpShape",
"",
"goff");
252 hRefDcpShape->SetDirectory(0);
253 hasReferenceDcp =
true;
254 std::cout <<
"Loaded reference dcp histogram from " << referenceTreeName << std::endl;
257 if (!refTree->GetBranch(
"theta23") && !refTree->GetBranch(
"sin2th_23")) {
258 std::cerr <<
"Warning: theta23 branch not found in reference tree." << std::endl;
259 }
else if (refTree->GetBranch(
"sin2th_23")) {
260 hRefSin2Th23Shape =
new TH1D(
"hRefSin2Th23Shape",
"", nBins_sin2th23, sin2th23_min, sin2th23_max);
261 refTree->Draw(
"sin2th_23>>hRefSin2Th23Shape",
"",
"goff");
262 hRefSin2Th23Shape->SetDirectory(0);
263 hasReferenceSin2Th23 =
true;
264 std::cout <<
"Loaded reference sin^{2}(theta23) histogram from " << referenceTreeName << std::endl;
266 hRefSin2Th23Shape =
new TH1D(
"hRefSin2Th23Shape",
"", nBins_sin2th23, sin2th23_min, sin2th23_max);
267 refTree->Draw(
"theta23>>hRefSin2Th23Shape",
"",
"goff");
268 hRefSin2Th23Shape->SetDirectory(0);
269 hasReferenceSin2Th23 =
true;
270 std::cout <<
"Loaded reference sin^{2}(theta23) histogram from " << referenceTreeName << std::endl;
273 if (!refTree->GetBranch(
"dm23") && !refTree->GetBranch(
"delm2_23")) {
274 std::cerr <<
"Warning: dm23 branch not found in reference tree." << std::endl;
275 }
else if (refTree->GetBranch(
"delm2_23")) {
276 hRefDelm23Shape =
new TH1D(
"hRefDelm23Shape",
"", nBins_delm23, delm23_io_min, delm23_no_max);
277 refTree->Draw(
"delm2_23>>hRefDelm23Shape",
"",
"goff");
278 TH1D *hRefDelm23IO_dbg =
new TH1D(
"hRefDelm23IO_dbg",
"", nBins_delm23, delm23_io_min, delm23_io_max);
279 TH1D *hRefDelm23NO_dbg =
new TH1D(
"hRefDelm23NO_dbg",
"", nBins_delm23, delm23_no_min, delm23_no_max);
280 refTree->Draw(
"delm2_23>>hRefDelm23IO_dbg",
"delm2_23 < 0",
"goff");
281 refTree->Draw(
"delm2_23>>hRefDelm23NO_dbg",
"delm2_23 > 0",
"goff");
282 printHistStats(
"Reference delm23 IO (raw)", hRefDelm23IO_dbg);
283 printHistStats(
"Reference delm23 NO (raw)", hRefDelm23NO_dbg);
284 hRefDelm23Shape->SetDirectory(0);
285 normalizeHist(hRefDelm23Shape);
286 hasReferenceDelm23 =
true;
287 std::cout <<
"Loaded reference delm23 histogram from " << referenceTreeName << std::endl;
289 hRefDelm23Shape =
new TH1D(
"hRefDelm23Shape",
"", nBins_delm23, delm23_io_min, delm23_no_max);
290 refTree->Draw(
"dm23>>hRefDelm23Shape",
"",
"goff");
291 TH1D *hRefDm23IO_dbg =
new TH1D(
"hRefDm23IO_dbg",
"", nBins_delm23, delm23_io_min, delm23_io_max);
292 TH1D *hRefDm23NO_dbg =
new TH1D(
"hRefDm23NO_dbg",
"", nBins_delm23, delm23_no_min, delm23_no_max);
293 refTree->Draw(
"dm23>>hRefDm23IO_dbg",
"dm23 < 0",
"goff");
294 refTree->Draw(
"dm23>>hRefDm23NO_dbg",
"dm23 > 0",
"goff");
295 printHistStats(
"Reference dm23 IO (raw)", hRefDm23IO_dbg);
296 printHistStats(
"Reference dm23 NO (raw)", hRefDm23NO_dbg);
297 hRefDelm23Shape->SetDirectory(0);
298 normalizeHist(hRefDelm23Shape);
299 hasReferenceDelm23 =
true;
300 std::cout <<
"Loaded reference dm23 histograms from " << referenceTreeName << std::endl;
308 bool hasReferenceLLH_Dcp =
false;
309 bool hasReferenceLLH_Dcp_NO =
false;
310 bool hasReferenceLLH_Dcp_IO =
false;
311 TH1D *hRefLLH_Dcp =
nullptr;
312 TH1D *hRefLLH_Dcp_NO =
nullptr;
313 TH1D *hRefLLH_Dcp_IO =
nullptr;
315 if (use_reference_LLH_scan && !referenceLLHScanFile.empty()) {
316 TFile *fLLH = TFile::Open(referenceLLHScanFile.c_str());
317 if (!fLLH || fLLH->IsZombie()) {
318 std::cerr <<
"Warning: Cannot open reference LLH-scan file: " << referenceLLHScanFile << std::endl;
321 auto loadAndNormalize1D = [&](
const std::string &name, TH1D *&outHist,
bool &outFlag) {
322 TObject *obj = fLLH->Get(name.c_str());
324 std::cerr <<
"Warning: LLH-scan histogram '" << name <<
"' not found in " << referenceLLHScanFile << std::endl;
327 TH1 *htmp =
dynamic_cast<TH1*
>(obj);
329 std::cerr <<
"Warning: Object '" << name <<
"' is not a histogram." << std::endl;
332 outHist = (TH1D*)htmp->Clone((std::string(
"hRefLLH_") + name +
"_clone").c_str());
333 outHist->SetDirectory(0);
335 double I = outHist->Integral();
336 if (I > 0) outHist->Scale(1.0 / I);
338 printHistStats(std::string(
"Reference LLH ") + name, outHist);
341 if (!referenceLLHScanDcpHistName.empty()) loadAndNormalize1D(referenceLLHScanDcpHistName, hRefLLH_Dcp, hasReferenceLLH_Dcp);
342 if (!referenceLLHScanDcp_NO_histName.empty()) loadAndNormalize1D(referenceLLHScanDcp_NO_histName, hRefLLH_Dcp_NO, hasReferenceLLH_Dcp_NO);
343 if (!referenceLLHScanDcp_IO_histName.empty()) loadAndNormalize1D(referenceLLHScanDcp_IO_histName, hRefLLH_Dcp_IO, hasReferenceLLH_Dcp_IO);
349 bool hasUmbrellaWeight =
false;
351 if (!tree->GetBranch(
"umbrella_weight")) {
352 std::cerr <<
"Warning: umbrella_weight branch not found, plotting as unweighted umbrella" << std::endl;
354 hasUmbrellaWeight =
true;
357 std::cout <<
"[DEBUG] Chain entries total=" << tree->GetEntries() << std::endl;
358 TH1D *hChainDelm23IO_dbg =
new TH1D(
"hChainDelm23IO_dbg",
"", nBins_delm23, delm23_io_min, delm23_io_max);
359 TH1D *hChainDelm23NO_dbg =
new TH1D(
"hChainDelm23NO_dbg",
"", nBins_delm23, delm23_no_min, delm23_no_max);
360 tree->Draw(
"delm2_23>>hChainDelm23IO_dbg",
"delm2_23 < 0",
"goff");
361 tree->Draw(
"delm2_23>>hChainDelm23NO_dbg",
"delm2_23 > 0",
"goff");
362 printHistStats(
"Chain delm23 IO (raw)", hChainDelm23IO_dbg);
363 printHistStats(
"Chain delm23 NO (raw)", hChainDelm23NO_dbg);
365 if (hasUmbrellaWeight) {
366 TH1D *hChainDelm23IO_w_dbg =
new TH1D(
"hChainDelm23IO_w_dbg",
"", nBins_delm23, delm23_io_min, delm23_io_max);
367 TH1D *hChainDelm23NO_w_dbg =
new TH1D(
"hChainDelm23NO_w_dbg",
"", nBins_delm23, delm23_no_min, delm23_no_max);
368 tree->Draw(
"delm2_23>>hChainDelm23IO_w_dbg",
"(delm2_23 < 0) * umbrella_weight",
"goff");
369 tree->Draw(
"delm2_23>>hChainDelm23NO_w_dbg",
"(delm2_23 > 0) * umbrella_weight",
"goff");
370 printHistStats(
"Chain delm23 IO (weighted)", hChainDelm23IO_w_dbg);
371 printHistStats(
"Chain delm23 NO (weighted)", hChainDelm23NO_w_dbg);
375 TCanvas *c1 =
new TCanvas(
"c1",
"Delta CP vs Delta m23", 900, 700);
376 c1->SetRightMargin(0.15);
378 TH2F *h2d =
new TH2F(
"h2d",
"#Delta m_{23}^{2} vs #delta_{CP};#delta_{CP};#Delta m_{23}^{2} (eV^{2})",
379 nBins_dcp, -3.14159, 3.14159,
380 nBins_delm23, delm23_io_min, delm23_no_max);
382 tree->Draw(
"delm2_23:delta_cp>>h2d",
"",
"COLZ");
387 h2d->GetXaxis()->SetTitle(
"#delta_{CP}");
388 h2d->GetYaxis()->SetTitle(
"#Delta m_{23}^{2} (eV^{2})");
389 h2d->GetZaxis()->SetTitle(
"Normalized Entries");
393 drawAsimovMarkerWithLegend(asimovDcp, asimovDelm23,
nullptr);
394 c1->SaveAs((outputDir +
"delm23_vs_dcp.png").c_str());
396 if (hasUmbrellaWeight){
397 tree->Draw(
"delm2_23:delta_cp>>h2d",
"umbrella_weight",
"COLZ");
401 drawAsimovMarkerWithLegend(asimovDcp, asimovDelm23,
nullptr);
402 c1->SaveAs((outputDir +
"delm23_vs_dcp_weighted.png").c_str());
407 TCanvas *c2 =
new TCanvas(
"c2",
"Delta m23 IO and NO", 1800, 700);
412 gPad->SetRightMargin(0.15);
414 TH2F *h2d_IO =
new TH2F(
"h2d_IO",
"Inverted Ordering;#Delta m_{23}^{2} (eV^{2});#delta_{CP}",
415 nBins_delm23, delm23_io_min, delm23_io_max,
416 nBins_dcp, -3.1415, 3.1415);
418 tree->Draw(
"delta_cp:delm2_23>>h2d_IO",
"delm2_23 < 0",
"COLZ");
419 normalizeHist(h2d_IO);
420 h2d_IO->Draw(
"COLZ");
423 h2d_IO->GetXaxis()->SetTitle(
"#Delta m_{23}^{2} (eV^{2})");
424 h2d_IO->GetYaxis()->SetTitle(
"#delta_{CP} / #pi");
425 h2d_IO->GetZaxis()->SetTitle(
"Normalized Entries");
430 gPad->SetRightMargin(0.15);
432 TH2F *h2d_NO =
new TH2F(
"h2d_NO",
"Normal Ordering;#Delta m_{23}^{2} (eV^{2});#delta_{CP}",
433 nBins_delm23, delm23_no_min, delm23_no_max,
434 nBins_dcp, -3.1415, 3.1415);
436 tree->Draw(
"delta_cp:delm2_23>>h2d_NO",
"delm2_23 > 0",
"COLZ");
437 normalizeHist(h2d_NO);
438 h2d_NO->Draw(
"COLZ");
441 h2d_NO->GetXaxis()->SetTitle(
"#Delta m_{23}^{2} (eV^{2})");
442 h2d_NO->GetYaxis()->SetTitle(
"#delta_{CP} / #pi");
443 h2d_NO->GetZaxis()->SetTitle(
"Normalized Entries");
449 drawAsimovMarkerWithLegend(asimovDelm23, asimovDcp,
nullptr);
451 drawAsimovMarkerWithLegend(asimovDelm23, asimovDcp,
nullptr);
453 c2->SaveAs((outputDir +
"delm23_vs_dcp_IO_NO.png").c_str());
455 if (hasUmbrellaWeight){
458 tree->Draw(
"delta_cp:delm2_23>>h2d_IO",
"(delm2_23 < 0) * umbrella_weight",
"COLZ");
459 normalizeHist(h2d_IO);
460 h2d_IO->Draw(
"COLZ");
464 tree->Draw(
"delta_cp:delm2_23>>h2d_NO",
"(delm2_23 > 0) * umbrella_weight",
"COLZ");
465 normalizeHist(h2d_NO);
466 h2d_NO->Draw(
"COLZ");
471 drawAsimovMarkerWithLegend(asimovDelm23, asimovDcp,
nullptr);
473 drawAsimovMarkerWithLegend(asimovDelm23, asimovDcp,
nullptr);
475 c2->SaveAs((outputDir +
"delm23_vs_dcp_IO_NO_weighted.png").c_str());
479 auto calculateHPDLevel = [](TH2F *hist,
double confidenceLevel) ->
double {
480 std::vector<double> binContents;
481 for (
int i = 1; i <= hist->GetNbinsX(); ++i) {
482 for (
int j = 1; j <= hist->GetNbinsY(); ++j) {
483 double content = hist->GetBinContent(i, j);
485 binContents.push_back(content);
490 if (binContents.empty())
return 0.0;
492 std::sort(binContents.rbegin(), binContents.rend());
495 for (
double val : binContents) totalSum += val;
497 double targetSum = confidenceLevel * totalSum;
498 double runningSum = 0;
500 for (
double val : binContents) {
502 if (runningSum >= targetSum) {
506 return binContents.back();
510 auto createWrappedHistogram = [](TH2F *originalHist,
const std::string &name) -> TH2F* {
511 int nBinsX = originalHist->GetNbinsX();
512 int nBinsY = originalHist->GetNbinsY();
514 double xMin = originalHist->GetXaxis()->GetBinLowEdge(1);
515 double xMax = originalHist->GetXaxis()->GetBinUpEdge(nBinsX);
516 double yMin = originalHist->GetYaxis()->GetBinLowEdge(1);
517 double yMax = originalHist->GetYaxis()->GetBinUpEdge(nBinsY);
518 double yRange = yMax - yMin;
521 TH2F *wrapped =
new TH2F(name.c_str(),
"",
523 nBinsY * 3, yMin - yRange, yMax + yRange);
524 wrapped->SetDirectory(0);
527 for (
int i = 1; i <= nBinsX; ++i) {
528 for (
int j = 1; j <= nBinsY; ++j) {
529 double content = originalHist->GetBinContent(i, j);
531 wrapped->SetBinContent(i, j + nBinsY, content);
533 wrapped->SetBinContent(i, j, content);
535 wrapped->SetBinContent(i, j + 2*nBinsY, content);
543 auto computeOneSidedBoundsValues = [&](TH1 *hist,
double targets[3],
double outBounds[3],
bool &integrateLeftToRight) {
544 for (
int i = 0; i < 3; ++i) outBounds[i] = std::numeric_limits<double>::quiet_NaN();
545 integrateLeftToRight =
true;
547 double total = hist->Integral();
548 if (total <= 0)
return;
549 int nBins = hist->GetNbinsX();
550 double leftSum = 0.0;
551 double rightSum = 0.0;
552 for (
int b = 1; b <= nBins; ++b) {
553 double center = hist->GetBinCenter(b);
554 double c = hist->GetBinContent(b);
555 if (center < 0) leftSum += c;
else rightSum += c;
557 integrateLeftToRight = (leftSum >= rightSum);
559 for (
int t = 0; t < 3; ++t) {
560 double target = targets[t];
562 if (integrateLeftToRight) {
563 for (
int b = 1; b <= nBins; ++b) {
564 cum += hist->GetBinContent(b);
565 if (cum / total >= target) {
566 outBounds[t] = hist->GetBinLowEdge(b+1);
570 if (!std::isfinite(outBounds[t])) outBounds[t] = hist->GetXaxis()->GetXmax();
572 for (
int b = nBins; b >= 1; --b) {
573 cum += hist->GetBinContent(b);
574 if (cum / total >= target) {
575 outBounds[t] = hist->GetBinLowEdge(b);
579 if (!std::isfinite(outBounds[t])) outBounds[t] = hist->GetXaxis()->GetXmin();
584 auto drawAbsDelm23Overlay = [&](
const std::string &suffix,
585 const std::string &ioSelection,
586 const std::string &noSelection) {
587 const int nBinsAbsDelm23 = 80;
588 const int nBinsAbsDcp = 60;
591 gStyle->SetPalette(kGreyScale);
592 TColor::InvertPalette();
594 TCanvas *cAbs =
new TCanvas((
"c_abs_" + suffix).c_str(),
"Delta m23 magnitude overlay", 900, 700);
595 cAbs->SetRightMargin(0.15);
596 cAbs->SetLeftMargin(0.12);
597 cAbs->SetBottomMargin(0.12);
599 TH2F *hAbsFrame =
new TH2F((
"hAbsFrame_" + suffix).c_str(),
600 "|#Delta m_{23}^{2}| vs #delta_{CP};|#Delta m_{23}^{2}| (eV^{2});#delta_{CP} / #pi",
601 nBinsAbsDelm23, delm23_no_min, delm23_no_max,
602 nBinsAbsDcp, -3.1415, 3.1415);
603 hAbsFrame->SetStats(0);
606 TH2F *hAbsIO =
new TH2F((
"hAbsIO_" + suffix).c_str(),
"",
607 nBinsAbsDelm23, delm23_no_min, delm23_no_max,
608 nBinsAbsDcp, -3.1415, 3.1415);
609 TH2F *hAbsNO =
new TH2F((
"hAbsNO_" + suffix).c_str(),
"",
610 nBinsAbsDelm23, delm23_no_min, delm23_no_max,
611 nBinsAbsDcp, -3.1415, 3.1415);
613 std::string ioDrawExpr = std::string(
"delta_cp:TMath::Abs(delm2_23)>>") + hAbsIO->GetName();
614 std::string noDrawExpr = std::string(
"delta_cp:TMath::Abs(delm2_23)>>") + hAbsNO->GetName();
615 tree->Draw(ioDrawExpr.c_str(), ioSelection.c_str(),
"goff");
616 tree->Draw(noDrawExpr.c_str(), noSelection.c_str(),
"goff");
618 hAbsIO->SetDirectory(0);
619 hAbsNO->SetDirectory(0);
620 printHistStats(
"Abs delm23 IO", hAbsIO);
621 printHistStats(
"Abs delm23 NO", hAbsNO);
624 double hpdLevel1SigmaNO = calculateHPDLevel(hAbsNO, 0.683);
626 double hpdLevel1SigmaIO = calculateHPDLevel(hAbsIO, 0.683);
629 hAbsNO->SetLineColor(kAzure + 2);
630 hAbsNO->SetLineWidth(1);
631 hAbsNO->Draw(
"COLZ");
633 hAbsIO->SetLineColor(kOrange + 7);
634 hAbsIO->SetLineWidth(1);
635 hAbsIO->Draw(
"COLZ SAME");
638 TH2F *hNO_contour = (TH2F *)hAbsNO->Clone(
"hNO_contour");
639 TH2F *hIO_contour = (TH2F *)hAbsIO->Clone(
"hIO_contour");
640 hNO_contour->SetDirectory(0);
641 hIO_contour->SetDirectory(0);
643 hNO_contour->Smooth(1,
"k5a");
644 hIO_contour->Smooth(1,
"k5a");
646 double noLevels[1] = {hpdLevel1SigmaNO};
647 hNO_contour->SetContour(1, noLevels);
648 hNO_contour->SetLineColor(kAzure + 2);
649 hNO_contour->SetLineWidth(3);
650 hNO_contour->Draw(
"CONT3 SAME");
652 double ioLevels[1] = {hpdLevel1SigmaIO};
653 hIO_contour->SetContour(1, ioLevels);
654 hIO_contour->SetLineColor(kOrange + 7);
655 hIO_contour->SetLineWidth(3);
656 hIO_contour->Draw(
"CONT3 SAME");
658 TLegend *legend =
new TLegend(0.68, 0.73, 0.88, 0.91);
659 legend->SetBorderSize(0);
660 legend->SetFillStyle(0);
661 legend->AddEntry(hAbsNO,
"NO 1#sigma",
"l");
662 legend->AddEntry(hAbsIO,
"IO 1#sigma",
"l");
665 drawAsimovMarkerWithLegend(std::abs(asimovDelm23), asimovDcp, legend);
667 cAbs->SaveAs((outputDir +
"delm23_vs_dcp_abs_IO_NO" + suffix +
".png").c_str());
670 drawAbsDelm23Overlay(
"",
"delm2_23 < 0",
"delm2_23 > 0");
672 if (hasUmbrellaWeight) {
673 drawAbsDelm23Overlay(
"_weighted",
674 "(delm2_23 < 0) * umbrella_weight",
675 "(delm2_23 > 0) * umbrella_weight");
679 gStyle->SetPalette(kBird);
682 TCanvas *c4 =
new TCanvas(
"c4",
"Delta m23 NO vs sin^{2}(#theta_{23})", 900, 700);
683 c4->SetRightMargin(0.15);
685 TH2F *h2d_sin =
new TH2F(
"h2d_sin",
"#Delta m_{23}^{2} vs sin^{2}(#theta_{23});sin^{2}(#theta_{23});#Delta m_{23}^{2} (eV^{2})",
686 nBins_sin2th23, sin2th23_min, sin2th23_max, nBins_delm23, delm23_no_min, delm23_no_max);
688 tree->Draw(
"delm2_23:sin2th_23>>h2d_sin",
"delm2_23 > 0",
"COLZ");
689 normalizeHist(h2d_sin);
690 h2d_sin->Draw(
"COLZ");
692 h2d_sin->SetStats(0);
693 h2d_sin->GetXaxis()->SetTitle(
"sin^{2}(#theta_{23})");
694 h2d_sin->GetYaxis()->SetTitle(
"#Delta m_{23}^{2} (eV^{2})");
695 h2d_sin->GetZaxis()->SetTitle(
"Normalized Entries");
699 drawAsimovMarkerWithLegend(asimovSin2th23, asimovDelm23,
nullptr);
701 c4->SaveAs((outputDir +
"th23_vs_delm23_no.png").c_str());
703 if (hasUmbrellaWeight){
704 tree->Draw(
"delm2_23:sin2th_23>>h2d_sin",
"(delm2_23 > 0) * umbrella_weight",
"COLZ");
705 normalizeHist(h2d_sin);
706 h2d_sin->Draw(
"COLZ");
707 drawAsimovMarkerWithLegend(asimovSin2th23, asimovDelm23,
nullptr);
709 c4->SaveAs((outputDir +
"th23_vs_delm23_no_weighted.png").c_str());
713 TCanvas *c5 =
new TCanvas(
"c5",
"Delta m23 IO vs sin^{2}(#theta_{23})", 900, 700);
714 c5->SetRightMargin(0.15);
716 TH2F *h2d_sin_IO =
new TH2F(
"h2d_sin_IO",
"#Delta m_{23}^{2} vs sin^{2}(#theta_{23});sin^{2}(#theta_{23});#Delta m_{23}^{2} (eV^{2})",
717 nBins_sin2th23, sin2th23_min, sin2th23_max,
718 nBins_delm23, delm23_io_min, delm23_io_max);
720 tree->Draw(
"delm2_23:sin2th_23>>h2d_sin_IO",
"delm2_23 < 0",
"COLZ");
721 normalizeHist(h2d_sin_IO);
722 h2d_sin_IO->Draw(
"COLZ");
724 h2d_sin_IO->SetStats(0);
725 h2d_sin_IO->GetXaxis()->SetTitle(
"sin^{2}(#theta_{23})");
726 h2d_sin_IO->GetYaxis()->SetTitle(
"#Delta m_{23}^{2} (eV^{2})");
727 h2d_sin_IO->GetZaxis()->SetTitle(
"Normalized Entries");
730 drawAsimovMarkerWithLegend(asimovSin2th23, asimovDelm23,
nullptr);
732 c5->SaveAs((outputDir +
"th23_vs_delm23_io.png").c_str());
734 if (hasUmbrellaWeight){
735 tree->Draw(
"delm2_23:sin2th_23>>h2d_sin_IO",
"(delm2_23 < 0)*umbrella_weight",
"COLZ");
736 normalizeHist(h2d_sin_IO);
737 h2d_sin_IO->Draw(
"COLZ");
738 drawAsimovMarkerWithLegend(asimovSin2th23, asimovDelm23,
nullptr);
740 c5->SaveAs((outputDir +
"th23_vs_delm23_io_weighted.png").c_str());
744 TCanvas *c6 =
new TCanvas(
"c6",
"Delta_cp vs sin^{2}(#theta_{23})", 900, 700);
745 c6->SetRightMargin(0.15);
747 TH2F *h2d_delta_cp =
new TH2F(
"h2d_delta_cp",
"#delta_{CP} vs sin^{2}(#theta_{23});#delta_{CP};sin^{2}(#theta_{23})",
748 nBins_dcp, -3.1415, 3.1415,
749 nBins_sin2th23, sin2th23_min, sin2th23_max);
751 tree->Draw(
"sin2th_23:delta_cp>>h2d_delta_cp",
"",
"COLZ");
752 normalizeHist(h2d_delta_cp);
753 h2d_delta_cp->Draw(
"COLZ");
755 h2d_delta_cp->SetStats(0);
756 h2d_delta_cp->GetYaxis()->SetTitle(
"sin^{2}(#theta_{23})");
757 h2d_delta_cp->GetXaxis()->SetTitle(
"#delta_{CP}");
758 h2d_delta_cp->GetZaxis()->SetTitle(
"Normalized Entries");
761 drawAsimovMarkerWithLegend(asimovDcp, asimovSin2th23,
nullptr);
763 c6->SaveAs((outputDir +
"th23_vs_delta_cp.png").c_str());
765 if (hasUmbrellaWeight){
766 tree->Draw(
"sin2th_23:delta_cp>>h2d_delta_cp",
"umbrella_weight",
"COLZ");
767 normalizeHist(h2d_delta_cp);
768 h2d_delta_cp->Draw(
"COLZ");
769 drawAsimovMarkerWithLegend(asimovDcp, asimovSin2th23,
nullptr);
771 c6->SaveAs((outputDir +
"th23_vs_delta_cp_weighted.png").c_str());
775 TCanvas *cth13 =
new TCanvas(
"cth13",
"Delta_cp vs sin^{2}(#theta_{13})", 900, 700);
776 cth13->SetRightMargin(0.15);
778 TH2F *h2d_delta_cp_13 =
new TH2F(
"h2d_delta_cp_13",
"#delta_{CP} vs sin^{2}(#theta_{13});#delta_{CP};sin^{2}(#theta_{13})",
779 nBins_dcp, -3.1415, 3.1415,
780 nBins_sin2th13, sin2th13_min, sin2th13_max);
782 tree->Draw(
"sin2th_13:delta_cp>>h2d_delta_cp_13",
"",
"COLZ");
783 normalizeHist(h2d_delta_cp_13);
784 h2d_delta_cp_13->Draw(
"COLZ");
786 h2d_delta_cp_13->SetStats(0);
787 h2d_delta_cp_13->GetYaxis()->SetTitle(
"sin^{2}(#theta_{13})");
788 h2d_delta_cp_13->GetXaxis()->SetTitle(
"#delta_{CP}");
789 h2d_delta_cp_13->GetZaxis()->SetTitle(
"Normalized Entries");
792 drawAsimovMarkerWithLegend(asimovDcp, asimovSin2th13,
nullptr);
794 cth13->SaveAs((outputDir +
"th13_vs_delta_cp.png").c_str());
796 if (hasUmbrellaWeight){
797 tree->Draw(
"sin2th_13:delta_cp>>h2d_delta_cp_13",
"umbrella_weight",
"COLZ");
798 normalizeHist(h2d_delta_cp_13);
799 h2d_delta_cp_13->Draw(
"COLZ");
800 drawAsimovMarkerWithLegend(asimovDcp, asimovSin2th13,
nullptr);
802 cth13->SaveAs((outputDir +
"th13_vs_delta_cp_weighted.png").c_str());
806 TCanvas *c7 =
new TCanvas(
"c7",
"1D Histograms", 3200, 1200);
811 TH1F *h1d_delta_cp_unweighted =
new TH1F(
"h1d_delta_cp_unweighted",
"#delta_{CP};#delta_{CP};Entries", nBins_dcp, -3.1415, 3.1415);
812 tree->Draw(
"delta_cp>>h1d_delta_cp_unweighted",
"",
"");
813 normalizeHist(h1d_delta_cp_unweighted);
814 h1d_delta_cp_unweighted->SetMinimum(0);
815 h1d_delta_cp_unweighted->SetStats(0);
816 h1d_delta_cp_unweighted->Draw(
"HIST");
817 h1d_delta_cp_unweighted->Draw(
"E SAME");
818 drawAsimovLineWithLegend(asimovDcp);
821 TH1F *h1d_delm23_all_unweighted =
new TH1F(
"h1d_delm23_all_unweighted",
"#Delta m_{23}^{2} (full range);#Delta m_{23}^{2} (eV^{2});Normalized Entries", nBins_delm23, delm23_io_min, delm23_no_max);
822 tree->Draw(
"delm2_23>>h1d_delm23_all_unweighted",
"",
"");
823 normalizeHist(h1d_delm23_all_unweighted);
824 h1d_delm23_all_unweighted->SetStats(0);
825 h1d_delm23_all_unweighted->Draw(
"HIST");
826 h1d_delm23_all_unweighted->Draw(
"E SAME");
827 drawAsimovLineWithLegend(asimovDelm23);
830 TH1F *h1d_delm23_unweighted = (TH1F*)h1d_delm23_all_unweighted->Clone(
"h1d_delm23_IO_unweighted");
831 h1d_delm23_unweighted->SetTitle(
"#Delta m_{23}^{2} (IO)");
832 h1d_delm23_unweighted->SetStats(0);
833 h1d_delm23_unweighted->GetXaxis()->SetRangeUser(delm23_io_min, delm23_io_max);
834 h1d_delm23_unweighted->Draw(
"HIST");
835 h1d_delm23_unweighted->Draw(
"E SAME");
836 drawAsimovLineWithLegend(asimovDelm23);
839 TH1F *h1d_delm23_NO_unweighted = (TH1F*)h1d_delm23_all_unweighted->Clone(
"h1d_delm23_NO_unweighted");
840 h1d_delm23_unweighted->SetTitle(
"#Delta m_{23}^{2} (NO)");
841 h1d_delm23_NO_unweighted->SetStats(0);
842 h1d_delm23_NO_unweighted->GetXaxis()->SetRangeUser(delm23_no_min, delm23_no_max);
843 h1d_delm23_NO_unweighted->Draw(
"HIST");
844 h1d_delm23_NO_unweighted->Draw(
"E SAME");
845 drawAsimovLineWithLegend(asimovDelm23);
848 TH1F *h1d_sinth23_unweighted =
new TH1F(
"h1d_sinth23_unweighted",
"sin^{2}(#theta_{23});sin^{2}(#theta_{23});Entries", nBins_sin2th23, sin2th23_min, sin2th23_max);
849 tree->Draw(
"sin2th_23>>h1d_sinth23_unweighted",
"",
"");
850 normalizeHist(h1d_sinth23_unweighted);
851 h1d_sinth23_unweighted->SetStats(0);
852 h1d_sinth23_unweighted->Draw(
"HIST");
853 h1d_sinth23_unweighted->Draw(
"E SAME");
854 drawAsimovLineWithLegend(asimovSin2th23);
857 TH1F *h1d_sinth13_unweighted =
new TH1F(
"h1d_sinth13_unweighted",
"sin^{2}(#theta_{13});sin^{2}(#theta_{13});Entries", nBins_sin2th13, sin2th13_min, sin2th13_max);
858 tree->Draw(
"sin2th_13>>h1d_sinth13_unweighted",
"",
"");
859 normalizeHist(h1d_sinth13_unweighted);
860 h1d_sinth13_unweighted->SetStats(0);
861 h1d_sinth13_unweighted->Draw(
"HIST");
862 h1d_sinth13_unweighted->Draw(
"E SAME");
863 drawAsimovLineWithLegend(asimovSin2th13);
866 TH1F *h1d_sinth12_unweighted =
new TH1F(
"h1d_sinth12_unweighted",
"sin^{2}(#theta_{12});sin^{2}(#theta_{12});Entries", nBins_sin2th12, sin2th12_min, sin2th12_max);
867 tree->Draw(
"sin2th_12>>h1d_sinth12_unweighted",
"",
"");
868 normalizeHist(h1d_sinth12_unweighted);
869 h1d_sinth12_unweighted->SetStats(0);
870 h1d_sinth12_unweighted->Draw(
"HIST");
871 h1d_sinth12_unweighted->Draw(
"E SAME");
872 drawAsimovLineWithLegend(asimovSin2th12);
875 TH1F *h1d_delm12_unweighted =
new TH1F(
"h1d_delm12_unweighted",
"#Delta m_{12}^{2};#Delta m_{12}^{2} (eV^{2});Entries", nBins_delm12, delm12_min, delm12_max);
876 tree->Draw(
"delm2_12>>h1d_delm12_unweighted",
"",
"");
877 normalizeHist(h1d_delm12_unweighted);
878 h1d_delm12_unweighted->SetStats(0);
879 h1d_delm12_unweighted->Draw(
"HIST");
880 h1d_delm12_unweighted->Draw(
"E SAME");
881 drawAsimovLineWithLegend(asimovDelm12);
884 c7->SaveAs((outputDir +
"1D_histograms_unweighted.png").c_str());
887 TCanvas *c7_weighted =
new TCanvas(
"c7_weighted",
"1D Histograms Weighted", 3200, 1200);
888 c7_weighted->Divide(4, 2);
892 TH1F *h1d_delta_cp =
new TH1F(
"h1d_delta_cp",
"#delta_{CP};#delta_{CP};Weighted Entries", nBins_dcp, -3.1415, 3.1415);
893 if (hasUmbrellaWeight) {
894 tree->Draw(
"delta_cp>>h1d_delta_cp",
"umbrella_weight",
"");
896 tree->Draw(
"delta_cp>>h1d_delta_cp",
"",
"");
897 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted delta_cp histogram." << std::endl;
899 normalizeHist(h1d_delta_cp);
900 h1d_delta_cp->SetStats(0);
901 h1d_delta_cp->Sumw2();
902 h1d_delta_cp->Draw(
"HIST");
903 h1d_delta_cp->Draw(
"E SAME");
906 double sigma1 = 0.6827;
907 double sigma3 = 0.9973;
908 double sigma5 = 0.99994;
919 double maxEntries = 0;
920 for (
int j = 1; j <= h1d_delta_cp->GetNbinsX(); j++) {
921 if (h1d_delta_cp->GetBinContent(j) > maxEntries) {
922 maxEntries = h1d_delta_cp->GetBinContent(j);
927 std::cout <<
"HPD bin: " << hpdBin <<
" with " << maxEntries <<
" entries" << std::endl;
930 TH1F *h1d_copy = (TH1F*)h1d_delta_cp->Clone(
"h1d_copy");
933 std::vector<bool> included(h1d_delta_cp->GetNbinsX() + 1,
false);
934 included[hpdBin] =
true;
937 auto findContiguousRegions = [&](
int gapTolerance = 2) {
938 std::vector<std::pair<int, int>> regions;
943 for (
int k = 1; k <= h1d_delta_cp->GetNbinsX(); k++) {
949 }
else if (start != -1) {
951 if (gapCount > gapTolerance) {
953 regions.push_back({start, k - gapCount});
962 regions.push_back({start, h1d_delta_cp->GetNbinsX()});
969 double totalEntries = h1d_delta_cp->Integral();
970 double sumEntries = h1d_delta_cp->GetBinContent(hpdBin);
975 std::vector<std::pair<double, double>> sigma1_regions;
976 std::vector<std::pair<double, double>> sigma3_regions;
977 std::vector<std::pair<double, double>> sigma5_regions;
979 for (
int i = 0; i < h1d_delta_cp->GetNbinsX(); i++) {
982 double maxBinEntries = 0;
983 for (
int j = 1; j <= h1d_delta_cp->GetNbinsX(); j++) {
984 if (!included[j] && h1d_copy->GetBinContent(j) > maxBinEntries) {
985 maxBinEntries = h1d_copy->GetBinContent(j);
990 if (maxBin == 0)
break;
992 sumEntries += maxBinEntries;
993 included[maxBin] =
true;
994 double frac = sumEntries / totalEntries;
996 std::cout <<
"Added bin " << maxBin <<
" with " << maxBinEntries <<
" entries. Fraction: " << frac << std::endl;
998 if (frac >= sigma1 && level1 == 0) {
999 level1 = maxBinEntries;
1000 std::cout <<
"1 sigma level: " << level1 << std::endl;
1002 auto regions = findContiguousRegions(2);
1003 std::cout <<
"1 sigma regions (" << regions.size() <<
" mode(s)):" << std::endl;
1004 for (
const auto& region : regions) {
1005 double lower = h1d_delta_cp->GetBinLowEdge(region.first);
1006 double upper = h1d_delta_cp->GetBinLowEdge(region.second + 1);
1007 sigma1_regions.push_back({lower, upper});
1008 std::cout <<
" [" << lower <<
", " << upper <<
"]" << std::endl;
1011 if (frac >= sigma3 && level3 == 0) {
1012 level3 = maxBinEntries;
1013 std::cout <<
"3 sigma level: " << level3 << std::endl;
1015 auto regions = findContiguousRegions(2);
1016 std::cout <<
"3 sigma regions (" << regions.size() <<
" mode(s)):" << std::endl;
1017 for (
const auto& region : regions) {
1018 double lower = h1d_delta_cp->GetBinLowEdge(region.first);
1019 double upper = h1d_delta_cp->GetBinLowEdge(region.second + 1);
1020 sigma3_regions.push_back({lower, upper});
1021 std::cout <<
" [" << lower <<
", " << upper <<
"]" << std::endl;
1024 if (frac >= sigma5 && level5 == 0) {
1025 level5 = maxBinEntries;
1026 std::cout <<
"5 sigma level: " << level5 << std::endl;
1028 auto regions = findContiguousRegions(2);
1029 std::cout <<
"5 sigma regions (" << regions.size() <<
" mode(s)):" << std::endl;
1030 for (
const auto& region : regions) {
1031 double lower = h1d_delta_cp->GetBinLowEdge(region.first);
1032 double upper = h1d_delta_cp->GetBinLowEdge(region.second + 1);
1033 sigma5_regions.push_back({lower, upper});
1034 std::cout <<
" [" << lower <<
", " << upper <<
"]" << std::endl;
1040 double ymax = h1d_delta_cp->GetMaximum();
1043 for (
const auto& region : sigma1_regions) {
1044 TLine *line_lower =
new TLine(region.first, 0, region.first, ymax);
1045 line_lower->SetLineColor(kOrange+1);
1046 line_lower->SetLineStyle(2);
1047 line_lower->SetLineWidth(2);
1048 line_lower->Draw(
"same");
1050 TLine *line_upper =
new TLine(region.second, 0, region.second, ymax);
1051 line_upper->SetLineColor(kOrange+1);
1052 line_upper->SetLineStyle(2);
1053 line_upper->SetLineWidth(2);
1054 line_upper->Draw(
"same");
1058 for (
const auto& region : sigma3_regions) {
1059 TLine *line_lower =
new TLine(region.first, 0, region.first, ymax);
1060 line_lower->SetLineColor(kAzure+2);
1061 line_lower->SetLineStyle(2);
1062 line_lower->SetLineWidth(2);
1063 line_lower->Draw(
"same");
1065 TLine *line_upper =
new TLine(region.second, 0, region.second, ymax);
1066 line_upper->SetLineColor(kAzure+2);
1067 line_upper->SetLineStyle(2);
1068 line_upper->SetLineWidth(2);
1069 line_upper->Draw(
"same");
1073 for (
const auto& region : sigma5_regions) {
1074 TLine *line_lower =
new TLine(region.first, 0, region.first, ymax);
1075 line_lower->SetLineColor(kMagenta+2);
1076 line_lower->SetLineStyle(2);
1077 line_lower->SetLineWidth(2);
1078 line_lower->Draw(
"same");
1080 TLine *line_upper =
new TLine(region.second, 0, region.second, ymax);
1081 line_upper->SetLineColor(kMagenta+2);
1082 line_upper->SetLineStyle(2);
1083 line_upper->SetLineWidth(2);
1084 line_upper->Draw(
"same");
1087 TLegend *legRef =
nullptr;
1088 if (hasReferenceDcp && hRefDcpShape) {
1089 std::cout <<
"Overlaying reference delta_cp shape on weighted histogram" << std::endl;
1090 TH1D *hRefOverlay = (TH1D*)hRefDcpShape->Clone(
"hRefDcpShape_overlay_linear");
1091 hRefOverlay->SetDirectory(0);
1092 double refIntegral = hRefOverlay->Integral();
1093 if (refIntegral > 0) {
1094 hRefOverlay->Scale(h1d_delta_cp->Integral() / refIntegral);
1096 hRefOverlay->SetLineColor(kMagenta + 2);
1097 hRefOverlay->SetLineWidth(3);
1098 hRefOverlay->SetLineStyle(1);
1099 hRefOverlay->SetFillStyle(0);
1100 hRefOverlay->Draw(
"HIST SAME");
1102 legRef =
new TLegend(0.15, 0.74, 0.48, 0.88);
1103 legRef->SetBorderSize(0);
1104 legRef->SetFillStyle(0);
1105 legRef->AddEntry(h1d_delta_cp,
"Umbrella weighted",
"l");
1106 legRef->AddEntry(hRefOverlay,
"Reference dcp (shape, area-normalized)",
"l");
1109 drawAsimovLineWithLegend(asimovDcp, hasReferenceDcp ? legRef :
nullptr);
1112 if (hasReferenceLLH_Dcp && hRefLLH_Dcp) {
1113 std::cout <<
"Overlaying LLH-scan reference dcp histogram on weighted histogram (resampled to umbrella bins)" << std::endl;
1115 TH1D *hLLHResamp =
new TH1D(
"hRefLLH_dcp_resamp",
"", h1d_delta_cp->GetNbinsX(), h1d_delta_cp->GetXaxis()->GetXmin(), h1d_delta_cp->GetXaxis()->GetXmax());
1116 hLLHResamp->SetDirectory(0);
1117 for (
int i = 1; i <= hLLHResamp->GetNbinsX(); ++i) {
1118 double xlow = hLLHResamp->GetBinLowEdge(i);
1119 double xhigh = hLLHResamp->GetBinLowEdge(i+1);
1121 int nOrig = hRefLLH_Dcp->GetNbinsX();
1122 for (
int k = 1; k <= nOrig; ++k) {
1123 double origLow = hRefLLH_Dcp->GetXaxis()->GetBinLowEdge(k);
1124 double origHigh = origLow + hRefLLH_Dcp->GetBinWidth(k);
1125 double overlap = std::max(0.0, std::min(origHigh, xhigh) - std::max(origLow, xlow));
1126 if (overlap > 0.0) {
1127 double origWidth = hRefLLH_Dcp->GetBinWidth(k);
1128 double contrib = hRefLLH_Dcp->GetBinContent(k) * (overlap / origWidth);
1132 hLLHResamp->SetBinContent(i, val);
1135 double llhInt = hLLHResamp->Integral();
1136 if (llhInt > 0) hLLHResamp->Scale(h1d_delta_cp->Integral() / llhInt);
1137 hLLHResamp->SetLineColor(kBlack);
1138 hLLHResamp->SetLineWidth(3);
1139 hLLHResamp->SetLineStyle(2);
1140 hLLHResamp->SetFillStyle(0);
1141 hLLHResamp->Draw(
"HIST SAME");
1143 TLegend *legLLH =
new TLegend(0.15, 0.60, 0.50, 0.74);
1144 legLLH->SetBorderSize(0);
1145 legLLH->SetFillStyle(0);
1146 legLLH->AddEntry(h1d_delta_cp,
"Umbrella weighted",
"l");
1147 legLLH->AddEntry(hLLHResamp,
"LLH scan (resampled)",
"l");
1152 TH1F *h1d_delm23_all =
new TH1F(
"h1d_delm23_all",
"#Delta m_{23}^{2} (full range);#Delta m_{23}^{2} (eV^{2});Normalized Entries", nBins_delm23, delm23_io_min, delm23_no_max);
1153 if (hasUmbrellaWeight) {
1154 tree->Draw(
"delm2_23>>h1d_delm23_all",
"umbrella_weight",
"");
1155 std::cout <<
"Applying umbrella weights to delm23 histogram" << std::endl;
1157 tree->Draw(
"delm2_23>>h1d_delm23_all",
"",
"");
1158 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted #Delta m_{23}^{2} histogram." << std::endl;
1160 normalizeHist(h1d_delm23_all);
1161 h1d_delm23_all->SetStats(0);
1162 h1d_delm23_all->Draw(
"HIST");
1163 h1d_delm23_all->Draw(
"E SAME");
1165 TLegend *legRefDelm23All =
nullptr;
1166 if (hasReferenceDelm23 && hRefDelm23Shape) {
1167 TH1D *hRefDelm23AllOverlay = (TH1D*)hRefDelm23Shape->Clone(
"hRefDelm23All_overlay_linear");
1168 hRefDelm23AllOverlay->SetDirectory(0);
1169 double refIntegral = hRefDelm23AllOverlay->Integral();
1170 if (refIntegral > 0) {
1171 hRefDelm23AllOverlay->Scale(h1d_delm23_all->Integral() / refIntegral);
1173 hRefDelm23AllOverlay->SetLineColor(kMagenta + 2);
1174 hRefDelm23AllOverlay->SetLineWidth(3);
1175 hRefDelm23AllOverlay->SetLineStyle(1);
1176 hRefDelm23AllOverlay->SetFillStyle(0);
1177 hRefDelm23AllOverlay->Draw(
"HIST SAME");
1179 legRefDelm23All =
new TLegend(0.50, 0.74, 0.88, 0.88);
1180 legRefDelm23All->SetBorderSize(0);
1181 legRefDelm23All->SetFillStyle(0);
1182 legRefDelm23All->AddEntry(h1d_delm23_all,
"Umbrella weighted",
"l");
1183 legRefDelm23All->AddEntry(hRefDelm23AllOverlay,
"Reference #Delta m_{23}^{2} (full range)",
"l");
1184 legRefDelm23All->Draw();
1186 drawAsimovLineWithLegend(asimovDelm23, hasReferenceDelm23 ? legRefDelm23All :
nullptr);
1189 TH1F *h1d_delm23 = (TH1F*)h1d_delm23_all->Clone(
"h1d_delm23_IO");
1190 h1d_delm23->SetStats(0);
1191 h1d_delm23->Sumw2();
1192 h1d_delm23->GetXaxis()->SetRangeUser(delm23_io_min, delm23_io_max);
1193 h1d_delm23->Draw(
"HIST");
1194 h1d_delm23->Draw(
"E SAME");
1196 TLegend *legRefDelm23IO =
nullptr;
1197 if (hasReferenceDelm23 && hRefDelm23Shape) {
1198 TH1D *hRefDelm23IOOverlay = (TH1D*)hRefDelm23Shape->Clone(
"hRefDelm23IO_overlay_linear");
1199 hRefDelm23IOOverlay->SetDirectory(0);
1200 hRefDelm23IOOverlay->GetXaxis()->SetRangeUser(delm23_io_min, delm23_io_max);
1201 hRefDelm23IOOverlay->SetLineColor(kMagenta + 2);
1202 hRefDelm23IOOverlay->SetLineWidth(3);
1203 hRefDelm23IOOverlay->SetLineStyle(1);
1204 hRefDelm23IOOverlay->SetFillStyle(0);
1205 hRefDelm23IOOverlay->Draw(
"HIST SAME");
1207 legRefDelm23IO =
new TLegend(0.50, 0.74, 0.88, 0.88);
1208 legRefDelm23IO->SetBorderSize(0);
1209 legRefDelm23IO->SetFillStyle(0);
1210 legRefDelm23IO->AddEntry(h1d_delm23,
"Umbrella weighted",
"l");
1211 legRefDelm23IO->AddEntry(hRefDelm23IOOverlay,
"Reference #Delta m_{23}^{2} (IO)",
"l");
1212 legRefDelm23IO->Draw();
1214 drawAsimovLineWithLegend(asimovDelm23, hasReferenceDelm23 ? legRefDelm23IO :
nullptr);
1217 TH1F *h1d_delm23_NO = (TH1F*)h1d_delm23_all->Clone(
"h1d_delm23_NO");
1218 h1d_delm23_NO->SetStats(0);
1219 h1d_delm23_NO->Sumw2();
1220 h1d_delm23_NO->GetXaxis()->SetRangeUser(delm23_no_min, delm23_no_max);
1221 h1d_delm23_NO->Draw(
"HIST");
1222 h1d_delm23_NO->Draw(
"E SAME");
1224 TLegend *legRefDelm23NO =
nullptr;
1225 if (hasReferenceDelm23 && hRefDelm23Shape) {
1226 std::cout <<
"Drawing reference delm23 shape for NO" << std::endl;
1227 TH1D *hRefDelm23NOOverlay = (TH1D*)hRefDelm23Shape->Clone(
"hRefDelm23NO_overlay_linear");
1228 hRefDelm23NOOverlay->SetDirectory(0);
1229 hRefDelm23NOOverlay->GetXaxis()->SetRangeUser(delm23_no_min, delm23_no_max);
1230 hRefDelm23NOOverlay->SetLineColor(kMagenta + 2);
1231 hRefDelm23NOOverlay->SetLineWidth(3);
1232 hRefDelm23NOOverlay->SetLineStyle(1);
1233 hRefDelm23NOOverlay->SetFillStyle(0);
1234 hRefDelm23NOOverlay->Draw(
"HIST SAME");
1236 legRefDelm23NO =
new TLegend(0.50, 0.74, 0.88, 0.88);
1237 legRefDelm23NO->SetBorderSize(0);
1238 legRefDelm23NO->SetFillStyle(0);
1239 legRefDelm23NO->AddEntry(h1d_delm23_NO,
"Umbrella weighted",
"l");
1240 legRefDelm23NO->AddEntry(hRefDelm23NOOverlay,
"Reference #Delta m_{23}^{2} (NO)",
"l");
1241 legRefDelm23NO->Draw();
1243 drawAsimovLineWithLegend(asimovDelm23, hasReferenceDelm23 ? legRefDelm23NO :
nullptr);
1247 if (h1d_delm23_all) {
1248 int binIO_low = h1d_delm23_all->GetXaxis()->FindBin(delm23_io_min);
1249 int binIO_high = h1d_delm23_all->GetXaxis()->FindBin(delm23_io_max);
1250 int binNO_low = h1d_delm23_all->GetXaxis()->FindBin(delm23_no_min);
1251 int binNO_high = h1d_delm23_all->GetXaxis()->FindBin(delm23_no_max);
1253 double fracIO = h1d_delm23_all->Integral(binIO_low, binIO_high);
1254 double fracNO = h1d_delm23_all->Integral(binNO_low, binNO_high);
1257 double ratioNOtoIO = fracNO / fracIO;
1258 std::cout <<
"Mass ordering preference (NO/IO) = " << ratioNOtoIO
1259 <<
" (NO frac=" << fracNO <<
", IO frac=" << fracIO <<
")" << std::endl;
1261 std::cout <<
"Mass ordering preference: IO fraction is zero; cannot compute ratio. "
1262 <<
"NO_frac=" << fracNO <<
" IO_frac=" << fracIO << std::endl;
1265 std::cout <<
"Mass ordering preference: h1d_delm23_all is null; cannot compute." << std::endl;
1269 TH1F *h1d_sinth23 =
new TH1F(
"h1d_sinth23",
"sin^{2}(#theta_{23});sin^{2}(#theta_{23});Weighted Entries", nBins_sin2th23, sin2th23_min, sin2th23_max);
1270 if (hasUmbrellaWeight) {
1271 tree->Draw(
"sin2th_23>>h1d_sinth23",
"umbrella_weight",
"");
1273 tree->Draw(
"sin2th_23>>h1d_sinth23",
"",
"");
1274 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted sin^2(theta23) histogram." << std::endl;
1276 normalizeHist(h1d_sinth23);
1277 h1d_sinth23->SetStats(0);
1278 h1d_sinth23->Sumw2();
1279 h1d_sinth23->Draw(
"HIST");
1280 h1d_sinth23->Draw(
"E SAME");
1282 TLegend *legRefSin =
nullptr;
1283 if (hasReferenceSin2Th23 && hRefSin2Th23Shape) {
1284 TH1D *hRefSinOverlay = (TH1D*)hRefSin2Th23Shape->Clone(
"hRefSin2Th23_overlay_linear");
1285 hRefSinOverlay->SetDirectory(0);
1286 double refIntegral = hRefSinOverlay->Integral();
1287 if (refIntegral > 0) {
1288 hRefSinOverlay->Scale(h1d_sinth23->Integral() / refIntegral);
1290 hRefSinOverlay->SetLineColor(kMagenta + 2);
1291 hRefSinOverlay->SetLineWidth(3);
1292 hRefSinOverlay->SetLineStyle(1);
1293 hRefSinOverlay->SetFillStyle(0);
1294 hRefSinOverlay->Draw(
"HIST SAME");
1296 legRefSin =
new TLegend(0.50, 0.74, 0.88, 0.88);
1297 legRefSin->SetBorderSize(0);
1298 legRefSin->SetFillStyle(0);
1299 legRefSin->AddEntry(h1d_sinth23,
"Umbrella weighted",
"l");
1300 legRefSin->AddEntry(hRefSinOverlay,
"Reference sin^{2}(#theta_{23})",
"l");
1303 drawAsimovLineWithLegend(asimovSin2th23, hasReferenceSin2Th23 ? legRefSin :
nullptr);
1306 TH1F *h1d_sinth13 =
new TH1F(
"h1d_sinth13",
"sin^{2}(#theta_{13});sin^{2}(#theta_{13});Weighted Entries", nBins_sin2th13, sin2th13_min, sin2th13_max);
1307 if (hasUmbrellaWeight) {
1308 tree->Draw(
"sin2th_13>>h1d_sinth13",
"umbrella_weight",
"");
1310 tree->Draw(
"sin2th_13>>h1d_sinth13",
"",
"");
1311 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted sin^2(theta13) histogram." << std::endl;
1313 normalizeHist(h1d_sinth13);
1314 h1d_sinth13->SetStats(0);
1315 h1d_sinth13->Sumw2();
1316 h1d_sinth13->Draw(
"HIST");
1317 h1d_sinth13->Draw(
"E SAME");
1318 drawAsimovLineWithLegend(asimovSin2th13);
1321 TH1F *h1d_sinth12 =
new TH1F(
"h1d_sinth12",
"sin^{2}(#theta_{12});sin^{2}(#theta_{12});Weighted Entries", nBins_sin2th12, sin2th12_min, sin2th12_max);
1322 if (hasUmbrellaWeight) {
1323 tree->Draw(
"sin2th_12>>h1d_sinth12",
"umbrella_weight",
"");
1325 tree->Draw(
"sin2th_12>>h1d_sinth12",
"",
"");
1326 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted sin^2(theta12) histogram." << std::endl;
1328 normalizeHist(h1d_sinth12);
1329 h1d_sinth12->SetStats(0);
1330 h1d_sinth12->Sumw2();
1331 h1d_sinth12->Draw(
"HIST");
1332 h1d_sinth12->Draw(
"E SAME");
1333 drawAsimovLineWithLegend(asimovSin2th12);
1336 TH1F *h1d_delm12 =
new TH1F(
"h1d_delm12",
"#Delta m_{12}^{2};#Delta m_{12}^{2} (eV^{2});Weighted Entries", nBins_delm12, delm12_min, delm12_max);
1337 if (hasUmbrellaWeight) {
1338 tree->Draw(
"delm2_12>>h1d_delm12",
"umbrella_weight",
"");
1340 tree->Draw(
"delm2_12>>h1d_delm12",
"",
"");
1341 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted #Delta m_{12}^{2} histogram." << std::endl;
1343 normalizeHist(h1d_delm12);
1344 h1d_delm12->SetStats(0);
1345 h1d_delm12->Sumw2();
1346 h1d_delm12->Draw(
"HIST");
1347 h1d_delm12->Draw(
"E SAME");
1348 drawAsimovLineWithLegend(asimovDelm12);
1350 c7_weighted->Update();
1351 c7_weighted->SaveAs((outputDir +
"1D_histograms_weighted.png").c_str());
1354 TCanvas *c8 =
new TCanvas(
"c8",
"Delta CP Log Scale", 900, 700);
1356 TH1F *h1d_delta_cp_log = (TH1F*)h1d_delta_cp->Clone(
"h1d_delta_cp_log");
1357 h1d_delta_cp_log->SetTitle(
"#delta_{CP} (Log Scale);#delta_{CP};Weighted Entries");
1358 h1d_delta_cp_log->Draw(
"HIST");
1359 h1d_delta_cp_log->Draw(
"E SAME");
1362 double ymax_log = h1d_delta_cp_log->GetMaximum();
1363 double ymin_log = h1d_delta_cp_log->GetMinimum();
1364 if (ymin_log <= 0) ymin_log = 0.1;
1367 for (
const auto& region : sigma1_regions) {
1368 TLine *line_lower =
new TLine(region.first, ymin_log, region.first, ymax_log);
1369 line_lower->SetLineColor(kRed);
1370 line_lower->SetLineStyle(2);
1371 line_lower->SetLineWidth(2);
1372 line_lower->Draw(
"same");
1374 TLine *line_upper =
new TLine(region.second, ymin_log, region.second, ymax_log);
1375 line_upper->SetLineColor(kRed);
1376 line_upper->SetLineStyle(2);
1377 line_upper->SetLineWidth(2);
1378 line_upper->Draw(
"same");
1382 for (
const auto& region : sigma3_regions) {
1383 TLine *line_lower =
new TLine(region.first, ymin_log, region.first, ymax_log);
1384 line_lower->SetLineColor(kAzure+2);
1385 line_lower->SetLineStyle(2);
1386 line_lower->SetLineWidth(2);
1387 line_lower->Draw(
"same");
1389 TLine *line_upper =
new TLine(region.second, ymin_log, region.second, ymax_log);
1390 line_upper->SetLineColor(kAzure+2);
1391 line_upper->SetLineStyle(2);
1392 line_upper->SetLineWidth(2);
1393 line_upper->Draw(
"same");
1397 for (
const auto& region : sigma5_regions) {
1398 TLine *line_lower =
new TLine(region.first, ymin_log, region.first, ymax_log);
1399 line_lower->SetLineColor(kMagenta+2);
1400 line_lower->SetLineStyle(2);
1401 line_lower->SetLineWidth(2);
1402 line_lower->Draw(
"same");
1404 TLine *line_upper =
new TLine(region.second, ymin_log, region.second, ymax_log);
1405 line_upper->SetLineColor(kMagenta+2);
1406 line_upper->SetLineStyle(2);
1407 line_upper->SetLineWidth(2);
1408 line_upper->Draw(
"same");
1411 TLegend *legRefLog =
nullptr;
1412 if (hasReferenceDcp && hRefDcpShape) {
1413 TH1D *hRefOverlayLog = (TH1D*)hRefDcpShape->Clone(
"hRefDcpShape_overlay_log");
1414 hRefOverlayLog->SetDirectory(0);
1415 double refIntegral = hRefOverlayLog->Integral();
1416 if (refIntegral > 0) {
1417 hRefOverlayLog->Scale(h1d_delta_cp_log->Integral() / refIntegral);
1419 hRefOverlayLog->SetLineColor(kMagenta + 2);
1420 hRefOverlayLog->SetLineWidth(3);
1421 hRefOverlayLog->SetLineStyle(1);
1422 hRefOverlayLog->SetFillStyle(0);
1423 hRefOverlayLog->Draw(
"HIST SAME");
1425 legRefLog =
new TLegend(0.50, 0.74, 0.88, 0.88);
1426 legRefLog->SetBorderSize(0);
1427 legRefLog->SetFillStyle(0);
1428 legRefLog->AddEntry(h1d_delta_cp_log,
"Umbrella weighted",
"l");
1429 legRefLog->AddEntry(hRefOverlayLog,
"Reference dcp (shape, area-normalized)",
"l");
1432 if (hasReferenceLLH_Dcp && hRefLLH_Dcp) {
1434 TH1D *hLLHResampLog =
new TH1D(
"hRefLLH_dcp_resamp_log",
"", h1d_delta_cp_log->GetNbinsX(), h1d_delta_cp_log->GetXaxis()->GetXmin(), h1d_delta_cp_log->GetXaxis()->GetXmax());
1435 hLLHResampLog->SetDirectory(0);
1436 for (
int i = 1; i <= hLLHResampLog->GetNbinsX(); ++i) {
1437 double xlow = hLLHResampLog->GetBinLowEdge(i);
1438 double xhigh = hLLHResampLog->GetBinLowEdge(i+1);
1440 int nOrig = hRefLLH_Dcp->GetNbinsX();
1441 for (
int k = 1; k <= nOrig; ++k) {
1442 double origLow = hRefLLH_Dcp->GetXaxis()->GetBinLowEdge(k);
1443 double origHigh = origLow + hRefLLH_Dcp->GetBinWidth(k);
1444 double overlap = std::max(0.0, std::min(origHigh, xhigh) - std::max(origLow, xlow));
1445 if (overlap > 0.0) {
1446 double origWidth = hRefLLH_Dcp->GetBinWidth(k);
1447 double contrib = hRefLLH_Dcp->GetBinContent(k) * (overlap / origWidth);
1451 hLLHResampLog->SetBinContent(i, val);
1453 double llhI = hLLHResampLog->Integral();
1454 if (llhI > 0) hLLHResampLog->Scale(h1d_delta_cp_log->Integral() / llhI);
1455 hLLHResampLog->SetLineColor(kBlue + 2);
1456 hLLHResampLog->SetLineWidth(3);
1457 hLLHResampLog->SetLineStyle(2);
1458 hLLHResampLog->SetFillStyle(0);
1459 hLLHResampLog->Draw(
"HIST SAME");
1460 TLegend *legLLHLog =
new TLegend(0.50, 0.60, 0.88, 0.74);
1461 legLLHLog->SetBorderSize(0);
1462 legLLHLog->SetFillStyle(0);
1463 legLLHLog->AddEntry(h1d_delta_cp_log,
"Umbrella weighted",
"l");
1464 legLLHLog->AddEntry(hLLHResampLog,
"LLH scan (resampled & area-normalized)",
"l");
1467 drawAsimovLineWithLegend(asimovDcp, hasReferenceDcp ? legRefLog :
nullptr);
1470 c8->SaveAs((outputDir +
"delta_cp_log_scale_weighted.png").c_str());
1473 TCanvas *c9 =
new TCanvas(
"c9",
"Delta CP Log Scale Marginalized by Ordering", 1800, 700);
1476 std::string ioSelection = hasUmbrellaWeight ?
"(delm2_23 < 0) * umbrella_weight" :
"(delm2_23 < 0)";
1477 std::string noSelection = hasUmbrellaWeight ?
"(delm2_23 > 0) * umbrella_weight" :
"(delm2_23 > 0)";
1482 TH1F *h1d_delta_cp_io_log =
new TH1F(
"h1d_delta_cp_io_log",
"#delta_{CP} marginalized over IO;#delta_{CP};Normalized Entries", nBins_dcp, -3.1415, 3.1415);
1483 tree->Draw(
"delta_cp>>h1d_delta_cp_io_log", ioSelection.c_str(),
"");
1484 normalizeHist(h1d_delta_cp_io_log);
1485 h1d_delta_cp_io_log->SetStats(0);
1486 double ioMinPositive = 1.0;
1487 bool ioFoundPositive =
false;
1488 for (
int b = 1; b <= h1d_delta_cp_io_log->GetNbinsX(); ++b) {
1489 double y = h1d_delta_cp_io_log->GetBinContent(b);
1491 if (!ioFoundPositive || y < ioMinPositive) {
1494 ioFoundPositive =
true;
1497 h1d_delta_cp_io_log->SetMinimum(ioFoundPositive ? 0.5 * ioMinPositive : 1e-8);
1498 h1d_delta_cp_io_log->Draw(
"HIST");
1499 h1d_delta_cp_io_log->Draw(
"E SAME");
1500 drawAsimovLineWithLegend(asimovDcp);
1501 if (hasReferenceLLH_Dcp_IO && hRefLLH_Dcp_IO) {
1502 TH1D *hLLHIO =
new TH1D(
"hRefLLH_dcp_io_resamp",
"", h1d_delta_cp_io_log->GetNbinsX(), h1d_delta_cp_io_log->GetXaxis()->GetXmin(), h1d_delta_cp_io_log->GetXaxis()->GetXmax());
1503 hLLHIO->SetDirectory(0);
1504 for (
int i = 1; i <= hLLHIO->GetNbinsX(); ++i) {
1505 double xlow = hLLHIO->GetBinLowEdge(i);
1506 double xhigh = hLLHIO->GetBinLowEdge(i+1);
1508 int nOrig = hRefLLH_Dcp_IO->GetNbinsX();
1509 for (
int k = 1; k <= nOrig; ++k) {
1510 double origLow = hRefLLH_Dcp_IO->GetXaxis()->GetBinLowEdge(k);
1511 double origHigh = origLow + hRefLLH_Dcp_IO->GetBinWidth(k);
1512 double overlap = std::max(0.0, std::min(origHigh, xhigh) - std::max(origLow, xlow));
1513 if (overlap > 0.0) {
1514 double origWidth = hRefLLH_Dcp_IO->GetBinWidth(k);
1515 double contrib = hRefLLH_Dcp_IO->GetBinContent(k) * (overlap / origWidth);
1519 hLLHIO->SetBinContent(i, val);
1521 double li = hLLHIO->Integral();
1522 if (li > 0) hLLHIO->Scale(h1d_delta_cp_io_log->Integral() / li);
1523 hLLHIO->SetLineColor(kBlue + 2);
1524 hLLHIO->SetLineWidth(2);
1525 hLLHIO->SetLineStyle(2);
1526 hLLHIO->Draw(
"HIST SAME");
1527 TLegend *legLLHIO =
new TLegend(0.50, 0.60, 0.88, 0.74);
1528 legLLHIO->SetBorderSize(0);
1529 legLLHIO->SetFillStyle(0);
1530 legLLHIO->AddEntry(h1d_delta_cp_io_log,
"Umbrella weighted (IO)",
"l");
1531 legLLHIO->AddEntry(hLLHIO,
"LLH scan IO (resampled & area-normalized)",
"l");
1538 TH1F *h1d_delta_cp_no_log =
new TH1F(
"h1d_delta_cp_no_log",
"#delta_{CP} marginalized over NO;#delta_{CP};Normalized Entries", nBins_dcp, -3.1415, 3.1415);
1539 tree->Draw(
"delta_cp>>h1d_delta_cp_no_log", noSelection.c_str(),
"");
1540 normalizeHist(h1d_delta_cp_no_log);
1541 h1d_delta_cp_no_log->SetStats(0);
1542 double noMinPositive = 1.0;
1543 bool noFoundPositive =
false;
1544 for (
int b = 1; b <= h1d_delta_cp_no_log->GetNbinsX(); ++b) {
1545 double y = h1d_delta_cp_no_log->GetBinContent(b);
1547 if (!noFoundPositive || y < noMinPositive) {
1550 noFoundPositive =
true;
1553 h1d_delta_cp_no_log->SetMinimum(noFoundPositive ? 0.5 * noMinPositive : 1e-8);
1554 h1d_delta_cp_no_log->Draw(
"HIST");
1555 h1d_delta_cp_no_log->Draw(
"E SAME");
1556 drawAsimovLineWithLegend(asimovDcp);
1557 if (hasReferenceLLH_Dcp_NO && hRefLLH_Dcp_NO) {
1558 TH1D *hLLHNO =
new TH1D(
"hRefLLH_dcp_no_resamp",
"", h1d_delta_cp_no_log->GetNbinsX(), h1d_delta_cp_no_log->GetXaxis()->GetXmin(), h1d_delta_cp_no_log->GetXaxis()->GetXmax());
1559 hLLHNO->SetDirectory(0);
1560 for (
int i = 1; i <= hLLHNO->GetNbinsX(); ++i) {
1561 double xlow = hLLHNO->GetBinLowEdge(i);
1562 double xhigh = hLLHNO->GetBinLowEdge(i+1);
1564 int nOrig = hRefLLH_Dcp_NO->GetNbinsX();
1565 for (
int k = 1; k <= nOrig; ++k) {
1566 double origLow = hRefLLH_Dcp_NO->GetXaxis()->GetBinLowEdge(k);
1567 double origHigh = origLow + hRefLLH_Dcp_NO->GetBinWidth(k);
1568 double overlap = std::max(0.0, std::min(origHigh, xhigh) - std::max(origLow, xlow));
1569 if (overlap > 0.0) {
1570 double origWidth = hRefLLH_Dcp_NO->GetBinWidth(k);
1571 double contrib = hRefLLH_Dcp_NO->GetBinContent(k) * (overlap / origWidth);
1575 hLLHNO->SetBinContent(i, val);
1577 double ln = hLLHNO->Integral();
1578 if (ln > 0) hLLHNO->Scale(h1d_delta_cp_no_log->Integral() / ln);
1579 hLLHNO->SetLineColor(kBlue + 2);
1580 hLLHNO->SetLineWidth(2);
1581 hLLHNO->SetLineStyle(2);
1582 hLLHNO->Draw(
"HIST SAME");
1583 TLegend *legLLHNO =
new TLegend(0.50, 0.60, 0.88, 0.74);
1584 legLLHNO->SetBorderSize(0);
1585 legLLHNO->SetFillStyle(0);
1586 legLLHNO->AddEntry(h1d_delta_cp_no_log,
"Umbrella weighted (NO)",
"l");
1587 legLLHNO->AddEntry(hLLHNO,
"LLH scan NO (resampled & area-normalized)",
"l");
1592 c9->SaveAs((outputDir +
"delta_cp_log_scale_marginalized_io_no.png").c_str());
1595 const double jarlskogMin = -0.06;
1596 const double jarlskogMax = 0.06;
1597 const int nBinsJarlskog = 160;
1599 TCanvas *c10 =
new TCanvas(
"c10",
"Jarlskog Invariant", 900, 700);
1600 TH1F *h1d_jarlskog_unweighted =
new TH1F(
"h1d_jarlskog_unweighted",
"Jarlskog invariant;Jarlskog invariant;Entries",
1601 nBinsJarlskog, jarlskogMin, jarlskogMax);
1602 tree->Draw(
"TMath::Sqrt(TMath::Max(0.,sin2th_12)*TMath::Max(0.,1.-sin2th_12)*TMath::Max(0.,sin2th_23)*TMath::Max(0.,1.-sin2th_23))*TMath::Max(0.,1.-sin2th_13)*TMath::Sqrt(TMath::Max(0.,sin2th_13))*TMath::Sin(delta_cp)>>h1d_jarlskog_unweighted",
1604 normalizeHist(h1d_jarlskog_unweighted);
1605 h1d_jarlskog_unweighted->SetStats(0);
1606 h1d_jarlskog_unweighted->Draw(
"HIST");
1607 h1d_jarlskog_unweighted->Draw(
"E SAME");
1608 drawAsimovLineWithLegend(asimovJarlskog);
1610 auto computeOneSidedBounds = [&](TH1 *hist,
double targets[3],
double outBounds[3]) {
1613 for (
int i = 0; i < 3; ++i) outBounds[i] = std::numeric_limits<double>::quiet_NaN();
1615 double total = hist->Integral();
1616 if (total <= 0)
return;
1617 int nBins = hist->GetNbinsX();
1619 double leftSum = 0.0;
1620 double rightSum = 0.0;
1621 for (
int b = 1; b <= nBins; ++b) {
1622 double center = hist->GetBinCenter(b);
1623 double c = hist->GetBinContent(b);
1624 if (center < 0) leftSum += c;
else rightSum += c;
1626 bool integrateLeftToRight = (leftSum >= rightSum);
1628 for (
int t = 0; t < 3; ++t) {
1629 double target = targets[t];
1631 if (integrateLeftToRight) {
1632 for (
int b = 1; b <= nBins; ++b) {
1633 cum += hist->GetBinContent(b);
1634 if (cum / total >= target) {
1636 outBounds[t] = hist->GetBinLowEdge(b+1);
1641 if (!std::isfinite(outBounds[t])) outBounds[t] = hist->GetXaxis()->GetXmax();
1643 for (
int b = nBins; b >= 1; --b) {
1644 cum += hist->GetBinContent(b);
1645 if (cum / total >= target) {
1647 outBounds[t] = hist->GetBinLowEdge(b);
1651 if (!std::isfinite(outBounds[t])) outBounds[t] = hist->GetXaxis()->GetXmin();
1655 double hist_ymax = hist->GetMaximum();
1657 int colors[3] = {kOrange+1, kAzure+2, kMagenta+2};
1658 for (
int t = 0; t < 3; ++t) {
1659 if (!std::isfinite(outBounds[t]))
continue;
1660 TLine *line =
nullptr;
1661 if (integrateLeftToRight) {
1663 line =
new TLine(outBounds[t], 0, outBounds[t], hist_ymax);
1666 line =
new TLine(outBounds[t], 0, outBounds[t], hist_ymax);
1668 line->SetLineColor(colors[t]);
1669 line->SetLineStyle(2);
1670 line->SetLineWidth(2);
1676 c10->SaveAs((outputDir +
"jarlskog_unweighted.png").c_str());
1678 TCanvas *c10_log =
new TCanvas(
"c10_log",
"Jarlskog Invariant Log Scale", 900, 700);
1680 TH1F *h1d_jarlskog_unweighted_log = (TH1F*)h1d_jarlskog_unweighted->Clone(
"h1d_jarlskog_unweighted_log");
1681 h1d_jarlskog_unweighted_log->SetTitle(
"Jarlskog invariant (Log Scale);Jarlskog invariant;Entries");
1682 h1d_jarlskog_unweighted_log->Draw(
"HIST");
1683 h1d_jarlskog_unweighted_log->Draw(
"E SAME");
1684 drawAsimovLineWithLegend(asimovJarlskog);
1687 c10_log->SaveAs((outputDir +
"jarlskog_unweighted_log.png").c_str());
1689 TCanvas *c10_weighted =
new TCanvas(
"c10_weighted",
"Jarlskog Invariant Weighted", 900, 700);
1690 TH1F *h1d_jarlskog_weighted =
new TH1F(
"h1d_jarlskog_weighted",
"Jarlskog invariant;Jarlskog invariant;Weighted Entries",
1691 nBinsJarlskog, jarlskogMin, jarlskogMax);
1692 if (hasUmbrellaWeight) {
1693 tree->Draw(
"TMath::Sqrt(TMath::Max(0.,sin2th_12)*TMath::Max(0.,1.-sin2th_12)*TMath::Max(0.,sin2th_23)*TMath::Max(0.,1.-sin2th_23))*TMath::Max(0.,1.-sin2th_13)*TMath::Sqrt(TMath::Max(0.,sin2th_13))*TMath::Sin(delta_cp)>>h1d_jarlskog_weighted",
1694 "umbrella_weight",
"");
1696 tree->Draw(
"TMath::Sqrt(TMath::Max(0.,sin2th_12)*TMath::Max(0.,1.-sin2th_12)*TMath::Max(0.,sin2th_23)*TMath::Max(0.,1.-sin2th_23))*TMath::Max(0.,1.-sin2th_13)*TMath::Sqrt(TMath::Max(0.,sin2th_13))*TMath::Sin(delta_cp)>>h1d_jarlskog_weighted",
1698 std::cout <<
"WARNING:::::No umbrella weights found, plotting unweighted Jarlskog histogram." << std::endl;
1700 normalizeHist(h1d_jarlskog_weighted);
1701 h1d_jarlskog_weighted->SetStats(0);
1702 h1d_jarlskog_weighted->Sumw2();
1703 h1d_jarlskog_weighted->Draw(
"HIST");
1704 h1d_jarlskog_weighted->Draw(
"E SAME");
1705 drawAsimovLineWithLegend(asimovJarlskog);
1707 double targets[3] = {sigma1, sigma3, sigma5};
1709 computeOneSidedBounds(h1d_jarlskog_weighted, targets, bounds);
1711 double ymax_w = h1d_jarlskog_weighted->GetMaximum();
1712 TLine *legLine1 =
nullptr;
1713 TLine *legLine3 =
nullptr;
1714 TLine *legLine5 =
nullptr;
1715 if (std::isfinite(bounds[0])) legLine1 =
new TLine(bounds[0], 0, bounds[0], ymax_w);
1716 if (std::isfinite(bounds[1])) legLine3 =
new TLine(bounds[1], 0, bounds[1], ymax_w);
1717 if (std::isfinite(bounds[2])) legLine5 =
new TLine(bounds[2], 0, bounds[2], ymax_w);
1718 if (legLine1) { legLine1->SetLineColor(kOrange+1); legLine1->SetLineStyle(2); legLine1->SetLineWidth(2); }
1719 if (legLine3) { legLine3->SetLineColor(kAzure+2); legLine3->SetLineStyle(2); legLine3->SetLineWidth(2); }
1720 if (legLine5) { legLine5->SetLineColor(kMagenta+2); legLine5->SetLineStyle(2); legLine5->SetLineWidth(2); }
1721 TLegend *legCI =
new TLegend(0.15, 0.60, 0.50, 0.74);
1722 legCI->SetBorderSize(0);
1723 legCI->SetFillStyle(0);
1724 if (legLine1) legCI->AddEntry(legLine1,
"1 #sigma (one-sided)",
"l");
1725 if (legLine3) legCI->AddEntry(legLine3,
"3 #sigma (one-sided)",
"l");
1726 if (legLine5) legCI->AddEntry(legLine5,
"5 #sigma (one-sided)",
"l");
1728 c10_weighted->Update();
1729 c10_weighted->SaveAs((outputDir +
"jarlskog_weighted.png").c_str());
1731 TCanvas *c10_weighted_log =
new TCanvas(
"c10_weighted_log",
"Jarlskog Invariant Weighted Log Scale", 900, 700);
1732 c10_weighted_log->SetLogy();
1733 TH1F *h1d_jarlskog_weighted_log = (TH1F*)h1d_jarlskog_weighted->Clone(
"h1d_jarlskog_weighted_log");
1734 h1d_jarlskog_weighted_log->SetTitle(
"Jarlskog invariant (Log Scale);Jarlskog invariant;Weighted Entries");
1735 h1d_jarlskog_weighted_log->Draw(
"HIST");
1736 h1d_jarlskog_weighted_log->Draw(
"E SAME");
1737 drawAsimovLineWithLegend(asimovJarlskog);
1739 for (
int t = 0; t < 3; ++t) {
1740 if (!std::isfinite(bounds[t]))
continue;
1741 double hist_ymax = h1d_jarlskog_weighted_log->GetMaximum();
1742 int colors_log[3] = {kOrange+1, kAzure+2, kMagenta+2};
1743 TLine *line =
new TLine(bounds[t], 0, bounds[t], hist_ymax);
1744 line->SetLineColor(colors_log[t]);
1745 line->SetLineStyle(2);
1746 line->SetLineWidth(2);
1750 TLegend *legCI_log =
new TLegend(0.15, 0.60, 0.50, 0.74);
1751 legCI_log->SetBorderSize(0);
1752 legCI_log->SetFillStyle(0);
1753 if (legLine1) legCI_log->AddEntry(legLine1,
"1 #sigma (one-sided)",
"l");
1754 if (legLine3) legCI_log->AddEntry(legLine3,
"3 #sigma (one-sided)",
"l");
1755 if (legLine5) legCI_log->AddEntry(legLine5,
"5 #sigma (one-sided)",
"l");
1757 c10_weighted_log->Update();
1758 c10_weighted_log->SaveAs((outputDir +
"jarlskog_weighted_log.png").c_str());
1760 struct TriangleVar {
1770 std::vector<TriangleVar> triangleVars = {
1771 {
"delta_cp",
"#delta_{CP}",
"delta_cp", nBins_dcp, -3.1415, 3.1415, asimovDcp},
1772 {
"sin2th_23",
"sin^{2}(#theta_{23})",
"sin2th_23", nBins_sin2th23, sin2th23_min, sin2th23_max, asimovSin2th23},
1773 {
"sin2th_13",
"sin^{2}(#theta_{13})",
"sin2th_13", nBins_sin2th13, sin2th13_min, sin2th13_max, asimovSin2th13},
1774 {
"sin2th_12",
"sin^{2}(#theta_{12})",
"sin2th_12", nBins_sin2th12, sin2th12_min, sin2th12_max, asimovSin2th12},
1775 {
"delm2_23",
"#Delta m_{23}^{2} (eV^{2})",
"delm2_23", nBins_delm23, delm23_io_min, delm23_no_max, asimovDelm23},
1776 {
"delm2_12",
"#Delta m_{12}^{2} (eV^{2})",
"delm2_12", nBins_delm12, delm12_min, delm12_max, asimovDelm12}
1779 auto drawAsimovLineNoLegend = [&](
double xValue) {
1780 if (!isAsimovChain || !std::isfinite(xValue) || !gPad)
return;
1782 const double yMin = gPad->GetUymin();
1783 const double yMax = gPad->GetUymax();
1784 TLine *asimovLine =
new TLine(xValue, yMin, xValue, yMax);
1785 asimovLine->SetLineColor(kBlack);
1786 asimovLine->SetLineStyle(3);
1787 asimovLine->SetLineWidth(2);
1788 asimovLine->Draw(
"SAME");
1791 auto drawAsimovMarkerNoLegend = [&](
double xValue,
double yValue) {
1792 if (!isAsimovChain || !std::isfinite(xValue) || !std::isfinite(yValue) || !gPad)
return;
1794 const double xMin = gPad->GetUxmin();
1795 const double xMax = gPad->GetUxmax();
1796 const double yMin = gPad->GetUymin();
1797 const double yMax = gPad->GetUymax();
1798 const double dx = 0.012 * (xMax - xMin);
1799 const double dy = 0.012 * (yMax - yMin);
1801 TLine *l1 =
new TLine(xValue - dx, yValue - dy, xValue + dx, yValue + dy);
1802 l1->SetLineColor(kRed);
1803 l1->SetLineWidth(2);
1806 TLine *l2 =
new TLine(xValue - dx, yValue + dy, xValue + dx, yValue - dy);
1807 l2->SetLineColor(kRed);
1808 l2->SetLineWidth(2);
1812 auto drawTrianglePlot = [&](
const std::string &weightExpr,
const std::string &suffix,
int mo = 0) {
1814 std::cout <<
"Drawing triangle plot for IO" << std::endl;
1815 triangleVars[4].min = delm23_no_min;
1816 triangleVars[4].max = delm23_no_max;
1817 }
else if (mo == -1) {
1818 std::cout <<
"Drawing triangle plot for NO" << std::endl;
1819 triangleVars[4].min = delm23_io_min;
1820 triangleVars[4].max = delm23_io_max;
1822 std::cout <<
"Drawing triangle plot for both MO" << std::endl;
1825 const int nVars =
static_cast<int>(triangleVars.size());
1826 TCanvas *cTri =
new TCanvas((
"c_triangle" + suffix).c_str(),
"Triangle Plot", 1400, 1400);
1827 cTri->SetFillStyle(0);
1831 const double TPm[4] = {.07, .07, .05, .05};
1832 const double Pm[2] = {.2, .1};
1834 const double TPw = 1.0 - TPm[0] - TPm[2];
1835 const double a_x = (Pm[0] * TPw) / (1.0 * nVars + Pm[0] * (1.0 - 1.0 * nVars));
1836 const double b_x = (TPw - a_x) / (1.0 * nVars);
1838 std::vector<double> X_Min(nVars), X_Max(nVars);
1840 X_Max[0] = X_Min[0] + a_x + b_x;
1841 for (
int i = 1; i < nVars; ++i) {
1842 X_Min[i] = X_Max[i - 1];
1843 X_Max[i] = X_Min[i] + b_x;
1846 const double TPh = 1.0 - TPm[1] - TPm[3];
1847 const double a_y = (Pm[1] * TPh) / (1.0 * nVars + Pm[1] * (1.0 - 1.0 * nVars));
1848 const double b_y = (TPh - a_y) / (1.0 * nVars);
1850 std::vector<double> Y_Min(nVars), Y_Max(nVars);
1851 Y_Min[nVars - 1] = TPm[1];
1852 Y_Max[nVars - 1] = Y_Min[nVars - 1] + a_y + b_y;
1853 for (
int i = nVars - 2; i >= 0; --i) {
1854 Y_Min[i] = Y_Max[i + 1];
1855 Y_Max[i] = Y_Min[i] + b_y;
1858 for (
int row = 0; row < nVars; ++row) {
1859 for (
int col = 0; col <= row; ++col) {
1860 const double x1 = X_Min[col];
1861 const double x2 = X_Max[col];
1862 const double y1 = Y_Min[row];
1863 const double y2 = Y_Max[row];
1865 TPad *pad =
new TPad(Form(
"tri_pad_%s_%d_%d", suffix.c_str(), row, col),
"", x1, y1, x2, y2);
1866 pad->SetFillStyle(0);
1867 pad->SetRightMargin(0.02);
1868 pad->SetTopMargin(0.02);
1869 pad->SetLeftMargin(col == 0 ? 0.26 : 0.06);
1870 pad->SetBottomMargin(row == nVars - 1 ? 0.18 : 0.06);
1874 const TriangleVar &xVar = triangleVars[col];
1875 const TriangleVar &yVar = triangleVars[row];
1878 TH1F *h1 =
new TH1F(Form(
"h_tri_1d_%s_%s", suffix.c_str(), xVar.name.c_str()),
1879 "", xVar.bins, xVar.min, xVar.max);
1880 std::string drawExpr = xVar.branch +
">>" + h1->GetName();
1881 tree->Draw(drawExpr.c_str(), weightExpr.c_str(),
"goff");
1884 h1->GetXaxis()->SetTitle(row == nVars - 1 ? xVar.title.c_str() :
"");
1885 h1->GetYaxis()->SetTitle(col == 0 ?
"Entries" :
"");
1886 h1->GetXaxis()->SetLabelSize(row == nVars - 1 ? 0.07 : 0.0);
1887 h1->GetYaxis()->SetLabelSize(col == 0 ? 0.07 : 0.0);
1888 h1->GetXaxis()->SetTitleSize(row == nVars - 1 ? 0.08 : 0.0);
1889 h1->GetYaxis()->SetTitleSize(col == 0 ? 0.08 : 0.0);
1892 drawAsimovLineNoLegend(xVar.asimov);
1894 TH2F *h2 =
new TH2F(Form(
"h_tri_2d_%s_%s_%s", suffix.c_str(), yVar.name.c_str(), xVar.name.c_str()),
1895 "", xVar.bins, xVar.min, xVar.max, yVar.bins, yVar.min, yVar.max);
1896 std::string drawExpr = yVar.branch +
":" + xVar.branch +
">>" + h2->GetName();
1897 tree->Draw(drawExpr.c_str(), weightExpr.c_str(),
"goff");
1900 h2->GetXaxis()->SetTitle(row == nVars - 1 ? xVar.title.c_str() :
"");
1901 h2->GetYaxis()->SetTitle(col == 0 ? yVar.title.c_str() :
"");
1902 h2->GetXaxis()->SetLabelSize(row == nVars - 1 ? 0.07 : 0.0);
1903 h2->GetYaxis()->SetLabelSize(col == 0 ? 0.07 : 0.0);
1904 h2->GetXaxis()->SetTitleSize(row == nVars - 1 ? 0.08 : 0.0);
1905 h2->GetYaxis()->SetTitleSize(col == 0 ? 0.08 : 0.0);
1907 drawAsimovMarkerNoLegend(xVar.asimov, yVar.asimov);
1915 cTri->SaveAs((outputDir +
"triangle" + suffix +
".png").c_str());
1918 drawTrianglePlot(
"",
"_unweighted", 0);
1919 if (hasUmbrellaWeight) {
1920 drawTrianglePlot(
"umbrella_weight",
"_weighted", 0);
1922 std::cout <<
"WARNING:::::No umbrella weights found, skipping weighted triangle plot." << std::endl;
1925 drawTrianglePlot(
"(delm2_23 < 0)",
"_io_unweighted",-1);
1926 drawTrianglePlot(
"(delm2_23 > 0)",
"_no_unweighted",1);
1927 if (hasUmbrellaWeight) {
1928 drawTrianglePlot(
"(delm2_23 < 0) * umbrella_weight",
"_io_weighted",-1);
1929 drawTrianglePlot(
"(delm2_23 > 0) * umbrella_weight",
"_no_weighted",1);
1931 std::cout <<
"WARNING:::::No umbrella weights found, skipping weighted triangle plots marginalized by ordering." << std::endl;