SystsCalibRelLoad17.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);
26 
27 
28  std::string fnamenear_con="prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
29  std::string fnameneardata_con="prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
30  std::string fFDMC_nons="prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
31  std::string fFDMC_swps="prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1";
32  std::string fFDMC_taus="prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1";
33 
34 /* std::string fnamenear_con="defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1 with limit 1";
35  std::string fnameneardata_con="defname: prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns with limit 1";
36  std::string fFDMC_nons="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1 with limit 1";
37  std::string fFDMC_swps="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1 with limit 1";
38  std::string fFDMC_taus="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1 with limit 1";
39 */
40 
41 
42  SpectrumLoader floadnear(fnamenear_con);
43  SpectrumLoader floadfar(fFDMC_nons);
44  SpectrumLoader floadswap(fFDMC_swps);
45  SpectrumLoader floadtau(fFDMC_taus);
46  SpectrumLoader floadneardata(fnameneardata_con);
47 
48  floadnear .SetSpillCut(kStandardSpillCuts);
50  floadswap .SetSpillCut(kStandardSpillCuts);
52  floadneardata.SetSpillCut(kStandardSpillCuts);
53 
54  // A map to set up systematics, starting with a label for the systematic,
55  // and finishing with a vector for items necessary to set up the Syst object
56  std::map<std::string, std::vector<std::string> > shiftlabels;
57  shiftlabels["CalFlat095ND"] = std::vector<std::string>();
58  shiftlabels["CalFlat105ND"] = std::vector<std::string>();
59  shiftlabels["CalFlat095FD"] = std::vector<std::string>();
60  shiftlabels["CalFlat105FD"] = std::vector<std::string>();
61  shiftlabels["CalFlat095ND"].push_back("prod_caf_R17-03-01-prod3reco.h_nd_genie_nonswap_fhc_nova_v08_periods1235_calib-shift-nd-xyview-neg-offset_v1");
62  shiftlabels["CalFlat095FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-xyview-neg-offset_v1");
63  shiftlabels["CalFlat095FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-xyview-neg-offset_v1");
64  shiftlabels["CalFlat095FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_calib-shift-fd-xyview-neg-offset_v1");
65 
66 
67  shiftlabels["CalFlat105ND"].push_back("prod_caf_R17-03-01-prod3reco.h_nd_genie_nonswap_fhc_nova_v08_periods1235_calib-shift-nd-xyview-pos-offset_v1");
68  shiftlabels["CalFlat105FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-xyview-pos-offset_v1");
69  shiftlabels["CalFlat105FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-xyview-pos-offset_v1");
70  shiftlabels["CalFlat105FD"].push_back("prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_calib-shift-fd-xyview-pos-offset_v1");
71  // A map of systematic objects, indexed by the same label as above
72  std::map<std::string, std::vector<SpectrumLoader*> > systematics;
73 
74  for(const auto& shiftlabel : shiftlabels) {
75  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
76  for(const auto& samdef : shiftlabel.second){
77  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
78  systematics[shiftlabel.first].back()->SetSpillCut(kStandardSpillCuts);
79  }
80  }
81 
82  // Define a map of samples and cuts/axes to set them up
83  // Each sample, essentially, is a way to set up the analysis
84  std::string labelRecoE = "Visible Energy (GeV)";
85  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
86  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
87  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
88  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
89  Ana01
90  );
91  HistAxis* FDAxis = new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusFDEnergy17);
92 
93  // Set up maps to the decompositions/predictions (each flavor component)
94  // Nominal maps are indexed purely by sample label
95  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
96  std::map<std::string, IDecomp*> decomps_nominal;
97  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
98  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
99  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
100  std::map<std::string, PredictionSterile*> predsSt_nominal;
101  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
102 
103  // Set up the actual decompositions/predictions
104  // sample.first = the sample label
105  // shiftlabel.first = the systematic shift label
106  // sample.second.first = the sample HistAxis
107  // sample.second.second = the sample Cut
108  for(const auto& sample : cut_samples) {
109  // Set up the nominal decompositions
110  // Only one is needed per sample
111  decomps_nominal[sample.first] = new CheatDecomp(
112  floadnear,
113  *sample.second.first, *sample.second.second.first,
114  kNoShift, kWgtP31
115  );
116  predsNE_nominal[sample.first] = new PredictionNoExtrap(
117  floadfar, floadswap, floadtau,
118  labelRecoE, kNCDisappearanceEnergyBinning,kNusFDEnergy17, *sample.second.second.second,
119  kNoShift, kWgtP31
120  );
121 
122  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
123  floadnear, floadneardata,
124  *sample.second.first, *sample.second.second.first,
125  kNoShift, kNoShift, kWgtP31
126  );
127  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
128  floadnear, floadneardata,
130  kNoShift, kNoShift, kWgtP31
131  );
133  floadnear, floadswap, floadfar, floadtau, *decompnc_n, *decompnumu_n,
134  *FDAxis, kNCBinsNumuCCAxis,
135  *sample.second.second.second, *sample.second.second.first, kNumuND,
136  kNoShift, kWgtP31
137  ));
138  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
139 
140  //Set up the actual decompositions/predictions
141  // sample.first = the sample label
142  // shiftlabel.first = the systematic shift label
143  // sample.second.first = the sample HistAxis
144  // sample.second.second = the sample Cut
145 
146  // Set up the shifted decompositions
147  // One is needed for every sample, systematic, and sigma level
148  //
149  for(const auto& systlabel : systematics) {
150  int fdpos = 0;
151  int fspos = 1;
152  int ftpos = 2;
153  if(systlabel.first.find("ND") != std::string::npos) {
154  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
155  *systlabel.second[0],
156  *sample.second.first, *sample.second.second.first,
157  kNoShift, kWgtP31
158  );
159  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
160  floadfar, floadswap, floadtau,
161  labelRecoE, kNCDisappearanceEnergyBinning,kNusFDEnergy17, *sample.second.second.second,
162  kNoShift, kWgtP31
163  );
164 
165  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
166  *systlabel.second[0], floadneardata,
167  *sample.second.first, *sample.second.second.first,
168  kNoShift, kNoShift, kWgtP31
169  );
170  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
171  *systlabel.second[0], floadneardata,
173  kNoShift, kNoShift, kWgtP31
174  );
176  *systlabel.second[0], floadswap, floadfar,
177  floadtau, *decompnc_s, *decompnumu_s,
178  *FDAxis, kNCBinsNumuCCAxis,
179  *sample.second.second.second, *sample.second.second.first, kNumuND,
180  kNoShift, kWgtP31
181  ));
182  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
183  extrap_s
184  );
185  }
186  else {
187  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
188  floadnear,
189  *sample.second.first, *sample.second.second.first,
190  kNoShift, kWgtP31
191  );
192  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
193  *systlabel.second[fdpos], *systlabel.second[fspos], *systlabel.second[ftpos],
194  labelRecoE, kNCDisappearanceEnergyBinning,kNusFDEnergy17, *sample.second.second.second,
195  kNoShift, kWgtP31
196  );
197 
198  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
199  floadnear, floadneardata,
200  *sample.second.first, *sample.second.second.first,
201  kNoShift, kNoShift, kWgtP31
202  );
203  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
204  floadnear, floadneardata,
206  kNoShift, kNoShift, kWgtP31
207  );
209  floadnear, *systlabel.second[fspos], *systlabel.second[fdpos],
210  *systlabel.second[ftpos], *decompnc_s, *decompnumu_s,
211  *FDAxis, kNCBinsNumuCCAxis,
212  *sample.second.second.second, *sample.second.second.first, kNumuND,
213  kNoShift, kWgtP31
214  ));
215  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
216  extrap_s
217  );
218  }
219  }
220  }
221 
222  for(const auto& systlabel : systematics) {
223  for(const auto& loader : systlabel.second) {
224  loader->Go();
225  }
226  }
227  floadnear.Go();
228  floadfar .Go();
229  floadswap.Go();
230  floadtau .Go();
231  floadneardata.Go();
232 
233  std::string folder = "./";
234  std::string filenm = "SystsCalibRel";
235 
236  std::string fullLocation = folder + filenm + ".root";
237  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
238 
239  SaveMaps(rootF,
240  decomps_nominal, decomps_shifted,
241  predsNE_nominal, predsNE_shifted,
242  predsSt_nominal, predsSt_shifted
243  );
244 }
_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.
const Var kWgtP31
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
void SystsCalibRelLoad17()
A prediction object compatible with sterile oscillations.
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.
Just return the ND truth spectra as the decomposition.
Definition: CheatDecomp.h:10
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string