SystsCalibAbsLoad.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["CalFlat095"] = std::vector<std::string>();
40  shiftlabels["CalFlat105"] = std::vector<std::string>();
41  shiftlabels["CalSlopeX"] = std::vector<std::string>();
42  shiftlabels["CalSlopeY"] = std::vector<std::string>();
43  shiftlabels["CalFlat095"].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["CalFlat095"].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["CalFlat095"].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["CalFlat105"].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["CalFlat105"].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["CalFlat105"].push_back("prod_caf_R16-03-03-prod2reco.d_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-xy-pos-offset_v1");
49  shiftlabels["CalSlopeX"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_calib-shift-nd-x-func_v1");
50  shiftlabels["CalSlopeX"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-x-func_v1");
51  shiftlabels["CalSlopeX"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-x-func_v1");
52  shiftlabels["CalSlopeY"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_calib-shift-nd-y-func_v1");
53  shiftlabels["CalSlopeY"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_calib-shift-fd-y-func_v1");
54  shiftlabels["CalSlopeY"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_calib-shift-fd-y-func_v1");
55 
56  // A map of systematic objects, indexed by the same label as above
57  std::map<std::string, std::vector<SpectrumLoader*> > systematics;
58 
59  for(const auto& shiftlabel : shiftlabels) {
60  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
61  for(const auto& samdef : shiftlabel.second){
62  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
63  systematics[shiftlabel.first].back()->SetSpillCut(kOnly14DB && kStandardSpillCuts);
64  }
65  }
66 
67  // Define a map of samples and cuts/axes to set them up
68  // Each sample, essentially, is a way to set up the analysis
69  std::string labelRecoE = "Calorimetric Energy (GeV)";
70  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
71  std::pair<Cut*, Cut*> Ana01(new Cut(kNusND), new Cut(kNusFD));
72  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
74  Ana01
75  );
76 
77  // Set up maps to the decompositions/predictions (each flavor component)
78  // Nominal maps are indexed purely by sample label
79  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
80  std::map<std::string, IDecomp*> decomps_nominal;
81  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
82  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
83  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
84  std::map<std::string, PredictionSterile*> predsSt_nominal;
85  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
86 
87  // Set up the actual decompositions/predictions
88  // sample.first = the sample label
89  // shiftlabel.first = the systematic shift label
90  // sample.second.first = the sample HistAxis
91  // sample.second.second = the sample Cut
92  for(const auto& sample : cut_samples) {
93  // Set up the nominal decompositions
94  // Only one is needed per sample
95  decomps_nominal[sample.first] = new CheatDecomp(
96  floadnear,
97  *sample.second.first, *sample.second.second.first,
99  );
100  predsNE_nominal[sample.first] = new PredictionNoExtrap(
101  floadfar, floadswap, floadtau,
102  sample.second.first->label, sample.second.first->bins,
103  sample.second.first->var, *sample.second.second.second,
105  );
106 
107  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
108  floadnear, floadneardata,
109  *sample.second.first, *sample.second.second.first,
111  );
112  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
113  floadnear, floadneardata,
116  );
118  floadnear, floadswap, floadfar, floadtau, *decompnc_n, *decompnumu_n,
119  *sample.second.first, kNCBinsNumuCCAxis,
120  *sample.second.second.second, *sample.second.second.first, kNumuND,
122  ));
123  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
124 
125  // Set up the shifted decompositions
126  // One is needed for every sample, systematic, and sigma level
127  for(const auto& systlabel : systematics) {
128  int ndpos = 0;
129  int fdpos = 1;
130  int fspos = 2;
131 
132  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
133  *systlabel.second[ndpos],
134  *sample.second.first, *sample.second.second.first,
136  );
137  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
138  *systlabel.second[fdpos], *systlabel.second[fspos], floadtau,
139  sample.second.first->label, sample.second.first->bins,
140  sample.second.first->var, *sample.second.second.second,
142  );
143 
144  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
145  *systlabel.second[ndpos], floadneardata,
146  *sample.second.first, *sample.second.second.first,
148  );
149  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
150  *systlabel.second[ndpos], floadneardata,
153  );
155  *systlabel.second[ndpos], *systlabel.second[fspos], *systlabel.second[fdpos],
156  floadtau, *decompnc_s, *decompnumu_s,
157  *sample.second.first, kNCBinsNumuCCAxis,
158  *sample.second.second.second, *sample.second.second.first, kNumuND,
160  ));
161  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
162  extrap_s
163  );
164  }
165  }
166 
167  for(const auto& systlabel : systematics) {
168  for(const auto& loader : systlabel.second) {
169  loader->Go();
170  }
171  }
172  floadnear.Go();
173  floadfar .Go();
174  floadswap.Go();
175  floadtau .Go();
176  floadneardata.Go();
177 
178  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
179  std::string filenm = "SystsCalibAbs";
180 
181  std::string fullLocation = folder + filenm + ".root";
182  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
183 
184  SaveMaps(rootF,
185  decomps_nominal, decomps_shifted,
186  predsNE_nominal, predsNE_shifted,
187  predsSt_nominal, predsSt_shifted
188  );
189 }
_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.
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.
void SystsCalibAbsLoad()
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