nus_ana01_box_opening.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
3 
4 
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"
16 
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, 555000), kSliceMeanTime);
33 
34  const HistAxis kNusAxisCVN("CVN NCID", Binning::Simple(21,0,1.05), kCVNnc);
35 
36  const std::vector<std::string> fnameunblind(MakeUnblindList());
37  SpectrumLoader loader(fnameunblind);
39 
40  // out of time spectra
41  Spectrum spec_nus_cvn_outtime(loader, kNusAxisCVN,
43  kNoShift);
44 
45  Spectrum spec_nus_time_outtime(loader, kTimeAxis,
47  kNoShift);
48 
49  Spectrum spec_nus_slctime_outtime(loader, kSliceTimeAxis,
51  kNoShift);
52 
53  Spectrum spec_nus_cale_outtime(loader, kNCAxis,
55  kNoShift);
56 
57  // in time spectra
58  Spectrum spec_nus_cvn_intime(loader, kNusAxisCVN,
60  kNoShift);
61 
62  Spectrum spec_nus_time_intime(loader, kTimeAxis,
64  kNoShift);
65 
66  Spectrum spec_nus_slctime_intime(loader, kSliceTimeAxis,
68  kNoShift);
69 
70  Spectrum spec_nus_cale_intime(loader, kNCAxis,
72  kNoShift);
73 
74 
75  // let's go!
76  loader.Go();
77 
78  std::cout<<"Making output file, the money number is in here! \n";
79 
80  TFile fout("fout_nus_ana01_box_opening_restricted.root", "RECREATE");
81 
82  spec_nus_cvn_intime.SaveTo(&fout, "spec_nus_cvn_numi");
83  spec_nus_cvn_outtime.SaveTo(&fout, "spec_nus_cvn_cosmic");
84 
85  spec_nus_time_intime.SaveTo(&fout, "spec_nus_time_numi");
86  spec_nus_time_outtime.SaveTo(&fout, "spec_nus_time_cosmic");
87 
88  spec_nus_slctime_intime.SaveTo(&fout, "spec_nus_slctime_numi");
89  spec_nus_slctime_outtime.SaveTo(&fout, "spec_nus_slctime_cosmic");
90 
91  spec_nus_cale_intime.SaveTo(&fout, "spec_nus_cale_numi");
92  spec_nus_cale_outtime.SaveTo(&fout, "spec_nus_cale_cosmic");
93 
94 
95  Var kRun = SIMPLEVAR(hdr.run);
96  Var kSubrun = SIMPLEVAR(hdr.subrun);
97  Var kEvt = SIMPLEVAR(hdr.evt);
98  Var kSlice = SIMPLEVAR(hdr.subevt);
99  std::vector<const Var*> vars = {&kRun, &kSubrun, &kEvt, &kSlice,
100  &kSliceMeanTime, &kCVNnc, &kCaloE};
101 
102 
103  MakeTextListFile(fnameunblind,
104  {kInBeamSpill && kNusFD,
105  kInTimingSideband && kNusFD},
106  {"nus_selected_numi.txt","nus_selected_cosmic.txt"},
107  vars,
109 
110 }
111 
112 std::vector<std::string> MakeUnblindList()
113 {
114  std::vector<std::string> fname1 = Wildcard(
115  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_period1_nus_contain_v1_goodruns_prod2-snapshot/"
116  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_period1_nus_contain_v1_goodruns_prod2-snapshot*.root"
117  );
118  std::vector<std::string> fname2 = Wildcard(
119  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_period2_nus_contain_v1_goodruns_prod2-snapshot/"
120  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_period2_nus_contain_v1_goodruns_prod2-snapshot*.root"
121  );
122  std::vector<std::string> fname3b = Wildcard(
123  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3*_nus_contain_v1_goodruns_prod2-snapshot.root"
124  );
125  std::vector<std::string> fname3c = Wildcard(
126  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3c_nus_contain_v1_goodruns_prod2-snapshot/"
127  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3c_nus_contain_v1_goodruns_prod2-snapshot*.root"
128  );
129  std::vector<std::string> fname3d = Wildcard(
130  diskdirFD + "by_period/prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3d_nus_contain_v1_goodruns_prod2-snapshot/"
131  + "prod_restricteddecaf_S16-05-20_fd_numi_fhc_epoch3d_nus_contain_v1_goodruns_prod2-snapshot*.root"
132  );
133  std::vector<std::string> ret;
134  for(const auto& file : fname1) { ret.push_back(file); }
135  for(const auto& file : fname2) { ret.push_back(file); }
136  for(const auto& file : fname3b) { ret.push_back(file); }
137  for(const auto& file : fname3c) { ret.push_back(file); }
138  for(const auto& file : fname3d) { ret.push_back(file); }
139  return ret;
140 }
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 Cut kNusFD
Definition: NusCuts.h:46
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
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:22
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
void nus_ana01_box_opening()
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