resolutionscript.C
Go to the documentation of this file.
1 #pragma once
2 
4 #include "CAFAna/Core/Spectrum.h"
5 
7 
11 
12 #include "CAFAna/Vars/XsecTunes.h"
14 
15 // temporary measure to use prod4 trained muonid
16 #include "NDAna/muonid/NDXSecMuonPID.h"
17 namespace nuebarccinc {
18  const ana::Cut kMuonIDProd4Cut = ana::kMuonIDProd4 < -0.2;
19 }
20 
22 {
23  const int ret = gSystem->Load("libNDAnamuonid");
24  if(ret != 0) exit(1);
25 }
26 
27 using namespace ana;
28 
29 HistAxis HistAxis2D(const HistAxis & x, const HistAxis & y);
30 
32 {
33 
35  //Setup the loaders and apply the spill cuts
38 
39  HistAxis axTrueElectronEnergy("True E_{e} (GeV)",
40  Binning::Simple(100, 0, 10),
42  HistAxis axTrueElectronCosTheta("True cos#theta_{e}",
43  Binning::Simple(50, 0, 1.01),
45  HistAxis axRecoElectronEnergy("Reco E_{e} (GeV)",
46  Binning::Simple(100, 0, 10),
48  HistAxis axRecoElectronCosTheta("Reco cos#theta_{e}",
49  Binning::Simple(50, 0, 1.01),
51 
52  HistAxis axFracResElectronEnergy("Fractional resolution",
53  Binning::Simple(1000, -2, 2),
55  HistAxis axFracResElectronCosTheta("Fractional resolution",
56  Binning::Simple(1000, -2, 2),
58 
59  HistAxis axAbsResElectronEnergy("Absolute resolution",
60  Binning::Simple(1000, -15, 15),
62  HistAxis axAbsResElectronCosTheta("Absolute resolution",
63  Binning::Simple(1000, -2, 2),
65 
66  // Only Concerned with how well we are able to reconstruct
67  // Electron Neutrino events so we only need 2 Truth Cuts
68  // kIsNueCC && kIsAntiNueCC (since we can't really tell the difference)
69 
71  const Cut kSelectedNueNuebarCC =
76 
77  const Cut kSelectedNuebarCC =
81  /////////////////////////////////////////////////////
82  Spectrum reco_angular_frac(lNDMC,
83  axRecoElectronCosTheta,
84  axFracResElectronCosTheta,
85  kSelectedNueNuebarCC,
86  kNoShift,
87  kCVWeight);
88  //**************************************************
89  Spectrum reco_angular_abs(lNDMC,
90  axRecoElectronCosTheta,
91  axAbsResElectronCosTheta,
92  kSelectedNueNuebarCC,
93  kNoShift,
94  kCVWeight);
95  /////////////////////////////////////////////////////
96  Spectrum truth_angular_frac(lNDMC,
97  axTrueElectronCosTheta,
98  axFracResElectronCosTheta,
99  kSelectedNueNuebarCC,
100  kNoShift,
101  kCVWeight);
102  //**************************************************
103  Spectrum truth_angular_abs(lNDMC,
104  axTrueElectronCosTheta,
105  axAbsResElectronCosTheta,
106  kSelectedNueNuebarCC,
107  kNoShift,
108  kCVWeight);
109  /////////////////////////////////////////////////////
110  Spectrum reco_energy_frac(lNDMC,
111  axRecoElectronEnergy,
112  axFracResElectronEnergy,
113  kSelectedNueNuebarCC,
114  kNoShift,
115  kCVWeight);
116  //**************************************************
117  Spectrum reco_energy_abs(lNDMC,
118  axRecoElectronEnergy,
119  axAbsResElectronEnergy,
120  kSelectedNueNuebarCC,
121  kNoShift,
122  kCVWeight);
123  /////////////////////////////////////////////////////
124  Spectrum truth_energy_frac(lNDMC,
125  axTrueElectronEnergy,
126  axFracResElectronEnergy,
127  kSelectedNueNuebarCC,
128  kNoShift,
129  kCVWeight);
130  //**************************************************
131  Spectrum truth_energy_abs(lNDMC,
132  axTrueElectronEnergy,
133  axAbsResElectronEnergy,
134  kSelectedNueNuebarCC,
135  kNoShift,
136  kCVWeight);
137 
138  /////////////////////////////////////////////////////
139  Spectrum standard_axis_truth_energy_abs(lNDMC,
141  axAbsResElectronEnergy,
142  kSelectedNueNuebarCC,
143  kNoShift,
144  kCVWeight);
145  //**************************************************
146  Spectrum standard_axis_reco_energy_abs(lNDMC,
148  axAbsResElectronEnergy,
149  kSelectedNueNuebarCC,
150  kNoShift,
151  kCVWeight);
152 
153  /////////////////////////////////////////////////////
154  Spectrum standard_axis_truth_angular_abs(lNDMC,
156  axAbsResElectronCosTheta,
157  kSelectedNueNuebarCC,
158  kNoShift,
159  kCVWeight);
160  //**************************************************
161  Spectrum standard_axis_reco_angular_abs(lNDMC,
163  axAbsResElectronCosTheta,
164  kSelectedNueNuebarCC,
165  kNoShift,
166  kCVWeight);
167  /////////////////////////////////////////////////////
168  Spectrum signal_reco_energy_vs_cos(lNDMC,
170  kSelectedNuebarCC,
171  kNoShift,
172  kCVWeight);
173 
174  Spectrum signal_truth_energy_vs_cos(lNDMC,
176  kSelectedNuebarCC,
177  kNoShift,
178  kCVWeight);
179 
180  lNDMC.Go();
181 
182  TFile* out = new TFile("resolution_spectra.root", "recreate");
183  out->cd();
184 
185  reco_angular_frac.SaveTo(out, "reco_angular_frac");
186  truth_angular_frac.SaveTo(out, "truth_angular_frac");
187 
188  reco_energy_frac.SaveTo(out, "reco_energy_frac");
189  truth_energy_frac.SaveTo(out, "truth_energy_frac");
190 
191  reco_angular_abs.SaveTo(out, "reco_angular_abs");
192  truth_angular_abs.SaveTo(out, "truth_angular_abs");
193 
194  reco_energy_abs.SaveTo(out, "reco_energy_abs");
195  truth_energy_abs.SaveTo(out, "truth_energy_abs");
196 
197  standard_axis_reco_angular_abs .SaveTo(out, "standard_axis_reco_angular_abs");
198  standard_axis_truth_angular_abs.SaveTo(out, "standard_axis_truth_angular_abs");
199  standard_axis_reco_energy_abs .SaveTo(out, "standard_axis_reco_energy_abs");
200  standard_axis_truth_energy_abs .SaveTo(out, "standard_axis_truth_energy_abs");
201 
202  signal_reco_energy_vs_cos .SaveTo(out, "signal_reco_energy_vs_cos");
203  signal_truth_energy_vs_cos.SaveTo(out, "signal_truth_energy_vs_cos");
204 
205  out->Close();
206 }
207 
208 HistAxis HistAxis2D(const HistAxis & x, const HistAxis & y)
209 {
210  return HistAxis(x.GetLabels()[0], x.GetBinnings()[0], x.GetMultiDVar(),
211  y.GetLabels()[0], y.GetBinnings()[0], y.GetMultiDVar());
212 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const ana::Var kAbsResTrueElectronE
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const ana::Cut kNuebarCC
const ana::HistAxis kTrueElectronEStandardAxis
const ana::Var kCVWeight
const ana::Var kTrueElectronRecoCosTheta([](const caf::SRProxy *sr) ->float{if(!sr->vtx.elastic.IsValid) return-1000.f;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1000.f;int true_electron_idx=true_electron_png(sr);if(true_electron_idx< 0) return-5.f;TVector3 elecdir=(TVector3) sr->vtx.elastic.fuzzyk.png[true_electron_idx].dir;TVector3 beamdir=ana::NuMIBeamDirection(caf::kNEARDET);return elecdir.Dot(beamdir);})
void SetSpillCut(const SpillCut &cut)
const ana::HistAxis kTrueElectronEVsCosStandardAxis
const ana::HistAxis kRecoElectronCosThetaStandardAxis("Reco cos #theta_{e}", costhetabins, kRecoElectronCosTheta)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const ana::Var kTrueElectronRecoE
const ana::Var kFracResTrueElectronCosTheta
const ana::HistAxis kTrueElectronCosThetaStandardAxis
const ana::Var kTrueElectronCosTheta
const std::string PROD5_MC_RHC_NOMINAL
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:534
const ana::Cut kPreselectionLoose
const ana::HistAxis kRecoElectronEStandardAxis("Reco E_{e} (GeV)", eelecbins, kElectronE)
const ana::Cut kHasReconstructedElectronProng([](const caf::SRProxy *sr){return true_electron_png(sr) >=0;})
const SystShifts kNoShift
Definition: SystShifts.cxx:22
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
HistAxis HistAxis2D(const HistAxis &x, const HistAxis &y)
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
exit(0)
const ana::Var kTrueElectronE
const ana::Cut kMuonIDProd4Cut
Definition: datamc.C:28
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const ana::Cut kNueCC
const ana::HistAxis kRecoElectronEVsCosStandardAxis({"cos#theta","Elec_{e} (GeV)"},{costhetabins, eelecbins},{kRecoElectronCosTheta, kElectronE})
void load_libs_muonid()
void resolutionscript()
const ana::Var kAbsResTrueElectronCosTheta
_HistAxis< Var > HistAxis
Definition: HistAxis.h:10
const std::vector< std::string > & GetLabels() const
Definition: LabelsAndBins.h:68
const Var kXSecCVWgt2020
Definition: XsecTunes.h:105
const ana::Var kFracResTrueElectronE