SystsCalibAbsLoad17.C
Go to the documentation of this file.
4 #include "CAFAna/Cuts/Cuts.h"
5 #include "NuXAna/Cuts/NusCuts.h"
10 #include "CAFAna/Extrap/ExtrapSterile.h"
13 #include "CAFAna/Systs/Systs.h"
18 #include "NuXAna/Vars/HistAxes.h"
19 
20 using namespace ana;
21 
23 {
24  TH1::AddDirectory(0);
25 
26 
27  const Var kWgtP3 = kXSecCVWgt2017*kPPFXFluxCVWgt;
28 
29 
30  const std::string fnameneardata_conc="prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
31  SpectrumLoader floadneardata(fnameneardata_conc);
32  floadneardata.SetSpillCut(kStandardSpillCuts);
33 
34  std::string fnear_ns="defname: prod_caf_R17-03-01-prod3reco.l_nd_genie_nonswap_fhc_nova_v08_full_no-shift_v1";
35  std::string ffar_ns="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_lightmodel-noshift_v2";
36  std::string fswap_ns="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_lightmodel-noshift_v2";
37  std::string ftau_ns="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_lightmodel-noshift_v2";
38 
39  SpectrumLoader floadnear_ns(fnear_ns);
40  SpectrumLoader floadfar_ns(ffar_ns);
41  SpectrumLoader floadswap_ns(fswap_ns);
42  SpectrumLoader floadtau_ns(ftau_ns);
43  floadnear_ns .SetSpillCut(kStandardSpillCuts);
44  floadfar_ns .SetSpillCut(kStandardSpillCuts);
45  floadswap_ns .SetSpillCut(kStandardSpillCuts);
46  floadtau_ns .SetSpillCut(kStandardSpillCuts);
47 
48 
49 
50 
51 
52  std::string Llevelu="defname: prod_caf_R17-03-01-prod3reco.l_nd_genie_nonswap_fhc_nova_v08_full_lightmodel-lightup-calibdown_v1";
53  std::string Lleveld="defname: prod_caf_R17-03-01-prod3reco.l_nd_genie_nonswap_fhc_nova_v08_full_lightmodel-lightdown-calibup_v1";
54  std::string cherenkov="defname: prod_caf_R17-03-01-prod3reco.l_nd_genie_nonswap_fhc_nova_v08_full_ckv-proton-shift-down_v1";
55 
56 
57 
58  std::string Llevelu_fd="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_lightmodel-lightup-calibdown_v2";
59  std::string Llevelu_swp="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_lightmodel-lightup-calibdown_v2";
60  std::string Llevelu_tau="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_lightmodel-lightup-calibdown_v2";
61 
62  std::string Lleveld_fd="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_lightmodel-lightdown-calibup_v2";
63  std::string Lleveld_swp="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_lightmodel-lightdown-calibup_v2";
64  std::string Lleveld_tau="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_lightmodel-lightdown-calibup_v2";
65 
66 
67  std::string cherenkovfd="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_ckv-proton-shift-down_v2";
68  std::string cherenkovswp="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_ckv-proton-shift-down_v2";
69  std::string cherenkovtau="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_ckv-proton-shift-down_v2";
70 
71 
72 
73  std::map<std::string, std::vector<std::string> > shiftlabels;
74  shiftlabels["ULLevel"] = std::vector<std::string>();
75  shiftlabels["DLLevel"] = std::vector<std::string>();
76  shiftlabels["Cherenkov"] = std::vector<std::string>();
77 
78 
79 
80  shiftlabels["ULLevel"].push_back(Llevelu);
81  shiftlabels["ULLevel"].push_back(Llevelu_fd);
82  shiftlabels["ULLevel"].push_back(Llevelu_swp);
83  shiftlabels["ULLevel"].push_back(Llevelu_tau);
84 
85  shiftlabels["DLLevel"].push_back(Lleveld);
86  shiftlabels["DLLevel"].push_back(Lleveld_fd);
87  shiftlabels["DLLevel"].push_back(Lleveld_swp);
88  shiftlabels["DLLevel"].push_back(Lleveld_tau);
89 
90  shiftlabels["Cherenkov"].push_back(cherenkov);
91  shiftlabels["Cherenkov"].push_back(cherenkovfd);
92  shiftlabels["Cherenkov"].push_back(cherenkovswp);
93  shiftlabels["Cherenkov"].push_back(cherenkovtau);
94 
95 /* shiftlabels["Noshift"].push_back(fnear_ns);
96  shiftlabels["Noshift"].push_back(ffar_ns);
97  shiftlabels["Noshift"].push_back(fswap_ns);
98  shiftlabels["Noshift"].push_back(ftau_ns);
99 */
100 
101  // A map of systematic objects, indexed by the same label as above
102  std::map<std::string, std::vector<SpectrumLoader*> > systematics;
103 
104  for(const auto& shiftlabel : shiftlabels) {
105  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
106  for(const auto& samdef : shiftlabel.second){
107  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
108  systematics[shiftlabel.first].back()->SetSpillCut(kStandardSpillCuts);
109  }
110  }
111 
112  // Define a map of samples and cuts/axes to set them up
113  // Each sample, essentially, is a way to set up the analysis
114  std::string labelRecoE = "Visible Energy (GeV)";
115  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
116  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
117  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
118  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
119  Ana01
120  );
121 
122  // Set up maps to the decompositions/predictions (each flavor component)
123  // Nominal maps are indexed purely by sample label
124  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
125  std::map<std::string, IDecomp*> decomps_nominal;
126  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
127  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
128  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
129  std::map<std::string, PredictionSterile*> predsSt_nominal;
130  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
131 
132  //std::cout << "Hey I am here "<<std::cout;
133 
134  // Set up the actual decompositions/predictions
135  // sample.first = the sample label
136  // shiftlabel.first = the systematic shift label
137  // sample.second.first = the sample HistAxis
138  // sample.second.second = the sample Cut
139  for(const auto& sample : cut_samples) {
140  decomps_nominal[sample.first] = new ProportionalDecomp(
141  floadnear_ns, floadneardata,
142  *sample.second.first, *sample.second.second.first,
143  kNoShift, kNoShift, kWgtP3
144  );
145 
146  predsNE_nominal[sample.first] = new PredictionNoExtrap(
147  floadfar_ns, floadswap_ns, floadtau_ns,
148  labelRecoE, kNCDisappearanceEnergyBinning,kNusNDEnergy17,*sample.second.second.second,
149  kNoShift, kWgtP3
150  );
151 
152 
153 
154  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
155  floadnear_ns, floadneardata,
156  *sample.second.first, *sample.second.second.first,
157  kNoShift, kNoShift, kWgtP3
158  );
159  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
160  floadnear_ns, floadneardata,
162  kNoShift, kNoShift, kWgtP3
163  );
165  floadnear_ns, floadswap_ns, floadfar_ns, floadtau_ns, *decompnc_n, *decompnumu_n,
166  *sample.second.first, kNCBinsNumuCCAxis,
167  *sample.second.second.second, *sample.second.second.first, kNumuND,
168  kNoShift, kWgtP3
169  ));
170  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
171 
172  for(const auto& systlabel : systematics) {
173  int ndpos = 0;
174  int fdpos = 1;
175  int fspos = 2;
176  int ftpos=3;
177  decomps_shifted[sample.first][systlabel.first][1] = new ProportionalDecomp(
178  *systlabel.second[ndpos],floadneardata,
179  *sample.second.first, *sample.second.second.first,
180  kNoShift, kNoShift, kWgtP3
181  );
182  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
183  *systlabel.second[fdpos], *systlabel.second[fspos], *systlabel.second[ftpos],
184  labelRecoE, kNCDisappearanceEnergyBinning ,
185  kNusNDEnergy17, *sample.second.second.second,
186  kNoShift, kWgtP3
187  );
188 
189  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
190  *systlabel.second[ndpos], floadneardata,
191  *sample.second.first, *sample.second.second.first,
192  kNoShift, kNoShift, kWgtP3
193  );
194  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
195  *systlabel.second[ndpos], floadneardata,
197  kNoShift, kNoShift, kWgtP3
198  );
200  *systlabel.second[ndpos], *systlabel.second[fspos], *systlabel.second[fdpos],
201  *systlabel.second[ftpos], *decompnc_s, *decompnumu_s,
202  *sample.second.first, kNCBinsNumuCCAxis,
203  *sample.second.second.second, *sample.second.second.first, kNumuND,
204  kNoShift, kWgtP3
205  ));
206  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
207  extrap_s
208  );
209  }
210  }
211 
212  for(const auto& systlabel : systematics) {
213  for(const auto& loader : systlabel.second) {
214  loader->Go();
215  }
216  }
217  floadneardata.Go();
218  floadnear_ns.Go();
219  floadfar_ns .Go();
220  floadswap_ns.Go();
221  floadtau_ns.Go();
222 
223  std::string folder = "./";
224  std::string filenm = "SystsCalibAbs17";
225 
226  std::string fullLocation = folder + filenm + ".root";
227  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
228 
229  SaveMaps(rootF,
230  decomps_nominal, decomps_shifted,
231  predsNE_nominal, predsNE_shifted,
232  predsSt_nominal, predsSt_shifted
233  );
234 }
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
void SaveMaps(TDirectory *out, std::map< std::string, IDecomp * > decomps_nominal, std::map< std::string, std::map< std::string, std::map< int, IDecomp * > > > decomps_shifted, std::map< std::string, PredictionNoExtrap * > predsNE_nominal, std::map< std::string, std::map< std::string, std::map< int, PredictionNoExtrap * > > > predsNE_shifted, std::map< std::string, PredictionSterile * > predsSt_nominal, std::map< std::string, std::map< std::string, std::map< int, PredictionSterile * > > > predsSt_shifted)
Save all of the objects in the input maps to the out directory/file.
Definition: PPFXHelper.h:1077
void SetSpillCut(const SpillCut &cut)
const Cut kNumuND
Definition: NumuCuts.h:55
const Cut kNus17ND
Full Nus17 ND analysis selection.
Definition: NusCuts17.h:120
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
Definition: Cut.h:96
virtual void Go() override
Load all the registered spectra.
loader
Definition: demo0.py:10
const SystShifts kNoShift
Definition: SystShifts.cxx:22
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
Splits Data proportionally according to MC.
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut kNus17FDAlt
Definition: NusCuts17.h:92
A prediction object compatible with sterile oscillations.
void SystsCalibAbsLoad17()
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Prediction that just uses FD MC, with no extrapolation.
const Var kXSecCVWgt2017
Definition: XsecTunes.h:36
static ModularExtrapSterile NCDisappearance(Loaders &loaders, const IDecomp &NCSurvDecomp, const IDecomp &NumuOscDecomp, const HistAxis &axis, const HistAxis &axisNumuND, const Cut &fdcut, const Cut &NCNDcut, const Cut &NumuNDcut, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Creates a NC disappearance extrapolation.
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string