AnalyzeNus18Pred.C
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////
2 // AnalyzeNus18Pred.C
3 // M Wallbank (wallbank@fnal.gov)
4 //
5 // Analyze predictions.
6 //////////////////////////////////////////////////////////////
7 
8 // framework
11 #include "CAFAna/Analysis/Style.h"
15 
16 // stl
17 #include <iomanip>
18 #include <utility>
19 
20 // root
21 #include "TH1.h"
22 #include "TLegend.h"
23 #include "TCanvas.h"
24 #include "TFile.h"
25 
26 using namespace ana;
27 
28 void AnalyzeNus18Pred(TString opt) {
29 
30  TH1::AddDirectory(0);
31 
32  // Get running options
33  bool rhc = opt.Contains("rhc", TString::kIgnoreCase);
34  bool fhc = opt.Contains("fhc", TString::kIgnoreCase);
35  assert(rhc || fhc);
36 
37  bool systematics = opt.Contains("syst", TString::kIgnoreCase);
38  bool cosmics = opt.Contains("cos", TString::kIgnoreCase);
39 
40  // Get the POT and livetime
41  double pot = fhc ? kAna2018FHCPOT : kAna2018RHCPOT;
43 
44  // Get the IPrediction and Cosmic spectrum
47 
48  // Get calculator
50  SetAngles(calc);
51 
52  // Get each component
53  TH1* total = pred->Predict(calc).ToTH1(pot);
58  TH1* cos = cosmic.ToTH1(livetime, kLivetime);
59  total->Add(cos);
60 
61  // Plot spectra
62  TCanvas* canv = new TCanvas("canv", "", 800, 600);
63  TLegend* leg = new TLegend(0.6, 0.5, 0.88, 0.88);
64 
65  total->SetLineWidth(2);
66  total->SetLineColor(kTotalMCColor);
67  leg->AddEntry(total, "Total Prediction", "l");
68  total->Draw("hist");
69 
70  nc->SetLineWidth(2);
71  nc->SetLineColor(kNCBackgroundColor);
72  leg->AddEntry(nc, "NC", "l");
73  nc->Draw("hist same");
74 
75  numu->SetLineWidth(2);
76  numu->SetLineColor(kNumuBackgroundColor);
77  leg->AddEntry(numu, "#nu_{#mu} CC", "l");
78  numu->Draw("hist same");
79 
80  nue->SetLineWidth(2);
81  nue->SetLineColor(kNueSignalColor);
82  leg->AddEntry(nue, "#nu_{e} CC", "l");
83  nue->Draw("hist same");
84 
85  nutau->SetLineWidth(2);
86  nutau->SetLineColor(kBeamNueBackgroundColor);
87  leg->AddEntry(nutau, "#nu_{#tau} CC", "l");
88  nutau->Draw("hist same");
89 
90  cos->SetLineWidth(2);
91  cos->SetLineColor(kCosmicBackgroundColor);
92  leg->AddEntry(cos, "Cosmic", "l");
93  cos->Draw("hist same");
94 
95  leg->Draw();
96 
97  // Save
98  TFile* outFile = new TFile("Nus18PredAnalysis.root", "RECREATE");
99  total->Write("Total");
100  nc->Write("NC");
101  numu->Write("NuMu");
102  nue->Write("NuE");
103  nutau->Write("NuTau");
104  cos->Write("Cos");
105  canv->Write("All");
106  outFile->Close();
107 
108  // Print
109  std::cout << std::endl << "Number of events: (POT " << pot << ", livetime " << livetime << ")" << std::endl;
110  std::cout << "------------------------------------------------------------------------"
111  << "------------------------------------------------------------------------" << std::endl;
112  std::cout << setw(12) << "Total" << setw(12) << "NC" << setw(12) << "numu" << setw(12) << "nue"
113  << setw(12) << "nutau" << setw(12) << "Cosmics" << std::endl;
114  std::cout << "------------------------------------------------------------------------"
115  << "------------------------------------------------------------------------" << std::endl << std::endl;
116  std::cout << setw(12) << total->Integral()
117  << setw(12) << nc->Integral()
118  << setw(12) << numu->Integral()
119  << setw(12) << nue->Integral()
120  << setw(12) << nutau->Integral()
121  << setw(12) << cos->Integral()
122  << std::endl;
123 
124  return;
125 
126 }
IPrediction * LoadExtrapPrediction(TString opt)
Spectrum LoadCosmicSpectrum(bool rhc=false)
Function to return cosmic spectrum.
osc::OscCalculatorDumb calc
Oscillation analysis framework, runs over CAF files outside of ART.
Adapt the PMNS_Sterile calculator to standard interface.
const Color_t kCosmicBackgroundColor
Definition: Style.h:28
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.
Definition: Spectrum.cxx:553
virtual Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const =0
TCanvas * canv
void AnalyzeNus18Pred(TString opt)
const Color_t kNumuBackgroundColor
Definition: Style.h:31
virtual Spectrum Predict(osc::IOscCalculator *calc) const =0
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
const double kAna2018RHCPOT
Definition: Exposures.h:208
const Color_t kNueSignalColor
Definition: Style.h:19
Charged-current interactions.
Definition: IPrediction.h:39
Sum up livetimes from individual cosmic triggers.
TFile * outFile
Definition: PlotXSec.C:135
const Color_t kBeamNueBackgroundColor
Definition: Style.h:24
void SetAngles(osc::OscCalculatorSterile *calc)
#define pot
OStream cout
Definition: OStream.cxx:6
Neutral-current interactions.
Definition: IPrediction.h:40
T cos(T number)
Definition: d0nt_math.hpp:78
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
bool systematics
Definition: fnexvscaf.C:31
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const Color_t kTotalMCColor
Definition: Style.h:17
const double kAna2018FHCPOT
Definition: Exposures.h:207
osc::OscCalculatorSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
All neutrinos, any flavor.
Definition: IPrediction.h:26
const Color_t kNCBackgroundColor
Definition: Style.h:22
const double kAna2018FHCLivetime
Definition: Exposures.h:213
const double kAna2018RHCLivetime
Definition: Exposures.h:214