SystsDecompLoad.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"
9 #include "CAFAna/Decomp/NueDecomp100Dn.h"
10 #include "CAFAna/Decomp/NueDecomp100Up.h"
13 #include "CAFAna/Extrap/ExtrapSterile.h"
17 #include "CAFAna/Systs/Systs.h"
19 #include "NuXAna/Vars/HistAxes.h"
22 
23 using namespace ana;
24 
26  const Cut& cut, std::string shiftlabel,
27  const SystShifts& kMCShift = kNoShift,
28  const Var& wei = kUnweighted);
29 
31 {
32  TH1::AddDirectory(0);
33 
35 
41 
43 
44  // A map to set up systematics, starting with a label for the systematic,
45  // and finishing with a vector for items necessary to set up the Syst object
46  std::map<std::string, std::string> shiftlabels;
47  shiftlabels["NC"] = "NC";
48  shiftlabels["Numu"] = "Numu";
49  shiftlabels["NueUp"] = "NueUp";
50  shiftlabels["NueDn"] = "NueDn";
51 
52  // A map of systematic objects, indexed by the same label as above
53  std::map<std::string, std::vector<IDecomp*> > systematics;
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  // syst.first = the integer number of sigmas for the shift
81  // syst.second = the systematic being shifted
82  for(const auto& sample : cut_samples) {
83  SterileGenerator gen(
84  *sample.second.first, kNCBinsNumuCCAxis,
85  *sample.second.second.second, *sample.second.second.first,
87  );
88 
89  // Set up the nominal decompositions
90  // Only one is needed per sample
91  decomps_nominal[sample.first] = MakeDecomp(
92  &loaders, *sample.second.first, *sample.second.second.first, "",
94  );
95  predsNE_nominal[sample.first] = new PredictionNoExtrap(
96  loaders,
97  *sample.second.first, *sample.second.second.second,
99  );
100  predsSt_nominal[sample.first] = (PredictionSterile*)gen.Generate(
101  loaders
102  ).release();
103 
104  // Set up the shifted decompositions
105  // One is needed for every sample, systematic, and sigma level
106  for(const auto& shiftlabel : shiftlabels) {
107  decomps_shifted[sample.first][shiftlabel.first][1] = MakeDecomp(
108  &loaders, *sample.second.first, *sample.second.second.first, shiftlabel.first,
110  );
111  predsNE_shifted[sample.first][shiftlabel.first][1] = new PredictionNoExtrap(
112  loaders, *sample.second.first, *sample.second.second.second,
114  );
115 
116  IDecomp* decompnc = MakeDecomp(
117  &loaders, *sample.second.first, *sample.second.second.first, shiftlabel.first,
119  );
120  IDecomp* decompnm = MakeDecomp(
121  &loaders, kNCBinsNumuCCAxis, kNumuND, shiftlabel.first,
123  );
125  loaders, *decompnc, *decompnm,
126  *sample.second.first, kNCBinsNumuCCAxis,
127  *sample.second.second.second, *sample.second.second.first, kNumuND,
129  ));
130  predsSt_shifted[sample.first][shiftlabel.first][1] =
131  new PredictionSterile(extrap);
132  }
133  }
134 
135  loaders.Go();
136 
137  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
138  std::string filenm = "SystsDecomp";
139 
140  std::string fullLocation = folder + filenm + ".root";
141  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
142 
143  SaveMaps(rootF,
144  decomps_nominal, decomps_shifted,
145  predsNE_nominal, predsNE_shifted,
146  predsSt_nominal, predsSt_shifted
147  );
148 }
149 
151  const Cut& cut, std::string shiftlabel,
152  const SystShifts& kMCShift,
153  const Var& wei)
154 {
155  if(shiftlabel.compare("NC") == 0) {
156  return new NCDecomp(
159  axis, cut, kMCShift, kNoShift, wei
160  );
161  }
162  if(shiftlabel.compare("Numu") == 0) {
163  return new NumuDecomp(
166  axis, cut, kMCShift, kNoShift, wei
167  );
168  }
169  if(shiftlabel.compare("NueUp") == 0) {
170  return new NueDecomp100Up(
173  axis, cut, kMCShift, kNoShift, wei
174  );
175  }
176  if(shiftlabel.compare("NueDn") == 0) {
177  return new NueDecomp100Dn(
180  axis, cut, kMCShift, kNoShift, wei
181  );
182  }
183 
184  std::cout << "Label not found, reverting to ProportionalDecomp." << std::endl;
185  return new ProportionalDecomp(
188  axis, cut, kMCShift, kNoShift, wei
189  );
190 }
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 std::string fnametau_concat
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
const Cut kNusFD
Definition: NusCuts.h:46
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 SystsDecompLoad()
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
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
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
const std::string fnameneardata_concat
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
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
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
Definition: Cut.h:96
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
IDecomp * MakeDecomp(Loaders *loaders, const HistAxis &axis, const Cut &cut, std::string shiftlabel, const SystShifts &kMCShift=kNoShift, const Var &wei=kUnweighted)
Splits Data proportionally according to MC.
const Var kTuftsWeightCC
Definition: XsecTunes.h:30
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Standard interface to all decomposition techniques.
Definition: IDecomp.h:13
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
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 Cut kNusND
Definition: NusCuts.h:71
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string