SystsBirksLoad.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 
24  std::string fnear_norock = "prod_limitedcaf_R16-03-03-prod2reco.d_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_v2_norock";
25 
26  SpectrumLoader floadnear(fnear_norock);
30  SpectrumLoader floadneardata(fnameneardata_concat);
31 
36  floadneardata.SetSpillCut(kOnly14DB && kStandardSpillCuts);
37 
38  // A map to set up systematics, starting with a label for the systematic,
39  // and finishing with a vector for items necessary to set up the Syst object
40  std::map<std::string, std::vector<std::string> > shiftlabels;
41  shiftlabels["BirksB"] = std::vector<std::string>();
42  shiftlabels["BirksC"] = std::vector<std::string>();
43 
44  shiftlabels["BirksB"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_birksmodB_v2");
45  shiftlabels["BirksB"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_birksmodB_v1");
46  shiftlabels["BirksB"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_birksmodB_v1");
47  shiftlabels["BirksC"].push_back("prod_caf_R16-03-03-prod2reco.a_nd_genie_nonswap_nogenierw_fhc_nova_v08_full_birksmodC_v1");
48  shiftlabels["BirksC"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_nonswap_fhc_nova_v08_full_birksmodC_v1");
49  shiftlabels["BirksC"].push_back("prod_caf_R16-03-03-prod2reco.a_fd_genie_fluxswap_fhc_nova_v08_full_birksmodC_v1");
50 
51  // A map of systematic objects, indexed by the same label as above
52  std::map<std::string, std::vector<SpectrumLoader*> > systematics;
53 
54  for(const auto& shiftlabel : shiftlabels) {
55  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
56  for(const auto& samdef : shiftlabel.second){
57  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
58  systematics[shiftlabel.first].back()->SetSpillCut(kOnly14DB && kStandardSpillCuts);
59  }
60  }
61 
62  // Define a map of samples and cuts/axes to set them up
63  // Each sample, essentially, is a way to set up the analysis
64  std::string labelRecoE = "Calorimetric Energy (GeV)";
65  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
66  std::pair<Cut*, Cut*> Ana01(new Cut(kNusND), new Cut(kNusFD));
67  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
69  Ana01
70  );
71 
72  // Set up maps to the decompositions/predictions (each flavor component)
73  // Nominal maps are indexed purely by sample label
74  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
75  std::map<std::string, IDecomp*> decomps_nominal;
76  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
77  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
78  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
79  std::map<std::string, PredictionSterile*> predsSt_nominal;
80  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
81 
82  // Set up the actual decompositions/predictions
83  // sample.first = the sample label
84  // shiftlabel.first = the systematic shift label
85  // sample.second.first = the sample HistAxis
86  // sample.second.second = the sample Cut
87  for(const auto& sample : cut_samples) {
88  // Set up the nominal decompositions
89  // Only one is needed per sample
90  decomps_nominal[sample.first] = new CheatDecomp(
91  floadnear,
92  *sample.second.first, *sample.second.second.first,
94  );
95  predsNE_nominal[sample.first] = new PredictionNoExtrap(
96  floadfar, floadswap, floadtau,
97  sample.second.first->label, sample.second.first->bins,
98  sample.second.first->var, *sample.second.second.second,
100  );
101 
102  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
103  floadnear, floadneardata,
104  *sample.second.first, *sample.second.second.first,
106  );
107  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
108  floadnear, floadneardata,
111  );
113  floadnear, floadswap, floadfar, floadtau, *decompnc_n, *decompnumu_n,
114  *sample.second.first, kNCBinsNumuCCAxis,
115  *sample.second.second.second, *sample.second.second.first, kNumuND,
117  ));
118  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
119 
120  // Set up the shifted decompositions
121  // One is needed for every sample, systematic, and sigma level
122  for(const auto& systlabel : systematics) {
123  int ndpos = 0;
124  int fdpos = 1;
125  int fspos = 2;
126 
127  decomps_shifted[sample.first][systlabel.first][1] = new CheatDecomp(
128  *systlabel.second[ndpos],
129  *sample.second.first, *sample.second.second.first,
131  );
132  predsNE_shifted[sample.first][systlabel.first][1] = new PredictionNoExtrap(
133  *systlabel.second[fdpos], *systlabel.second[fspos], floadtau,
134  sample.second.first->label, sample.second.first->bins,
135  sample.second.first->var, *sample.second.second.second,
137  );
138 
139  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
140  *systlabel.second[ndpos], floadneardata,
141  *sample.second.first, *sample.second.second.first,
143  );
144  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
145  *systlabel.second[ndpos], floadneardata,
148  );
150  *systlabel.second[ndpos], *systlabel.second[fspos], *systlabel.second[fdpos],
151  floadtau, *decompnc_s, *decompnumu_s,
152  *sample.second.first, kNCBinsNumuCCAxis,
153  *sample.second.second.second, *sample.second.second.first, kNumuND,
155  ));
156  predsSt_shifted[sample.first][systlabel.first][1] = new PredictionSterile(
157  extrap_s
158  );
159  }
160  }
161 
162  for(const auto& systlabel : systematics) {
163  for(const auto& loader : systlabel.second) {
164  loader->Go();
165  }
166  }
167  floadnear.Go();
168  floadfar .Go();
169  floadswap.Go();
170  floadtau .Go();
171  floadneardata.Go();
172 
173  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
174  std::string filenm = "SystsBirks";
175 
176  std::string fullLocation = folder + filenm + ".root";
177  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
178 
179  SaveMaps(rootF,
180  decomps_nominal, decomps_shifted,
181  predsNE_nominal, predsNE_shifted,
182  predsSt_nominal, predsSt_shifted
183  );
184 }
_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 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
void SystsBirksLoad()
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