TrueNCSpectrum.C
Go to the documentation of this file.
1 /// Function to draw true NC spectrum for Nus20 analysis
2 
3 // CAFAna includes
4 #include "CAFAna/Core/Spectrum.h"
6 #include "CAFAna/Vars/Vars.h"
10 
11 #include "NuXAna/Cuts/NusCuts18.h"
12 
13 // ROOT includes
14 #include "TFile.h"
15 
16 using namespace ana;
17 
19 
20  // Instantiate loaders, axis, weights
23  const HistAxis axis("True #nu energy (GeV)", Binning::Simple(100, 0, 20), kTrueE);
24  const Var kReweight = kXSecCVWgt2018RPAFix * kPPFXFluxCVWgt;
25 
26  // Get spectra in the far detector
27  Spectrum spectrumFDNonSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kNonSwap),
28  axis, kNus18FD, kNoShift, kReweight);
29  Spectrum spectrumFDFluxSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kFluxSwap),
30  axis, kNus18FD, kNoShift, kReweight);
31  Spectrum spectrumFDTauSwap(loaders.GetLoader(caf::kFARDET, Loaders::kMC, kBeam, Loaders::kTauSwap),
32  axis, kNus18FD, kNoShift, kReweight);
33 
34  // Populate spectra from MC loaders
35  loaders.Go();
36 
37  // Add together FD spectra
38  Spectrum spectrumFD(spectrumFDNonSwap);
39  spectrumFD += spectrumFDFluxSwap + spectrumFDTauSwap;
40 
41  // Save spectra to output file
42  TFile* f = TFile::Open("TrueNCSpectrum.root", "recreate");
43  spectrumFD.SaveTo(f->mkdir("SpectrumFD"));
44 
45 }
46 
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:39
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:534
const Var kXSecCVWgt2018RPAFix
Definition: XsecTunes.h:52
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
void TrueNCSpectrum()
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