12 #pragma GCC diagnostic ignored "-Wfloat-conversion"
47 for (
int i = 0; i <
nDraw; ++i)
52 const std::string CurrentName =
ParamNames[ParamEnum][ParamNo].Data();
55 if (CurrentName ==
"sin2th_13") {
58 }
else if (CurrentName ==
"sin2th_12") {
61 }
else if (CurrentName ==
"sin2th_23") {
64 }
else if (CurrentName ==
"delta_cp") {
67 }
else if (CurrentName ==
"delm2_23") {
78 Chain->SetAlias(
"J_cp",
"TMath::Sqrt(sin2th_13)*TMath::Sqrt(1.-sin2th_13)*TMath::Sqrt(1.-sin2th_13)*TMath::Sqrt(sin2th_12)*TMath::Sqrt(1.-sin2th_12)*TMath::Sqrt(sin2th_23)*TMath::Sqrt(1.-sin2th_23)*TMath::Sin(delta_cp)");
100 const double s13 = std::sqrt(s2th13);
101 const double s23 = std::sqrt(s2th23);
102 const double s12 = std::sqrt(s2th12);
103 const double sdcp = std::sin(dcp);
104 const double c13 = std::sqrt(1.-s2th13);
105 const double c12 = std::sqrt(1.-s2th12);
106 const double c23 = std::sqrt(1.-s2th23);
108 const double j = s13*c13*c13*s12*c12*s23*c23*sdcp;
117 double Prior = 1.0, PriorError = 1.0;
118 bool FlatPrior =
false;
125 FlatPrior =
ParamFlat[ParType][ParamTemp];
128 return randGen->Uniform(FlatBounds[0], FlatBounds[1]);
131 return randGen->Gaus(Prior, PriorError);
139 MACH3LOG_INFO(
"Found more than 1 weight for Jarlskog analysis");
143 TFile *TempFile =
M3::Open((
MCMCFile +
".root"),
"open", __FILE__, __LINE__);
146 TMacro *Config = TempFile->Get<TMacro>(
"Reweight_Config");
149 if (Config !=
nullptr) {
156 int dimension = Get<int>(firstReweight[
"ReweightDim"], __FILE__ , __LINE__);
157 std::string reweightType = Get<std::string>(firstReweight[
"ReweightType"],__FILE__ , __LINE__);
158 auto paramNames = Get<std::vector<std::string>>(firstReweight[
"ReweightVar"], __FILE__ , __LINE__);
159 if (dimension == 1 && reweightType ==
"Gaussian" && paramNames.size() == 1){
160 auto Priors = Get<std::vector<std::pair<double, double>>>(firstReweight[
"ReweightPrior"], __FILE__,__LINE__);
161 Sin13_NewPrior = Priors[0];
164 MACH3LOG_INFO(
"No valid reweighting configuration (1D Gaussian on sin2th_13 only) found for Jarlskog analysis");
167 MACH3LOG_INFO(
"No reweighting configuration found for Jarlskog analysis");
186 MACH3LOG_WARN(
"Will not {}, as oscillation parameters are missing", __func__);
194 bool DoReweight =
false;
195 std::pair<double, double> Sin13_NewPrior;
198 TDirectory *JarlskogDir =
OutputFile->mkdir(
"Jarlskog");
201 unsigned int step = 0;
202 Chain->SetBranchStatus(
"*",
false);
219 Chain->SetBranchStatus(
"step",
true);
220 Chain->SetBranchAddress(
"step", &step);
231 auto jarl = std::make_unique<TH1D>(
"jarl",
"jarl", 1000, -0.05, 0.05);
232 jarl->SetDirectory(
nullptr);
233 auto jarl_th23 = std::make_unique<TH2D>(
"jarl_th23",
"jarl_th23", 500, -0.05, 0.05, 500, 0.3, 0.7);
234 jarl_th23->SetDirectory(
nullptr);
235 auto jarl_dcp = std::make_unique<TH2D>(
"jarl_dcp",
"jarl_dcp", 500, -0.05, 0.05, 500, -1. * TMath::Pi(), TMath::Pi());
236 jarl_dcp->SetDirectory(
nullptr);
238 jarl->SetTitle(
"Jarlskog Invariant;J #equiv s_{13}c_{13}^{2}s_{12}c_{12}s_{23}c_{23}sin#delta;Posterior probability");
239 jarl_th23->SetTitle(
"Jarlskog Invariant;J #equiv s_{13}c_{13}^{2}s_{12}c_{12}s_{23}c_{23}sin#delta;Posterior probability");
242 auto jarl_IH =
M3::Clone(jarl.get(),
"jarl_IH");
243 auto jarl_NH =
M3::Clone(jarl.get(),
"jarl_NH");
245 auto jarl_th23_IH =
M3::Clone(jarl_th23.get(),
"jarl_th23_IH");
246 auto jarl_th23_NH =
M3::Clone(jarl_th23.get(),
"jarl_th23_NH");
248 auto jarl_dcp_IH =
M3::Clone(jarl_dcp.get(),
"jarl_dcp_IH");
249 auto jarl_dcp_NH =
M3::Clone(jarl_dcp.get(),
"jarl_dcp_NH");
251 auto jarl_flatsindcp =
M3::Clone(jarl.get(),
"jarl_flatsindcp");
252 auto jarl_IH_flatsindcp =
M3::Clone(jarl.get(),
"jarl_IH_flatsindcp");
253 auto jarl_NH_flatsindcp =
M3::Clone(jarl.get(),
"jarl_NH_flatsindcp");
255 auto jarl_th23_flatsindcp =
M3::Clone(jarl_th23.get(),
"jarl_th23_flatsindcp");
256 auto jarl_th23_IH_flatsindcp =
M3::Clone(jarl_th23.get(),
"jarl_th23_IH_flatsindcp");
257 auto jarl_th23_NH_flatsindcp =
M3::Clone(jarl_th23.get(),
"jarl_th23_NH_flatsindcp");
259 auto jarl_prior =
M3::Clone(jarl.get(),
"jarl_prior");
260 auto jarl_prior_flatsindcp =
M3::Clone(jarl.get(),
"jarl_prior_flatsindcp");
261 std::unique_ptr<TH1D> jarl_wRC_prior, jarl_wRC_prior_flatsindcp, jarl_wRC_prior_t2kth23;
264 jarl_wRC_prior =
M3::Clone(jarl.get(),
"jarl_wRC_prior");
265 jarl_wRC_prior_flatsindcp =
M3::Clone(jarl.get(),
"jarl_wRC_prior_flatsindcp");
266 jarl_wRC_prior_t2kth23 =
M3::Clone(jarl.get(),
"jarl_wRC_prior_flatsindcp");
270 auto prior3 = std::make_unique<TF1>(
"prior3",
"TMath::Abs(TMath::Cos(x))");
273 auto randGen = std::make_unique<TRandom3>(0);
274 const Long64_t countwidth =
nEntries/5;
277 if (i % countwidth == 0) {
286 const double j =
CalcJarlskog(s2th13, s2th23, s2th12, dcp);
287 const double prior_weight = prior3->Eval(dcp);
289 jarl->Fill(j, weight);
290 jarl_th23->Fill(j, s2th23, weight);
291 jarl_dcp->Fill(j, dcp, weight);
293 jarl_flatsindcp->Fill(j, prior_weight*weight);
294 jarl_th23_flatsindcp->Fill(j, s2th23, prior_weight*weight);
301 const double prior_sindcp = randGen->Uniform(-1., 1.);
303 const double prior_s13 = std::sqrt(prior_s2th13);
304 const double prior_s23 = std::sqrt(prior_s2th23);
305 const double prior_s12 = std::sqrt(prior_s2th12);
306 const double prior_sdcp = std::sin(prior_dcp);
307 const double prior_c13 = std::sqrt(1.-prior_s2th13);
308 const double prior_c12 = std::sqrt(1.-prior_s2th12);
309 const double prior_c23 = std::sqrt(1.-prior_s2th23);
310 const double prior_j = prior_s13*prior_c13*prior_c13*prior_s12*prior_c12*prior_s23*prior_c23*prior_sdcp;
311 const double prior_flatsindcp_j = prior_s13*prior_c13*prior_c13*prior_s12*prior_c12*prior_s23*prior_c23*prior_sindcp;
313 jarl_prior->Fill(prior_j);
314 jarl_prior_flatsindcp->Fill(prior_flatsindcp_j);
317 const double prior_wRC_s2th13 = randGen->Gaus(Sin13_NewPrior.first, Sin13_NewPrior.second);
318 const double prior_wRC_s13 = std::sqrt(prior_wRC_s2th13);
319 const double prior_wRC_c13 = std::sqrt(1.-prior_wRC_s2th13);
320 const double prior_wRC_j = prior_wRC_s13*prior_wRC_c13*prior_wRC_c13*prior_s12*prior_c12*prior_s23*prior_c23*prior_sdcp;
321 const double prior_wRC_flatsindcp_j = prior_wRC_s13*prior_wRC_c13*prior_wRC_c13*prior_s12*prior_c12*prior_s23*prior_c23*prior_sindcp;
322 const double s23 = std::sqrt(s2th23);
323 const double c23 = std::sqrt(1.-s2th23);
325 jarl_wRC_prior->Fill(prior_wRC_j);
326 jarl_wRC_prior_flatsindcp->Fill(prior_wRC_flatsindcp_j);
327 jarl_wRC_prior_t2kth23->Fill(prior_wRC_s13*prior_wRC_c13*prior_wRC_c13*prior_s12*prior_c12*s23*c23*prior_sdcp);
331 jarl_NH->Fill(j, weight);
332 jarl_th23_NH->Fill(j, s2th23, weight);
333 jarl_dcp_NH->Fill(j, dcp, weight);
334 jarl_NH_flatsindcp->Fill(j, prior_weight*weight);
335 jarl_th23_NH_flatsindcp->Fill(j, s2th23, prior_weight*weight);
338 jarl_IH->Fill(j, weight);
339 jarl_th23_IH->Fill(j, s2th23, weight);
340 jarl_dcp_IH->Fill(j, dcp, weight);
341 jarl_IH_flatsindcp->Fill(j, prior_weight*weight);
342 jarl_th23_IH_flatsindcp->Fill(j, s2th23, prior_weight*weight);
346 jarl->Write(
"jarlskog_both");
347 jarl_NH->Write(
"jarlskog_NH");
348 jarl_IH->Write(
"jarlskog_IH");
349 jarl_th23->Write(
"jarlskog_th23_both");
350 jarl_th23_NH->Write(
"jarlskog_th23_NH");
351 jarl_th23_IH->Write(
"jarlskog_th23_IH");
353 jarl_dcp->Write(
"jarlskog_dcp_both");
354 jarl_dcp_NH->Write(
"jarlskog_dcp_NH");
355 jarl_dcp_IH->Write(
"jarlskog_dcp_IH");
358 jarl_flatsindcp->Write(
"jarlskog_both_flatsindcp");
359 jarl_NH_flatsindcp->Write(
"jarlskog_NH_flatsindcp");
360 jarl_IH_flatsindcp->Write(
"jarlskog_IH_flatsindcp");
361 jarl_th23_flatsindcp->Write(
"jarlskog_th23_both_flatsindcp");
362 jarl_th23_NH_flatsindcp->Write(
"jarlskog_th23_NH_flatsindcp");
363 jarl_th23_IH_flatsindcp->Write(
"jarlskog_th23_IH_flatsindcp");
365 jarl_prior->Write(
"jarl_prior");
366 jarl_prior_flatsindcp->Write(
"jarl_prior_flatsindcp");
368 jarl_wRC_prior->Write(
"jarl_wRC_prior");
369 jarl_wRC_prior_flatsindcp->Write(
"jarl_wRC_prior_flatsindcp");
370 jarl_wRC_prior_t2kth23->Write(
"jarl_wRC_prior_t2kth23");
374 jarl_NH, jarl_NH_flatsindcp,
375 jarl_IH, jarl_IH_flatsindcp);
380 SavageDickeyPlot(jarl_flatsindcp, jarl_wRC_prior_flatsindcp,
"Jarlskog flat sin#delta_{CP}", 0);
383 SavageDickeyPlot(jarl_flatsindcp, jarl_prior_flatsindcp,
"Jarlskog flat sin#delta_{CP}", 0);
386 JarlskogDir->Close();
389 Chain->SetBranchStatus(
"*",
true);
396 const std::unique_ptr<TH1D>& jarl_flatsindcp,
397 const std::unique_ptr<TH1D>& jarl_NH,
398 const std::unique_ptr<TH1D>& jarl_NH_flatsindcp,
399 const std::unique_ptr<TH1D>& jarl_IH,
400 const std::unique_ptr<TH1D>& jarl_IH_flatsindcp) {
403 int originalErrorLevel = gErrorIgnoreLevel;
404 gErrorIgnoreLevel = kFatal;
407 for(
int hierarchy = -1; hierarchy <= 1; hierarchy++)
409 std::unique_ptr<TH1D> j_hist;
410 std::unique_ptr<TH1D> j_hist_sdcp;
413 j_hist_sdcp =
M3::Clone(jarl_NH_flatsindcp.get(),
"");
414 j_hist->SetTitle(
";J_{CP} #equiv s_{13}c^{2}_{13}s_{12}c_{12}s_{23}c_{23}sin#delta_{CP};Posterior probability");
415 }
else if(hierarchy == 0) {
417 j_hist_sdcp =
M3::Clone(jarl_flatsindcp.get(),
"");
418 j_hist->SetTitle(
";J_{CP} #equiv s_{13}c^{2}_{13}s_{12}c_{12}s_{23}c_{23}sin#delta_{CP};Posterior probability");
419 }
else if(hierarchy == -1) {
421 j_hist_sdcp =
M3::Clone(jarl_IH_flatsindcp.get(),
"");
422 j_hist->SetTitle(
";J_{CP} #equiv s_{13}c^{2}_{13}s_{12}c_{12}s_{23}c_{23}sin#delta_{CP};Posterior probability");
424 MACH3LOG_ERROR(
"Invalid hierarchy option. 1 for NH, 0 for both, -1 for IH");
429 j_hist_sdcp->Rebin(7);
431 j_hist->SetLineColor(kAzure-2);
432 j_hist_sdcp->SetLineColor(kOrange+1);
433 j_hist->SetLineWidth(2);
434 j_hist_sdcp->SetLineWidth(2);
436 auto StyleAxis = [](TH1* h) {
437 auto xAxis = h->GetXaxis();
438 auto yAxis = h->GetYaxis();
440 xAxis->SetLabelSize(0.04);
441 xAxis->SetLabelFont(132);
442 xAxis->SetTitleSize(0.04);
443 xAxis->SetTitleOffset(0.80);
444 xAxis->SetTitleFont(132);
445 xAxis->SetNdivisions(505);
446 xAxis->SetTickSize(0.04);
448 yAxis->SetLabelSize(0.04);
449 yAxis->SetLabelFont(132);
450 yAxis->SetTitleSize(0.04);
451 yAxis->SetTitleOffset(1.2);
452 yAxis->SetTitleFont(132);
453 yAxis->SetNdivisions(505);
454 yAxis->SetTickSize(0.04);
457 StyleAxis(j_hist.get());
459 j_hist->GetXaxis()->SetRangeUser(-0.04,0.04);
460 j_hist->Scale(1./j_hist->Integral());
461 j_hist_sdcp->Scale(1./j_hist_sdcp->Integral());
463 std::unique_ptr<TH1D> j_hist_copy =
M3::Clone(j_hist.get(),
"j_hist_copy");
464 std::unique_ptr<TH1D> j_hist_1sig =
M3::Clone(j_hist.get(),
"j_hist_1sig");
465 std::unique_ptr<TH1D> j_hist_2sig =
M3::Clone(j_hist.get(),
"j_hist_2sig");
466 std::unique_ptr<TH1D> j_hist_3sig =
M3::Clone(j_hist.get(),
"j_hist_3sig");
469 double j_bf = j_hist_copy->GetXaxis()->GetBinCenter(j_hist_copy->GetMaximumBin());
470 double j_1sig_low = 9999999.;
471 double j_1sig_up = -9999999.;
472 double j_2sig_low = 9999999.;;
473 double j_2sig_up = -9999999.;
474 double j_3sig_low = 9999999.;;
475 double j_3sig_up = -9999999.;
478 std::unique_ptr<TH1D> j_hist_sdcp_copy =
M3::Clone(j_hist_sdcp.get(),
"j_hist_sdcp_copy");
479 std::unique_ptr<TH1D> j_hist_sdcp_1sig =
M3::Clone(j_hist_sdcp.get(),
"j_hist_sdcp_1sig");
480 std::unique_ptr<TH1D> j_hist_sdcp_2sig =
M3::Clone(j_hist_sdcp.get(),
"j_hist_sdcp_2sig");
481 std::unique_ptr<TH1D> j_hist_sdcp_3sig =
M3::Clone(j_hist_sdcp.get(),
"j_hist_sdcp_3sig");
484 double j_sdcp_1sig_low = 9999999.;
485 double j_sdcp_1sig_up = -9999999.;
486 double j_sdcp_2sig_low = 9999999.;;
487 double j_sdcp_2sig_up = -9999999.;
488 double j_sdcp_3sig_low = 9999999.;;
489 double j_sdcp_3sig_up = -9999999.;
491 double contlevel1 = 0.68;
492 double contlevel2 = 0.90;
493 double contlevel4 = 0.99;
494 double contlevel5 = 0.9973;
495 double integral, tsum = 0.;
497 integral = j_hist_copy->Integral();
499 while((tsum/integral)<contlevel5) {
500 double tmax = j_hist_copy->GetMaximum();
501 int bin = j_hist_copy->GetMaximumBin();
502 double xval = j_hist_copy->GetXaxis()->GetBinCenter(bin);
503 double xwidth = j_hist_copy->GetXaxis()->GetBinWidth(bin);
504 if((tsum/integral)<contlevel1) {
505 j_hist_copy->SetBinContent(bin,-1.0);
506 j_hist_1sig->SetBinContent(bin,0.);
507 j_hist_2sig->SetBinContent(bin,0.);
508 j_hist_3sig->SetBinContent(bin,0.);
509 if(xval<j_1sig_low && xval<j_bf) j_1sig_low = xval - xwidth/2.;
510 if(xval>j_1sig_up && xval>j_bf) j_1sig_up = xval + xwidth/2.;
512 if((tsum/integral)<contlevel2 && (tsum / integral > contlevel1) ) {
513 j_hist_copy->SetBinContent(bin,-5.0);
514 j_hist_2sig->SetBinContent(bin,0.);
515 j_hist_3sig->SetBinContent(bin,0.);
516 if(xval<j_2sig_low && xval<j_bf) j_2sig_low = xval - xwidth/2.;
517 if(xval>j_2sig_up && xval>j_bf) j_2sig_up = xval + xwidth/2.;
519 if((tsum/integral)<contlevel4 && (tsum / integral > contlevel1) ) {
520 j_hist_copy->SetBinContent(bin,-9.0);
521 j_hist_3sig->SetBinContent(bin,0.);
522 if(xval < j_3sig_low && xval <j_bf) j_3sig_low = xval - xwidth/2.;
523 if(xval > j_3sig_up && xval > j_bf) j_3sig_up = xval + xwidth/2.;
528 integral = j_hist_sdcp_copy->Integral();
531 while((tsum/integral)<contlevel5) {
532 double tmax = j_hist_sdcp_copy->GetMaximum();
533 int bin = j_hist_sdcp_copy->GetMaximumBin();
534 double xval = j_hist_sdcp_copy->GetXaxis()->GetBinCenter(bin);
535 double xwidth = j_hist_sdcp_copy->GetXaxis()->GetBinWidth(bin);
536 if((tsum/integral)<contlevel1) {
537 j_hist_sdcp_copy->SetBinContent(bin,-1.0);
538 j_hist_sdcp_1sig->SetBinContent(bin,0.);
539 j_hist_sdcp_2sig->SetBinContent(bin,0.);
540 j_hist_sdcp_3sig->SetBinContent(bin,0.);
541 if(xval<j_sdcp_1sig_low && xval<j_bf) j_sdcp_1sig_low = xval - xwidth/2.;
542 if(xval>j_sdcp_1sig_up && xval>j_bf) j_sdcp_1sig_up = xval + xwidth/2.;
544 if((tsum/integral)<contlevel2 && (tsum / integral > contlevel1) ) {
545 j_hist_sdcp_copy->SetBinContent(bin,-5.0);
546 j_hist_sdcp_2sig->SetBinContent(bin,0.);
547 j_hist_sdcp_3sig->SetBinContent(bin,0.);
548 if(xval<j_sdcp_2sig_low && xval<j_bf) j_sdcp_2sig_low = xval - xwidth/2.;
549 if(xval>j_sdcp_2sig_up && xval>j_bf) j_sdcp_2sig_up = xval + xwidth/2.;
551 if((tsum/integral)<contlevel4 && (tsum / integral > contlevel1) ) {
552 j_hist_sdcp_copy->SetBinContent(bin,-9.0);
553 j_hist_sdcp_3sig->SetBinContent(bin,0.);
554 if(xval<j_sdcp_3sig_low && xval<j_bf) j_sdcp_3sig_low = xval - xwidth/2.;
555 if(xval>j_sdcp_3sig_up && xval>j_bf) j_sdcp_3sig_up = xval + xwidth/2.;
560 j_hist_1sig->SetLineStyle(9);
561 j_hist_sdcp_1sig->SetLineStyle(9);
562 j_hist_2sig->SetLineStyle(7);
563 j_hist_sdcp_2sig->SetLineStyle(7);
564 j_hist_3sig->SetLineStyle(2);
565 j_hist_sdcp_3sig->SetLineStyle(2);
567 auto ldash = std::make_unique<TH1D>(
"ldash",
"solid", 10, -0.04, 0.04);
568 auto sdash = std::make_unique<TH1D>(
"sdash",
"dashed", 10, -0.04, 0.04);
569 auto fdash = std::make_unique<TH1D>(
"fdash",
"fdashed",10, -0.04, 0.04);
570 ldash->SetLineColor(kBlack);
571 sdash->SetLineColor(kBlack);
572 fdash->SetLineColor(kBlack);
573 ldash->SetLineWidth(2);
574 sdash->SetLineWidth(2);
575 fdash->SetLineWidth(2);
576 ldash->SetLineStyle(9);
577 sdash->SetLineStyle(7);
578 fdash->SetLineStyle(2);
580 double vertUp = 0.5 * j_hist->GetMaximum();
581 auto jline_1sig_low = std::make_unique<TLine>(j_1sig_low, 0., j_1sig_low, vertUp);
582 auto jline_2sig_low = std::make_unique<TLine>(j_2sig_low, 0., j_2sig_low, vertUp);
583 auto jline_3sig_low = std::make_unique<TLine>(j_3sig_low, 0., j_3sig_low, vertUp);
585 auto jline_1sig_up = std::make_unique<TLine>(j_1sig_up, 0., j_1sig_up,vertUp);
586 auto jline_2sig_up = std::make_unique<TLine>(j_2sig_up, 0., j_2sig_up,vertUp);
587 auto jline_3sig_up = std::make_unique<TLine>(j_3sig_up, 0., j_3sig_up,vertUp);
589 auto jline_sdcp_1sig_low = std::make_unique<TLine>(j_sdcp_1sig_low, 0., j_sdcp_1sig_low, vertUp);
590 auto jline_sdcp_2sig_low = std::make_unique<TLine>(j_sdcp_2sig_low, 0., j_sdcp_2sig_low, vertUp);
591 auto jline_sdcp_3sig_low = std::make_unique<TLine>(j_sdcp_3sig_low, 0., j_sdcp_3sig_low, vertUp);
593 auto jline_sdcp_1sig_up = std::make_unique<TLine>(j_sdcp_1sig_up, 0., j_sdcp_1sig_up, vertUp);
594 auto jline_sdcp_2sig_up = std::make_unique<TLine>(j_sdcp_2sig_up, 0., j_sdcp_2sig_up, vertUp);
595 auto jline_sdcp_3sig_up = std::make_unique<TLine>(j_sdcp_3sig_up, 0., j_sdcp_3sig_up, vertUp);
597 double arrowLength = 0.003;
598 double arrowHeight = vertUp;
600 auto MakeArrow = [&](
double x, Color_t color, Width_t width) -> std::unique_ptr<TArrow> {
601 auto arrow = std::make_unique<TArrow>(x, arrowHeight, x - arrowLength, arrowHeight, 0.02,
">");
602 arrow->SetLineColor(color);
603 arrow->SetLineWidth(width);
607 auto j_arrow_1sig_up = MakeArrow(j_1sig_up, j_hist_1sig->GetLineColor(), j_hist_1sig->GetLineWidth());
608 auto j_arrow_2sig_up = MakeArrow(j_2sig_up, j_hist_2sig->GetLineColor(), j_hist_2sig->GetLineWidth());
609 auto j_arrow_3sig_up = MakeArrow(j_3sig_up, j_hist_3sig->GetLineColor(), j_hist_3sig->GetLineWidth());
611 auto j_sdcp_arrow_1sig_up = MakeArrow(j_sdcp_1sig_up, j_hist_sdcp_1sig->GetLineColor(), j_hist_sdcp_1sig->GetLineWidth());
612 auto j_sdcp_arrow_2sig_up = MakeArrow(j_sdcp_2sig_up, j_hist_sdcp_2sig->GetLineColor(), j_hist_sdcp_2sig->GetLineWidth());
613 auto j_sdcp_arrow_3sig_up = MakeArrow(j_sdcp_3sig_up, j_hist_sdcp_3sig->GetLineColor(), j_hist_sdcp_3sig->GetLineWidth());
615 MACH3LOG_DEBUG(
"j_1sig_low = {:.4f}, j_2sig_low = {:.4f}, j_3sig_low = {:.4f}", j_1sig_low, j_2sig_low, j_3sig_low);
616 MACH3LOG_DEBUG(
"j_1sig_up = {:.4f}, j_2sig_up = {:.4f}, j_3sig_up = {:.4f}", j_1sig_up, j_2sig_up, j_3sig_up);
618 auto CopyLineStyle = [](
const TH1D* src, TLine* dst) {
619 dst->SetLineColor(src->GetLineColor());
620 dst->SetLineStyle(src->GetLineStyle());
621 dst->SetLineWidth(src->GetLineWidth());
624 CopyLineStyle(j_hist_1sig.get(), jline_1sig_low.get());
625 CopyLineStyle(j_hist_1sig.get(), jline_1sig_up.get());
626 CopyLineStyle(j_hist_2sig.get(), jline_2sig_low.get());
627 CopyLineStyle(j_hist_2sig.get(), jline_2sig_up.get());
628 CopyLineStyle(j_hist_3sig.get(), jline_3sig_low.get());
629 CopyLineStyle(j_hist_3sig.get(), jline_3sig_up.get());
631 CopyLineStyle(j_hist_sdcp_1sig.get(), jline_sdcp_1sig_low.get());
632 CopyLineStyle(j_hist_sdcp_1sig.get(), jline_sdcp_1sig_up.get());
633 CopyLineStyle(j_hist_sdcp_2sig.get(), jline_sdcp_2sig_low.get());
634 CopyLineStyle(j_hist_sdcp_2sig.get(), jline_sdcp_2sig_up.get());
635 CopyLineStyle(j_hist_sdcp_3sig.get(), jline_sdcp_3sig_low.get());
636 CopyLineStyle(j_hist_sdcp_3sig.get(), jline_sdcp_3sig_up.get());
638 auto leg = std::make_unique<TLegend>(0.45, 0.60, 0.75, 0.90);
639 leg->SetTextSize(0.05);
640 leg->SetFillStyle(0);
642 leg->SetTextFont(132);
643 leg->SetBorderSize(0);
645 leg->AddEntry(j_hist.get(),
"Prior flat in #delta_{CP}",
"l");
646 leg->AddEntry(j_hist_sdcp.get(),
"Prior flat in sin#delta_{CP}",
"l");
647 leg->AddEntry(ldash.get(),
"68% CI",
"l");
648 leg->AddEntry(sdash.get(),
"90% CI",
"l");
649 leg->AddEntry(fdash.get(),
"99% CI",
"l");
651 j_hist->GetYaxis()->SetRangeUser(0., j_hist->GetMaximum()*1.15);
653 j_hist_sdcp->Draw(
"same h");
655 jline_sdcp_1sig_up->Draw(
"same");
656 jline_sdcp_2sig_up->Draw(
"same");
657 jline_sdcp_3sig_up->Draw(
"same");
658 jline_1sig_up->Draw(
"same");
659 jline_2sig_up->Draw(
"same");
660 jline_3sig_up->Draw(
"same");
662 j_arrow_1sig_up->Draw();
663 j_arrow_2sig_up->Draw();
664 j_arrow_3sig_up->Draw();
665 j_sdcp_arrow_1sig_up->Draw();
666 j_sdcp_arrow_2sig_up->Draw();
667 j_sdcp_arrow_3sig_up->Draw();
670 auto ttext = std::make_unique<TText>();
672 ttext->SetTextSize(0.03);
673 ttext->SetTextAlign(13);
675 if (hierarchy == 1) ttext->DrawText(0.15, 0.85,
"Normal Ordering");
676 else if (hierarchy == 0) ttext->DrawText(0.15, 0.85,
"Both Orderings");
677 else if (hierarchy == -1) ttext->DrawText(0.15, 0.85,
"Inverted Ordering");
685 if(hierarchy == 1)
Posterior->Write(
"jarl1D_NH_comp");
686 else if(hierarchy == 0)
Posterior->Write(
"jarl1D_both_comp");
687 else if(hierarchy == -1)
Posterior->Write(
"jarl1D_IH_comp");
690 gErrorIgnoreLevel = originalErrorLevel;
698 MACH3LOG_WARN(
"Will not {}, as oscillation parameters are missing", __func__);
706 const double sigma_p = (*Errors_HPD_Positive)(
DeltaCPIndex);
707 const double sigma_n = (*Errors_HPD_Negative)(
DeltaCPIndex);
709 auto wrap_pi = [](
double x) {
710 while (x > TMath::Pi()) x -= 2*TMath::Pi();
711 while (x < -TMath::Pi()) x += 2*TMath::Pi();
715 std::array<double, 6> bds;
716 bds[0] = wrap_pi(best_fit - 3.0 * sigma_n);
717 bds[1] = wrap_pi(best_fit - 2.0 * sigma_n);
718 bds[2] = wrap_pi(best_fit - 1.0 * sigma_n);
719 bds[3] = wrap_pi(best_fit + 1.0 * sigma_p);
720 bds[4] = wrap_pi(best_fit + 2.0 * sigma_p);
721 bds[5] = wrap_pi(best_fit + 3.0 * sigma_p);
723 constexpr
double radius = 0.4;
724 constexpr
double rad_to_deg = 180.0 / TMath::Pi();
729 auto normalize_angle = [](
double rad) {
731 if (rad < 0) rad += 2.0 * TMath::Pi();
735 TEllipse onesig (0.5, 0.5, radius, radius, bds[2] * rad_to_deg, bds[4] * rad_to_deg);
736 TEllipse twosigA (0.5, 0.5, radius, radius, bds[1] * rad_to_deg, bds[2] * rad_to_deg);
737 TEllipse twosigB (0.5, 0.5, radius, radius, bds[3] * rad_to_deg, bds[4] * rad_to_deg);
740 TEllipse threesigA(0.5, 0.5, radius, radius, bds[0] * rad_to_deg, normalize_angle(bds[1]) * rad_to_deg);
741 TEllipse threesigB(0.5, 0.5, radius, radius, bds[4] * rad_to_deg, bds[5] * rad_to_deg);
744 TEllipse rest(0.5, 0.5, radius, radius, bds[5]*rad_to_deg, bds[0]*rad_to_deg);
745 TEllipse restA(0.5, 0.5, radius, radius, bds[5]*rad_to_deg, 180.0);
746 TEllipse restB(0.5, 0.5, radius, radius, -180.0, bds[0]*rad_to_deg);
748 onesig.SetFillColor(13);
749 twosigA.SetFillColor(12);
750 twosigB.SetFillColor(12);
751 threesigA.SetFillColor(11);
752 threesigB.SetFillColor(11);
753 TLine line1(0.5 - radius, 0.5, 0.5 + radius, 0.5);
754 line1.SetLineWidth(3);
756 TLine line2(0.5, 0.5 - radius, 0.5, 0.5 + radius);
757 line2.SetLineWidth(3);
759 TArrow bf(0.5, 0.5, 0.5 + radius * cos(best_fit),0.5 + radius * sin(best_fit),0.04,
"|>");
761 bf.SetLineColor(kRed);
762 bf.SetFillColor(kRed);
764 TCanvas canvas(
"canvas",
"canvas", 0, 0, 1000, 1000);
785 TLegend leg(0.0, 0.8, 0.23, 0.95);
786 leg.AddEntry(&bf,
"Best Fit",
"L");
787 leg.AddEntry(&onesig,
"1#sigma",
"F");
788 leg.AddEntry(&twosigA,
"2#sigma",
"F");
789 leg.AddEntry(&threesigA,
"3#sigma",
"F");
793 auto draw_text = [](
auto& txt, Color_t color = kBlack) {
794 txt.SetTextAlign(22);
795 txt.SetTextColor(color);
804 constexpr
double too_close_threshold = 0.1;
807 const double tbf_x = 0.5 + (radius + 0.02) * cos(best_fit);
808 const double tbf_y = 0.5 + (radius + 0.02) * sin(best_fit);
811 auto distance = [](
double x1,
double y1,
double x2,
double y2) {
812 return std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
816 constexpr
double t0_x = 0.5 + radius + 0.02;
817 constexpr
double t0_y = 0.5;
818 TText t0(t0_x, t0_y,
"0");
819 if (distance(tbf_x, tbf_y, t0_x, t0_y) > too_close_threshold) {
824 constexpr
double tp_x = 0.5 - radius - 0.02;
825 constexpr
double tp_y = 0.5;
826 TLatex tp(tp_x, tp_y,
"#pi");
827 if (distance(tbf_x, tbf_y, tp_x, tp_y) > too_close_threshold) {
832 constexpr
double tp2_x = 0.5;
833 constexpr
double tp2_y = 0.5 + radius + 0.04;
834 TLatex tp2(tp2_x, tp2_y,
"#frac{#pi}{2}");
835 if (distance(tbf_x, tbf_y, tp2_x, tp2_y) > too_close_threshold) {
840 constexpr
double tmp2_x = 0.5;
841 constexpr
double tmp2_y = 0.5 - radius - 0.04;
842 TLatex tmp2(tmp2_x, tmp2_y,
"-#frac{#pi}{2}");
843 if (distance(tbf_x, tbf_y, tmp2_x, tmp2_y) > too_close_threshold) {
847 TLatex tbf(0.5 + (radius + 0.02) * cos(best_fit),
848 0.5 + (radius + 0.02) * sin(best_fit),
849 fmt::format(
"{:.2f}", best_fit).c_str());
850 draw_text(tbf, kRed);
859 const double s13 = std::sqrt(s2th13);
860 const double s23 = std::sqrt(s2th23);
861 const double s12 = std::sqrt(s2th12);
863 const double sdcp = std::sin(dcp);
864 const double cdcp = std::cos(dcp);
866 const double c13 = std::sqrt(1.-s2th13);
867 const double c12 = std::sqrt(1.-s2th12);
868 const double c23 = std::sqrt(1.-s2th23);
872 real_ue[0] = c12*c13;
874 real_ue[1] = s12*c13;
876 real_ue[2] = s13*cdcp;
877 imag_ue[2] = -s13*sdcp;
881 real_umu[0] = -s12*c23 - c12*s23*s13*cdcp;
882 imag_umu[0] = -c12*s23*s13*sdcp;
883 real_umu[1] = c12*c23 - s12*s23*s13*cdcp;
884 imag_umu[1] = -s12*s23*s13*sdcp;
885 real_umu[2] = s23*c13;
890 real_utau[0] = s12*s23 - c12*c23*s13*cdcp;
891 imag_utau[0] = -c12*c23*s13*sdcp;
892 real_utau[1] = -c12*s23 - s12*c23*s13*cdcp;
893 imag_utau[1] = -s12*c23*s13*sdcp;
894 real_utau[2] = c23*c13;
898 for (
int i = 0; i < 3; i++) {
899 U[0][i] = TComplex(real_ue[i], imag_ue[i]);
900 U[1][i] = TComplex(real_umu[i], imag_umu[i]);
901 U[2][i] = TComplex(real_utau[i], imag_utau[i]);
904 return {{{U[0][0], U[0][1], U[0][2]}, {U[1][0], U[1][1], U[1][2]}, {U[2][0], U[2][1], U[2][2]}}};
917 MACH3LOG_WARN(
"Will not {}, as oscillation parameters are missing", __func__);
925 TDirectory *PMNSElementsDir =
OutputFile->mkdir(
"PMNSElements");
926 PMNSElementsDir->cd();
928 unsigned int step = 0;
929 Chain->SetBranchStatus(
"*",
false);
943 Chain->SetBranchStatus(
"step",
true);
944 Chain->SetBranchAddress(
"step", &step);
948 bool anyMissing =
false;
951 if (
Chain->GetBranch(name.c_str())) {
952 Chain->SetBranchStatus(name.c_str(),
true);
953 Chain->SetBranchAddress(name.c_str(), &reweights[i]);
959 MACH3LOG_WARN(
"Some reweight branches were missing — using partial weight");
962 constexpr
int n_bins = 1000;
964 std::unique_ptr<TH1D> h_ue[3];
965 std::unique_ptr<TH1D> h_umu[3];
966 std::unique_ptr<TH1D> h_utau[3];
968 std::unique_ptr<TH1D> h_ue_real[3];
969 std::unique_ptr<TH1D> h_umu_real[3];
970 std::unique_ptr<TH1D> h_utau_real[3];
972 std::unique_ptr<TH1D> h_ue_imag[3];
973 std::unique_ptr<TH1D> h_umu_imag[3];
974 std::unique_ptr<TH1D> h_utau_imag[3];
976 std::unique_ptr<TH2D> h_ue_s2th12[3];
977 std::unique_ptr<TH2D> h_umu_s2th12[3];
978 std::unique_ptr<TH2D> h_utau_s2th12[3];
980 std::unique_ptr<TH2D> h_ue_s2th13[3];
981 std::unique_ptr<TH2D> h_umu_s2th13[3];
982 std::unique_ptr<TH2D> h_utau_s2th13[3];
984 std::unique_ptr<TH2D> h_ue_s2th23[3];
985 std::unique_ptr<TH2D> h_umu_s2th23[3];
986 std::unique_ptr<TH2D> h_utau_s2th23[3];
988 std::unique_ptr<TH2D> h_ue_dcp[3];
989 std::unique_ptr<TH2D> h_umu_dcp[3];
990 std::unique_ptr<TH2D> h_utau_dcp[3];
992 for (
int iU = 0; iU < 3; iU++) {
993 h_ue[iU] = std::make_unique<TH1D>(Form(
"h_ue%d", iU+1), Form(
";|U_{e%d}|", iU+1), n_bins, 0., 1.);
994 h_ue[iU]->SetDirectory(
nullptr);
995 h_umu[iU] = std::make_unique<TH1D>(Form(
"h_umu%d", iU+1), Form(
";|U_{#mu%d}|", iU+1), n_bins, 0., 1.);
996 h_umu[iU]->SetDirectory(
nullptr);
997 h_utau[iU] = std::make_unique<TH1D>(Form(
"h_utau%d", iU+1), Form(
";|U_{#tau%d}|", iU+1), n_bins, 0., 1.);
998 h_utau[iU]->SetDirectory(
nullptr);
1000 h_ue_real[iU] = std::make_unique<TH1D>(Form(
"h_ue%d_real", iU+1), Form(
";Re(U_{e%d})", iU+1), n_bins, -1., 1.);
1001 h_ue_real[iU]->SetDirectory(
nullptr);
1002 h_umu_real[iU] = std::make_unique<TH1D>(Form(
"h_umu%d_real", iU+1), Form(
";Re(U_{#mu%d})", iU+1), n_bins, -1., 1.);
1003 h_umu_real[iU]->SetDirectory(
nullptr);
1004 h_utau_real[iU] = std::make_unique<TH1D>(Form(
"h_utau%d_real", iU+1), Form(
";Re(U_{#tau%d})", iU+1), n_bins, -1., 1.);
1005 h_utau_real[iU]->SetDirectory(
nullptr);
1007 h_ue_imag[iU] = std::make_unique<TH1D>(Form(
"h_ue%d_imag", iU+1), Form(
";Im(U_{e%d})", iU+1), n_bins, -1., 1.);
1008 h_ue_imag[iU]->SetDirectory(
nullptr);
1009 h_umu_imag[iU] = std::make_unique<TH1D>(Form(
"h_umu%d_imag", iU+1), Form(
";Im(U_{#mu%d})", iU+1), n_bins, -1., 1.);
1010 h_umu_imag[iU]->SetDirectory(
nullptr);
1011 h_utau_imag[iU] = std::make_unique<TH1D>(Form(
"h_utau%d_imag", iU+1), Form(
";Im(U_{#tau%d})", iU+1), n_bins, -1., 1.);
1012 h_utau_imag[iU]->SetDirectory(
nullptr);
1014 h_ue_s2th12[iU] = std::make_unique<TH2D>(Form(
"h_ue%d_s2th12", iU+1), Form(
";|U_{e%d}|;sin^{2}(#theta_{12})", iU+1),
1015 n_bins, 0., 1., n_bins, 0.15, 0.5);
1016 h_ue_s2th12[iU]->SetDirectory(
nullptr);
1017 h_umu_s2th12[iU] = std::make_unique<TH2D>(Form(
"h_umu%d_s2th12", iU+1), Form(
";|U_{#mu%d}|;sin^{2}(#theta_{12})", iU+1),
1018 n_bins, 0., 1., n_bins, 0.15, 0.5);
1019 h_umu_s2th12[iU]->SetDirectory(
nullptr);
1020 h_utau_s2th12[iU] = std::make_unique<TH2D>(Form(
"h_utau%d_s2th12", iU+1), Form(
";|U_{#tau%d}|;sin^{2}(#theta_{12})", iU+1),
1021 n_bins, 0., 1., n_bins, 0.15, 0.5);
1022 h_utau_s2th12[iU]->SetDirectory(
nullptr);
1025 h_ue_s2th13[iU] = std::make_unique<TH2D>(Form(
"h_ue%d_s2th13", iU+1), Form(
";|U_{e%d}|;sin^{2}(#theta_{13})", iU+1),
1026 n_bins, 0., 1., n_bins, 0., 0.1);
1027 h_ue_s2th13[iU]->SetDirectory(
nullptr);
1028 h_umu_s2th13[iU] = std::make_unique<TH2D>(Form(
"h_umu%d_s2th13", iU+1), Form(
";|U_{#mu%d}|;sin^{2}(#theta_{13})", iU+1),
1029 n_bins, 0., 1., n_bins, 0., 0.1);
1030 h_umu_s2th13[iU]->SetDirectory(
nullptr);
1031 h_utau_s2th13[iU] = std::make_unique<TH2D>(Form(
"h_utau%d_s2th13", iU+1), Form(
";|U_{#tau%d}|;sin^{2}(#theta_{13})", iU+1),
1032 n_bins, 0., 1., n_bins, 0., 0.1);
1033 h_utau_s2th13[iU]->SetDirectory(
nullptr);
1036 h_ue_s2th23[iU] = std::make_unique<TH2D>(Form(
"h_ue%d_s2th23", iU+1), Form(
";|U_{e%d}|;sin^{2}(#theta_{23})", iU+1),
1037 n_bins, 0., 1., n_bins, 0.3, 0.8);
1038 h_ue_s2th23[iU]->SetDirectory(
nullptr);
1039 h_umu_s2th23[iU] = std::make_unique<TH2D>(Form(
"h_umu%d_s2th23", iU+1), Form(
";|U_{#mu%d}|;sin^{2}(#theta_{23})", iU+1),
1040 n_bins, 0., 1., n_bins, 0.3, 0.8);
1041 h_umu_s2th23[iU]->SetDirectory(
nullptr);
1042 h_utau_s2th23[iU] = std::make_unique<TH2D>(Form(
"h_utau%d_s2th23", iU+1), Form(
";|U_{#tau%d}|;sin^{2}(#theta_{23})", iU+1),
1043 n_bins, 0., 1., n_bins, 0.3, 0.8);
1044 h_utau_s2th23[iU]->SetDirectory(
nullptr);
1047 h_ue_dcp[iU] = std::make_unique<TH2D>(Form(
"h_ue%d_dcp", iU+1), Form(
";|U_{e%d}|;#delta_{CP}", iU+1),
1048 n_bins, 0., 1., n_bins, -TMath::Pi(), TMath::Pi());
1049 h_ue_dcp[iU]->SetDirectory(
nullptr);
1050 h_umu_dcp[iU] = std::make_unique<TH2D>(Form(
"h_umu%d_dcp", iU+1), Form(
";|U_{#mu%d}|;#delta_{CP}", iU+1),
1051 n_bins, 0., 1., n_bins, -TMath::Pi(), TMath::Pi());
1052 h_umu_dcp[iU]->SetDirectory(
nullptr);
1053 h_utau_dcp[iU] = std::make_unique<TH2D>(Form(
"h_utau%d_dcp", iU+1), Form(
";|U_{#tau%d}|;#delta_{CP}", iU+1),
1054 n_bins, 0., 1., n_bins, -TMath::Pi(), TMath::Pi());
1055 h_utau_dcp[iU]->SetDirectory(
nullptr);
1059 std::vector<std::unique_ptr<TH2D>> h_UU;
1060 std::string U_names[9] = {
"ue1",
"ue2",
"ue3",
"umu1",
"umu2",
"umu3",
"utau1",
"utau2",
"utau3"};
1061 std::string U_tex[9] = {
"|U_{e1}|",
"|U_{e2}|",
"|U_{e3}|",
"|U_{#mu1}|",
"|U_{#mu2}|",
"|U_{#mu3}|",
"|U_{#tau1}|",
"|U_{#tau2}|",
"|U_{#tau3}|"};
1062 for(
int i=0; i < 9; ++i){
1063 for(
int j = i+1; j < 9; ++j){
1064 std::string name =
"h_" + U_names[i] +
"_" + U_names[j];
1065 std::string title =
";" + U_tex[i] +
";" + U_tex[j];
1066 h_UU.push_back(std::make_unique<TH2D>(name.c_str(), title.c_str(), n_bins, 0., 1., n_bins, 0., 1.));
1067 h_UU.back()->SetDirectory(
nullptr);
1070 const Long64_t countwidth =
nEntries/5;
1071 for(
int i = 0; i <
nEntries; i++) {
1072 if (i % countwidth == 0) {
1081 const std::array<std::array<TComplex, 3>, 3> U =
CalculatePMNSElements(s2th13, s2th23, s2th12, dcp);
1084 for (
const auto& w : reweights) {
1087 for(
int iU = 0; iU < 3; iU++){
1088 h_ue[iU]->Fill(TComplex::Abs(U[0][iU]), weight);
1089 h_umu[iU]->Fill(TComplex::Abs(U[1][iU]), weight);
1090 h_utau[iU]->Fill(TComplex::Abs(U[2][iU]), weight);
1092 h_ue_real[iU]->Fill(U[0][iU].Re(), weight);
1093 h_umu_real[iU]->Fill(U[1][iU].Re(), weight);
1094 h_utau_real[iU]->Fill(U[2][iU].Re(), weight);
1096 h_ue_imag[iU]->Fill(U[0][iU].Im(), weight);
1097 h_umu_imag[iU]->Fill(U[1][iU].Im(), weight);
1098 h_utau_imag[iU]->Fill(U[2][iU].Im(), weight);
1100 h_ue_s2th12[iU]->Fill(TComplex::Abs(U[0][iU]), s2th12, weight);
1101 h_umu_s2th12[iU]->Fill(TComplex::Abs(U[1][iU]), s2th12, weight);
1102 h_utau_s2th12[iU]->Fill(TComplex::Abs(U[2][iU]), s2th12, weight);
1104 h_ue_s2th13[iU]->Fill(TComplex::Abs(U[0][iU]), s2th13, weight);
1105 h_umu_s2th13[iU]->Fill(TComplex::Abs(U[1][iU]), s2th13, weight);
1106 h_utau_s2th13[iU]->Fill(TComplex::Abs(U[2][iU]), s2th13, weight);
1108 h_ue_s2th23[iU]->Fill(TComplex::Abs(U[0][iU]), s2th23, weight);
1109 h_umu_s2th23[iU]->Fill(TComplex::Abs(U[1][iU]), s2th23, weight);
1110 h_utau_s2th23[iU]->Fill(TComplex::Abs(U[2][iU]), s2th23, weight);
1112 h_ue_dcp[iU]->Fill(TComplex::Abs(U[0][iU]), dcp, weight);
1113 h_umu_dcp[iU]->Fill(TComplex::Abs(U[1][iU]), dcp, weight);
1114 h_utau_dcp[iU]->Fill(TComplex::Abs(U[2][iU]), dcp, weight);
1118 double U_mod[9] = {TComplex::Abs(U[0][0]), TComplex::Abs(U[0][1]), TComplex::Abs(U[0][2]), TComplex::Abs(U[1][0]), TComplex::Abs(U[1][1]), TComplex::Abs(U[1][2]), TComplex::Abs(U[2][0]), TComplex::Abs(U[2][1]), TComplex::Abs(U[2][2])};
1120 for(
int ix = 0; ix < 9; ++ix){
1121 for(
int iy = ix+1; iy<9; ++iy){
1122 h_UU[idx]->Fill(U_mod[ix], U_mod[iy], weight);
1129 PMNSElementsDir->cd();
1131 for (
int iU = 0; iU < 3; iU++) {
1132 h_ue[iU]->Write(Form(
"h_ue%d", iU+1));
1133 h_umu[iU]->Write(Form(
"h_umu%d", iU+1));
1134 h_utau[iU]->Write(Form(
"h_utau%d", iU+1));
1136 h_ue_real[iU]->Write(Form(
"h_ue%d_real", iU+1));
1137 h_umu_real[iU]->Write(Form(
"h_umu%d_real", iU+1));
1138 h_utau_real[iU]->Write(Form(
"h_utau%d_real", iU+1));
1140 h_ue_imag[iU]->Write(Form(
"h_ue%d_imag", iU+1));
1141 h_umu_imag[iU]->Write(Form(
"h_umu%d_imag", iU+1));
1142 h_utau_imag[iU]->Write(Form(
"h_utau%d_imag", iU+1));
1144 h_ue_s2th12[iU]->Write(Form(
"h_ue%d_s2th12", iU+1));
1145 h_umu_s2th12[iU]->Write(Form(
"h_umu%d_s2th12", iU+1));
1146 h_utau_s2th12[iU]->Write(Form(
"h_utau%d_s2th12", iU+1));
1148 h_ue_s2th13[iU]->Write(Form(
"h_ue%d_s2th13", iU+1));
1149 h_umu_s2th13[iU]->Write(Form(
"h_umu%d_s2th13", iU+1));
1150 h_utau_s2th13[iU]->Write(Form(
"h_utau%d_s2th13", iU+1));
1152 h_ue_s2th23[iU]->Write(Form(
"h_ue%d_s2th23", iU+1));
1153 h_umu_s2th23[iU]->Write(Form(
"h_umu%d_s2th23", iU+1));
1154 h_utau_s2th23[iU]->Write(Form(
"h_utau%d_s2th23", iU+1));
1156 h_ue_dcp[iU]->Write(Form(
"h_ue%d_dcp", iU+1));
1157 h_umu_dcp[iU]->Write(Form(
"h_umu%d_dcp", iU+1));
1158 h_utau_dcp[iU]->Write(Form(
"h_utau%d_dcp", iU+1));
1162 for(
size_t iPlot = 0; iPlot < h_UU.size(); ++iPlot){
1163 h_UU[iPlot]->Write();
1166 PMNSElementsDir->Close();
1167 delete PMNSElementsDir;
1169 Chain->SetBranchStatus(
"*",
true);
1183 MACH3LOG_WARN(
"Will not {}, as oscillation parameters are missing", __func__);
1190 TComplex tr_emu_num, tr_etau_num, tr_mutau_num, tr_12_num, tr_13_num, tr_23_num;
1191 TComplex tr_emu_denom, tr_etau_denom, tr_mutau_denom, tr_12_denom, tr_13_denom, tr_23_denom;
1192 TComplex tr_emu, tr_etau, tr_mutau, tr_12, tr_13, tr_23;
1194 TDirectory *UnitarityTrianglesDir =
OutputFile->mkdir(
"UnitarityTriangles");
1195 UnitarityTrianglesDir->cd();
1197 unsigned int step = 0;
1198 Chain->SetBranchStatus(
"*",
false);
1212 Chain->SetBranchStatus(
"step",
true);
1213 Chain->SetBranchAddress(
"step", &step);
1215 double weight = 1.0;
1217 bool anyMissing =
false;
1220 if (
Chain->GetBranch(name.c_str())) {
1221 Chain->SetBranchStatus(name.c_str(),
true);
1222 Chain->SetBranchAddress(name.c_str(), &reweights[i]);
1228 MACH3LOG_WARN(
"Some reweight branches were missing — using partial weight");
1231 constexpr
int n_bins = 1000;
1233 std::unique_ptr<TH2D> h_tr_emu;
1234 std::unique_ptr<TH2D> h_tr_etau;
1235 std::unique_ptr<TH2D> h_tr_mutau;
1237 std::unique_ptr<TH2D> h_tr_12;
1238 std::unique_ptr<TH2D> h_tr_13;
1239 std::unique_ptr<TH2D> h_tr_23;
1241 h_tr_emu = std::make_unique<TH2D>(
"h_tr_emu",
";#rho_{e#mu};#eta_{e#mu}",n_bins,-5,5,n_bins,-5,5);
1242 h_tr_emu->SetDirectory(
nullptr);
1243 h_tr_etau = std::make_unique<TH2D>(
"h_tr_etau",
";#rho_{e#tau};#eta_{e#tau}",n_bins,0,2,n_bins,-1,1);
1244 h_tr_etau->SetDirectory(
nullptr);
1245 h_tr_mutau = std::make_unique<TH2D>(
"h_tr_mutau",
";#rho_{#mu#tau};#eta_{#mu#tau}",n_bins,0,2,n_bins,-1,1);
1246 h_tr_mutau->SetDirectory(
nullptr);
1248 h_tr_12 = std::make_unique<TH2D>(
"h_tr_12",
";#rho_{12};#eta_{12}",n_bins,0,3.2,n_bins,-1.5,1.5);
1249 h_tr_12->SetDirectory(
nullptr);
1250 h_tr_13 = std::make_unique<TH2D>(
"h_tr_13",
";#rho_{13};#eta_{13}",n_bins,0,2,n_bins,-1,1);
1251 h_tr_13->SetDirectory(
nullptr);
1252 h_tr_23 = std::make_unique<TH2D>(
"h_tr_23",
";#rho_{23};#eta_{23}",n_bins,-8,8,n_bins,-8,8);
1253 h_tr_23->SetDirectory(
nullptr);
1255 const Long64_t countwidth =
nEntries/5;
1256 for(
int i = 0; i <
nEntries; i++) {
1257 if (i % countwidth == 0) {
1268 for (
const auto& w : reweights) {
1272 const std::array<std::array<TComplex, 3>, 3> U =
CalculatePMNSElements(s2th13, s2th23, s2th12, dcp);
1275 tr_emu_num = U[0][0].operator*(TComplex::Conjugate(U[1][0]));
1276 tr_emu_denom = U[0][2].operator*(TComplex::Conjugate(U[1][2]));
1277 tr_emu = - tr_emu_num.operator/(tr_emu_denom);
1279 tr_etau_num = U[0][1].operator*(TComplex::Conjugate(U[2][1]));
1280 tr_etau_denom = U[0][0].operator*(TComplex::Conjugate(U[2][0]));
1281 tr_etau = - tr_etau_num.operator/(tr_etau_denom);
1283 tr_mutau_num = U[1][2].operator*(TComplex::Conjugate(U[2][2]));
1284 tr_mutau_denom = U[1][1].operator*(TComplex::Conjugate(U[2][1]));
1285 tr_mutau = - tr_mutau_num.operator/(tr_mutau_denom);
1287 tr_12_num = U[0][0].operator*(TComplex::Conjugate(U[0][1]));
1288 tr_12_denom = U[1][0].operator*(TComplex::Conjugate(U[1][1]));
1289 tr_12 = - tr_12_num.operator/(tr_12_denom);
1291 tr_13_num = U[1][0].operator*(TComplex::Conjugate(U[1][2]));
1292 tr_13_denom = U[2][0].operator*(TComplex::Conjugate(U[2][2]));
1293 tr_13 = - tr_13_num.operator/(tr_13_denom);
1295 tr_23_num = U[2][1].operator*(TComplex::Conjugate(U[2][2]));
1296 tr_23_denom = U[0][1].operator*(TComplex::Conjugate(U[0][2]));
1297 tr_23 = - tr_23_num.operator/(tr_23_denom);
1299 h_tr_emu->Fill(tr_emu.Re(), tr_emu.Im(), weight);
1300 h_tr_etau->Fill(tr_etau.Re(), tr_etau.Im(), weight);
1301 h_tr_mutau->Fill(tr_mutau.Re(), tr_mutau.Im(), weight);
1303 h_tr_12->Fill(tr_12.Re(), tr_12.Im(), weight);
1304 h_tr_13->Fill(tr_13.Re(), tr_13.Im(), weight);
1305 h_tr_23->Fill(tr_23.Re(), tr_23.Im(), weight);
1309 UnitarityTrianglesDir->cd();
1311 h_tr_emu->Write(
"h_tr_emu");
1312 h_tr_etau->Write(
"h_tr_etau");
1313 h_tr_mutau->Write(
"h_tr_mutau");
1315 h_tr_12->Write(
"h_tr_12");
1316 h_tr_13->Write(
"h_tr_13");
1317 h_tr_23->Write(
"h_tr_23");
1319 UnitarityTrianglesDir->Close();
1320 delete UnitarityTrianglesDir;
1322 Chain->SetBranchStatus(
"*",
true);
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
#define _MaCh3_Safe_Include_End_
YAML::Node TMacroToYAML(const TMacro ¯o)
KS: Convert a ROOT TMacro object to a YAML node.
bool CheckNodeExists(const YAML::Node &node, Args... args)
KS: Wrapper function to call the recursive helper.
Class responsible for processing MCMC chains, performing diagnostics, generating plots,...
void GetNthParameter(const int param, double &Prior, double &PriorError, TString &Title) const
Get properties of parameter by passing it number.
std::vector< std::string > ReweightNames
Name of branch used for chain reweighting.
std::vector< std::vector< double > > ParamCentral
Parameters central values which we are going to analyse.
std::vector< std::vector< double > > ParamErrors
Uncertainty on a single parameter.
std::vector< int > nParam
Number of parameters per type.
std::vector< std::vector< bool > > ParamFlat
Whether Param has flat prior or not.
std::unique_ptr< TCanvas > Posterior
Fancy canvas used for our beautiful plots.
TFile * OutputFile
The output file.
TChain * Chain
Main chain storing all steps etc.
std::string MCMCFile
Name of MCMC file.
int nDraw
Number of all parameters used in the analysis.
std::vector< ParameterEnum > ParamType
Make an enum for which class this parameter belongs to so we don't have to keep string comparing.
TString CanvasName
Name of canvas which help to save to the sample pdf.
std::vector< std::string > ParameterGroup
std::vector< TString > BranchNames
std::vector< std::vector< TString > > ParamNames
Name of parameters which we are going to analyse.
std::vector< int > ParamTypeStartPos
int nEntries
KS: For merged chains number of entries will be different from nSteps.
void SavageDickeyPlot(std::unique_ptr< TH1D > &PriorHist, std::unique_ptr< TH1D > &PosteriorHist, const std::string &Title, const double EvaluationPoint) const
Produce Savage Dickey plot.
unsigned int BurnInCut
Value of burn in cut.
Custom exception class used throughout MaCh3.
double SamplePriorForParam(const int paramIndex, const std::unique_ptr< TRandom3 > &randGen, const std::vector< double > &FlatBounds) const
Draw Prior value.
void ProduceUnitarityTriangles()
MP: Produce unitarity triangles from PMNS matrix elements.
int DeltaCPIndex
Index of in the parameter list.
double CalcJarlskog(const double s2th13, const double s2th23, const double s2th12, const double dcp) const
Calculate Jarlskog Invariant using oscillation parameters.
std::string Sin2Theta13Name
Name of the parameter representing .
std::string Sin2Theta12Name
Name of the parameter representing .
int Sin2Theta12Index
Index of in the parameter list.
OscProcessor(const std::string &InputFile)
Constructs an OscProcessor object with the specified input file and options.
int DeltaM2_23Index
Index of in the parameter list.
std::string DeltaCPName
Name of the parameter representing (the CP-violating phase).
bool PlotJarlskog
Will plot Jarlskog Invariant using information in the chain.
void ProducePMNSElements()
MP: Produce PMNS matrix elements.
int Sin2Theta13Index
Index of in the parameter list.
std::string Sin2Theta23Name
Name of the parameter representing .
std::array< std::array< TComplex, 3 >, 3 > CalculatePMNSElements(const double s2th13, const double s2th23, const double s2th12, const double dcp) const
MP: Calculate PMNS matrix elements.
void Get1DReactorConstraintInfo(std::pair< double, double > &Sin13_NewPrior, bool &DoReweight) const
Extract 1D reactor constraint information from an MCMC file.
void MakeJarlskogPlot(const std::unique_ptr< TH1D > &jarl, const std::unique_ptr< TH1D > &jarl_flatsindcp, const std::unique_ptr< TH1D > &jarl_NH, const std::unique_ptr< TH1D > &jarl_NH_flatsindcp, const std::unique_ptr< TH1D > &jarl_IH, const std::unique_ptr< TH1D > &jarl_IH_flatsindcp)
Perform Jarlskog Plotting.
int Sin2Theta23Index
Index of in the parameter list.
virtual ~OscProcessor()
Destroys the OscProcessor object.
std::string DeltaM2_23Name
Name of the parameter representing (mass-squared difference).
void LoadAdditionalInfo() final
Read the Osc cov file and get the input central values and errors Here we allow Jarlskog Shenanigans.
bool OscEnabled
Will plot Jarlskog Invariant using information in the chain.
void MakePiePlot()
Make fancy Pie plot for delta CP.
void PerformJarlskogAnalysis()
Perform Several Jarlskog Plotting.
void EstimateDataTransferRate(TChain *chain, const Long64_t entry)
KS: Check what CPU you are using.
void PrintProgressBar(const Long64_t Done, const Long64_t All)
KS: Simply print progress bar.
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.
constexpr static const double _BAD_DOUBLE_
Default value used for double initialisation.
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.