SystsBeamTranspLoad17.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"
12 #include "CAFAna/Systs/Systs.h"
14 #include "NuXAna/Vars/HistAxes.h"
18 #include "NuXAna/Cuts/NusCuts17.h"
19 #include "CAFAna/Systs/BeamSysts.h"
20 
21 using namespace ana;
22 
24 {
25  TH1::AddDirectory(0);
26 
28 
30 
31 
32  std::string fnamenear_con="prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
33  std::string fnameneardata_con="prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
34  std::string fFDMC_nons="prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
35  std::string fFDMC_swps="prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1";
36  std::string fFDMC_taus="prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1";
37 
38 
39 
45 
47 
48  // Vector of sigmas, levels to set each systematic
49  std::vector<int> sigmas{-3, -2, -1, +1, +2, +3};
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::vector<std::string> > shiftlabels;
54  shiftlabels["BeamHornCurrent"] = std::vector<std::string>();
55  shiftlabels["BeamSpotSize"] = std::vector<std::string>();
56  shiftlabels["BeamposX"] = std::vector<std::string>();
57  shiftlabels["BeamposY"] = std::vector<std::string>();
58  shiftlabels["BeamH1PosX"] = std::vector<std::string>();
59  shiftlabels["BeamH1PosY"] = std::vector<std::string>();
60  shiftlabels["BeamH2PosX"] = std::vector<std::string>();
61  shiftlabels["BeamH2PosY"] = std::vector<std::string>();
62  shiftlabels["TargetPosZ"] = std::vector<std::string>();
63  shiftlabels["BeamExp"] = std::vector<std::string>();
64  shiftlabels["HornWater"] = std::vector<std::string>();
65  shiftlabels["totErr"] = std::vector<std::string>();
66 
67  shiftlabels["BeamHornCurrent"] .push_back("2kA");
68  shiftlabels["BeamHornCurrent"] .push_back("Horn Current");
69  shiftlabels["BeamSpotSize"] .push_back("0.2mmBeamSpotSize");
70  shiftlabels["BeamSpotSize"] .push_back("Spot Size");
71  shiftlabels["BeamposX"] .push_back("1mmBeamShiftX");
72  shiftlabels["BeamposX"] .push_back("Beam Position X");
73  shiftlabels["BeamposY"] .push_back("1mmBeamShiftY");
74  shiftlabels["BeamposY"] .push_back("Beam Position Y");
75  shiftlabels["BeamH1PosX"] .push_back("3mmHorn1X");
76  shiftlabels["BeamH1PosX"] .push_back("Horn 1 X Position");
77  shiftlabels["BeamH1PosY"] .push_back("3mmHorn1Y");
78  shiftlabels["BeamH1PosY"] .push_back("Horn 1 Y Position");
79  shiftlabels["BeamH2PosX"] .push_back("3mmHorn2X");
80  shiftlabels["BeamH2PosX"] .push_back("Horn 2 X Position");
81  shiftlabels["BeamH2PosY"] .push_back("3mmHorn2Y");
82  shiftlabels["BeamH2PosY"] .push_back("Horn 2 Y Position");
83  shiftlabels["TargetPosZ"] .push_back("7mmTargetZ");
84  shiftlabels["TargetPosZ"] .push_back("Target Z position");
85  shiftlabels["BeamExp"] .push_back("Magnetic Field in Decay Pipe");
86  shiftlabels["BeamExp"] .push_back("Magnet Field in Decay Pipe");
87  shiftlabels["HornWater"] .push_back("1mmHornWater");
88  shiftlabels["HornWater"] .push_back("New Horn Geometry and 1mm water");
89  shiftlabels["totErr"] .push_back("totErr");
90  shiftlabels["totErr"] .push_back("Combined Beam Transport Systematics");
91 
92  // A map of systematic objects, indexed by the same label as above
93  std::map<std::string, std::map<int, SystShifts*> > systematics;
94 
95  std::string rootfile = FindCAFAnaDir() +"/data/beam/TABeamSyst.root";
96  for(const auto& shiftlabel : shiftlabels) {
97  for(const auto& sigma : sigmas) {
98  systematics[shiftlabel.first][sigma] = new SystShifts(
99  new BeamSyst(rootfile, shiftlabel.second[0], shiftlabel.second[1]),
100  sigma
101  );
102  }
103  }
104 
105  // Define a map of samples and cuts/axes to set them up
106  // Each sample, essentially, is a way to set up the analysis
107  std::string labelRecoE = "Visible Energy (GeV)";
108  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
109  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
110  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
111  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
112  Ana01
113  );
114 
115  HistAxis* FDAxis = new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusFDEnergy17);
116  // Set up maps to the decompositions/predictions (each flavor component)
117  // Nominal maps are indexed purely by sample label
118  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
119  std::map<std::string, IDecomp*> decomps_nominal;
120  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
121  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
122  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
123  std::map<std::string, PredictionSterile*> predsSt_nominal;
124  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
125 
126  // Set up the actual decompositions/predictions
127  // sample.first = the sample label
128  // shiftlabel.first = the systematic shift label
129  // sample.second.first = the sample HistAxis
130  // sample.second.second = the sample Cut
131  // syst.first = the integer number of sigmas for the shift
132  // syst.second = the systematic being shifted
133  for(const auto& sample : cut_samples) {
134  SterileGenerator gen(
135  *FDAxis, kNCBinsNumuCCAxis,
136  *sample.second.second.second, *sample.second.second.first,
137  kNumuND, kNoShift, kWgtP31
138  );
139 
140  // Set up the nominal decompositions
141  // Only one is needed per sample
142  decomps_nominal[sample.first] = new CheatDecomp(
144  *sample.second.first, *sample.second.second.first,
146  );
147  predsNE_nominal[sample.first] = new PredictionNoExtrap(
148  loaders,
149  *FDAxis, *sample.second.second.second,
150  kNoShift, kWgtP31
151  );
152  predsSt_nominal[sample.first] = (PredictionSterile*)gen.Generate(
153  loaders
154  ).release();
155 
156  // Set up the shifted decompositions
157  // One is needed for every sample, systematic, and sigma level
158  for(const auto& shiftlabel : shiftlabels) {
159  for(const auto& syst : systematics[shiftlabel.first]) {
160  decomps_shifted[sample.first][shiftlabel.first][syst.first] = new CheatDecomp(
162  *sample.second.first, *sample.second.second.first,
163  *syst.second, kWgtP31
164  );
165  predsNE_shifted[sample.first][shiftlabel.first][syst.first] = new PredictionNoExtrap(
166  loaders,
167  *FDAxis, *sample.second.second.second,
168  *syst.second, kWgtP31
169  );
170  predsSt_shifted[sample.first][shiftlabel.first][syst.first] = (PredictionSterile*)gen.Generate(
171  loaders,
172  *syst.second
173  ).release();
174  }
175  }
176  }
177 
178  loaders.Go();
179 
180  std::string folder = "./";
181  std::string filenm = "SystsBeam17";
182 
183  std::string fullLocation = folder + filenm + ".root";
184  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
185 
186  SaveMaps(rootF,
187  decomps_nominal, decomps_shifted,
188  predsNE_nominal, predsNE_shifted,
189  predsSt_nominal, predsSt_shifted
190  );
191 }
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
Beam systematics:
Definition: BeamSysts.h:38
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
Generates extrapolated NC predictions using ProportionalDecomp.
std::string FindCAFAnaDir()
Definition: Utilities.cxx:204
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
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
const Var kWgtP31
void SystsBeamTranspLoad17()
double sigma(TH1F *hist, double percentile)
const SystShifts kNoShift
Definition: SystShifts.cxx:22
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
std::vector< Loaders * > loaders
Definition: syst_header.h:386
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
Just return the ND truth spectra as the decomposition.
Definition: CheatDecomp.h:10
const Binning kNCDisappearanceEnergyBinning
Energy binnings used in Ana01 for nus extrapolation.
Definition: Binning.cxx:68
enum BeamMode string