make_nueFDprediction_kinematics.C
Go to the documentation of this file.
1 // Macro to make nominal and shifted predictions
2 // Takes names and datasets as input
3 // Create files for nominal and shifted samples
4 // set systematicSample to false for beam or genie systematics
5 // USAGE
6 // cafe -bq make_nueFDprediction_shifted.C bool "ShortName" "Long Name"
7 // "filename" "nd data" "nd mc dataset" "FDMC nonswap" "swap" "tau"
8 // See full examples in run_nueFDprediction*.sh
9 //hastau,plus2,plus1,minu1,minu2,knoshift,compareto
10 
11 // Analysis
13 #include "CAFAna/Analysis/Plots.h"
15 #include "CAFAna/Analysis/Style.h"
16 
17 // Core
18 #include "CAFAna/Core/Binning.h"
19 #include "CAFAna/Core/Cut.h"
20 #include "CAFAna/Core/HistAxis.h"
22 #include "CAFAna/Core/Spectrum.h"
25 
26 // Cuts
27 #include "CAFAna/Cuts/Cuts.h"
28 #include "CAFAna/Cuts/NumuCuts.h"
30 #include "CAFAna/Cuts/SpillCuts.h"
32 
33 
34 // Decomp
39 
40 // Extrap
42 
43 // Predict
46 
47 // Systs
48 #include "CAFAna/Systs/Systs.h"
49 
50 // Vars
52 #include "CAFAna/Vars/HistAxes.h"
53 #include "CAFAna/Vars/NueVars.h"
54 #include "CAFAna/Vars/Vars.h"
57 
59 
61 
62 
63 #include <iostream>
64 #include <iomanip>
65 
66 using namespace ana;
67 
68 void CheckFileOverwrite(TString);
69 
71 
72 void make_nueFDprediction_kinematics( const std::string& outfilename = "FDprediction_kinematics.root",
73  const bool hastau = false
74 )
75 
76 {
77  // ND loaders
78  std::string loaderNDData = "prod_decaf_R17-03-01-prod3reco.d_nd_numi_fhc_full_nue_or_numu_or_nus_contain_v1_goodruns";
79  std::string loaderNDMC = "prod_decaf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
80 
81  // FD loaders
82  std::string loaderFDnonswapMC = "prod_decaf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
83  std::string loaderFDfluxswapMC = "prod_decaf_R17-03-01-prod3reco.l_fd_genie_fluxswap_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
84  std::string loaderFDtauswapMC = "prod_decaf_R17-03-01-prod3reco.l_fd_genie_tau_fhc_nova_v08_full_nue_or_numu_or_nus_contain_v1";
85 
86  //******* 1. Set up selection and variables ********
87  //Only needed here. Keep updated!
89 
90  const Var kWOscDumb([](const caf::SRProxy* sr){return sr->mc.nu[0].woscdumb;});
91 
92  const int kNumSels = 1;
93  const int kNumVars = 5;
94 
95  const HistDef defs[kNumVars] = {
96  {"recoE", {"E_{reco} (GeV)", Binning::Simple(10, 0, 5), kNueEnergy2017}},
97  {"trueQ2", {"true Q^{2} (GeV^{2})", Binning::Simple(500, 0, 5), kTrueQ2}},
98  {"trueW2", {"true W^{2} (GeV^{2})", Binning::Simple(100, 0, 2), kTrueW}},
99  {"PtP", {"p_{t}/p", Binning::Simple(500,0,1), kPtP}},
100  {"CosTheta", {"CosTheta", Binning::Simple(500,0,1), kCosTheta}}
101  };
102 
103  const Cut selFD[kNumSels] = {
105  };
106  const Cut selND[kNumSels] = {
108  };
109  const std::string selNames[kNumSels] = {
110  "AllSamples"
111  };
112  const Cut cutNDNumu = {
113  kNumuNDCvn
114  };
115 
117 
118  //********** 2. Set up loaders *********************
120 
121  loaders.SetLoaderPath(loaderNDData, caf::kNEARDET, ana::Loaders::DataMC::kData);
122  loaders.SetLoaderPath(loaderNDMC, caf::kNEARDET, ana::Loaders::DataMC::kMC);
123 
124  loaders.SetLoaderPath(loaderFDnonswapMC, caf::kFARDET, ana::Loaders::DataMC::kMC, DataSource::kBeam, ana::Loaders::SwappingConfig::kNonSwap);
125  loaders.SetLoaderPath(loaderFDfluxswapMC, caf::kFARDET, ana::Loaders::DataMC::kMC, DataSource::kBeam,ana::Loaders::SwappingConfig::kFluxSwap);
126  if(hastau)
128  else
130 
131  loaders.SetSpillCut(kStandardSpillCuts);
132 
133  //******* 3. Set up the extrapolations and go *******
134  SystShifts thisShift = kNoShift;
135 
136  NumuDecomp * numuDecomp;
137  ProportionalDecomp * propDecomp[kNumSels][kNumVars];
138  ModularExtrap extrapProp[kNumSels][kNumVars];
139  PredictionExtrap * predicProp[kNumSels][kNumVars];
140  PredictionNoExtrap * predicNoXP[kNumSels][kNumVars];
141 
142  numuDecomp = new NumuDecomp (loaders, axisNumu, cutNDNumu, thisShift, kNoShift, kXSecCVWgt2017*kPPFXFluxCVWgt);
143 
144  for(unsigned int selIdx = 0; selIdx < kNumSels; ++selIdx){
145  for(unsigned int varIdx = 0; varIdx < kNumVars; ++varIdx){
146 
147  const HistAxis& axisNue = defs[varIdx].axis;
148 
149  propDecomp[selIdx][varIdx] = new ProportionalDecomp (loaders,
150  axisNue, selND[selIdx],
151  thisShift, kNoShift, kXSecCVWgt2017*kPPFXFluxCVWgt );
152 
153  extrapProp[selIdx][varIdx] = ModularExtrap::Nue (loaders,
154  *propDecomp[selIdx][varIdx], *numuDecomp,
155  axisNue, axisNumu,
156  selFD[selIdx], selND[selIdx], cutNDNumu,
157  thisShift, kXSecCVWgt2017*kPPFXFluxCVWgt);
158 
159  predicProp[selIdx][varIdx] = new PredictionExtrap (&extrapProp[selIdx][varIdx]);
160 
161  predicNoXP[selIdx][varIdx] = new PredictionNoExtrap (loaders,
162  axisNue,
163  selFD[selIdx], thisShift, kXSecCVWgt2017*kPPFXFluxCVWgt);
164 
165  }//vars
166  }//sels
167  loaders.Go();
168 
169  //********** 4. Save everything ********************
170  TFile * file = new TFile(outfilename.c_str(),"RECREATE");
171  TDirectory * dFDshi = file->mkdir("prediction");
172  for(unsigned int selIdx = 0; selIdx < kNumSels; ++selIdx){
173  for(unsigned int varIdx = 0; varIdx < kNumVars; ++varIdx){
174  TString varName = defs[varIdx].name.c_str();
175  predicProp[selIdx][varIdx]->SaveTo(dFDshi->mkdir("nue_pred_"+selNames[selIdx]+"_"+varName) );
176  predicNoXP[selIdx][varIdx]->SaveTo(dFDshi->mkdir("nue_pred_noextrap_"+selNames[selIdx]+"_"+varName) );
177  }
178  }
179  file->Close();
180 
181 } // end
182 
183 //****************************************
185  if(!gSystem->AccessPathName(outfilename.Data())){
186  std::cout << "\n\nThis will overwrite " << outfilename
187  << "\n\nAre you sure you want to continue? y/n ";
188  string input = ""; getline(cin,input);
189  if (input!="y") abort();
190  }
191 }
Near Detector underground.
Definition: SREnums.h:10
const int kNumVars
Definition: vars.h:14
Far Detector at Ash River.
Definition: SREnums.h:11
osc::OscCalculatorDumb calc
Oscillation analysis framework, runs over CAF files outside of ART.
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
VectorProxy< SRNeutrinoProxy > nu
Definition: SRProxy.h:1890
nue decafs in FD, nue_or_numu in ND
Definition: SALoaders.h:36
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
HistAxis axis
Definition: NuePlotLists.h:13
Proxy for StandardRecord.
Definition: SRProxy.h:2237
const Color_t kMC
static ModularExtrap Nue(Loaders &loaders, const IDecomp &nueDecomp, const IDecomp &numuDecomp, const HistAxis &axis, const HistAxis &axisNumuND, const Cut &fdcut, const Cut &nueNDcut, const Cut &numuNDcut, const SystShifts &shiftMC=kNoShift, const Var &weight=kUnweighted)
Creates a nue-like extrapolation.
const Var kTrueQ2
Definition: TruthVars.h:27
void make_nueFDprediction_kinematics(const std::string &outfilename="FDprediction_kinematics.root", const bool hastau=false)
string outfilename
knobs that need extra care
const Var kPtP
Transverse momentum fraction in slice.
Definition: NueVars.cxx:90
Uses MC for NC and CC components, assigns remainder of data to CC.
Definition: NumuDecomp.h:10
const Var kNueEnergy2017([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;return NueRecoE_2017FDFit(kCVNemE(sr), kCVNhadE(sr));})
Definition: NueEnergy2017.h:11
const Var kWOscDumb([](const caf::SRProxy *sr){return sr->mc.nu[0].woscdumb;})
Definition: TruthVars.h:10
const Cut kNueSecondAnaCVNeSsb([](const caf::SRProxy *sr){return(sr->sel.cvn.nueid > 0.75);})
const Cut kNumuNDCvn
Definition: NumuCuts.h:61
Simple oscillation probability calculator that has no solar term or mass hierarchy or delta so it&#39;s s...
void CheckFileOverwrite(TString)
virtual void SaveTo(TDirectory *dir) const override
const HistAxis kNumuNonQEAxisFirstAna("Reconstructed Neutrino Energy (GeV)", kNumuEnergyBinningFirstAna, kCCE)
const HistDef defs[kNumVars]
Definition: vars.h:15
const int kNumSels
Definition: vars.h:43
virtual void SaveTo(TDirectory *dir) const override
std::string name
Definition: NuePlotLists.h:12
const SystShifts kNoShift
Definition: SystShifts.h:112
OStream cout
Definition: OStream.cxx:6
const HistAxis axisNue
Definition: syst_header.h:377
const Cut kNue2017NDPresel
Definition: NueCuts2017.h:289
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Splits Data proportionally according to MC.
std::vector< Loaders * > loaders
Definition: syst_header.h:385
SRTruthBranchProxy mc
Definition: SRProxy.h:2253
TFile * file
Definition: cellShifts.C:17
const HistAxis axisNumu
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:28
Prediction that just uses FD MC, with no extrapolation.
Take the output of an extrapolation and oscillate it as required.
const Var kCosTheta
const std::string selNames[kNumSels]
Definition: vars.h:46
const Var kXSecCVWgt2017
Definition: XsecTunes.h:40
Extrapolate each component using a separate ModularExtrapComponent.
Definition: ModularExtrap.h:21
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Var kTrueW
Definition: TruthVars.h:22
static constexpr Double_t sr
Definition: Munits.h:164
const Cut kNue2017FDAllSamples
Our FD selection including all samples, for making predictions, etc.
Definition: NueCuts2017.h:159