MakeNus18CovarSim.C
Go to the documentation of this file.
1 #ifdef __CINT__
3  bool rhc = false, std::string syst_type = "all")
4 {
5  std::cout << "You must run in compiled mode" << std::endl;
6 }
7 #else
8 
10 #include "CAFAna/Cuts/SpillCuts.h"
11 #include "NuXAna/Vars/NusVars.h"
13 #include "CAFAna/Vars/HistAxes.h"
14 #include "NuXAna/Vars/HistAxes.h"
16 #include "CAFAna/Extrap/NDExtrap.h"
17 #include "CAFAna/Extrap/FDExtrap.h"
24 #include "CAFAna/Analysis/Calcs.h"
27 
28 #include "OscLib/OscCalcSterile.h"
29 
30 using namespace ana;
31 
33  bool rhc = false, std::string syst_type = "all")
34 {
35  DontAddDirectory guard;
36 
37  bool nd;
38  if (detector == "nd") nd = true;
39  else if (detector == "fd") nd = false;
40  else throw std::runtime_error("Detector string must be \"nd\" or \"fd\"; \""
41  + detector + "\" is not understood.");
42 
43  const Var kReweight = kXSecCVWgt2018 * kPPFXFluxCVWgt;
45  std::vector<const ISyst*> systs = GetNus18Systs(rhc, detector, syst_type);
46 
47  // Set up the loaders
51  if (nd) loaders->SetND(true);
53 
54  std::cout << std::endl << "Enabled systematics:" << std::endl;
55  for (auto syst : systs)
56  std::cout << " " << syst->ShortName() << std::endl;
58 
59  if (nd) {
60 
61  NDPredictionGenerator nusnd_gen(
62  kNus18AxisE, kNus18ND, kNoShift, kReweight);
63  PredictionInterp pred_interp({systs}, calc, nusnd_gen, *loaders);
64 
65  NDExtrap nusnd_extrap = NDExtrap::NDExtrap_c(
66  *loaders, kNus18AxisE, kNus18ND, kNoShift, kReweight);
67  NDPredictionSterile pred_extrap( &nusnd_extrap );
68 
69  loaders->Go();
70 
71  // Open output file
72  std::string f_out_name = "pred_nus18_nd_" + syst_type + ".root";
73  TFile* f_out = new TFile(f_out_name.c_str(), "RECREATE");
74 
75  // Save predictions to file
76  pred_interp.SaveTo(f_out, "pred_interp");
77  pred_extrap.SaveTo(f_out, "pred_extrap");
78  f_out->Close();
79 
80  } else {
81 
82  FDPredictionGenerator nusfd_gen(
83  kNus18AxisE, kNus18FD, kNoShift, kReweight);
84  PredictionInterp pred_interp({systs}, calc, nusfd_gen, *loaders);
85 
86  FDExtrap nusfd_extrap = FDExtrap::FDExtrap_c(
87  *loaders, kNus18AxisE, kNus18FD, kNoShift, kReweight);
88  FDPredictionSterile pred_extrap( &nusfd_extrap );
89 
90  loaders->Go();
91 
92  // Set up output filename
93  std::string f_out_name = "pred_nus18_fd_" + syst_type + ".root";
94  TFile* f_out = new TFile(f_out_name.c_str(), "RECREATE");
95 
96  // Save all of the objects
97  pred_interp.SaveTo(f_out, "pred_interp");
98  pred_extrap.SaveTo(f_out, "pred_extrap");
99  f_out->Close();
100 
101  }
102 }
103 
104 #endif
Implements systematic errors by interpolation between shifted templates.
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
Adapt the PMNS_Sterile calculator to standard interface.
osc::OscCalcDumb calc
const Cut kNus18FD
Definition: NusCuts18.h:100
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
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
static NDExtrap NDExtrap_c(Loaders &loaders, const HistAxis &axis, const Cut &selection, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Definition: NDExtrap.cxx:25
const Cut kNus18ND
Full Nus18 ND analysis selection.
Definition: NusCuts18.h:137
Take the output of an extrapolation and oscillate it as required.
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
std::vector< Loaders * > loaders
Definition: syst_header.h:386
void SetND(bool nd)
Definition: Loaders.h:65
void MakeNus18CovarSim(std::string detector, bool concat=true, bool rhc=false, std::string syst_type="all")
Take the output of an extrapolation and oscillate it as required.
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
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
Generates Near Detector predictions.
std::vector< const ISyst * > GetNus18Systs(bool rhc, std::string det_type, std::string syst_type)
Definition: Nus18Systs.cxx:439
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
static FDExtrap FDExtrap_c(Loaders &loaders, const HistAxis &axis, const Cut &selection, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Definition: FDExtrap.cxx:23
enum BeamMode string