nus18_box_opening.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
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 
17 #include "TH1D.h"
18 
19 using namespace ana;
20 
21 void nus18_box_opening(bool rhc = false)
22 {
23 
24  const std::string fname = rhc ? "prod4_sumrestricteddecaf_fd_numi_rhc_full_goodruns_nus2018" :
25  "prod4_sumrestricteddecaf_fd_numi_fhc_full_goodruns_nus2018";
26 
27  std::stringstream fnameout; fnameout << "fout_nus18_box_opening";
28  rhc? fnameout << "_rhc" : fnameout << "_fhc";
29  std::string foutroot = fnameout.str() + ".root";
30  std::string fouttxt = fnameout.str() + ".txt";
31 
32  // Make time axis for Nus2018 period
33  const Var kSliceTime = SIMPLEVAR(hdr.unixtime);
34  const HistAxis kTimeAxis("Unix Time (s)",Binning::Simple(13900, 1391000000, 1530000000), kSliceTime);
35 
36  const Var kSliceMeanTime = SIMPLEVAR(hdr.subevtmeantime);
37  const HistAxis kSliceTimeAxis("Slice Time (ns)",Binning::Simple(600, -50000, 555000), kSliceMeanTime);
38 
39  const HistAxis kNusAxisCVN("CVN NCID", Binning::Simple(21,0,1.05), kCVNnc);
40 
41  SpectrumLoader loader(fname);
43 
44  // out of time spectra
45  Spectrum spec_nus_cvn_outtime(loader, kNusAxisCVN,
47  kNoShift);
48 
49  Spectrum spec_nus_time_outtime(loader, kTimeAxis,
51  kNoShift);
52 
53  Spectrum spec_nus_slctime_outtime(loader, kSliceTimeAxis,
55  kNoShift);
56 
57  Spectrum spec_nus_vise_outtime(loader, kNus18AxisE,
59  kNoShift);
60 
61  // in time spectra
62  Spectrum spec_nus_cvn_intime(loader, kNusAxisCVN,
64  kNoShift);
65 
66  Spectrum spec_nus_time_intime(loader, kTimeAxis,
68  kNoShift);
69 
70  Spectrum spec_nus_slctime_intime(loader, kSliceTimeAxis,
72  kNoShift);
73 
74  Spectrum spec_nus_vise_intime(loader, kNus18AxisE,
76  kNoShift);
77 
78  // let's go!
79  loader.Go();
80 
81  std::cout << "Making output file, the money number is in here!" << std::endl;
82 
83  TFile fout(foutroot.c_str(), "RECREATE");
84 
85  spec_nus_cvn_intime.SaveTo(&fout, "spec_nus_cvn_numi");
86  spec_nus_cvn_outtime.SaveTo(&fout, "spec_nus_cvn_cosmic");
87 
88  spec_nus_time_intime.SaveTo(&fout, "spec_nus_time_numi");
89  spec_nus_time_outtime.SaveTo(&fout, "spec_nus_time_cosmic");
90 
91  spec_nus_slctime_intime.SaveTo(&fout, "spec_nus_slctime_numi");
92  spec_nus_slctime_outtime.SaveTo(&fout, "spec_nus_slctime_cosmic");
93 
94  spec_nus_vise_intime.SaveTo(&fout, "spec_nus_vise_numi");
95  spec_nus_vise_outtime.SaveTo(&fout, "spec_nus_vise_cosmic");
96 
97  fout.Close();
98 
99  Var kRun = SIMPLEVAR(hdr.run);
100  Var kSubrun = SIMPLEVAR(hdr.subrun);
101  Var kEvt = SIMPLEVAR(hdr.evt);
102  Var kSlice = SIMPLEVAR(hdr.subevt);
103  std::vector<const Var*> vars = {&kRun, &kSubrun, &kEvt, &kSlice,
104  &kSliceMeanTime, &kCVNnc, &kNus18Energy};
105 
106  MakeTextListFile(fname,
107  {kInBeamSpill && kNus18FD},
108  {fouttxt},
109  vars,
111 
112 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kNus18Energy([](const caf::SRProxy *sr){bool h_FHC=sr->spill.isFHC;bool h_RHC=sr->spill.isRHC;double cale=sr->slc.calE;double recoE=0.;if(h_FHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18 *cale;else if(h_FHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18 *cale;else if(h_RHC &&sr->hdr.det==caf::kFARDET) recoE=FDscaleCalE18RHC *cale;else if(h_RHC &&sr->hdr.det==caf::kNEARDET) recoE=NDscaleCalE18RHC *cale;return recoE;})
Definition: NusVars.h:63
const Var kCVNnc
PID
Definition: Vars.cxx:44
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
const Cut kNus18FD
Definition: NusCuts18.h:100
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const HistAxis kNus18AxisE("Energy Deposited in Scintillator (GeV)", kNus18EnergyBinning, kNus18Energy)
Axes used in Nus18 analysis by nus group.
Definition: HistAxes.h:16
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
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
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
const Var kEvt
Definition: Vars.cxx:23
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
void nus18_box_opening(bool rhc=false)
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.
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