SystsAcceptanceLoad17.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/Extrap/ExtrapSterile.h"
13 #include "CAFAna/Systs/Systs.h"
17 #include "NuXAna/Cuts/NusCuts17.h"
19 #include "NuXAna/Vars/HistAxes.h"
20 
21 using namespace ana;
22 
24 {
25  TH1::AddDirectory(0);
26 
29 
30 /* std::string fnear="defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1 with limit 50";
31  std::string ffar ="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1 with limit 50";
32  std::string fswap="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1 with limit 50";
33  std::string ftau="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1 with limit 50";
34  std::string fnameneardata_con="defname: prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns with limit 50";
35 */
36  std::string fnear="prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
37  std::string ffar ="prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
38  std::string fswap="prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1";
39  std::string ftau="prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1";
40  std::string fnameneardata_con="prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
41 
42 
43 
49 
51 
52  // A map to set up systematics, starting with a label for the systematic,
53  // and finishing with a vector for items necessary to set up the Syst object
54  std::map<std::string, std::string> shiftlabels;
55  shiftlabels["ND1"] = "ND1";
56  shiftlabels["ND2"] = "ND2";
57  shiftlabels["ND3"] = "ND3";
58  shiftlabels["ND4"] = "ND4";
59 
60  const Cut kNDFirstBlock(
61  [](const caf::SRProxy* sr)
62  {
63  if(!sr->vtx.elastic.IsValid) { return false; }
64  if(sr->vtx.elastic.vtx.X() > NDR) { return false; }
65  if(sr->vtx.elastic.vtx.X() < NDL ) { return false; }
66  if(sr->vtx.elastic.vtx.Y() > NDT) { return false; }
67  if(sr->vtx.elastic.vtx.Y() <0) { return false; }
68  if(sr->vtx.elastic.vtx.Z() < 0) { return false; }
69  if(sr->vtx.elastic.vtx.Z() > 635) { return false; }
70  return true;
71  });
72 
73  const Cut kNDSecondBlock(
74  [](const caf::SRProxy* sr)
75  {
76  if( !sr->vtx.elastic.IsValid) { return false; }
77  if(sr->vtx.elastic.vtx.X() > NDR) { return false; }
78  if(sr->vtx.elastic.vtx.X() < NDL ) { return false; }
79  if(sr->vtx.elastic.vtx.Y() > NDT) { return false; }
80  if(sr->vtx.elastic.vtx.Y() <0) { return false; }
81  if(sr->vtx.elastic.vtx.Z() >1270) { return false; }
82  if(sr->vtx.elastic.vtx.Z() < 635) { return false; }
83  return true;
84  });
85 
86  const Cut kNDThirdBlock(
87  [](const caf::SRProxy* sr)
88  {
89  if( !sr->vtx.elastic.IsValid) { return false; }
90  if(sr->vtx.elastic.vtx.X() > NDR) { return false; }
91  if(sr->vtx.elastic.vtx.X() < NDL ) { return false; }
92  if(sr->vtx.elastic.vtx.Y() > 0) { return false; }
93  if(sr->vtx.elastic.vtx.Y() <NDB) { return false; }
94  if(sr->vtx.elastic.vtx.Z() >1270) { return false; }
95  if(sr->vtx.elastic.vtx.Z() < 635) { return false; }
96  return true;
97  });
98 
99  const Cut kNDFourthBlock(
100  [](const caf::SRProxy* sr)
101  {
102  if(!sr->vtx.elastic.IsValid) { return false; }
103  if(sr->vtx.elastic.vtx.X() > NDR) { return false; }
104  if(sr->vtx.elastic.vtx.X() < NDL ) { return false; }
105  if(sr->vtx.elastic.vtx.Y() > 0) { return false; }
106  if(sr->vtx.elastic.vtx.Y() <NDB) { return false; }
107  if(sr->vtx.elastic.vtx.Z() >635) { return false; }
108  if(sr->vtx.elastic.vtx.Z() < 0) { return false; }
109  return true;
110  });
111 
112 
113 
114  // A map of systematic objects, indexed by the same label as above
115  std::map<std::string, Cut*> systematics;
116  systematics["ND1"] = new Cut(kNDFirstBlock);
117  systematics["ND2"] = new Cut(kNDSecondBlock);
118  systematics["ND3"] = new Cut(kNDThirdBlock);
119  systematics["ND4"] = new Cut(kNDFourthBlock);
120 
121 
122 
123  // Define a map of samples and cuts/axes to set them up
124  // Each sample, essentially, is a way to set up the analysis
125  std::string labelRecoE = "Energy Deposited in Scintillator (GeV)";
126  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
127  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
128  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
129  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
130  Ana01
131  );
132 
133  HistAxis* FDAxis = new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusFDEnergy17);
134  // Set up maps to the decompositions/predictions (each flavor component)
135  // Nominal maps are indexed purely by sample label
136  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
137  std::map<std::string, IDecomp*> decomps_nominal;
138  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
139  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
140  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
141  std::map<std::string, PredictionSterile*> predsSt_nominal;
142  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
143 
144  // Set up the actual decompositions/predictions
145  // sample.first = the sample label
146  // shiftlabel.first = the systematic shift label
147  // sample.second.first = the sample HistAxis
148  // sample.second.second = the sample Cut
149  // syst.first = the integer number of sigmas for the shift
150  // syst.second = the systematic being shifted
151  for(const auto& sample : cut_samples) {
152  SterileGenerator gen(
153  *FDAxis, kNCBinsNumuCCAxis,
154  *sample.second.second.second, *sample.second.second.first,
155  kNumuND, kNoShift, kWgtP31
156  );
157 
158  // Set up the nominal decompositions
159  // Only one is needed per sample
160  decomps_nominal[sample.first] = new CheatDecomp(
162  *sample.second.first, *sample.second.second.first,
164  );
165  predsNE_nominal[sample.first] = new PredictionNoExtrap(
166  loaders,
167  *FDAxis, *sample.second.second.second,
168  kNoShift, kWgtP31
169  );
170  predsSt_nominal[sample.first] = (PredictionSterile*)gen.Generate(
171  loaders
172  ).release();
173 
174  // Set up the shifted decompositions
175  // One is needed for every sample, systematic, and sigma level
176  for(const auto& shiftlabel : shiftlabels) {
177  decomps_shifted[sample.first][shiftlabel.first][1] = new CheatDecomp(
179  *sample.second.first, *sample.second.second.first && *systematics[shiftlabel.first],
181  );
182  predsNE_shifted[sample.first][shiftlabel.first][1] = new PredictionNoExtrap(
183  loaders,
184  *FDAxis, *sample.second.second.second,
185  kNoShift, kWgtP31
186  );
187 
188  SterileGenerator gen(
189  *FDAxis, kNCBinsNumuCCAxis,
190  *sample.second.second.second,
191  *sample.second.second.first && *systematics[shiftlabel.first],
192  kNumuND && *systematics[shiftlabel.first],
193  kNoShift, kWgtP31
194  );
195  predsSt_shifted[sample.first][shiftlabel.first][1] =
196  (PredictionSterile*)gen.Generate(loaders).release();
197  }
198  }
199 
200  loaders.Go();
201 
202  std::string folder = "./";
203  std::string filenm = "SystsNDAcceptance17";
204 
205  std::string fullLocation = folder + filenm + ".root";
206  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
207 
208  SaveMaps(rootF,
209  decomps_nominal, decomps_shifted,
210  predsNE_nominal, predsNE_shifted,
211  predsSt_nominal, predsSt_shifted
212  );
213 }
Near Detector underground.
Definition: SREnums.h:10
const double NDT
Definition: NusCuts.cxx:12
_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
const double NDR
Definition: NusCuts.cxx:10
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
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
Generates extrapolated NC predictions using ProportionalDecomp.
const double NDL
Definition: NusCuts.cxx:9
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
caf::Proxy< caf::SRElastic > elastic
Definition: SRProxy.h:2118
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
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
caf::StandardRecord * sr
const Var kWgtP31
const SystShifts kNoShift
Definition: SystShifts.cxx:21
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
caf::Proxy< bool > IsValid
Definition: SRProxy.h:2058
const double NDB
Definition: NusCuts.cxx:11
std::vector< Loaders * > loaders
Definition: syst_header.h:386
caf::Proxy< caf::SRVector3D > vtx
Definition: SRProxy.h:2073
const Cut kNus17FDAlt
Definition: NusCuts17.h:92
bool systematics
Definition: fnexvscaf.C:31
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.
caf::Proxy< caf::SRVertexBranch > vtx
Definition: SRProxy.h:2146
const Var kXSecCVWgt2017
Definition: XsecTunes.h:37
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
Just return the ND truth spectra as the decomposition.
Definition: CheatDecomp.h:10
void SystsAcceptanceLoad17()
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string