NueExtrapSysts.cxx
Go to the documentation of this file.
5 
7 
9 
10 #include "TFile.h"
11 #include "TH1.h"
12 #include "TKey.h"
13 #include "TMath.h"
14 
15 namespace ana
16 {
19 
20  void NueExtrapSystBkg2017::Shift(double sigma, caf::SRProxy* sr, double& weight) const
21  {
22  //Nue extrapolation systs of bkg from docdb-22478 ND subcomponents extrapolation
23  //maximal +-1.2 % in core sample and +-1.3 % in peripheral sample
24  const double core = .012;
25  const double peri = .013;
26 
27  //Check if in FD, otherwise left unaltered
28  if(sr->hdr.det != caf::kFARDET) return;
29 
30  //Check if neutrino, but not numu->nue signal, otherwise left unaltered
31  if(sr->mc.nnu == 0) return;
32  if(abs(sr->mc.nu[0].pdg) == 12 && abs(sr->mc.nu[0].pdgorig) == 14 && sr->mc.nu[0].iscc) return;
33 
34  if(sigma == 0) return;
35 
36  //Check whether in peripheral or core sample
37  if(kNue2017FDPeripheral(sr))
38  weight *= 1+peri*sigma;
39  else if(kNue2017FD(sr))
40  weight *= 1+core*sigma;
41  }
42 
44  {
45  //Check if in ND, otherwise no reweighting
46  if(sr->hdr.det != caf::kNEARDET) return;
47 
48  //Check if muon neutrino
49  if(sr->mc.nnu == 0) return;
50  if(abs(sr->mc.nu[0].pdg) != 14) return;
51 
52  //Check if affecting nue background
53  if(kCVNe(sr) >= 0.5) return;
54 
55  if(!fWeightHist){
56 
57  //Weights in file from docdb-22478 ND to FD kinematics technote
58  //Can be remade with CAFAna/nue/Ana2017/NDtoFDkin/ scripts
59  //Using only the weight with max impact, i.e. trueQ2 weight, see technote
60  const std::string kWeightsFname = FindCAFAnaDir()+"/data/nue/NDtoFD_kin_combo_weights.root";
61  const std::string kWeightName = "trueQ2_weight_AllSamples";
62 
63  TFile weightsFile (kWeightsFname.c_str(),"read");
64  if(weightsFile.IsZombie()){
65  std::cerr << "Warning: couldn't open " << kWeightsFname << std::endl;
66  abort();
67  }
68 
69  fWeightHist = (TH1*) weightsFile.Get(kWeightName.c_str())->Clone();
70 
71  //disassociate the weight histogram from file
72  fWeightHist -> SetDirectory(0);
73 
74  weightsFile.Close();
75  }
76 
77  double kKinVar = kRecoQ2(sr);
78  double kKinWeight = 1;
79 
80  if(kKinVar >= fWeightHist->GetXaxis()->GetXmin() &&
81  kKinVar <= fWeightHist->GetXaxis()->GetXmax() ){
82  kKinWeight = fWeightHist->GetBinContent(fWeightHist->GetXaxis()->FindBin(kKinVar));
83  }
84  else if(kKinVar > fWeightHist->GetXaxis()->GetXmax()){
85  kKinWeight = fWeightHist->GetBinContent(fWeightHist->GetNbinsX());
86  }
87  else if(kKinVar < fWeightHist->GetXaxis()->GetXmin()){
88  kKinWeight = fWeightHist->GetBinContent(1);
89  }
90 
91  weight *= 1+(kKinWeight-1)*sigma;
92  }
93 }
94 
Near Detector underground.
Definition: SREnums.h:10
const ana::Var kRecoQ2([](const caf::SRProxy *sr){const double M_mu_sqrd=util::sqr(0.1056);double E_mu=kMuE(sr);double p_mu=sqrt(util::sqr(E_mu)-M_mu_sqrd);return 2 *kCCE(sr)*(E_mu-p_mu *kCosNumi(sr))-M_mu_sqrd;})
Reconstructed four-momentum transfer invariant (Q^2)
Definition: NumuVars.h:146
Far Detector at Ash River.
Definition: SREnums.h:11
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Var kCVNe
PID
Definition: Vars.cxx:35
const Var weight
caf::Proxy< caf::SRHeader > hdr
Definition: SRProxy.h:2136
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2125
void Shift(double sigma, caf::SRProxy *sr, double &weight) const override
Perform the systematic shift.
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:617
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
caf::Proxy< short int > nnu
Definition: SRProxy.h:616
const Cut kNue2017FD
Full FD nue selection for 2017 analysis.
Definition: NueCuts2017.h:130
std::string FindCAFAnaDir()
Definition: Utilities.cxx:204
void Shift(double sigma, caf::SRProxy *sr, double &weight) const override
Perform the systematic shift.
correl_xv GetXaxis() -> SetDecimals()
const Cut kNue2017FDPeripheral
Definition of the FD peripheral sample around our core selected events.
Definition: NueCuts2017.h:152
caf::StandardRecord * sr
const NueExtrapSystSignalKin2017 kNueExtrapSystSignalKin2017
const NueExtrapSystBkg2017 kNueExtrapSystBkg2017
double sigma(TH1F *hist, double percentile)
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2137
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:231
enum BeamMode string