SystsDecompLoad17.C
Go to the documentation of this file.
1 #include "CAFAna/Core/Loaders.h"
4 #include "CAFAna/Cuts/Cuts.h"
5 #include "NuXAna/Cuts/NusCuts.h"
11 #include "CAFAna/Extrap/ExtrapSterile.h"
15 #include "CAFAna/Systs/Systs.h"
17 #include "NuXAna/Vars/HistAxes.h"
20 #include "NuXAna/Cuts/NusCuts17.h"
22 
23 using namespace ana;
24 
26  const Cut& cut, std::string shiftlabel,
27  const SystShifts& kMCShift = kNoShift,
28  const Var& wei = kUnweighted);
31 {
32  TH1::AddDirectory(0);
33 
35 
36 
37  std::string fnear="defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
38  std::string ffar ="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
39  std::string fswap="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1";
40  std::string ftau="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1";
41  std::string fnameneardata_con="defname: prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
42 
48 
50 
51  // A map to set up systematics, starting with a label for the systematic,
52  // and finishing with a vector for items necessary to set up the Syst object
53  std::map<std::string, std::string> shiftlabels;
54  shiftlabels["NC"] = "NC";
55  shiftlabels["Numu"] = "Numu";
56  shiftlabels["Nue"] = "Nue";
57 
58  // A map of systematic objects, indexed by the same label as above
59  std::map<std::string, std::vector<IDecomp*> > systematics;
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 = "Visible Energy (GeV)";
64  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
65  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
66  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
67  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
68  Ana01
69  );
70 
71  HistAxis* FDAxis = new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusFDEnergy17);
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  // syst.first = the integer number of sigmas for the shift
88  // syst.second = the systematic being shifted
89  for(const auto& sample : cut_samples) {
90  SterileGenerator gen(
91  *FDAxis, kNCBinsNumuCCAxis,
92  *sample.second.second.second, *sample.second.second.first,
93  kNumuND, kNoShift, kWgtP31
94  );
95 
96  // Set up the nominal decompositions
97  // Only one is needed per sample
98  decomps_nominal[sample.first] = MakeDecomp(
99  &loaders, *sample.second.first, *sample.second.second.first, "",
100  kNoShift, kWgtP31
101  );
102  predsNE_nominal[sample.first] = new PredictionNoExtrap(
103  loaders,
104  *FDAxis, *sample.second.second.second,
105  kNoShift, kWgtP31
106  );
107  predsSt_nominal[sample.first] = (PredictionSterile*)gen.Generate(
108  loaders
109  ).release();
110 
111  // Set up the shifted decompositions
112  // One is needed for every sample, systematic, and sigma level
113  for(const auto& shiftlabel : shiftlabels) {
114  decomps_shifted[sample.first][shiftlabel.first][1] = MakeDecomp(
115  &loaders, *sample.second.first, *sample.second.second.first, shiftlabel.first,
116  kNoShift, kWgtP31
117  );
118  predsNE_shifted[sample.first][shiftlabel.first][1] = new PredictionNoExtrap(
119  loaders, *FDAxis, *sample.second.second.second,
120  kNoShift, kWgtP31
121  );
122 
123  IDecomp* decompnc = MakeDecomp(
124  &loaders, *sample.second.first, *sample.second.second.first, shiftlabel.first,
125  kNoShift, kWgtP31
126  );
127  IDecomp* decompnm = MakeDecomp(
128  &loaders, kNCBinsNumuCCAxis, kNumuND, shiftlabel.first,
129  kNoShift, kWgtP31
130  );
132  loaders, *decompnc, *decompnm,
133  *FDAxis, kNCBinsNumuCCAxis,
134  *sample.second.second.second, *sample.second.second.first, kNumuND,
135  kNoShift, kWgtP31
136  ));
137  predsSt_shifted[sample.first][shiftlabel.first][1] =
138  new PredictionSterile(extrap);
139  }
140  }
141 
142  loaders.Go();
143 
144  std::string folder = "./";
145  std::string filenm = "SystsDecomp";
146 
147  std::string fullLocation = folder + filenm + ".root";
148  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
149 
150  SaveMaps(rootF,
151  decomps_nominal, decomps_shifted,
152  predsNE_nominal, predsNE_shifted,
153  predsSt_nominal, predsSt_shifted
154  );
155 }
156 
158  const Cut& cut, std::string shiftlabel,
159  const SystShifts& kMCShift,
160  const Var& wei)
161 {
162  if(shiftlabel.compare("NC") == 0) {
163  return new NCDecomp(
166  axis, cut, kMCShift, kNoShift, wei
167  );
168  }
169  if(shiftlabel.compare("Numu") == 0) {
170  return new NumuDecomp(
173  axis, cut, kMCShift, kNoShift, wei
174  );
175  }
176  if(shiftlabel.compare("Nue") == 0) {
177  return new NueDecomp(
180  axis, cut, kMCShift, kNoShift, wei
181  );
182  }
183  std::cout << "Label not found, reverting to ProportionalDecomp." << std::endl;
184  return new ProportionalDecomp(
187  axis, cut, kMCShift, kNoShift, wei
188  );
189 }
Near Detector underground.
Definition: SREnums.h:10
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const override
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
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 SystsDecompLoad17()
Generates extrapolated NC predictions using ProportionalDecomp.
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
Uses MC for CC and CC components, assigns remainder of data to NC.
Definition: NCDecomp.h:10
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
Uses MC for NC and CC components, assigns remainder of data to CC.
Definition: NumuDecomp.h:10
Uses MC for CC and NC components, assigns remainder of data to CC.
Definition: NueDecomp.h:10
SpectrumLoaderBase & GetLoader(caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Retrieve a specific loader.
Definition: Loaders.cxx:129
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
IDecomp * MakeDecomp(Loaders *loaders, const HistAxis &axis, const Cut &cut, std::string shiftlabel, const SystShifts &kMCShift=kNoShift, const Var &wei=kUnweighted)
const Var kWgtP31
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
const Cut cut
Definition: exporter_fd.C:30
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
Splits Data proportionally according to MC.
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Standard interface to all decomposition techniques.
Definition: IDecomp.h:13
const Cut kNus17FDAlt
Definition: NusCuts17.h:92
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
void SetLoaderPath(const std::string &path, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via wildcard path.
Definition: Loaders.cxx:25
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.
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string