SystsPPFXLoad17.C
Go to the documentation of this file.
4 #include "CAFAna/Cuts/Cuts.h"
5 #include "NuXAna/Cuts/NusCuts.h"
10 #include "CAFAna/Extrap/ExtrapSterile.h"
13 #include "CAFAna/Systs/Systs.h"
15 #include "NuXAna/Vars/HistAxes.h"
19 
20 using namespace ana;
21 
22 
24  {
25  char pot[3];
26  sprintf(pot, "%d", i);
27  std::string potStr = std::string(pot);
28 
29  return potStr;
30  }
31 
32 
34 {
35  TH1::AddDirectory(0);
36 
37 
38  const Var kWgtP3 = kXSecCVWgt2017*kPPFXFluxCVWgt;
39 
40 
41  const std::string fnamenear_conc="defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1";
42  const std::string fnameneardata_conc="defname: prod_caf_R17-03-01-prod3reco.d_nd_numi_fhc_full_v1_goodruns";
43  const std::string fnamefar_con="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
44  const std::string fnameswap_con="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_v1";
45  const std::string fnametau_conc="defname: prod_caf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_v1";
46 
47 
48  SpectrumLoader floadnear(fnamenear_conc);
49  SpectrumLoader floadfar(fnamefar_con);
50  SpectrumLoader floadswap(fnameswap_con);
51  SpectrumLoader floadtau(fnametau_conc);
52  SpectrumLoader floadneardata(fnameneardata_conc);
53 
54  floadnear .SetSpillCut(kStandardSpillCuts);
56  floadswap .SetSpillCut(kStandardSpillCuts);
58  floadneardata.SetSpillCut(kStandardSpillCuts);
59 
60  // A map of systematic objects, indexed by the same label as above
61 /* std::map<std::string, std::vector<SpectrumLoader*> > systematics;
62 
63  for(const auto& shiftlabel : shiftlabels) {
64  systematics[shiftlabel.first] = std::vector<SpectrumLoader*>();
65  for(const auto& samdef : shiftlabel.second){
66  systematics[shiftlabel.first].push_back(new SpectrumLoader(samdef));
67  systematics[shiftlabel.first].back()->SetSpillCut(kStandardSpillCuts);
68  }
69  }
70 */
71  // std::map<std::string, std::string> systematics;
72  // systematics["PPFX"] = "PPFX Weight";
73 
74  // Define a map of samples and cuts/axes to set them up
75  // Each sample, essentially, is a way to set up the analysis
76  std::string labelRecoE = "Energy Deposited in Scintillator (GeV)";
77  std::map<std::string, std::pair<HistAxis*, std::pair<Cut*, Cut*> > > cut_samples;
78  std::pair<Cut*, Cut*> Ana01(new Cut(kNus17ND), new Cut(kNus17FDAlt));
79  cut_samples["Ana01"] = std::pair<HistAxis*, std::pair<Cut*, Cut*> >(
80  new HistAxis(labelRecoE, kNCDisappearanceEnergyBinning, kNusNDEnergy17),
81  Ana01
82  );
83 
84  // Set up maps to the decompositions/predictions (each flavor component)
85  // Nominal maps are indexed purely by sample label
86  // Shifted maps are indexed by sample label, systematic label, then sigma of the shift
87  std::map<std::string, IDecomp*> decomps_nominal;
88  std::map<std::string, std::map<std::string, std::map<int, IDecomp*> > > decomps_shifted;
89  std::map<std::string, PredictionNoExtrap*> predsNE_nominal;
90  std::map<std::string, std::map<std::string, std::map<int, PredictionNoExtrap*> > > predsNE_shifted;
91  std::map<std::string, PredictionSterile*> predsSt_nominal;
92  std::map<std::string, std::map<std::string, std::map<int, PredictionSterile*> > > predsSt_shifted;
93 
94 
95 
96  std::vector<Var> kPPFXFluxUnivWgts;
97  for(unsigned int UnivIdx = 0; UnivIdx < 100; UnivIdx++){
98  const Var tempPPFXWgt(
99  [UnivIdx](const caf::SRProxy* sr){
100  if (!sr->hdr.ismc)return 1.f;
101  if (sr->mc.nnu != 1)return 1.f;
102  if(sr->mc.nu[0].rwgt.ppfx.vuniv[UnivIdx] <= 0)return 1.f;
103  return (float)sr->mc.nu[0].rwgt.ppfx.vuniv[UnivIdx];
104  });
105  kPPFXFluxUnivWgts.push_back(tempPPFXWgt);
106  }
107 
108 
109 
110  //std::cout << "Hey I am here "<<std::cout;
111 
112  // Set up the actual decompositions/predictions
113  // sample.first = the sample label
114  // shiftlabel.first = the systematic shift label
115  // sample.second.first = the sample HistAxis
116  // sample.second.second = the sample Cut
117  for(const auto& sample : cut_samples) {
118 
119  decomps_nominal[sample.first] = new CheatDecomp(
120  floadnear,
121  *sample.second.first, *sample.second.second.first,
122  kNoShift, kWgtP3
123  );
124 
125  predsNE_nominal[sample.first] = new PredictionNoExtrap(
126  floadfar, floadswap, floadtau,
127  labelRecoE, kNCDisappearanceEnergyBinning,kNusNDEnergy17,*sample.second.second.second,
128  kNoShift, kWgtP3
129  );
130 
131 
132 
133  ProportionalDecomp* decompnc_n = new ProportionalDecomp(
134  floadnear, floadneardata,
135  *sample.second.first, *sample.second.second.first,
136  kNoShift, kNoShift, kWgtP3
137  );
138  ProportionalDecomp* decompnumu_n = new ProportionalDecomp(
139  floadnear, floadneardata,
141  kNoShift, kNoShift, kWgtP3
142  );
144  floadnear, floadswap, floadfar, floadtau, *decompnc_n, *decompnumu_n,
145  *sample.second.first, kNCBinsNumuCCAxis,
146  *sample.second.second.second, *sample.second.second.first, kNumuND,
147  kNoShift, kWgtP3
148  ));
149  predsSt_nominal[sample.first] = new PredictionSterile(extrap_n);
150 
151 
152  for(unsigned int Idx = 0; Idx < 100; Idx++){
153  const Var kPPFXFluxWgt = kPPFXFluxUnivWgts[Idx];
154  const Var kMCUnivWeight = kPPFXFluxWgt*kXSecCVWgt2017;
155 
156  decomps_shifted[sample.first][StringFromInt1(Idx)][1] = new CheatDecomp(
157  floadnear,
158  *sample.second.first, *sample.second.second.first,
159  kNoShift, kMCUnivWeight
160  );
161 
162 
163  predsNE_shifted[sample.first][StringFromInt1(Idx)][1] = new PredictionNoExtrap(
164  floadfar, floadswap, floadtau,
165  labelRecoE, kNCDisappearanceEnergyBinning ,
166  kNusNDEnergy17, *sample.second.second.second,
167  kNoShift, kMCUnivWeight
168  );
169 
170  ProportionalDecomp* decompnc_s = new ProportionalDecomp(
171  floadnear, floadneardata,
172  *sample.second.first, *sample.second.second.first,
173  kNoShift, kNoShift, kMCUnivWeight
174  );
175  ProportionalDecomp* decompnumu_s = new ProportionalDecomp(
176  floadnear, floadneardata,
178  kNoShift, kNoShift, kMCUnivWeight
179  );
181  floadnear, floadswap, floadfar, floadtau, *decompnc_s, *decompnumu_s,
182  *sample.second.first, kNCBinsNumuCCAxis,
183  *sample.second.second.second, *sample.second.second.first, kNumuND,
184  kNoShift, kMCUnivWeight
185  ));
186  predsSt_shifted[sample.first][StringFromInt1(Idx)][1] = new PredictionSterile(
187  extrap_s
188  );
189  }
190  }
191 
192  /* for(const auto& systlabel : systematics) {
193  for(const auto& loader : systlabel.second) {
194  loader->Go();
195  }
196  }*/
197  floadnear.Go();
198  floadfar .Go();
199  floadswap.Go();
200  floadtau .Go();
201  floadneardata.Go();
202  /* floadnear_ns.Go();
203  floadfar_ns .Go();
204  floadswap_ns.Go();
205  floadtau_ns.Go();
206 */
207  std::string folder = "./";
208  std::string filenm = "ppfx_debug";
209 
210  std::string fullLocation = folder + filenm + ".root";
211  TFile* rootF = new TFile(fullLocation.c_str(), "RECREATE");
212 
213  SaveMaps(rootF,
214  decomps_nominal, decomps_shifted,
215  predsNE_nominal, predsNE_shifted,
216  predsSt_nominal, predsSt_shifted
217  );
218 }
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2137
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
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
void SetSpillCut(const SpillCut &cut)
void SystsPPFXLoad17()
if(dump)
const Cut kNumuND
Definition: NumuCuts.h:55
const Cut kNus17ND
Full Nus17 ND analysis selection.
Definition: NusCuts17.h:120
#define pot
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
Definition: Cut.h:96
caf::StandardRecord * sr
virtual void Go() override
Load all the registered spectra.
const SystShifts kNoShift
Definition: SystShifts.cxx:21
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2138
const HistAxis kNCBinsNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNCDisappearanceEnergyBinning, kCCE)
Definition: HistAxes.h:9
Splits Data proportionally according to MC.
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
caf::Proxy< bool > ismc
Definition: SRProxy.h:242
std::string StringFromInt1(int i)
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:37
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.
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