HighLAND
FluxWeightSystematics.cxx
1 #include "FluxWeightSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "ToyBoxND280.hxx"
4 #include "Parameters.hxx"
5 
6 bool debug=false;
7 
8 //********************************************************************
9 FluxWeightSystematics::FluxWeightSystematics(const std::string& name):BinnedParams(name,k2D_SYMMETRIC){
10 //********************************************************************
11  SetNParameters(GetNBins());
12 
13  _flux = new FluxWeighting(ND::params().GetParameterS("psycheSystematics.FluxWeighting.Folder"),
14  ND::params().GetParameterS("psycheSystematics.FluxWeighting.Version"),
15  ND::params().GetParameterS("psycheSystematics.FluxWeighting.Tuning"));
16 
17 }
18 
19 //********************************************************************
21 //********************************************************************
22 
23  const AnaEventB& event = *static_cast<const AnaEventB*>(&eventBB);
24 
25  // Cast the ToyBox to the appropriate type
26  const ToyBoxND280& box = *static_cast<const ToyBoxND280*>(&boxB);
27 
28  Weight_h eventWeight=1;
29 
30  if (event.GetIsSandMC()) return eventWeight; // No weight for sand MC
31  if (!this->IsCorrectRunPeriod(anaUtils::GetRunPeriod(event.EventInfo.Run))) return eventWeight; //should be in the correct run
32  if (!box.TrueVertex) return eventWeight; // True vertex associated to the recon vertex should exist
33 
34  // Get the true neutrino energy
35  Float_t enu = box.TrueVertex->NuEnergy;
36  int type = box.TrueVertex->NuPDG;
37 
38  // Get the flux error values for this energy
39  Float_t mean_dummy;
40  Float_t sigma;
41  Int_t index;
42  if(!GetBinValues(enu, type, mean_dummy, sigma, index)) return eventWeight;
43 
44  // Actual mean from FluxWeighting class
45  Float_t mean= _flux->GetWeight(box.TrueVertex,anaUtils::GetRunPeriod(event.EventInfo.Run));
46 
47  // Compute the weight
48  eventWeight.Systematic = 1 + (mean-1) + sigma * toy.GetToyVariations(_index)->Variations[index];
49  eventWeight.Correction = 1 + (mean-1);
50  if(debug)
51  {
52  std::cout << "Run: " << event.EventInfo.Run << " Enu: " << enu << " type: " << type << " mean " << mean << " sigma " << sigma
53  << " index " << index << " variation " << toy.GetToyVariations(_index)->Variations[index] << " weight " << eventWeight << std::endl;
54  }
55 
56  return eventWeight;
57 
58 }
59 
60 //********************************************************************
61 FluxWeightSystematicsNeutrino::FluxWeightSystematicsNeutrino():FluxWeightSystematics("FluxWeightNeutrino"){
62 //********************************************************************
63 
64 }
65 
66 //********************************************************************
67 bool FluxWeightSystematicsNeutrino::IsCorrectRunPeriod(int runPeriod){
68 //********************************************************************
69  return (runPeriod<8);
70 
71 }
72 
73 
74 //********************************************************************
75 FluxWeightSystematicsAntiNeutrino::FluxWeightSystematicsAntiNeutrino():FluxWeightSystematics("FluxWeightAntiNeutrino"){
76 //********************************************************************
77 
78 }
79 
80 //********************************************************************
81 bool FluxWeightSystematicsAntiNeutrino::IsCorrectRunPeriod(int runPeriod){
82 //********************************************************************
83 
84  return (runPeriod>=8);
85 
86 }
Int_t _index
The index of this systematic (needed by SystematicsManager);.
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
Int_t NuPDG
The PDG code of the incoming neutrino.
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
AnaTrueVertexB * TrueVertex
For storing the true vertex, for analyses with no reconstructed primary vertex.
Definition: ToyBoxND280.hxx:22
Float_t NuEnergy
The true energy of the incoming neutrino.
int GetRunPeriod(int run, int subrun=-1)
Returns the run period (sequentially: 0,1,2,3,4,5 ...)
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
This is a normalization systematic. It takes into account the uncertainty on the neutrino flux...
Weight_h ComputeWeight(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &box)