MakeNus18SidebandPred.C
Go to the documentation of this file.
4 #include "CAFAna/Core/Loaders.h"
5 #include "CAFAna/Core/Binning.h"
6 #include "CAFAna/Core/Spectrum.h"
9 #include "NuXAna/Cuts/NusCuts.h"
10 #include "NuXAna/Cuts/NusCuts18.h"
11 #include "CAFAna/Cuts/SpillCuts.h"
12 #include "CAFAna/Cuts/TimingCuts.h"
14 #include "CAFAna/Extrap/ExtrapSterile.h"
20 #include "CAFAna/Vars/HistAxes.h"
22 #include "NuXAna/macros/Nus18/NusLoadProd4.h"
23 #include "NuXAna/Vars/HistAxes.h"
24 
25 #include "OscLib/OscCalcSterile.h"
26 
27 #include <utility>
28 
29 using namespace ana;
30 
31 void MakeNus18SidebandPred(bool concat = true, bool rhc = false) {
32 
33  TH1::AddDirectory(0);
34 
35  const Var kReweight = kXSecCVWgt2018*kPPFXFluxCVWgt;
36 
37  // Set up the loaders
38  Loaders* loaders_mc = new Prod4NomLoaders(
41  loaders_mc->SetSpillCut(kStandardSpillCuts);
42 
43  // Data loaders
44  std::map<bool,std::map<bool,std::string> > dataFiles;
45  dataFiles[true][false] = "prod4_sumrestricteddecaf_fd_numi_fhc_full_goodruns_nus2018";
46  dataFiles[true][true] = "prod4_sumrestricteddecaf_fd_numi_rhc_full_goodruns_nus2018";
47  dataFiles[false][false] = "prod4_restrictedcaf_fd_numi_fhc_full_goodruns";
48  dataFiles[false][true] = "prod4_restrictedcaf_fd_numi_rhc_full_goodruns";
49  SpectrumLoader loaders_data(dataFiles[concat][rhc]);
50  loaders_data.SetSpillCut(kStandardSpillCuts);
51 
52  // Axes and binning
53  const HistAxis CVNAxis ("CVNnc Indentifier", Binning::Simple(100,0.,1.), kCVNnc);
54  const HistAxis NHitsAxis("Number of Hits", Binning::Simple(800,0.,800.), kNHit);
55  const HistAxis BDTAxis ("Cosmic Rejection BDT", Binning::Simple(100,0.,1.), kNCCosRejAltp4_6);
56 
57  // Set up the prediction objects
58 
59  // Energy
60  PredictionNoExtrap* pred_genie_e = new PredictionNoExtrap(*loaders_mc, kNus18AxisE, kNus18FDSideband, kNoShift, kReweight);
61  Spectrum* spec_data_e = new Spectrum(loaders_data, kNus18AxisE, kNus18FDSideband && kInBeamSpill);
62  Spectrum* spec_cos_e = new Spectrum(loaders_data, kNus18AxisE, kNus18FDSideband && kInTimingSideband);
63 
64  // CVN
65  PredictionNoExtrap* pred_genie_cvn = new PredictionNoExtrap(*loaders_mc, CVNAxis, kNus18FDSideband, kNoShift, kReweight);
66  Spectrum* spec_data_cvn = new Spectrum(loaders_data, CVNAxis, kNus18FDSideband && kInBeamSpill);
67  Spectrum* spec_cos_cvn = new Spectrum(loaders_data, CVNAxis, kNus18FDSideband && kInTimingSideband);
68 
69  // NHits
70  PredictionNoExtrap* pred_genie_nhits = new PredictionNoExtrap(*loaders_mc, NHitsAxis, kNus18FDSideband, kNoShift, kReweight);
71  Spectrum* spec_data_nhits = new Spectrum(loaders_data, NHitsAxis, kNus18FDSideband && kInBeamSpill);
72  Spectrum* spec_cos_nhits = new Spectrum(loaders_data, NHitsAxis, kNus18FDSideband && kInTimingSideband);
73 
74  // BDT
75  PredictionNoExtrap* pred_genie_bdt = new PredictionNoExtrap(*loaders_mc, BDTAxis, kNus18FDSideband, kNoShift, kReweight);
76  Spectrum* spec_data_bdt = new Spectrum(loaders_data, BDTAxis, kNus18FDSideband && kInBeamSpill);
77  Spectrum* spec_cos_bdt = new Spectrum(loaders_data, BDTAxis, kNus18FDSideband && kInTimingSideband);
78 
79  // Fill the spectra!
80  loaders_mc->Go();
81  loaders_data.Go();
82 
83  // Set up output file
84  std::stringstream outFile; outFile << "pred_nus18_";
85  rhc ? outFile << "rhc" : outFile << "fhc";
86  outFile << "_sideband.root";
87  TFile* rootOut = new TFile(outFile.str().c_str(), "RECREATE");
88 
89  // Save all of the objects
90  pred_genie_e->SaveTo(rootOut, "pred_genie_e");
91  spec_data_e->SaveTo(rootOut, "spec_data_e");
92  spec_cos_e->SaveTo(rootOut, "spec_cos_e");
93 
94  pred_genie_cvn->SaveTo(rootOut, "pred_genie_cvn");
95  spec_data_cvn->SaveTo(rootOut, "spec_data_cvn");
96  spec_cos_cvn->SaveTo(rootOut, "spec_cos_cvn");
97 
98  pred_genie_nhits->SaveTo(rootOut, "pred_genie_nhits");
99  spec_data_nhits->SaveTo(rootOut, "spec_data_nhits");
100  spec_cos_nhits->SaveTo(rootOut, "spec_cos_nhits");
101 
102  pred_genie_bdt->SaveTo(rootOut, "pred_genie_bdt");
103  spec_data_bdt->SaveTo(rootOut, "spec_data_bdt");
104  spec_cos_bdt->SaveTo(rootOut, "spec_cos_bdt");
105 
106  rootOut->Close(); // Close the file
107 
108 }
const Var kNCCosRejAltp4_6
Definition: NusVarsTemp.h:110
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kCVNnc
PID
Definition: Vars.cxx:44
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
std::vector< double > Spectrum
Definition: Constants.h:746
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const HistAxis kNus18AxisE("Energy Deposited in Scintillator (GeV)", kNus18EnergyBinning, kNus18Energy)
Axes used in Nus18 analysis by nus group.
Definition: HistAxes.h:16
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
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 SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
TFile * outFile
Definition: PlotXSec.C:135
const Var kNHit
Definition: Vars.cxx:71
virtual void Go() override
Load all the registered spectra.
void MakeNus18SidebandPred(bool concat=true, bool rhc=false)
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:534
const Cut kNus18FDSideband
Definition: NusCuts18.h:109
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
const SystShifts kNoShift
Definition: SystShifts.cxx:22
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kXSecCVWgt2018
Definition: XsecTunes.h:48
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 SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Prediction that just uses FD MC, with no extrapolation.
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod4Loaders.h:96
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107