nus_ana01_sideband_box_opening.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
2 #include "NuXAna/Cuts/NusCuts.h"
4 #include "CAFAna/Core/Binning.h"
8 #include "CAFAna/Core/Spectrum.h"
9 #include "CAFAna/Vars/Vars.h"
10 #include "CAFAna/Vars/HistAxes.h"
11 #include "NuXAna/Vars/HistAxes.h"
13 #include "CAFAna/Cuts/TimingCuts.h"
14 #include "OscLib/OscCalcDumb.h"
17 
18 #include "TH1D.h"
19 
20 using namespace ana;
21 
22 std::vector<std::string> MakeUnblindList();
23 
25 {
26 
27  const Var kSliceTime = SIMPLEVAR(hdr.unixtime);
28  const Var kSliceMeanTime = SIMPLEVAR(hdr.subevtmeantime);
29 
30  //Make time axis for second analysis period
31  const HistAxis kTimeAxis("unix time (s)",Binning::Simple(7200, 1391000000, 1463000000), kSliceTime);
32  const HistAxis kSliceTimeAxis("slice time (ns)",Binning::Simple(600, -50000, 550000), kSliceMeanTime);
33 
34  const HistAxis kCVNncAxis("CVN NCID",Binning::Simple(21,0,1.05), kCVNnc);
35  const Binning kNusHEBins = Binning::Simple(8,4,6);
36  const HistAxis kNusHEAxis("Calorimetric Energy (GeV)",kNusHEBins,kCaloE);
37 
38 
39  const std::vector<std::string> fnameunblind(MakeUnblindList());
40  SpectrumLoader loader(fnameunblind);
41 
43 
44  // High E outime
45  Spectrum spec_cvn_he_outtime(loader, kCVNncAxis,
46  kNusHighE && kInTimingSideband,
47  kNoShift);
48 
49  Spectrum spec_caloE_he_outtime(loader, kNusHEAxis,
50  kNusHighE && kInTimingSideband,
51  kNoShift);
52 
53  Spectrum spec_time_he_outtime(loader, kTimeAxis,
54  kNusHighE && kInTimingSideband,
55  kNoShift);
56 
57  Spectrum spec_slctime_he_outtime(loader, kSliceTimeAxis,
58  kNusHighE && kInTimingSideband,
59  kNoShift);
60 
61  // Low CVN outtime
62  Spectrum spec_cvn_lowcvn_outtime(loader, kCVNncAxis,
63  kNusLowCVN && kInTimingSideband,
64  kNoShift);
65 
66  Spectrum spec_caloE_lowcvn_outtime(loader, kNCAxis,
67  kNusLowCVN && kInTimingSideband,
68  kNoShift);
69 
70  Spectrum spec_time_lowcvn_outtime(loader, kTimeAxis,
71  kNusLowCVN && kInTimingSideband,
72  kNoShift);
73 
74  Spectrum spec_slctime_lowcvn_outtime(loader, kSliceTimeAxis,
75  kNusLowCVN &&
77  kNoShift);
78 
79  // Mid BDT outtime
80  Spectrum spec_cvn_midbdt_outtime(loader, kCVNncAxis,
81  kNusMidBDTSideband &&
83  kNoShift);
84 
85  Spectrum spec_caloE_midbdt_outtime(loader, kNCAxis,
86  kNusMidBDTSideband &&
88  kNoShift);
89 
90  Spectrum spec_time_midbdt_outtime(loader, kTimeAxis,
91  kNusMidBDTSideband &&
93  kNoShift);
94  Spectrum spec_slctime_midbdt_outtime(loader, kSliceTimeAxis,
95  kNusMidBDTSideband &&
97  kNoShift);
98 
99  // High E intime
100  Spectrum spec_cvn_he_intime(loader, kCVNncAxis,
101  kNusHighE && kInBeamSpill,
102  kNoShift);
103 
104  Spectrum spec_caloE_he_intime(loader, kNusHEAxis,
105  kNusHighE && kInBeamSpill,
106  kNoShift);
107 
108  Spectrum spec_time_he_intime(loader, kTimeAxis,
109  kNusHighE && kInBeamSpill,
110  kNoShift);
111 
112  Spectrum spec_slctime_he_intime(loader, kSliceTimeAxis,
113  kNusHighE && kInBeamSpill,
114  kNoShift);
115 
116  // Low CVN intime
117  Spectrum spec_cvn_lowcvn_intime(loader, kCVNncAxis,
118  kNusLowCVN && kInBeamSpill,
119  kNoShift);
120 
121  Spectrum spec_caloE_lowcvn_intime(loader, kNCAxis,
122  kNusLowCVN && kInBeamSpill,
123  kNoShift);
124 
125  Spectrum spec_time_lowcvn_intime(loader, kTimeAxis,
126  kNusLowCVN && kInBeamSpill,
127  kNoShift);
128 
129  Spectrum spec_slctime_lowcvn_intime(loader, kSliceTimeAxis,
130  kNusLowCVN &&
131  kInBeamSpill,
132  kNoShift);
133 
134  // Mid BDT intime
135  Spectrum spec_cvn_midbdt_intime(loader, kCVNncAxis,
136  kNusMidBDTSideband &&
137  kInBeamSpill,
138  kNoShift);
139 
140  Spectrum spec_caloE_midbdt_intime(loader, kNCAxis,
141  kNusMidBDTSideband &&
142  kInBeamSpill,
143  kNoShift);
144 
145  Spectrum spec_time_midbdt_intime(loader, kTimeAxis,
146  kNusMidBDTSideband &&
147  kInBeamSpill,
148  kNoShift);
149 
150  Spectrum spec_slctime_midbdt_intime(loader, kSliceTimeAxis,
151  kNusMidBDTSideband &&
152  kInBeamSpill,
153  kNoShift);
154 
155 
156 
157  // let's go!
158  loader.Go();
159 
160  std::cout<<"making output file \n";
161  TFile fout("fout_nus_ana01_sideband_box_opening.root", "RECREATE");
162 
163  // High E
164  spec_cvn_he_intime.SaveTo(&fout, "spec_cvn_he_numi");
165  spec_cvn_he_outtime.SaveTo(&fout, "spec_cvn_he_cosmic");
166 
167  spec_caloE_he_intime.SaveTo(&fout, "spec_caloE_he_numi");
168  spec_caloE_he_outtime.SaveTo(&fout, "spec_caloE_he_cosmic");
169 
170  spec_time_he_intime.SaveTo(&fout, "spec_time_he_numi");
171  spec_time_he_outtime.SaveTo(&fout, "spec_time_he_cosmic");
172 
173  spec_slctime_he_intime.SaveTo(&fout, "spec_slctime_he_numi");
174  spec_slctime_he_outtime.SaveTo(&fout, "spec_slctime_he_cosmic");
175 
176  // Low CVN
177  spec_cvn_lowcvn_intime.SaveTo(&fout, "spec_cvn_lowcvn_numi");
178  spec_cvn_lowcvn_outtime.SaveTo(&fout, "spec_cvn_lowcvn_cosmic");
179 
180  spec_caloE_lowcvn_intime.SaveTo(&fout, "spec_caloE_lowcvn_numi");
181  spec_caloE_lowcvn_outtime.SaveTo(&fout, "spec_caloE_lowcvn_cosmic");
182 
183  spec_time_lowcvn_intime.SaveTo(&fout, "spec_time_lowcvn_numi");
184  spec_time_lowcvn_outtime.SaveTo(&fout, "spec_time_lowcvn_cosmic");
185 
186  spec_slctime_lowcvn_intime.SaveTo(&fout, "spec_slctime_lowcvn_numi");
187  spec_slctime_lowcvn_outtime.SaveTo(&fout, "spec_slctime_lowcvn_cosmic");
188 
189  // MID BDT
190  spec_cvn_midbdt_intime.SaveTo(&fout, "spec_cvn_midbdt_numi");
191  spec_cvn_midbdt_outtime.SaveTo(&fout, "spec_cvn_midbdt_cosmic");
192 
193  spec_caloE_midbdt_intime.SaveTo(&fout, "spec_caloE_midbdt_numi");
194  spec_caloE_midbdt_outtime.SaveTo(&fout, "spec_caloE_midbdt_cosmic");
195 
196  spec_time_midbdt_intime.SaveTo(&fout, "spec_time_midbdt_numi");
197  spec_time_midbdt_outtime.SaveTo(&fout, "spec_time_midbdt_cosmic");
198 
199  spec_slctime_midbdt_intime.SaveTo(&fout, "spec_slctime_midbdt_numi");
200  spec_slctime_midbdt_outtime.SaveTo(&fout, "spec_slctime_midbdt_cosmic");
201 
202  Var kRun = SIMPLEVAR(hdr.run);
203  Var kSubrun = SIMPLEVAR(hdr.subrun);
204  Var kEvt = SIMPLEVAR(hdr.evt);
205  Var kSlice = SIMPLEVAR(hdr.subevt);
206  std::vector<const Var*> vars = {&kRun, &kSubrun, &kEvt, &kSlice,
207  &kSliceMeanTime, &kCVNnc,
208  &kCaloE};
209  MakeTextListFile(fnameunblind,
210  {kInBeamSpill && kNusHighE,
211  kInTimingSideband && kNusHighE,
212  kInBeamSpill && kNusLowCVN,
213  kInTimingSideband && kNusLowCVN,
214  kInBeamSpill && kNusMidBDTSideband,
215  kInTimingSideband && kNusMidBDTSideband},
216  {"hesideband_numi.txt", "hesideband_cosmic.txt",
217  "lowcvnsideband_numi.txt", "lowcvnsideband_cosmic.txt",
218  "midbdtsideband_numi.txt", "midbdtsideband_cosmic.txt"},
219  vars,
221 
222 }
223 
224 std::vector<std::string> MakeUnblindList()
225 {
226 
227  std::vector<std::string> fname1 = Wildcard(
228  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_period1_nus_contain_v1_goodruns_prod2-snapshot/"
229  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_period1_nus_contain_v1_goodruns_prod2-snapshot*.root"
230  );
231  std::vector<std::string> fname2 = Wildcard(
232  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_period2_nus_contain_v1_goodruns_prod2-snapshot/"
233  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_period2_nus_contain_v1_goodruns_prod2-snapshot*.root"
234  );
235  std::vector<std::string> fname3b = Wildcard(
236  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3*_nus_contain_v1_goodruns_prod2-snapshot.root"
237  );
238  std::vector<std::string> fname3c = Wildcard(
239  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3c_nus_contain_v1_goodruns_prod2-snapshot/"
240  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3c_nus_contain_v1_goodruns_prod2-snapshot*.root"
241  );
242  std::vector<std::string> fname3d = Wildcard(
243  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3d_nus_contain_v1_goodruns_prod2-snapshot/"
244  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3d_nus_contain_v1_goodruns_prod2-snapshot*.root"
245  );
246  std::vector<std::string> ret;
247  for(const auto& file : fname1) { ret.push_back(file); }
248  for(const auto& file : fname2) { ret.push_back(file); }
249  for(const auto& file : fname3b) { ret.push_back(file); }
250  for(const auto& file : fname3c) { ret.push_back(file); }
251  for(const auto& file : fname3d) { ret.push_back(file); }
252  return ret;
253 }
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kCVNnc
PID
Definition: Vars.cxx:44
std::vector< std::string > MakeUnblindList()
Definition: Ana01Data.h:7
const Var kSliceTime([](const caf::SRProxy *sr){return sr->slc.meantime/1000;})
Definition: NumuVars.h:34
void SetSpillCut(const SpillCut &cut)
const Var kSubrun
Definition: Vars.cxx:21
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Cut kInTimingSideband([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return(kInTimingSideband_before(sr)|| kInTimingSideband_after(sr));else return(kInTimingSideband_before(sr)|| kInTimingSideband_afterA(sr)|| kInTimingSideband_afterB(sr));}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_after.Livetime(spill));else return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_afterA.Livetime(spill)+ kInTimingSideband_afterB.Livetime(spill));}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:12
void MakeTextListFile(const std::string &wildcard, const std::vector< Cut > &cut, const std::vector< std::string > &output, const std::vector< const Var * > &floatVars, const std::vector< const Var * > &intVars, const SpillCut *spillCut)
Make a file listing all the events passing the specified cut.
Definition: EventList.cxx:193
std::vector< std::string > Wildcard(const std::string &wildcardString)
Find files matching a UNIX glob, plus expand environment variables.
Definition: UtilsExt.cxx:268
const Var kEvt
Definition: Vars.cxx:23
void nus_ana01_sideband_box_opening()
const Var kCaloE
Summed calorimetric energy of all hits in slice, uncorrected.
Definition: Vars.cxx:52
const std::string diskdirFD
virtual void Go() override
Load all the registered spectra.
const std::map< std::pair< std::string, std::string >, Variable > vars
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const HistAxis kNCAxis("Calorimetric Energy (GeV)", kNCDisappearanceEnergyBinning, kCaloE)
Axes used in Ana01 analysis by nus group.
Definition: HistAxes.h:8
loader
Definition: demo0.py:10
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
TFile * file
Definition: cellShifts.C:17
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const Var kSlice
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Var kRun
Definition: Vars.cxx:20
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107