make_prediction_noextrap.C
Go to the documentation of this file.
1 #pragma once
2 
5 
6 using namespace ana;
7 
8 
9 void make_prediction_noextrap(std::string polarity = "rhc",
10  std::string period = "full",
11  bool nh = true,
12  bool systematics = false,
13  bool calc3a = true)
14 {
15 
16  std::cout << "\n=================================" << std::endl;
17  std::cout << " make predictions no extrap " << std::endl;
18  std::cout << "=================================\n" << std::endl;
19 
20  std::string extrapName = "noextrap";
21 
22 
23  // production files
24  std::string production = "";
25  if(polarity == "fhc"){
26  production += ".d";
27  }
28  if(polarity == "rhc"){
29  production += ".e";
30  }
31 
32  // systematics
33  std::string systName = "";
35  if(systematics){
36  systName = "systs";
37  }
38  if(!systematics){
39  systName = "stats";
40  systs = {};
41  }
42  for (auto & sys:systs) std::cout << sys->ShortName() << std::endl;
43 
44  // calculator
45  std::string calcName = "2018calc";
46  std::string hierarchy = "";
48  if(nh){
49  hierarchy = "nh";
50  calc->SetTh23(asin(sqrt(0.559455)));
51  calc->SetDmsq32(0.00244);
52  }
53  if(!nh){
54  hierarchy = "ih";
55  calc->SetTh23(asin(sqrt(0.559455)));
56  calc->SetDmsq32(-0.00244);
57  }
58 
59 
60  // selection and weight
61  const Cut kNumuNDCut = kNumuCutND2018;
62  const Cut kNumuFDCut = kNumuCutFD2018;
63  const Var kXSecWeight = kXSecCVWgt2018;
64 
65  std::string OutDir = "";
66  std::cout << "polarity: " << polarity << ", period: " << period << ", files: " << production << std::endl;
67  std::cout << "systematics: " << systName << " , calculator: " << calcName << ", hierarchy: " << hierarchy << std::endl;
68 
69 
70  // quantiles
71  std::string InDirQuant = "/pnfs/nova/persistent/analysis/numu/Ana2018/provisional/quantiles";
72  std::string InFileQuant = InDirQuant + "/quantiles__" + polarity + "_full__numu2018.root";
73  std::cout << "\n\n --- get quantile cuts from file ---" << std::endl;
74  TFile* inFile = TFile::Open( pnfs2xrootd(InFileQuant).c_str() );
75  TH2* FDSpec2D = (TH2*)inFile->FindObjectAny("FDSpec2D");
76  std::vector<Cut> HadEFracQuantCuts = QuantileCutsFromTH2(FDSpec2D, kNumuCCOptimisedAxis, kHadEFracAxis, 4);
77  inFile->Close();
78  delete inFile;
79 
80 
81  //////////////////// make loader for prediction ////////////////////
82  std::cout << "loaders" << std::endl;
85 
86  std::cout << "set loaders" << std::endl;
87  set_loaders_ana2018(loaders, polarity, period, production);
88 
89  std::cout << "declare prediction" << std::endl;
90  std::vector<NoExtrapGenerator*> NoExtrapVec;
91  std::vector<PredictionInterp*> predictionVec;
92 
93  std::cout << "loop over quantiles for prediction" << std::endl;
94  for(auto thisCut : HadEFracQuantCuts){
95  NoExtrapVec.push_back(new NoExtrapGenerator(kNumuCCOptimisedAxis, thisCut && kNumuFDCut, kPPFXFluxCVWgt*kXSecWeight));
96  predictionVec.push_back(new PredictionInterp(systs, calc, *(NoExtrapVec.back()), loaders));
97  }
98 
99  std::cout << "loaders.Go()" << std::endl;
100  loaders.Go();
101 
102 
103  std::cerr << "Saving Predictions" << std::endl;
104  for(size_t quant=1; quant <= predictionVec.size();quant++){
105  auto prediction = predictionVec[quant-1];
106  std::string OutFileName = Form("prediction_quant%d__", quant) + extrapName + "_" + systName + "__" + polarity + "_" + calcName + "_" + hierarchy + "__" + period + "__numu2018.root";
107  std::cerr << "Saving Quantile " << quant << " to Prediction file: " << OutFileName << std::endl;
108  TFile *f = TFile::Open(OutFileName.c_str(), "RECREATE");
109  prediction -> SaveTo(f, "prediction");
110  f->Close();
111  }
112 
113 
114 }//make_predictions_noextrap
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
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Cut kNumuCutND2018
Definition: NumuCuts2018.h:41
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
T sqrt(T number)
Definition: d0nt_math.hpp:156
void set_loaders_ana2018(Loaders &loaders, std::string polarity, std::string period, std::string production)
const HistAxis kHadEFracAxis("E_{had.} / E_{#nu}", Binning::Simple(200, 0, 1), kHadEFrac)
HistAxis that implements Hadronic Energy fraction binning used by L.Vinton to derive Hadronic Energy ...
Definition: HistAxes.h:30
OStream cerr
Definition: OStream.cxx:7
std::string pnfs2xrootd(std::string loc, bool unauth)
Definition: UtilsExt.cxx:237
osc::OscCalcDumb calc
osc::IOscCalcAdjustable * DefaultOscCalc()
Create a new calculator with default assumptions for all parameters.
Definition: Calcs.cxx:49
Generates FD-only predictions (no extrapolation)
virtual void SetDmsq32(const T &dmsq32)=0
std::string extrapName
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
ifstream inFile
Definition: AnaPlotMaker.h:34
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
std::vector< const ISyst * > getAllAna2018Systs(const EAnaType2018 ana, const bool smallgenie, const BeamType2018 beam, bool isFit)
std::string OutDir
const HistAxis kNumuCCOptimisedAxis("Reconstructed Neutrino Energy (GeV)", kNumuCCEOptimisedBinning, kCCE)
HistAxis that implements optimised numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39;...
Definition: HistAxes.h:24
OStream cout
Definition: OStream.cxx:6
void make_prediction_noextrap(std::string polarity="rhc", std::string period="full", bool nh=true, bool systematics=false, bool calc3a=true)
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
std::vector< Loaders * > loaders
Definition: syst_header.h:386
virtual void SetTh23(const T &th23)=0
std::vector< Cut > QuantileCutsFromTH2(TH2 *quantileHist, const HistAxis &independentAxis, const HistAxis &quantileAxis, const unsigned int &numQuantiles, const bool verbose)
: Do the same as the QuantileCuts function but taking in the TH2 instead of making it...
bool systematics
Definition: fnexvscaf.C:31
const Cut kNumuCutFD2018
Definition: NumuCuts2018.h:39
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
T asin(T number)
Definition: d0nt_math.hpp:60
enum BeamMode string