268 TFile* fAnalysis =
new TFile((
sDir+
sAnalysis).c_str(),
"read");
269 TFile* fSysts =
new TFile((
sDir+
sSysts).c_str(),
"read");
275 sprintf(name,
"mc_%s_%s_%s_postfit",
dataName.c_str(),
281 TH2F* hFitTotal2D = (TH2F*)hFitTotal3D->Project3D(
"yx");
282 hFitTotal2D->SetName(
"hFitTotal2D");
285 sprintf(name,
"mc_%s_%s_%s",
dataName.c_str(),
"analysis",
"mc");
290 TH2F* hDataTotal2D = (TH2F*)hDataTotal3D->Project3D(
"yx");
291 hDataTotal2D->SetName(
"hDataTotal1D");
294 sprintf(name,
"mc_%s_%s_%s",
"nominal",
"analysis",
"mc");
299 TH2F* hMCTotal2D = (TH2F*)hMCTotal3D->Project3D(
"yx");
300 hMCTotal2D->SetName(
"hMCTotal2D");
303 "Events/8.09 #times 10^{20} POT",
304 "Reconstructed Electron Energy, E_{e} (GeV)",
305 dataName,xsecResult,
"total_fit_comparison");
310 sprintf(name,
"mc_%s_%s_signal_postfit",
dataName.c_str(),
"tot");
315 TH2F* hSignalEst = (TH2F*)hSignalEst3D->Project3D(
"yx");
316 hSignalEst->SetName(
"hSignalEst");
319 std::vector<std::unique_ptr<Spectrum>> sSystsReco;
320 std::vector<TH3F*> hSystsReco3D;
321 std::vector<TH2F*> hSystsReco2D;
322 std::vector<std::string> sSystsName = {
"calibshape",
"ckv",
"genie",
"ppfx",
325 for(
uint i = 0;
i < sSystsName.size();
i++){
326 sprintf(name,
"mc_%s_%s_signal_postfit",
dataName.c_str(),
327 sSystsName[
i].c_str());
332 sprintf(name,
"mc_%s_%s_signal_postfit_1d",
dataName.c_str(),
333 sSystsName[
i].c_str());
334 hSystsReco2D.push_back((TH2F*)hSystsReco3D[i]->Project3D(
"yx"));
335 hSystsReco2D[
i]->SetName(name);
343 TH3F* hTrueRecoSignal3D = (TH3F*)
ana::ToTH3(sTrueRecoSignal,
347 TH2F* hTrueRecoSignal =
348 (TH2F*)hTrueRecoSignal3D->Project3D(
"yx");
349 hTrueRecoSignal->SetName(
"hTrueRecoSignal");
352 sprintf(name,
"mc_nominal_analysis_%s",
chns[2].name.c_str());
355 TH3F* hTrueRecoSignal_nofit3D = (TH3F*)
ana::ToTH3(sTrueRecoSignal_nofit,
359 TH2F* hTrueRecoSignal_nominal =
360 (TH2F*)hTrueRecoSignal_nofit3D->Project3D(
"yx");
361 hTrueRecoSignal_nominal->SetName(
"hTrueRecoSignal_nominal");
363 MakePlots(hSignalEst, hSystsReco2D, hTrueRecoSignal,
364 "Signal Events/8.09 #times 10^{20}",
365 "Reconstructed Electron Energy, E_{e} (GeV)",
366 dataName, xsecResult,
"reco_signal_estimate");
372 sprintf(name,
"%s_%s_%s_%s",
"mc",
"nominal",
"efficiency",
"num_2d");
374 sprintf(name,
"%s_%s_%s_%s",
"mc",
"nominal",
"efficiency",
"denom_2d");
377 std::vector<std::unique_ptr<Spectrum>> vSystsEfficiencyNum;
378 std::vector<std::unique_ptr<Spectrum>> vSystsEfficiencyDenom;
379 std::vector<std::string> dataset_labels = {
"lightdown",
380 "lightup",
"ckv",
"calibneg",
381 "calibpos",
"calibshape",
384 for(
uint idataset = 0; idataset < dataset_labels.size(); idataset++){
385 if(dataset_labels[idataset] ==
"genie" ||
386 dataset_labels[idataset] ==
"ppfx"){
388 for(
uint i = 0; i < 100; i++){
389 sprintf(name,
"%s_%s_%i_%s_%s",
"mc",
390 dataset_labels[idataset].c_str(),i,
391 "efficiency",
"num_2d");
393 (fSysts->GetDirectory(name)));
394 sprintf(name,
"%s_%s_%i_%s_%s",
"mc",
395 dataset_labels[idataset].c_str(),i,
396 "efficiency",
"denom_2d");
398 (fSysts->GetDirectory(name)));
402 sprintf(name,
"%s_%s_%s_%s",
"mc", dataset_labels[idataset].c_str(),
403 "efficiency",
"num_2d");
405 (fSysts->GetDirectory(name)));
406 sprintf(name,
"%s_%s_%s_%s",
"mc", dataset_labels[idataset].c_str(),
407 "efficiency",
"denom_2d");
409 (fSysts->GetDirectory(name)));
418 std::vector<TH2F*> vSystsEff;
419 for(
uint i = 0; i < vSystsEfficiencyNum.size();i++){
426 hHolder->Divide(hHolder2);
427 vSystsEff.push_back(hHolder);
433 sprintf(name,
"%s_%s_%s",
"mc",
"nominal",
"flux");
435 TH1F* hFlux = (TH1F*)sflux_nom.
ToTH1(
pot);
438 std::vector<double> hAvgFluxVal;
439 hAvgFluxVal.push_back(hFlux->Integral());
441 std::vector<std::unique_ptr<Spectrum>> vsSystsFlux;
442 std::vector<TH1F*> vSystsFlux;
443 for(
uint i = 0; i < 100; i++){
444 sprintf(name,
"%s_%s_%i_%s",
"mc",
"ppfx",i,
"flux");
446 (fSysts->GetDirectory(name)));
447 vSystsFlux.push_back((TH1F*)vsSystsFlux[i]->ToTH1(
pot));
448 vSystsFlux[
i]->Scale(1
e-4);
449 hAvgFluxVal.push_back(vSystsFlux[i]->
Integral());
455 sprintf(name,
"%s_%s_%s_%s",
"mc",
dataName.c_str(),
"unfolding",
"2d");
456 TH2F* hResponseMatrix =
460 int numBins = hSignalEst->GetXaxis()->GetNbins() *
461 hSignalEst->GetYaxis()->GetNbins();
463 std::vector<TH1F*> hForUnfoldHists;
464 for(
int j = 0;
j <=(
int)hSystsReco2D.size();
j++){
467 for(
int i = 0; i <= hHolder->GetNbinsX();++
i){
468 if(
j == (
int)hSystsReco2D.size()){
469 const int ix = i/ hSignalEst->GetYaxis()->GetNbins();
470 const int iy = i % hSignalEst->GetYaxis()->GetNbins();
471 const double val = hSignalEst->GetBinContent(ix+1, iy+1);
472 const double err = hSignalEst->GetBinError (ix+1, iy+1);
473 hHolder->SetBinContent(i+1,val);
474 hHolder->SetBinError(i+1,err);
477 const int ix = i/ hSystsReco2D[
j]->GetYaxis()->GetNbins();
478 const int iy = i % hSystsReco2D[
j]->GetYaxis()->GetNbins();
479 const double val = hSystsReco2D[
j]->GetBinContent(ix+1, iy+1);
480 const double err = hSystsReco2D[
j]->GetBinError (ix+1, iy+1);
481 hHolder->SetBinContent(i+1,val);
482 hHolder->SetBinError(i+1,err);
485 hForUnfoldHists.push_back(hHolder);
491 std::vector<TH1F*> hUnfoldedSysts;
492 for(
int i = 0; i < (
int)hForUnfoldHists.size(); i++){
495 hUnfoldedSysts.push_back((TH1F*)
DoUnfolding(hForUnfoldHists[i],
500 std::vector<TH2F*> hUnfolded2D;
501 for(
int j = 0;
j < (
int) hUnfoldedSysts.size();
j++){
503 for(
int i = 0; i < hUnfoldedSysts[0]->GetNbinsX(); ++
i){
504 const double val = hUnfoldedSysts[
j]->GetBinContent(i+1);
505 const double err = hUnfoldedSysts[
j]->GetBinError(i+1);
506 const int ix = i/ hSignalEst->GetYaxis()->GetNbins();
507 const int iy = i % hSignalEst->GetYaxis()->GetNbins();
509 hHolder->SetBinContent(ix+1, iy+1, val);
510 hHolder->SetBinError (ix+1, iy+1, err);
512 hUnfolded2D.push_back(hHolder);
515 TH2F* hUnfolded_SignalEst =
516 (TH2F*)hUnfolded2D.back()->Clone(
"hUnfoldedSignal");
523 TH2F* hXsec_cv_2d = (TH2F*)hUnfolded_SignalEst->Clone(
ana::UniqueName().c_str());
524 hXsec_cv_2d->SetTitle(
"Cross Section");
526 hXsec_cv_2d->Scale(1,
"width");
527 hXsec_cv_2d->Divide(cv_eff);
528 hXsec_cv_2d->Scale(1./hAvgFluxVal[0]);
533 std::vector<TH2F*> hXSec_systs;
534 for(
int i = 0; i < (
int) vSystsEff.size();i++){
538 hHolder->Scale(1,
"width");
540 hHolder->Divide(vSystsEff[i]);
543 hHolder->Scale(1./hAvgFluxVal[i-106]);
546 hHolder->Scale(1./hAvgFluxVal[0]);
549 hXSec_systs.push_back(hHolder);
556 hXSec_systs[0]->SetLineColor(
kRed+3);
557 hXSec_systs[0]->SetLineStyle(7);
558 hXSec_systs[1]->SetLineColor(
kRed-3);
559 hXSec_systs[1]->SetLineStyle(7);
560 hXSec_systs[2]->SetLineColor(
kGreen);
561 hXSec_systs[3]->SetLineColor(
kBlue-3);
562 hXSec_systs[4]->SetLineColor(
kBlue+3);
563 hXSec_systs[5]->SetLineColor(
kGreen);
564 hXSec_systs[5]->SetLineStyle(7);
569 std::vector<TH1F*> hForGenieMultiverse;
570 for(
int j = 6;
j < 100+6;
j++){
573 for(
int i = 0; i <= hHolder->GetNbinsX();++
i){
574 const int ix = i/ hXSec_systs[
j]->GetYaxis()->GetNbins();
575 const int iy = i % hXSec_systs[
j]->GetYaxis()->GetNbins();
576 const double val = hXSec_systs[
j]->GetBinContent(ix+1, iy+1);
577 const double err = hXSec_systs[
j]->GetBinError (ix+1, iy+1);
578 hHolder->SetBinContent(i+1,val);
579 hHolder->SetBinError(i+1,err);
581 hForGenieMultiverse.push_back(hHolder);
585 std::vector<TH1F*> hForPPFXMultiverse;
586 for(
int j = 106;
j < 200+6;
j++){
589 for(
int i = 0; i <= hHolder->GetNbinsX();++
i){
590 const int ix = i/ hXSec_systs[
j]->GetYaxis()->GetNbins();
591 const int iy = i % hXSec_systs[
j]->GetYaxis()->GetNbins();
592 const double val = hXSec_systs[
j]->GetBinContent(ix+1, iy+1);
593 const double err = hXSec_systs[
j]->GetBinError (ix+1, iy+1);
594 hHolder->SetBinContent(i+1,val);
595 hHolder->SetBinError(i+1,err);
597 hForPPFXMultiverse.push_back(hHolder);
602 std::vector<Spectrum*> spects_xsec_genie;
603 std::vector<std::unique_ptr<Spectrum>> vspects_xsec_genie;
604 for(
int i = 0; i < (
int)hForGenieMultiverse.size(); i++){
606 spects_xsec_genie.push_back(spect);
607 vspects_xsec_genie.push_back((std::unique_ptr<Spectrum>)
608 spects_xsec_genie[i]);
612 std::vector<Spectrum*> spects_xsec_ppfx;
613 std::vector<std::unique_ptr<Spectrum>> vspects_xsec_ppfx;
614 for(
int i = 0; i < (
int)hForPPFXMultiverse.size(); i++){
616 spects_xsec_ppfx.push_back(spect);
617 vspects_xsec_ppfx.push_back((std::unique_ptr<Spectrum>)
618 spects_xsec_ppfx[i]);
628 TH1F* hGenie_up = (TH1F*)(genie_xsec_syst.
UpperSigma())->ToTH1(
pot);
629 TH1F* hGenie_dwn = (TH1F*)(genie_xsec_syst.
LowerSigma())->ToTH1(
pot);
630 TH1F* hPPFX_up = (TH1F*)(ppfx_xsec_syst.
UpperSigma())->ToTH1(
pot);
631 TH1F* hPPFX_dwn = (TH1F*)(ppfx_xsec_syst.
LowerSigma())->ToTH1(
pot);
633 hGenie_up->SetLineColor(
kOrange+3);
634 hGenie_dwn->SetLineColor(
kOrange-3);
635 hPPFX_up->SetLineColor(
kOrange+3);
636 hPPFX_dwn->SetLineColor(
kOrange-3);
637 hPPFX_up->SetLineStyle(7);
638 hPPFX_dwn->SetLineStyle(7);
643 TH2F* hGenie_down_2d =
647 TH2F* hPPFX_down_2d =
649 for(
int i = 0; i < hGenie_up->GetNbinsX(); ++
i){
650 const double val_gu = hGenie_up->GetBinContent(i+1);
651 const double err_gu = hGenie_up->GetBinError(i+1);
652 const double val_gd = hGenie_dwn->GetBinContent(i+1);
653 const double err_gd = hGenie_dwn->GetBinError(i+1);
654 const double val_pu = hPPFX_up->GetBinContent(i+1);
655 const double err_pu = hPPFX_up->GetBinError(i+1);
656 const double val_pd = hPPFX_dwn->GetBinContent(i+1);
657 const double err_pd = hPPFX_dwn->GetBinError(i+1);
658 const int ix = i/ hSignalEst->GetYaxis()->GetNbins();
659 const int iy = i % hSignalEst->GetYaxis()->GetNbins();
661 hGenie_up_2d->SetBinContent(ix+1, iy+1, val_gu);
662 hGenie_up_2d->SetBinError (ix+1, iy+1, err_gu);
663 hGenie_down_2d->SetBinContent(ix+1, iy+1, val_gd);
664 hGenie_down_2d->SetBinError (ix+1, iy+1, err_gd);
665 hPPFX_up_2d->SetBinContent(ix+1, iy+1, val_pu);
666 hPPFX_up_2d->SetBinError (ix+1, iy+1, err_pu);
667 hPPFX_down_2d->SetBinContent(ix+1, iy+1, val_pd);
668 hPPFX_down_2d->SetBinError (ix+1, iy+1, err_pd);
671 std::vector<TH2F*>systs_up_2d =
681 std::vector<TH2F*> systs_down_2d =
689 TH2F* hCVHolder_2d = (TH2F*)hXsec_cv_2d->Clone(
ana::UniqueName().c_str());
692 sprintf(name,
"%s_%s_%s_%s",
"mc",
dataName.c_str(),
"efficiency",
"denom_2d");
697 hTrueSignal_2d->Scale(1./hAvgFluxVal[0]);
699 hTrueSignal_2d->Scale(1,
"width");
701 hTrueSignal_2d->SetLineColor(
kRed);
705 for(
int xbin = 0; xbin <= hXsec_cv_2d->GetXaxis()->GetNbins();xbin++){
706 std::stringstream low_X;
707 low_X << std::fixed << std::setprecision(2) <<
708 hXsec_cv_2d->GetXaxis()->GetBinLowEdge(xbin);
709 std::stringstream hi_X;
710 hi_X << std::fixed << std::setprecision(2) <<
711 hXsec_cv_2d->GetXaxis()->GetBinUpEdge(xbin);
718 hXsec_cv->GetXaxis()->SetTitle(
"Electron Energy, E_{e} (GeV)");
720 (TH1F*)hTrueSignal_2d->ProjectionY(
ana::UniqueName().c_str(),xbin,xbin);
724 std::vector<TH1F*>systs_up;
725 std::vector<TH1F*>systs_down;
727 for(
int i = 0; i < (
int)systs_up_2d.size(); i++){
728 systs_up.push_back((TH1F*)systs_up_2d[i]->
730 systs_down.push_back((TH1F*)systs_down_2d[i]->
734 TH1F* hUnfolded_SignalEst_1d =
738 TGraphAsymmErrors*
g =
746 hXsec_cv->SetMarkerColor(kBlack);
747 hXsec_cv->SetLineColor(kBlack);
749 for(
int i = 1; i <= (
int)hUncert_tot->GetXaxis()->GetNbins();i++){
750 double uncert = hUnfolded_SignalEst_1d->GetBinError(i);
751 double total = hUncert_tot->GetBinContent(i);
752 double selected_tot = hUnfolded_SignalEst_1d->GetBinContent(i);
753 double err_hi = g->GetErrorYhigh(i);
754 double err_lo = g->GetErrorYlow(i);
757 double err_fluxeff = (err_hi > err_lo)? err_hi/total : err_lo/total;
760 double tot_err = total*
sqrt(
pow(uncert/selected_tot,2) +
762 if(total == 0) tot_err = 0;
764 hUncert_tot->SetBinError(i,tot_err);
766 std::cout << i <<
"\t" << total <<
"\t" <<
767 uncert <<
"\t" << selected_tot <<
"\t" <<
768 err_fluxeff <<
"\t" <<
769 sqrt(
pow(uncert/selected_tot,2) +
774 hUncert_tot->GetYaxis()->SetTitle(
"#frac{d^{2} #sigma}{dcos#theta dE_{e}} #left(#frac{10^{-38} cm^{2}}{nucleon GeV}#right)");
775 hUncert_tot->SetTitle(caption.c_str());
777 std::vector<TH2F*>systs_up_2d =
787 std::vector<TH2F*> systs_down_2d =
798 cResult->SetLeftMargin(0.15);
799 hUncert_tot->GetXaxis()->SetRangeUser(1.0,10.0);
800 hUncert_tot->SetMarkerStyle(20);
803 systs_down[2]->Draw(
"hist same");
804 systs_up[2]->Draw(
"hist same");
805 systs_up[4]->Draw(
"hist same");
806 systs_down[3]->Draw(
"hist same");
807 systs_up[3]->Draw(
"hist same");
808 systs_up[5]->Draw(
"hist same");
809 systs_up[0]->Draw(
"hist same");
810 systs_down[0]->Draw(
"hist same");
811 systs_up[1]->Draw(
"hist same");
812 systs_down[1]->Draw(
"hist same");
813 hTrueSignal->Draw(
"hist same");
814 hUncert_tot->Draw(
"same");
816 leg_total->AddEntry(hTrueSignal,
"Truth",
"l");
817 leg_total->AddEntry(hUncert_tot,
"FakeData",
"p");
818 leg_total->AddEntry(systs_down[3],
"Calibration -1 #sigma",
"l");
819 leg_total->AddEntry(systs_up[3],
"Calibration +1 #sigma",
"l");
820 leg_total->AddEntry(systs_down[2],
"Light Level -1 #sigma",
"l");
821 leg_total->AddEntry(systs_up[2],
"Light Level +1 #sigma",
"l");
822 leg_total->AddEntry(systs_up[4],
"Cherenkov Variation",
"l");
823 leg_total->AddEntry(systs_up[5],
"Calibration Shape",
"l");
824 leg_total->AddEntry(systs_down[1],
"Flux -1 #sigma",
"l");
825 leg_total->AddEntry(systs_up[1],
"Flux +1 #sigma",
"l");
826 leg_total->AddEntry(systs_down[0],
"#nu-Interaction -1 #sigma",
"l");
827 leg_total->AddEntry(systs_up[0],
"#nu-Interaction +1 #sigma",
"l");
829 sprintf(name,
"%s%s_%s_%s_%s_%i.png",
"AnalysisPlots/",
dataName.c_str(),
830 "xsec",
"results_all_systs",xsecResult.c_str(),xbin);
831 cResult->SaveAs(name);
834 c3->SetLeftMargin(0.15);
835 hUncert_tot->GetXaxis()->SetRangeUser(1.0,10.0);
836 hUncert_tot->SetMarkerStyle(20);
838 hTrueSignal->Draw(
"hist same");
839 hUncert_tot->Draw(
"same");
840 sprintf(name,
"%s%s_%s_%s_%s_%i.png",
"AnalysisPlots/",
dataName.c_str(),
841 "xsec",
"results_truth_compare",xsecResult.c_str(),xbin);
846 TH1F* hRelUnc_tot = (TH1F*)hUncert_tot->Clone(
ana::UniqueName().c_str());
847 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
848 double uncert = hRelUnc_tot->GetBinError(i);
849 double total = hRelUnc_tot->GetBinContent(i);
850 if(total == 0) hRelUnc_tot->SetBinContent(i,0);
851 else hRelUnc_tot->SetBinContent(i,uncert/total);
855 std::vector<TH1F*> hRelUncert;
856 for(
int i = 0; i < (
int)systs_up.size();i++){
861 for(
int ibin = 0;
ibin <= hHolder->GetXaxis()->GetNbins();
ibin++){
862 double val_up = hHolder->GetBinContent(
ibin);
863 double val_down = hHolderLo->GetBinContent(
ibin);
864 double val_cv = hXsec_cv->GetBinContent(
ibin);
871 if(val_cv == 0) hHolder->SetBinContent(
ibin,0);
872 else hHolder->SetBinContent(
ibin,uncert/val_cv);
874 hRelUncert.push_back(hHolder);
879 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
880 double uncert = hRelUnc_fit->GetBinError(i);
881 double total = hRelUnc_fit->GetBinContent(i);
882 if(total == 0) hRelUnc_fit->SetBinContent(i,0);
883 else hRelUnc_fit->SetBinContent(i,uncert/total);
889 hRelUncert[5]->SetLineColor(
kGreen+2);
890 hRelUncert[4]->SetLineColor(
kOrange-3);
891 hRelUncert[0]->SetLineColor(
kRed - 2);
892 hRelUncert[1]->SetLineColor(kCyan-3);
893 hRelUncert[2]->SetLineColor(
kBlue-4);
894 hRelUncert[3]->SetLineColor(kMagenta+1);
895 hRelUnc_fit->SetLineColor(kBlack);
896 hRelUnc_fit->SetLineStyle(7);
897 hRelUnc_tot->SetLineColor(kBlack);
900 hRelUnc_tot->GetYaxis()->SetTitle(
"Relative Uncertainty");
901 hRelUnc_tot->SetTitle(
" ");
902 hRelUnc_tot->GetYaxis()->SetRangeUser(0,1.0);
903 hRelUnc_tot->GetXaxis()->SetRangeUser(1,10);
904 hRelUnc_tot->Draw(
"hist");
905 hRelUncert[5]->Draw(
"hist same");
906 hRelUncert[4]->Draw(
"hist same");
907 hRelUncert[3]->Draw(
"hist same");
908 hRelUncert[2]->Draw(
"hist same");
909 hRelUncert[1]->Draw(
"hist same");
910 hRelUncert[0]->Draw(
"hist same");
911 hRelUnc_fit->Draw(
"hist same");
912 hRelUnc_tot->Draw(
"hist same");
914 leg_systs->AddEntry(hRelUnc_tot,
"Total",
"l");
915 leg_systs->AddEntry(hRelUnc_fit,
"Fit",
"l");
916 leg_systs->AddEntry(hRelUncert[3],
"Calibration Normalization",
"l");
917 leg_systs->AddEntry(hRelUncert[2],
"Light Level",
"l");
918 leg_systs->AddEntry(hRelUncert[1],
"Flux",
"l");
919 leg_systs->AddEntry(hRelUncert[0],
"#nu-Interaction",
"l");
920 leg_systs->AddEntry(hRelUncert[4],
"Cherenkov Variation",
"l");
921 leg_systs->AddEntry(hRelUncert[5],
"Calibration Shape",
"l");
923 sprintf(name,
"%s%s_%s_%s_%s_%i.png",
"AnalysisPlots/",
dataName.c_str(),
924 "xsec",
"relative_uncertantiy",xsecResult.c_str(),xbin);
939 std::vector<TH1F*>systs_up;
940 std::vector<TH1F*>systs_down;
942 for(
int i = 0; i < (
int)systs_up_2d.size(); i++){
943 systs_up.push_back((TH1F*)systs_up_2d[i]->
945 systs_down.push_back((TH1F*)systs_down_2d[i]->
949 TH1F* hUnfolded_SignalEst_1d =
952 TGraphAsymmErrors* g =
960 hXsec_cv->SetMarkerColor(kBlack);
961 hXsec_cv->SetLineColor(kBlack);
963 for(
int i = 1; i <= (
int)hUncert_tot->GetXaxis()->GetNbins();i++){
964 double uncert = hUnfolded_SignalEst_1d->GetBinError(i);
965 double total = hUncert_tot->GetBinContent(i);
966 double selected_tot = hUnfolded_SignalEst_1d->GetBinContent(i);
967 double err_hi = g->GetErrorYhigh(i);
968 double err_lo = g->GetErrorYlow(i);
971 double err_fluxeff = (err_hi > err_lo)? err_hi/total : err_lo/total;
974 double tot_err = total*
sqrt(
pow(uncert/selected_tot,2) +
976 if(total == 0) tot_err = 0;
978 hUncert_tot->SetBinError(i,tot_err);
980 std::cout << i <<
"\t" << total <<
"\t" <<
981 uncert <<
"\t" << selected_tot <<
"\t" <<
982 err_fluxeff <<
"\t" <<
983 sqrt(
pow(uncert/selected_tot,2) +
988 hUncert_tot->GetYaxis()->SetTitle(
"#frac{d #sigma}{dE_{e}} #left(#frac{10^{-38} cm^{2}}{nucleon GeV}#right)");
989 hUncert_tot->GetXaxis()->SetTitle(
"Electron Energy, E_{#e} (GeV)");
990 hUncert_tot->SetTitle(
"");
993 cResult->SetLeftMargin(0.15);
994 hUncert_tot->GetXaxis()->SetRangeUser(1.0,10.0);
995 hUncert_tot->SetMarkerStyle(20);
998 systs_down[2]->Draw(
"hist same");
999 systs_up[2]->Draw(
"hist same");
1000 systs_up[4]->Draw(
"hist same");
1001 systs_down[3]->Draw(
"hist same");
1002 systs_up[3]->Draw(
"hist same");
1003 systs_up[5]->Draw(
"hist same");
1004 systs_up[0]->Draw(
"hist same");
1005 systs_down[0]->Draw(
"hist same");
1006 systs_up[1]->Draw(
"hist same");
1007 systs_down[1]->Draw(
"hist same");
1008 hTrueSignal->Draw(
"hist same");
1009 hUncert_tot->Draw(
"same");
1011 leg_total->AddEntry(hTrueSignal,
"Truth",
"l");
1012 leg_total->AddEntry(hUncert_tot,
"FakeData",
"p");
1013 leg_total->AddEntry(systs_down[3],
"Calibration -1 #sigma",
"l");
1014 leg_total->AddEntry(systs_up[3],
"Calibration +1 #sigma",
"l");
1015 leg_total->AddEntry(systs_down[2],
"Light Level -1 #sigma",
"l");
1016 leg_total->AddEntry(systs_up[2],
"Light Level +1 #sigma",
"l");
1017 leg_total->AddEntry(systs_up[4],
"Cherenkov Variation",
"l");
1018 leg_total->AddEntry(systs_up[5],
"Calibration Shape",
"l");
1019 leg_total->AddEntry(systs_down[1],
"Flux -1 #sigma",
"l");
1020 leg_total->AddEntry(systs_up[1],
"Flux +1 #sigma",
"l");
1021 leg_total->AddEntry(systs_down[0],
"#nu-Interaction -1 #sigma",
"l");
1022 leg_total->AddEntry(systs_up[0],
"#nu-Interaction +1 #sigma",
"l");
1024 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1025 "xsec",
"results_all_systs",xsecResult.c_str(),
"elecE");
1026 cResult->SaveAs(name);
1029 c3->SetLeftMargin(0.15);
1030 hUncert_tot->GetXaxis()->SetRangeUser(1.0,10.0);
1031 hUncert_tot->SetMarkerStyle(20);
1032 hUncert_tot->Draw();
1033 hTrueSignal->Draw(
"hist same");
1034 hUncert_tot->Draw(
"same");
1035 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1036 "xsec",
"results_truth_compare",xsecResult.c_str(),
"elecE");
1041 TH1F* hRelUnc_tot = (TH1F*)hUncert_tot->Clone(
ana::UniqueName().c_str());
1042 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
1043 double uncert = hRelUnc_tot->GetBinError(i);
1044 double total = hRelUnc_tot->GetBinContent(i);
1045 if(total == 0) hRelUnc_tot->SetBinContent(i,0);
1046 else hRelUnc_tot->SetBinContent(i,uncert/total);
1050 std::vector<TH1F*> hRelUncert;
1051 for(
int i = 0; i < (
int)systs_up.size();i++){
1056 for(
int ibin = 0;
ibin <= hHolder->GetXaxis()->GetNbins();
ibin++){
1057 double val_up = hHolder->GetBinContent(
ibin);
1058 double val_down = hHolderLo->GetBinContent(
ibin);
1059 double val_cv = hXsec_cv->GetBinContent(
ibin);
1064 if(val_cv == 0) hHolder->SetBinContent(
ibin,0);
1065 else hHolder->SetBinContent(
ibin,uncert/val_cv);
1067 hRelUncert.push_back(hHolder);
1071 TH1F* hRelUnc_fit = (TH1F*)hXsec_cv->Clone(
ana::UniqueName().c_str());
1072 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
1073 double uncert = hRelUnc_fit->GetBinError(i);
1074 double total = hRelUnc_fit->GetBinContent(i);
1075 if(total == 0) hRelUnc_fit->SetBinContent(i,0);
1076 else hRelUnc_fit->SetBinContent(i,uncert/total);
1082 hRelUncert[5]->SetLineColor(
kGreen+2);
1083 hRelUncert[4]->SetLineColor(
kOrange-3);
1084 hRelUncert[0]->SetLineColor(
kRed - 2);
1085 hRelUncert[1]->SetLineColor(kCyan-3);
1086 hRelUncert[2]->SetLineColor(
kBlue-4);
1087 hRelUncert[3]->SetLineColor(kMagenta+1);
1088 hRelUnc_fit->SetLineColor(kBlack);
1089 hRelUnc_fit->SetLineStyle(7);
1090 hRelUnc_tot->SetLineColor(kBlack);
1093 hRelUnc_tot->GetYaxis()->SetTitle(
"Relative Uncertainty");
1094 hRelUnc_tot->SetTitle(
" ");
1095 hRelUnc_tot->GetYaxis()->SetRangeUser(0,1.0);
1096 hRelUnc_tot->GetXaxis()->SetRangeUser(1,10);
1097 hRelUnc_tot->Draw(
"hist");
1098 hRelUncert[5]->Draw(
"hist same");
1099 hRelUncert[4]->Draw(
"hist same");
1100 hRelUncert[3]->Draw(
"hist same");
1101 hRelUncert[2]->Draw(
"hist same");
1102 hRelUncert[1]->Draw(
"hist same");
1103 hRelUncert[0]->Draw(
"hist same");
1104 hRelUnc_fit->Draw(
"hist same");
1105 hRelUnc_tot->Draw(
"hist same");
1107 leg_systs->AddEntry(hRelUnc_tot,
"Total",
"l");
1108 leg_systs->AddEntry(hRelUnc_fit,
"Fit",
"l");
1109 leg_systs->AddEntry(hRelUncert[3],
"Calibration Normalization",
"l");
1110 leg_systs->AddEntry(hRelUncert[2],
"Light Level",
"l");
1111 leg_systs->AddEntry(hRelUncert[1],
"Flux",
"l");
1112 leg_systs->AddEntry(hRelUncert[0],
"#nu-Interaction",
"l");
1113 leg_systs->AddEntry(hRelUncert[4],
"Cherenkov Variation",
"l");
1114 leg_systs->AddEntry(hRelUncert[5],
"Calibration Shape",
"l");
1116 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1117 "xsec",
"relative_uncertantiy",xsecResult.c_str(),
"elecE");
1129 std::vector<TH1F*>systs_up;
1130 std::vector<TH1F*>systs_down;
1132 for(
int i = 0; i < (
int)systs_up_2d.size(); i++){
1133 systs_up.push_back((TH1F*)systs_up_2d[i]->
1135 systs_down.push_back((TH1F*)systs_down_2d[i]->
1139 TH1F* hUnfolded_SignalEst_1d =
1142 TGraphAsymmErrors* g =
1144 systs_up,systs_down,
1150 hXsec_cv->SetMarkerColor(kBlack);
1151 hXsec_cv->SetLineColor(kBlack);
1152 TH1F* hUncert_tot = (TH1F*)hXsec_cv->Clone(
ana::UniqueName().c_str());
1153 for(
int i = 1; i <= (
int)hUncert_tot->GetXaxis()->GetNbins();i++){
1154 double uncert = hUnfolded_SignalEst_1d->GetBinError(i);
1155 double total = hUncert_tot->GetBinContent(i);
1156 double selected_tot = hUnfolded_SignalEst_1d->GetBinContent(i);
1157 double err_hi = g->GetErrorYhigh(i);
1158 double err_lo = g->GetErrorYlow(i);
1161 double err_fluxeff = (err_hi > err_lo) ? err_hi/total : err_lo/total;
1164 double tot_err = total*
sqrt(
pow(uncert/selected_tot,2) +
1165 pow(err_fluxeff,2));
1166 if(total == 0) tot_err = 0;
1168 hUncert_tot->SetBinError(i,tot_err);
1170 std::cout << i <<
"\t" << total <<
"\t" <<
1171 uncert <<
"\t" << selected_tot <<
"\t" <<
1172 err_fluxeff <<
"\t" <<
1173 sqrt(
pow(uncert/selected_tot,2) +
1178 hUncert_tot->GetYaxis()->SetTitle(
"#frac{d #sigma}{dcos #theta} #left(#frac{10^{-38} cm^{2}}{nucleon}#right)");
1179 hUncert_tot->GetXaxis()->SetTitle(
"cos #theta_{e}");
1180 hUncert_tot->SetTitle(
"");
1183 cResult->SetLeftMargin(0.15);
1184 hUncert_tot->GetXaxis()->SetRangeUser(0.75,1.0);
1185 hUncert_tot->SetMarkerStyle(20);
1186 hUncert_tot->Draw();
1188 systs_down[2]->Draw(
"hist same");
1189 systs_up[2]->Draw(
"hist same");
1190 systs_up[4]->Draw(
"hist same");
1191 systs_down[3]->Draw(
"hist same");
1192 systs_up[3]->Draw(
"hist same");
1193 systs_up[5]->Draw(
"hist same");
1194 systs_up[0]->Draw(
"hist same");
1195 systs_down[0]->Draw(
"hist same");
1196 systs_up[1]->Draw(
"hist same");
1197 systs_down[1]->Draw(
"hist same");
1198 hTrueSignal->Draw(
"hist same");
1199 hUncert_tot->Draw(
"same");
1201 leg_total->AddEntry(hTrueSignal,
"Truth",
"l");
1202 leg_total->AddEntry(hUncert_tot,
"FakeData",
"p");
1203 leg_total->AddEntry(systs_down[3],
"Calibration -1 #sigma",
"l");
1204 leg_total->AddEntry(systs_up[3],
"Calibration +1 #sigma",
"l");
1205 leg_total->AddEntry(systs_down[2],
"Light Level -1 #sigma",
"l");
1206 leg_total->AddEntry(systs_up[2],
"Light Level +1 #sigma",
"l");
1207 leg_total->AddEntry(systs_up[4],
"Cherenkov Variation",
"l");
1208 leg_total->AddEntry(systs_up[5],
"Calibration Shape",
"l");
1209 leg_total->AddEntry(systs_down[1],
"Flux -1 #sigma",
"l");
1210 leg_total->AddEntry(systs_up[1],
"Flux +1 #sigma",
"l");
1211 leg_total->AddEntry(systs_down[0],
"#nu-Interaction -1 #sigma",
"l");
1212 leg_total->AddEntry(systs_up[0],
"#nu-Interaction +1 #sigma",
"l");
1214 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1215 "xsec",
"results_all_systs",xsecResult.c_str(),
"costheta");
1216 cResult->SaveAs(name);
1219 c3->SetLeftMargin(0.15);
1220 hUncert_tot->GetXaxis()->SetRangeUser(0.75,1.0);
1221 hUncert_tot->SetMarkerStyle(20);
1222 hUncert_tot->Draw();
1223 hTrueSignal->Draw(
"hist same");
1224 hUncert_tot->Draw(
"same");
1225 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1226 "xsec",
"results_truth_compare",xsecResult.c_str(),
"costheta");
1231 TH1F* hRelUnc_tot = (TH1F*)hUncert_tot->Clone(
ana::UniqueName().c_str());
1232 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
1233 double uncert = hRelUnc_tot->GetBinError(i);
1234 double total = hRelUnc_tot->GetBinContent(i);
1235 if(total == 0) hRelUnc_tot->SetBinContent(i,0);
1236 else hRelUnc_tot->SetBinContent(i,uncert/total);
1240 std::vector<TH1F*> hRelUncert;
1241 for(
int i = 0; i < (
int)systs_up.size();i++){
1246 for(
int ibin = 0;
ibin <= hHolder->GetXaxis()->GetNbins();
ibin++){
1247 double val_up = hHolder->GetBinContent(
ibin);
1248 double val_down = hHolderLo->GetBinContent(
ibin);
1249 double val_cv = hXsec_cv->GetBinContent(
ibin);
1254 if(val_cv == 0) hHolder->SetBinContent(
ibin,0);
1255 else hHolder->SetBinContent(
ibin,uncert/val_cv);
1257 hRelUncert.push_back(hHolder);
1261 TH1F* hRelUnc_fit = (TH1F*)hXsec_cv->Clone(
ana::UniqueName().c_str());
1262 for(
int i = 0; i <= (
int)hRelUnc_tot->GetXaxis()->GetNbins();i++){
1263 double uncert = hRelUnc_fit->GetBinError(i);
1264 double total = hRelUnc_fit->GetBinContent(i);
1265 if(total == 0) hRelUnc_fit->SetBinContent(i,0);
1266 else hRelUnc_fit->SetBinContent(i,uncert/total);
1272 hRelUncert[5]->SetLineColor(
kGreen+2);
1273 hRelUncert[4]->SetLineColor(
kOrange-3);
1274 hRelUncert[0]->SetLineColor(
kRed - 2);
1275 hRelUncert[1]->SetLineColor(kCyan-3);
1276 hRelUncert[2]->SetLineColor(
kBlue-4);
1277 hRelUncert[3]->SetLineColor(kMagenta+1);
1278 hRelUnc_fit->SetLineColor(kBlack);
1279 hRelUnc_fit->SetLineStyle(7);
1280 hRelUnc_tot->SetLineColor(kBlack);
1283 hRelUnc_tot->GetYaxis()->SetTitle(
"Relative Uncertainty");
1284 hRelUnc_tot->SetTitle(
" ");
1285 hRelUnc_tot->GetYaxis()->SetRangeUser(0,1.0);
1286 hRelUnc_tot->GetXaxis()->SetRangeUser(0.75,1);
1287 hRelUnc_tot->Draw(
"hist");
1288 hRelUncert[5]->Draw(
"hist same");
1289 hRelUncert[4]->Draw(
"hist same");
1290 hRelUncert[3]->Draw(
"hist same");
1291 hRelUncert[2]->Draw(
"hist same");
1292 hRelUncert[1]->Draw(
"hist same");
1293 hRelUncert[0]->Draw(
"hist same");
1294 hRelUnc_fit->Draw(
"hist same");
1295 hRelUnc_tot->Draw(
"hist same");
1297 leg_systs->AddEntry(hRelUnc_tot,
"Total",
"l");
1298 leg_systs->AddEntry(hRelUnc_fit,
"Fit",
"l");
1299 leg_systs->AddEntry(hRelUncert[3],
"Calibration Normalization",
"l");
1300 leg_systs->AddEntry(hRelUncert[2],
"Light Level",
"l");
1301 leg_systs->AddEntry(hRelUncert[1],
"Flux",
"l");
1302 leg_systs->AddEntry(hRelUncert[0],
"#nu-Interaction",
"l");
1303 leg_systs->AddEntry(hRelUncert[4],
"Cherenkov Variation",
"l");
1304 leg_systs->AddEntry(hRelUncert[5],
"Calibration Shape",
"l");
1306 sprintf(name,
"%s%s_%s_%s_%s_%s.png",
"AnalysisPlots/",
dataName.c_str(),
1307 "xsec",
"relative_uncertantiy",xsecResult.c_str(),
"costheta");
T max(const caf::Proxy< T > &a, T b)
void MakePlots(TH2F *hFitted2D, std::vector< TH2F * > hSysts, TH2F *hTruth2D, std::string ytitle, std::string xtitle, std::string dataName, std::string xsecResult, std::string varName, bool calcCov=false)
fvar< T > fabs(const fvar< T > &x)
Eigen::ArrayXd ProjectionX(const Eigen::MatrixXd &mat)
Helper for Unweighted.
const ana::Binning eelecbins
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
const SelDef chns[knumchns]
double Integral(const Spectrum &s, const double pot, int cvnregion)
const ana::Binning costhetabins
const std::string sSignalEst
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Representation of a spectrum in any variable, with associated POT.
TH1F * DoUnfolding(TH1F *hMeasured, TH2F *hResponse, int iter)
std::vector< float > Spectrum
const std::string sAnalysis
const ana::Binning enubins
Eigen::ArrayXd ProjectionY(const Eigen::MatrixXd &mat)
Helper for WeightingVariable.
void MakePlots1D(TH2F *hData, TH2F *hFit, TH2F *hMC, std::string ytitle, std::string xtitle, std::string dataName, std::string xsecResult, std::string varName)
const Spectrum * UpperSigma(BandOptions opt=kBandFromNominal) const
const Spectrum * LowerSigma(BandOptions opt=kBandFromNominal) const
TLegend * AutoPlaceLegend(double dx, double dy, double yPin)
Create a legend, maximizing distance from all histograms.
TH3 * ToTH3(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, const Binning &binsz, ana::EBinType bintype)
Same as ToTH2, but with 3 dimensions.
std::string UniqueName()
Return a different string each time, for creating histograms.
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
TGraphAsymmErrors * PlotSystErrorBand(TH1F *&nom, std::vector< TH1F * > &ups, std::vector< TH1F * > &dns, int col, int errCol, float headroom, bool newaxis)