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