Ana2018_box_opening_macro.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
5 
9 #include "CAFAna/Core/Spectrum.h"
10 
11 #include "CAFAna/Vars/Vars.h"
12 #include "CAFAna/Vars/HistAxes.h"
14 
15 #include "OscLib/OscCalcDumb.h"
17 
18 #include "TH1D.h"
19 
20 using namespace ana;
21 
22 
24 {
25  // Make time axis for 2018 analysis period
26  const Var kSliceTime = SIMPLEVAR(hdr.unixtime);
27  const Var kSliceMeanTime = SIMPLEVAR(hdr.subevtmeantime);
28  const HistAxis kTimeAxis("unix time (s)",Binning::Simple(10000, 1391000000, 1524000000), kSliceTime);
29  const HistAxis kSliceTimeAxis("slice time (ns)",Binning::Simple(600, -50000, 550000), kSliceMeanTime);
30 
31  const std::string fname = beam == "fhc" ?
32  // 2018 restricted files!
33  "prod4_sumrestricteddecaf_fd_numi_fhc_full_goodruns_nue2018" :
34  "prod4_sumrestricteddecaf_fd_numi_rhc_full_goodruns_nue2018" ;
35 
36  SpectrumLoader loader(fname);
38 
39  // out of time spectra
40  Spectrum spec_cvn_outtime(loader, kNue2018Axis,
42 
43  Spectrum spec_cvn_merged_outtime(loader, kNue2018AxisMergedPeripheral,
45 
46  Spectrum spec_cvn_time_outtime(loader, kTimeAxis,
48 
49  Spectrum spec_cvn_slctime_outtime(loader, kSliceTimeAxis,
51 
52  // in time spectra
53  Spectrum spec_cvn_intime(loader, kNue2018Axis,
55 
56  Spectrum spec_cvn_merged_intime(loader, kNue2018AxisMergedPeripheral,
58 
59  Spectrum spec_cvn_time_intime(loader, kTimeAxis,
61 
62  Spectrum spec_cvn_slctime_intime(loader, kSliceTimeAxis,
64 
65  // let's find some neutrinos!
66  loader.Go();
67 
68  std::cout<<"Making output file: ";
69  TFile fout(("nue2018_numi_"+beam+"_data.root").c_str(), "RECREATE");
70  std::cout<< fout.GetName() << std::endl;
71 
72  spec_cvn_intime.SaveTo(&fout, "spec_cvn2d_numi");
73  spec_cvn_outtime.SaveTo(&fout, "spec_cvn2d_cosmic");
74 
75  spec_cvn_merged_intime.SaveTo(&fout, "spec_cvn2d_merged_numi");
76  spec_cvn_merged_outtime.SaveTo(&fout, "spec_cvn2d_merged_cosmic");
77 
78  spec_cvn_time_intime.SaveTo(&fout, "spec_time_numi");
79  spec_cvn_time_outtime.SaveTo(&fout, "spec_time_cosmic");
80 
81  spec_cvn_slctime_intime.SaveTo(&fout, "spec_slctime_numi");
82  spec_cvn_slctime_outtime.SaveTo(&fout, "spec_slctime_cosmic");
83 
84  fout.close();
85 
86  Var kRun = SIMPLEVAR(hdr.run);
87  Var kSubrun = SIMPLEVAR(hdr.subrun);
88  Var kEvt = SIMPLEVAR(hdr.evt);
89  Var kSlice = SIMPLEVAR(hdr.subevt);
90 
91  std::vector<const Var*> vars = {&kRun, &kSubrun, &kEvt, &kSlice, &kSliceTime,
92  &kSliceMeanTime,
94  &kCVNSSe,
96  };
97 
98  MakeTextListFile(fname,
100  kInTimingSideband && kNue2018FDAllSamples},
101  {("nue2018_selected_"+beam+"_numi.txt").c_str(),
102  ("nue2018_selected_"+beam+"_cosmic.txt").c_str()},
103  vars,
105 
106 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
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
void Ana2018_box_opening_macro(const std::string beam="fhc")
const Var kNue2018AnaBin([](const caf::SRProxy *sr){int selBin=kNue2018SelectionBin(sr);float nuE=kNueEnergy2018(sr);int nuEBin=nuE/0.5;assert(nuEBin<=8 &&"An event with nuE > 4.5 should never happen");int anaBin=9 *selBin+nuEBin;return anaBin;})
Use this Analysis Binning for Ana2018, official Binning.
Definition: NueCuts2018.h:171
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
const Var kNueEnergy2018([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;if(kIsRHC(sr)) return kNueEnergyRHC(sr);else return kNueEnergyFHC(sr);})
Definition: NueEnergy2018.h:25
const HistAxis kNue2018AxisMergedPeripheral("NuE Energy / Analysis Bin", kNue2018BinningMergedPeripheral, kNue2018AnaBinMergedPeripheral)
Definition: NueCuts2018.h:181
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
loader
Definition: demo0.py:10
const Var kCVNSSe([](const caf::SRProxy *sr){throw std::runtime_error("kCVNSSe is no longer available. Fix your macro so you don't use it.");return-5.;})
2018 nue PID
Definition: Vars.h:52
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut kNue2018FDAllSamples
Definition: NueCuts2018.h:77
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
const HistAxis kNue2018Axis("NuE Energy / Analysis Bin", kNue2018Binning, kNue2018AnaBin)
Use this Axis for Ana2018, official Axis.
enum BeamMode string