Functions
MakePrediction.C File Reference
#include "CAFAna/Extrap/NDExtrap.h"
#include "CAFAna/Extrap/FDExtrap.h"
#include "CAFAna/Prediction/PredictionGenerator.h"
#include "CAFAna/Prediction/PredictionInterp.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Vars/GenieWeights.h"
#include "CAFAna/Vars/HistAxes.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "CAFAna/Systs/XSecSystLists.h"
#include "CAFAna/Analysis/Calcs.h"
#include "CAFAna/Analysis/Prod5Loaders.h"
#include "CAFAna/Core/Sample.h"
#include "NuXAna/Vars/NusVars.h"
#include "NuXAna/Systs/NusAna2020Systs.h"
#include "NuXAna/Prediction/NDPredictionSterile.h"
#include "NuXAna/Prediction/FDPredictionSterile.h"
#include "NuXAna/Prediction/PredictionGeneratorNuX.h"
#include "NuXAna/macros/Nus20/Utilities.h"
#include "OscLib/OscCalcSterile.h"

Go to the source code of this file.

Functions

void MakePrediction (TString opt, string systFile="default", double res=0)
 

Function Documentation

void MakePrediction ( TString  opt,
string  systFile = "default",
double  res = 0 
)

Definition at line 44 of file MakePrediction.C.

References calc, om::cout, ana::DefaultSterileCalc(), e, allTimeWatchdog::endl, ana::NDPredictionGenerator::Generate(), ana::getNusAna2020AllSysts(), GetSampleFromOptString(), ana::Loaders::Go(), makeTrainCVSamples::int, ana::covmx::kCCNue, ana::covmx::kCCNumu, kFHC, ana::covmx::kNC, ana::covmx::kNearDet, ana::kNoShift, ana::kNueConcat, ana::kNumuConcat, ana::kNusConcat, ana::kPPFXFluxCVWgt, kRHC, ana::covmx::kRHC, ana::kStandardSpillCuts, loaders, outFile, plot_validation_datamc::pred, ana::PredictionInterp::SaveTo(), SetAxis(), SetCut(), ana::Loaders::SetND(), ana::Loaders::SetSpillCut(), and systs.

45 {
46  try {
47  DontAddDirectory guard;
48 
49  Sample sample = GetSampleFromOptString(opt);
50  SetAxis(sample, res);
51  SetCut(sample);
52 
53  // Important variables
54  const Var kReweight = kPPFXFluxCVWgt;
56 
57  vector<const ISyst*> systs = getNusAna2020AllSysts(sample);
58 
59  // Set CAF type
60  enum ECAFType CAFType;
61  if (sample.selection == covmx::kCCNue) CAFType = ECAFType::kNueConcat;
62  else if (sample.selection == covmx::kCCNumu) CAFType = ECAFType::kNumuConcat;
63  else if (sample.selection == covmx::kNC) CAFType = ECAFType::kNusConcat;
64 
65  // Define the loader
66  Prod5NomLoaders loaders(CAFType,
68  if (sample.detector == covmx::kNearDet) loaders.SetND(true);
69  loaders.SetSpillCut(kStandardSpillCuts);
70 
71  // Create the prediction
72  IPredictionGenerator* gen = nullptr;
73  if (sample.detector == covmx::kNearDet) gen = new NDPredictionGenerator(*sample.GetAxis(), *sample.GetCut(), kNoShift, kReweight);
74  else gen = new FDPredictionGenerator(*sample.GetAxis(), *sample.GetCut(), kNoShift, kReweight);
75  IPrediction* pred = gen->Generate(loaders).release();
76  PredictionInterp* predInterp = nullptr;
77  if (systs.size() > 0) predInterp = new PredictionInterp(systs, calc, *gen, loaders);
78  loaders.Go();
79 
80  // Initialise output file
81  ostringstream outFileName;
82  outFileName << "pred_" << sample.GetTag();
83  if (res!=0) outFileName << "_res" << (int)res;
84  outFileName << ".root";
85  TFile* outFile = TFile::Open(outFileName.str().c_str(), "recreate");
86  TDirectory* predDir = outFile->mkdir(sample.GetTag().c_str());
87 
88  // Save prediction to file
89  pred->SaveTo(predDir, "pred");
90  if (predInterp) predInterp->SaveTo(predDir, "pred_interp");
91 
92  } catch(const exception& e) {
93  cout << endl << "Exception occurred! " << e.what() << endl;
94  }
95 
96 } // macro MakePrediction
Implements systematic errors by interpolation between shifted templates.
std::vector< SystGroupDef > systs
Definition: syst_header.h:385
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
vector< const ISyst * > getNusAna2020AllSysts(covmx::Sample &s)
Adapt the PMNS_Sterile calculator to standard interface.
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
void SetCut(covmx::Sample &sample)
Definition: Utilities.h:263
osc::OscCalcDumb calc
covmx::Sample GetSampleFromOptString(TString optString)
Function to take an option TString and return a single associated covmx::Sample.
Definition: Utilities.h:344
void SetAxis(TH1 *h, bool visible, int color, int style=1, bool scale=true)
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
osc::OscCalcSterile * DefaultSterileCalc(int nflavors)
Create a sterile calculator with default assumptions for all parameters.
Definition: Calcs.cxx:97
TFile * outFile
Definition: PlotXSec.C:135
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod5Loaders.h:101
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
std::unique_ptr< IPrediction > Generate(Loaders &loaders, const SystShifts &shiftMC=kNoShift) const override
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Given loaders and an MC shift, Generate() generates an IPrediction.
Prevent histograms being added to the current directory.
Definition: UtilsExt.h:46
Float_t e
Definition: plot.C:35
Generates Near Detector predictions.
ECAFType
Definition: Loaders.h:19