nus17_box_opening.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
4 
5 
9 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Vars/Vars.h"
11 #include "CAFAna/Vars/HistAxes.h"
12 #include "NuXAna/Vars/HistAxes.h"
14 #include "CAFAna/Cuts/TimingCuts.h"
15 #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 summer 2017 (nus17) period
31  const HistAxis kTimeAxis("Unix Time (s)",Binning::Simple(9900, 1391000000, 1490000000), 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_vise_outtime(loader, kNus17Axis,
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_vise_intime(loader, kNus17Axis,
72  kNoShift);
73 
74 
75  // let's go!
76  loader.Go();
77 
78  std::cout << "Making output file, the money number is in here!" << std::endl;
79 
80  TFile fout("fout_nus17_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_vise_intime.SaveTo(&fout, "spec_nus_vise_numi");
92  spec_nus_vise_outtime.SaveTo(&fout, "spec_nus_vise_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, &kNus17Energy};
101 
102 
103  MakeTextListFile(fnameunblind,
105  kInTimingSideband && kNus17FDAlt},
106  {"nus17_selected_numi.txt","nus17_selected_cosmic.txt"},
107  vars,
109 
110 }
111 
112 std::vector<std::string> MakeUnblindList()
113 {
114  std::vector<std::string> ret;
115  const std::string pnfsdir = "/pnfs/nova/persistent/users/gsdavies/nus/prod3/concat/";
116 
117  std::vector<std::string> fnumi_period1 = Wildcard(
118  pnfsdir + "prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_period1_v1_goodruns_nus2017/*.root"
119  );
120  std::vector<std::string> fnumi_period2 = Wildcard(
121  pnfsdir + "prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_period2_v1_goodruns_nus2017/*.root"
122  );
123  std::vector<std::string> fnumi_period3 = Wildcard(
124  pnfsdir + "prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_period3_v1_goodruns_nus2017/*.root"
125  );
126  std::vector<std::string> fnumi_period5 = Wildcard(
127  pnfsdir + "prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_period5_v1_goodruns_nus2017/*.root"
128  );
129 
130  for(const auto& file : fnumi_period1) {ret.push_back(file);}
131  for(const auto& file : fnumi_period2) {ret.push_back(file);}
132  for(const auto& file : fnumi_period3) {ret.push_back(file);}
133  for(const auto& file : fnumi_period5) {ret.push_back(file);}
134  return ret;
135 
136 }
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 > fnumi_period3
Definition: NusLoadProd3.h:77
std::vector< std::string > MakeUnblindList()
Definition: Ana01Data.h:7
#define SIMPLEVAR(CAFNAME)
Definition: Var.h:11
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
void nus17_box_opening()
std::vector< std::string > fnumi_period1
Definition: NusLoadProd3.h:71
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Var kNus17Energy([](const caf::SRProxy *sr){double cale=sr->slc.calE;double recoE=0.;if(sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE17 *cale;if(sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE17 *cale;return recoE;})
Definition: NusVars.h:62
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 std::string pnfsdir
Definition: NusLoadProd3.h:69
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:534
const HistAxis kNus17Axis("Visible Energy (GeV)", kNus17EnergyBinning, kNus17Energy)
Axes used in Nus17 analysis by nus group.
Definition: HistAxes.h:12
loader
Definition: demo0.py:10
std::vector< std::string > fnumi_period2
Definition: NusLoadProd3.h:74
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
std::vector< std::string > fnumi_period5
Definition: NusLoadProd3.h:80
const Cut kNus17FDAlt
Definition: NusCuts17.h:92
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
enum BeamMode string