SystsCalibRelLoad.C
Go to the documentation of this file.
4 #include "CAFAna/Cuts/Cuts.h"
5 #include "NuXAna/Cuts/NusCuts.h"
9 #include "CAFAna/Extrap/ExtrapSterile.h"
12 #include "CAFAna/Systs/Systs.h"
14 #include "NuXAna/Vars/HistAxes.h"
17 
18 using namespace ana;
19 
21 {
22  TH1::AddDirectory(0);
23 
28  SpectrumLoader floadneardata(fnameneardata_concat);
29 
34  floadneardata.SetSpillCut(kOnly14DB && kStandardSpillCuts);
35 
36  // A map to set up systematics, starting with a label for the systematic,
37  // and finishing with a vector for items necessary to set up the Syst object
38  std::map<std::string, std::vector<std::string> > shiftlabels;
39  shiftlabels["CalFlat095ND"] = std::vector<std::string>();
40  shiftlabels["CalFlat105ND"] = std::vector<std::string>();
41  shiftlabels["CalFlat095FD"] = std::vector<std::string>();
42  shiftlabels["CalFlat105FD"] = std::vector<std::string>();
43  shiftlabels["CalFlat095ND"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_calib-shift-nd-xyview-neg-offset_v1");
44  shiftlabels["CalFlat095FD"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-xy-neg-offset_v1");
45  shiftlabels["CalFlat095FD"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-xy-neg-offset_v1");
46  shiftlabels["CalFlat105ND"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_calib-shift-nd-xyview-pos-offset_v1");
47  shiftlabels["CalFlat105FD"].push_back("prod_caf_R16-03-03-prod2reco.d_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-xy-pos-offset_v1");
48  shiftlabels["CalFlat105FD"].push_back("prod_caf_R16-03-03-prod2reco.d_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-xy-pos-offset_v1");
49 
50  // A map of systematic objects, indexed by the same label as above
51  std::map<std::string, std::vector<SpectrumLoader*> > systematics;
52 
53  for(const auto& shiftlabel : shiftlabels) {
54  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
55  for(const auto& samdef : shiftlabel.second){
56  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
57  systematics[shiftlabel.first].back()->SetSpillCut(kOnly14DB && kStandardSpillCuts);
58  }
59  }
60 
61  // Define a map of samples and cuts/axes to set them up
62  // Each sample, essentially, is a way to set up the analysis
63  std::string labelRecoE = "Calorimetric Energy (GeV)";
64  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
65  std::pair<Cut*, Cut*> Ana01(new Cut(kNusND), new Cut(kNusFD));
66  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
68  Ana01
69  );
70 
71  // Set up maps to the decompositions/predictions (each flavor component)
72  // Nominal maps are indexed purely by sample label
73  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
74  std::map<std::string, IDecomp*> decomps_nominal;
75  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
76  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
77  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
78  std::map<std::string, PredictionSterile*> predsSt_nominal;
79  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
80 
81  // Set up the actual decompositions/predictions
82  // sample.first = the sample label
83  // shiftlabel.first = the systematic shift label
84  // sample.second.first = the sample HistAxis
85  // sample.second.second = the sample Cut
86  for(const auto& sample : cut_samples) {
87  // Set up the nominal decompositions
88  // Only one is needed per sample
89  decomps_nominal[sample.first] = new CheatDecomp(
90  floadnear,
91  *sample.second.first, *sample.second.second.first,
93  );
94  predsNE_nominal[sample.first] = new PredictionNoExtrap(
95  floadfar, floadswap, floadtau,
96  sample.second.first->label, sample.second.first->bins,
97  sample.second.first->var, *sample.second.second.second,
99  );
100 
101  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
102  floadnear, floadneardata,
103  *sample.second.first, *sample.second.second.first,
105  );
106  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
107  floadnear, floadneardata,
110  );
112  floadnear, floadswap, floadfar, floadtau, *decompnc_n, *decompnumu_n,
113  *sample.second.first, kNCBinsNumuCCAxis,
114  *sample.second.second.second, *sample.second.second.first, kNumuND,
116  ));
117  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
118 
119  // Set up the shifted decompositions
120  // One is needed for every sample, systematic, and sigma level
121  for(const auto& systlabel : systematics) {
122  int fdpos = 0;
123  int fspos = 1;
124 
125  if(systlabel.first.find("ND") != std::string::npos) {
126  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
127  *systlabel.second[0],
128  *sample.second.first, *sample.second.second.first,
130  );
131  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
132  floadfar, floadswap, floadtau,
133  sample.second.first->label, sample.second.first->bins,
134  sample.second.first->var, *sample.second.second.second,
136  );
137 
138  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
139  *systlabel.second[0], floadneardata,
140  *sample.second.first, *sample.second.second.first,
142  );
143  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
144  *systlabel.second[0], floadneardata,
147  );
149  *systlabel.second[0], floadswap, floadfar,
150  floadtau, *decompnc_s, *decompnumu_s,
151  *sample.second.first, kNCBinsNumuCCAxis,
152  *sample.second.second.second, *sample.second.second.first, kNumuND,
154  ));
155  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
156  extrap_s
157  );
158  }
159  else {
160  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
161  floadnear,
162  *sample.second.first, *sample.second.second.first,
164  );
165  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
166  *systlabel.second[fdpos], *systlabel.second[fspos], floadtau,
167  sample.second.first->label, sample.second.first->bins,
168  sample.second.first->var, *sample.second.second.second,
170  );
171 
172  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
173  floadnear, floadneardata,
174  *sample.second.first, *sample.second.second.first,
176  );
177  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
178  floadnear, floadneardata,
181  );
183  floadnear, *systlabel.second[fspos], *systlabel.second[fdpos],
184  floadtau, *decompnc_s, *decompnumu_s,
185  *sample.second.first, kNCBinsNumuCCAxis,
186  *sample.second.second.second, *sample.second.second.first, kNumuND,
188  ));
189  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
190  extrap_s
191  );
192  }
193  }
194  }
195 
196  for(const auto& systlabel : systematics) {
197  for(const auto& loader : systlabel.second) {
198  loader->Go();
199  }
200  }
201  floadnear.Go();
202  floadfar .Go();
203  floadswap.Go();
204  floadtau .Go();
205  floadneardata.Go();
206 
207  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
208  std::string filenm = "SystsCalibRel";
209 
210  std::string fullLocation = folder + filenm + ".root";
211  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
212 
213  SaveMaps(rootF,
214  decomps_nominal, decomps_shifted,
215  predsNE_nominal, predsNE_shifted,
216  predsSt_nominal, predsSt_shifted
217  );
218 }
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const std::string fnametau_concat
const Cut kNusFD
Definition: NusCuts.h:46
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 SpillCut kOnly14DB([](const caf::SRSpillProxy *spill){if(spill->det!=caf::kFARDET) return true;std::bitset< 14 > binary(spill->dibmask);for(int i=0;i< 14;++i){if(!binary[i]) return false;}return true;})
const std::string fnamenear_concat
const std::string fnameneardata_concat
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const Cut kNumuND
Definition: NumuCuts.h:55
_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.
const Var kTuftsWeightCC
Definition: XsecTunes.h:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void SystsCalibRelLoad()
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 std::string fnameswap_concat
const std::string fnamefar_concat
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 Cut kNusND
Definition: NusCuts.h:71
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string