SystsNDRockLoad.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"
15 #include "NuXAna/Vars/HistAxes.h"
18 
19 using namespace ana;
20 
22 {
23  TH1::AddDirectory(0);
24 
26 
32 
34 
35  // A map to set up systematics, starting with a label for the systematic,
36  // and finishing with a vector for items necessary to set up the Syst object
37  std::map<std::string, std::string> shiftlabels;
38  shiftlabels["NDRock"] = "ND Rock Contamination";
39 
40  const Cut kNDTruthFull(
41  [](const caf::SRProxy* sr)
42  {
43  if(sr->hdr.ismc == false) { return true; }
44  if(sr->mc.nnu < 1) { return false; }
45  if(sr->mc.nu[0].vtx.X() < NDL) { return false; }
46  if(sr->mc.nu[0].vtx.X() > NDR) { return false; }
47  if(sr->mc.nu[0].vtx.Y() < NDB) { return false; }
48  if(sr->mc.nu[0].vtx.Y() > NDT) { return false; }
49  if(sr->mc.nu[0].vtx.Z() < NDF) { return false; }
50 
51  double NDM = 1587.;
52  if(sr->mc.nu[0].vtx.Z() > NDM) { return false; }
53  if(sr->mc.nu[0].vtx.Z() > NDE) {
54  double MCT = (2./3.)*(NDT - NDB) + NDB;
55  if(sr->mc.nu[0].vtx.Y() > MCT) { return false; }
56  }
57  return true;
58  });
59 
60  // A map of systematic objects, indexed by the same label as above
61  std::map<std::string, Cut*> systematics;
62  systematics["NDRock"] = new Cut(kNDTruthFull);
63 
64  // Define a map of samples and cuts/axes to set them up
65  // Each sample, essentially, is a way to set up the analysis
66  std::string labelRecoE = "Calorimetric Energy (GeV)";
67  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
68  std::pair<Cut*, Cut*> Ana01(new Cut(kNusND), new Cut(kNusFD));
69  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
71  Ana01
72  );
73 
74  // Set up maps to the decompositions/predictions (each flavor component)
75  // Nominal maps are indexed purely by sample label
76  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
77  std::map<std::string, IDecomp*> decomps_nominal;
78  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
79  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
80  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
81  std::map<std::string, PredictionSterile*> predsSt_nominal;
82  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
83 
84  // Set up the actual decompositions/predictions
85  // sample.first = the sample label
86  // shiftlabel.first = the systematic shift label
87  // sample.second.first = the sample HistAxis
88  // sample.second.second = the sample Cut
89  // syst.first = the integer number of sigmas for the shift
90  // syst.second = the systematic being shifted
91  for(const auto& sample : cut_samples) {
92  SterileGenerator gen(
93  *sample.second.first, kNCBinsNumuCCAxis,
94  *sample.second.second.second, *sample.second.second.first,
96  );
97 
98  // Set up the nominal decompositions
99  // Only one is needed per sample
100  decomps_nominal[sample.first] = new CheatDecomp(
102  *sample.second.first, *sample.second.second.first,
104  );
105  predsNE_nominal[sample.first] = new PredictionNoExtrap(
106  loaders,
107  *sample.second.first, *sample.second.second.second,
109  );
110  predsSt_nominal[sample.first] = (PredictionSterile*)gen.Generate(
111  loaders
112  ).release();
113 
114  // Set up the shifted decompositions
115  // One is needed for every sample, systematic, and sigma level
116  for(const auto& shiftlabel : shiftlabels) {
117  decomps_shifted[sample.first][shiftlabel.first][1] = new CheatDecomp(
119  *sample.second.first, *sample.second.second.first && *systematics[shiftlabel.first],
121  );
122  predsNE_shifted[sample.first][shiftlabel.first][1] = new PredictionNoExtrap(
123  loaders,
124  *sample.second.first, *sample.second.second.second,
125  kNoShift, kTuftsWeightCC
126  );
127 
128  SterileGenerator gen(
129  *sample.second.first, kNCBinsNumuCCAxis,
130  *sample.second.second.second,
131  *sample.second.second.first && *systematics[shiftlabel.first],
132  kNumuND && *systematics[shiftlabel.first],
133  kNoShift, kTuftsWeightCC
134  );
135  predsSt_shifted[sample.first][shiftlabel.first][1] =
136  (PredictionSterile*)gen.Generate(loaders).release();
137  }
138  }
139 
140  loaders.Go();
141 
142  std::string folder = "/nova/ana/steriles/Ana01/Systematics/";
143  std::string filenm = "SystsNDRock";
144 
145  std::string fullLocation = folder + filenm + ".root";
146  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
147 
148  SaveMaps(rootF,
149  decomps_nominal, decomps_shifted,
150  predsNE_nominal, predsNE_shifted,
151  predsSt_nominal, predsSt_shifted
152  );
153 }
Near Detector underground.
Definition: SREnums.h:10
const double NDT
Definition: NusCuts.cxx:12
const Cut kNDTruthFull([](const caf::SRProxy *sr){if(sr->hdr.ismc==false){return true;}if(sr->mc.nnu< 1){return false;}if(sr->mc.nu[0].vtx.X()< NDL){return false;}if(sr->mc.nu[0].vtx.X() > NDR){return false;}if(sr->mc.nu[0].vtx.Y()< NDB){return false;}if(sr->mc.nu[0].vtx.Y() > NDT){return false;}if(sr->mc.nu[0].vtx.Z()< NDF){return false;}double NDM=1587.;if(sr->mc.nu[0].vtx.Z() > NDM){return false;}if(sr->mc.nu[0].vtx.Z() > NDE){double MCT=(2./3.)*(NDT-NDB)+NDB;if(sr->mc.nu[0].vtx.Y() > MCT){return false;}}return true;})
_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
void SystsNDRockLoad()
std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const override
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
const Cut kNusFD
Definition: NusCuts.h:46
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
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:618
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
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
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
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
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
caf::StandardRecord * sr
const SystShifts kNoShift
Definition: SystShifts.cxx:21
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
const double NDF
Definition: NusCuts.cxx:13
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
const Var kTuftsWeightCC
Definition: XsecTunes.h:31
const double NDB
Definition: NusCuts.cxx:11
std::vector< Loaders * > loaders
Definition: syst_header.h:386
caf::Proxy< bool > ismc
Definition: SRProxy.h:242
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.
const double NDE
Definition: NusCuts.cxx:14
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
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