Functions
MakePredictionNoOsc_FHC_ND.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/Core/Utilities.h"
#include "NuXAna/Vars/NusVars.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 MakePredictionNoOsc_FHC_ND (TString opt, string systFile="default", double res=0)
 

Function Documentation

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

Definition at line 44 of file MakePredictionNoOsc_FHC_ND.C.

References calc, submit_concat_project::concat, om::cout, ana::DefaultSterileCalc(), e, febshutoff_auto::end, allTimeWatchdog::endl, ana::getAllXsecSysts_2020(), GetSampleFromOptString(), ana::Loaders::Go(), ana::InputPath(), makeTrainCVSamples::int, ana::covmx::kCCNue, ana::covmx::kCCNumu, kFHC, ana::kFullCAF, ana::covmx::kNC, ana::covmx::kNearDet, ana::kNoShift, ana::kNueConcat, ana::kNumuConcat, ana::kNusConcat, ana::kPPFXFluxCVWgt, kRHC, ana::covmx::kRHC, ana::kStandardSpillCuts, loaders, ana::LoadSystsFromFile(), MECModelEnuComparisons::opt, outFile, ana::pnfs2xrootd(), plot_validation_datamc::pred, ana::PredictionInterp::SaveTo(), SetAxis(), SetCut(), ana::Loaders::SetND(), ana::Loaders::SetSpillCut(), and systs.

45 {
46  //Load systs in memory
48  //vector<const ISyst*> systsfile = LoadSystsFromFile("/nova/app/users/mrajaoal/my_new_release/CAFAna/nus/Nus20/Systs/isysts.root", "isysts_numusel_rhc_fardet");
49  vector<const ISyst*> systsfile = LoadSystsFromFile(InputPath() + "/systs/isysts.root", "isysts_numusel_fhc_neardet");
50 
51  try {
52  DontAddDirectory guard;
53 
54  Sample sample = GetSampleFromOptString(opt);
55  SetAxis(sample, res);
56  SetCut(sample);
57 
58  // What type of file to run over
59  vector<pair<string, bool>> loaderOpts
60  = { {"fullcaf",false}, {"concat",true} };
61  bool concat = ParseOption<bool>(loaderOpts, opt, true);
62 
63  // Systematic option
64  vector<pair<string, string>> systOpts
65  = { {"nosysts","nosysts"}, {"filesysts","file"}, {"xsecsysts","xsec"},
66  {"allsysts","all"} };
67 
68  string systType = ParseOption<string>(systOpts, opt, "nosysts");
69 
70  // Important variables
71  const Var kReweight = kPPFXFluxCVWgt;
73 
74  // Set up systematics
75  vector<const ISyst*> systs;
76  if (systType == "file" || systType == "all") {
77  vector<const ISyst*> fileSysts = systFile == "default" ?
78  //LoadSysts(sample, kUseCVMFS) : LoadSystsFromFile(pnfs2xrootd(systFile), "isysts_"+sample.GetTag());
79  LoadSysts(sample) : LoadSystsFromFile(pnfs2xrootd(systFile), "isysts_"+sample.GetTag());
80  systs.insert(end(systs), begin(fileSysts), end(fileSysts));
81  }
82  if (systType == "xsec" || systType == "all") {
83  vector<const ISyst*> xsecSysts = getAllXsecSysts_2020();
84  systs.insert(end(systs), begin(xsecSysts), end(xsecSysts));
85  }
86  // Add in neutron here eventually
87 
88  // Set CAF type
90  if (concat) {
91  if (sample.selection == covmx::kCCNue) CAFType = ECAFType::kNueConcat;
92  else if (sample.selection == covmx::kCCNumu) CAFType = ECAFType::kNumuConcat;
93  else if (sample.selection == covmx::kNC) CAFType = ECAFType::kNusConcat;
94  }
95 
96  // Define the loader
97  Prod5NomLoaders loaders(CAFType,
99  if (sample.detector == covmx::kNearDet) {
100  loaders.SetND(true);
101  }
102  loaders.SetSpillCut(kStandardSpillCuts);
103 
104  // Create the prediction
105  IPredictionGenerator* gen = nullptr;
106  if (sample.detector == covmx::kNearDet) gen = new NDPredictionNoOscGenerator(*sample.GetAxis(), *sample.GetCut(), kNoShift, kReweight);
107  else gen = new FDPredictionGenerator(*sample.GetAxis(), *sample.GetCut(), kNoShift, kReweight);
108  IPrediction* pred = gen->Generate(loaders).release();
109  PredictionInterp* predInterp = nullptr;
110  if (systs.size() > 0) {
111  predInterp = new PredictionInterp(systs, calc, *gen, loaders);
112  }
113  loaders.Go();
114 
115  // Initialise output file
116  ostringstream outFileName;
117  outFileName << "pred_" << sample.GetTag();
118  if (res!=0) outFileName << "_res" << (int)res;
119  outFileName << ".root";
120  TFile* outFile = TFile::Open(outFileName.str().c_str(), "recreate");
121 
122  // Save prediction to file
123  ostringstream dirname;
124  dirname << "pred_" << sample.GetTag();
125  pred->SaveTo(outFile->mkdir(dirname.str().c_str()));
126 
127  if (predInterp) {
128  dirname.str("");
129  dirname << "pred_interp_" << sample.GetTag();;
130  predInterp->SaveTo(outFile->mkdir(dirname.str().c_str()));
131  }
132  } catch(const exception& e) {
133  cout << endl << "Exception occurred! " << e.what() << endl;
134  }
135 
136 } // 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
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
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: UtilsExt.cxx:237
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)
std::vector< const ISyst * > getAllXsecSysts_2020()
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
string InputPath()
Definition: Utilities.cxx:12
vector< const ISyst * > LoadSystsFromFile(string filePath, string dirName)
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
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
ECAFType
Definition: Loaders.h:19