TrueSpectrumFromKaons.C
Go to the documentation of this file.
1 /// TrueSpectrumFromKaons by J. Hewes <jhewes15@fnal.gov>
2 
3 // CAFAna includes
4 #include "CAFAna/Core/Spectrum.h"
6 #include "CAFAna/Cuts/BeamCuts.h"
7 #include "CAFAna/Vars/Vars.h"
11 
12 #include "NuXAna/Cuts/NusCuts18.h"
13 
14 // ROOT includes
15 #include "TFile.h"
16 
17 using namespace ana;
18 
20 
21  // Instantiate loaders, axis, weights
24  const HistAxis axis("True #nu energy (GeV)", Binning::Simple(100, 0, 20), kTrueE);
25  const Var kReweight = kXSecCVWgt2018RPAFix * kPPFXFluxCVWgt;
26 
27  // Create spectra for ND
29  axis, kNus18ND, kNoShift, kReweight);
31  axis, kNus18ND && kIsAllFromKaons, kNoShift, kReweight);
32 
33  // Get nonswap spectra in the far detector
34  Spectrum spectrumFDNonSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kNonSwap),
35  axis, kNus18FD, kNoShift, kReweight);
36  Spectrum spectrumFDNonSwapKaon(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kNonSwap),
37  axis, kNus18FD && kIsAllFromKaons, kNoShift, kReweight);
38 
39  // Get fluxswap spectra in the far detector
40  Spectrum spectrumFDFluxSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kFluxSwap),
41  axis, kNus18FD, kNoShift, kReweight);
42  Spectrum spectrumFDFluxSwapKaon(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kFluxSwap),
43  axis, kNus18FD && kIsAllFromKaons, kNoShift, kReweight);
44 
45  // Get tauswap spectra in the far detector
46  Spectrum spectrumFDTauSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kTauSwap),
47  axis, kNus18FD, kNoShift, kReweight);
48  Spectrum spectrumFDTauSwapKaon(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kTauSwap),
49  axis, kNus18FD && kIsAllFromKaons, kNoShift, kReweight);
50 
51  // Populate spectra from MC loaders
52  loaders.Go();
53 
54  // Add together FD spectra
55  Spectrum spectrumFD(spectrumFDNonSwap);
56  spectrumFD += spectrumFDFluxSwap + spectrumFDTauSwap;
57  Spectrum spectrumFDKaon(spectrumFDNonSwapKaon);
58  spectrumFDKaon += spectrumFDFluxSwapKaon + spectrumFDTauSwapKaon;
59 
60  // Save spectra to output file
61  TFile* f = TFile::Open("KaonSpectra.root", "recreate");
62  spectrumND.SaveTo(f->mkdir("SpectrumND"));
63  spectrumFD.SaveTo(f->mkdir("SpectrumFD"));
64  spectrumNDKaon.SaveTo(f->mkdir("SpectrumNDKaon"));
65  spectrumFDKaon.SaveTo(f->mkdir("SpectrumFDKaon"));
66 
67 } // macro TrueSpectrumFromKaons
Near Detector underground.
Definition: SREnums.h:10
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Cut kNus18FD
Definition: NusCuts18.h:100
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
SpectrumLoaderBase & GetLoader(caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Retrieve a specific loader.
Definition: Loaders.cxx:129
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:507
const Var kXSecCVWgt2018RPAFix
Definition: XsecTunes.h:52
const Cut kNus18ND
Full Nus18 ND analysis selection.
Definition: NusCuts18.h:137
const SystShifts kNoShift
Definition: SystShifts.cxx:22
std::vector< Loaders * > loaders
Definition: syst_header.h:386
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod4Loaders.h:96
const Cut kIsAllFromKaons([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return( (abs(sr->mc.nu[0].beam.tptype)==310)|| (abs(sr->mc.nu[0].beam.tptype)==130)|| (abs(sr->mc.nu[0].beam.tptype)==311)|| (abs(sr->mc.nu[0].beam.tptype)==321));})
Definition: BeamCuts.h:30
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:107
void TrueSpectrumFromKaons()