Ana2017_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 2017 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, 1491000000), kSliceTime);
29  const HistAxis kSliceTimeAxis("slice time (ns)",Binning::Simple(600, -50000, 550000), kSliceMeanTime);
30 
31  const HistAxis kNue2017EnergyAxis( "Nue Energy Estimator (GeV)",
32  Binning::Simple( 10, 0, 5 ), kNueEnergy2017 );
33 
34  const std::string fnamecos =
35  // !!! Nue 2017 retricted dataset !!!
36  "prod_sumrestricteddecaf_R17-03-01-prod3reco.k_fd_numi_fhc_full_v1_goodruns_nue2017";
37 
38  SpectrumLoader loadercos(fnamecos);
39 
41 
42  // out of time spectra
43  Spectrum spec_cvn_outtime(loadercos, kNue2017Axis,
45  kNoShift);
46 
47  Spectrum spec_cvn_nueE_core_outtime(loadercos, kNue2017EnergyAxis,
49  kNoShift);
50 
51  Spectrum spec_cvn_nueE_peripheral_outtime(loadercos, kNue2017EnergyAxis,
53  kNoShift);
54 
55  Spectrum spec_cvn_time_outtime(loadercos, kTimeAxis,
57  kNoShift);
58 
59  Spectrum spec_cvn_slctime_outtime(loadercos, kSliceTimeAxis,
61  kNoShift);
62 
63  // in time spectra
64  Spectrum spec_cvn_intime(loadercos, kNue2017Axis,
66  kNoShift);
67 
68  Spectrum spec_cvn_nueE_core_intime(loadercos, kNue2017EnergyAxis,
70  kNoShift);
71 
72  Spectrum spec_cvn_nueE_peripheral_intime(loadercos, kNue2017EnergyAxis,
74  kNoShift);
75 
76  Spectrum spec_cvn_time_intime(loadercos, kTimeAxis,
78  kNoShift);
79 
80  Spectrum spec_cvn_slctime_intime(loadercos, kSliceTimeAxis,
82  kNoShift);
83 
84  // let's go!
85  loadercos.Go();
86 
87  std::cout<<"Making output file ";
88  TFile fout("Ana2017_numi_data.root", "RECREATE");
89  std::cout<< fout.GetName() << std::endl;
90 
91  spec_cvn_intime.SaveTo(&fout, "spec_cvn_cvn2d_numi");
92  spec_cvn_outtime.SaveTo(&fout, "spec_cvn_cvn2d_cosmic");
93 
94  spec_cvn_nueE_core_intime.SaveTo(&fout, "spec_cvn_nueE_core_numi");
95  spec_cvn_nueE_core_outtime.SaveTo(&fout, "spec_cvn_nueE_core_cosmic");
96 
97  spec_cvn_nueE_peripheral_intime.SaveTo(&fout, "spec_cvn_nueE_peripheral_numi");
98  spec_cvn_nueE_peripheral_outtime.SaveTo(&fout, "spec_cvn_nueE_peripheral_cosmic");
99 
100  spec_cvn_time_intime.SaveTo(&fout, "spec_cvn_time_numi");
101  spec_cvn_time_outtime.SaveTo(&fout, "spec_cvn_time_cosmic");
102 
103  spec_cvn_slctime_intime.SaveTo(&fout, "spec_cvn_slctime_numi");
104  spec_cvn_slctime_outtime.SaveTo(&fout, "spec_cvn_slctime_cosmic");
105 
106  Var kRun = SIMPLEVAR(hdr.run);
107  Var kSubrun = SIMPLEVAR(hdr.subrun);
108  Var kEvt = SIMPLEVAR(hdr.evt);
109  Var kSlice = SIMPLEVAR(hdr.subevt);
110 
111  std::vector<const Var*> vars = {&kRun, &kSubrun, &kEvt, &kSlice,
112  &kSliceMeanTime,
114  &kCVNe,
116  };
117 
118  MakeTextListFile(fnamecos,
120  kInTimingSideband && kNue2017FDAllSamples},
121  {"nue2017_selected_numi.txt",
122  "nue2017_selected_cosmic.txt"},
123  vars,
125 
126 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kCVNe
PID
Definition: Vars.cxx:35
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 kNue2017FD
Full FD nue selection for 2017 analysis.
Definition: NueCuts2017.h:130
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
const Var kNueEnergy2017([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;return NueRecoE_2017FDFit(kCVNemE(sr), kCVNhadE(sr));})
Definition: NueEnergy2017.h:11
const Var kEvt
Definition: Vars.cxx:23
const Cut kNue2017FDPeripheral
Definition of the FD peripheral sample around our core selected events.
Definition: NueCuts2017.h:152
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 kNue2017Axis("NuE Energy / Analysis Bin", kNue2017Binning, kNue2017AnaBin)
Definition: NueCuts2017.h:313
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
const Var kNue2017AnaBin([](const caf::SRProxy *sr){int selBin=kNue2017SelectionBin(sr);float nuE=kNueEnergy2017(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;})
Definition: NueCuts2017.h:311
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
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
void Ana2017_box_opening_macro()
const Cut kNue2017FDAllSamples
Our FD selection including all samples, for making predictions, etc.
Definition: NueCuts2017.h:155
enum BeamMode string