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 #include <iostream>
16 
17 namespace ana
18 {
21 
22  void NueExtrapSystBkg2017::Shift(double sigma, caf::SRProxy* sr, double& weight) const
23  {
24  //Nue extrapolation systs of bkg from docdb-22478 ND subcomponents extrapolation
25  //maximal +-1.2 % in core sample and +-1.3 % in peripheral sample
26  const double core = .012;
27  const double peri = .013;
28 
29  //Check if in FD, otherwise left unaltered
30  if(sr->hdr.det != caf::kFARDET) return;
31 
32  //Check if neutrino, but not numu->nue signal, otherwise left unaltered
33  if(sr->mc.nnu == 0) return;
34  if(abs(sr->mc.nu[0].pdg) == 12 && abs(sr->mc.nu[0].pdgorig) == 14 && sr->mc.nu[0].iscc) return;
35 
36  if(sigma == 0) return;
37 
38  //Check whether in peripheral or core sample
39  if(kNue2017FDPeripheral(sr))
40  weight *= 1+peri*sigma;
41  else if(kNue2017FD(sr))
42  weight *= 1+core*sigma;
43  }
44 
46  {
47  //Check if in ND, otherwise no reweighting
48  if(sr->hdr.det != caf::kNEARDET) return;
49 
50  //Check if muon neutrino
51  if(sr->mc.nnu == 0) return;
52  if(abs(sr->mc.nu[0].pdg) != 14) return;
53 
54  //Check if affecting nue background
55  if(kCVNe(sr) >= 0.5) return;
56 
57  if(!fWeightHist){
58 
59  //Weights in file from docdb-22478 ND to FD kinematics technote
60  //Can be remade with CAFAna/nue/Ana2017/NDtoFDkin/ scripts
61  //Using only the weight with max impact, i.e. trueQ2 weight, see technote
62  const std::string kWeightsFname = FindCAFAnaDir()+"/data/nue/NDtoFD_kin_combo_weights.root";
63  const std::string kWeightName = "trueQ2_weight_AllSamples";
64 
65  TFile weightsFile (kWeightsFname.c_str(),"read");
66  if(weightsFile.IsZombie()){
67  std::cerr << "Warning: couldn't open " << kWeightsFname << std::endl;
68  abort();
69  }
70 
71  fWeightHist = (TH1*) weightsFile.Get(kWeightName.c_str())->Clone();
72 
73  //disassociate the weight histogram from file
74  fWeightHist -> SetDirectory(0);
75 
76  weightsFile.Close();
77  }
78 
79  double kKinVar = kRecoQ2(sr);
80  double kKinWeight = 1;
81 
82  if(kKinVar >= fWeightHist->GetXaxis()->GetXmin() &&
83  kKinVar <= fWeightHist->GetXaxis()->GetXmax() ){
84  kKinWeight = fWeightHist->GetBinContent(fWeightHist->GetXaxis()->FindBin(kKinVar));
85  }
86  else if(kKinVar > fWeightHist->GetXaxis()->GetXmax()){
87  kKinWeight = fWeightHist->GetBinContent(fWeightHist->GetNbinsX());
88  }
89  else if(kKinVar < fWeightHist->GetXaxis()->GetXmin()){
90  kKinWeight = fWeightHist->GetBinContent(1);
91  }
92 
93  weight *= 1+(kKinWeight-1)*sigma;
94  }
95 }
96 
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:2137
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2126
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:618
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
caf::Proxy< short int > nnu
Definition: SRProxy.h:617
const Cut kNue2017FD
Full FD nue selection for 2017 analysis.
Definition: NueCuts2017.h:130
std::string FindCAFAnaDir()
Definition: Utilities.cxx:203
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:2138
caf::Proxy< caf::Det_t > det
Definition: SRProxy.h:232
enum BeamMode string