HighLAND
FGDMassSystematics.cxx
1 #include "FGDMassSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "BasicUtils.hxx"
4 #include "ToyBoxTracker.hxx"
5 
6 //********************************************************************
7 FGDMassSystematics::FGDMassSystematics():EventWeightBase(2){
8  //********************************************************************
9 
10  Int_t baseindex=0;
11  _scintmass = new BinnedParams("FGD1Mass", BinnedParams::k1D_SYMMETRIC, versionUtils::Extension());
12  baseindex += _scintmass->GetNBins();
13  _watermass = new BinnedParams("FGD2MassWater", BinnedParams::k1D_SYMMETRIC);
14  baseindex +=_watermass->GetNBins();
15  SetNParameters(baseindex);
16 
17 
18  _scintmass->GetParametersForBin(0, _scintmass_corr, _scintmass_err);
19  _watermass->GetParametersForBin(0, _watermass_corr, _watermass_err);
20 }
21 
22 //********************************************************************
24 //********************************************************************
25 
26  const AnaEventB& event = *static_cast<const AnaEventB*>(&eventBB);
27 
28  // Cast the ToyBox to the appropriate type
29  const ToyBoxTracker& box = *static_cast<const ToyBoxTracker*>(&boxB);
30 
31  Weight_h eventWeight=1;
32 
33  // True vertex associated to the recon vertex should exist
34  if (!box.Vertex->TrueVertex) return eventWeight;
35 
36  // Apply FGD mass systematic when the true vertex is in FGD
37 
38  // Depending on FGD1 or FGD2
39  if( box.DetectorFV==SubDetId::kFGD1){ // Event selected in FGD1 FV
40  if (anaUtils::InDetVolume(SubDetId::kFGD1, box.Vertex->TrueVertex->Position)){ // TrueVertex in FGD1 FV
41  eventWeight.Systematic = 1 + _scintmass_corr + _scintmass_err * toy.GetToyVariations(_index)->Variations[0];
42  eventWeight.Correction = 1 + _scintmass_corr;
43  }
44  }
45  else if( box.DetectorFV==SubDetId::kFGD2){ // Event selected in FGD2 FV
46  if (anaUtils::InDetVolume(SubDetId::kFGD2, box.Vertex->TrueVertex->Position)){ // TrueVertex in FGD2 FV
47  // Check water of scintilator
48  if (anaUtils::GetFgdModuleTypeNoFV(event.GetIsMC(), box.Vertex->TrueVertex->Position,true) == 2){
49  eventWeight.Systematic = 1 + _watermass_corr + _watermass_err * toy.GetToyVariations(_index)->Variations[1];
50  eventWeight.Correction = 1 + _watermass_corr;
51  }
52  else{
53  eventWeight.Systematic = 1 + _scintmass_corr + _scintmass_err * toy.GetToyVariations(_index)->Variations[0];
54  eventWeight.Correction = 1 + _scintmass_corr;
55  }
56  }
57  }
58  return eventWeight;
59 }
60 
Int_t _index
The index of this systematic (needed by SystematicsManager);.
AnaTrueVertexB * TrueVertex
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
Weight_h ComputeWeight(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &box)
SubDetId_h DetectorFV
Indicate the FV we are interested in.
Definition: ToyBoxB.hxx:52
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
AnaVertexB * Vertex
For storing the reconstructed vertex.
Float_t Position[4]
The position the true interaction happened at.
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
bool InDetVolume(SubDetId::SubDetEnum det, const Float_t *pos)