HighLAND
P0dMassSystematics.cxx
1 #include "P0dMassSystematics.hxx"
2 #include "GeometryManager.hxx"
3 #include "ND280AnalysisUtils.hxx"
4 #include "BasicUtils.hxx"
5 #include "DataClasses.hxx"
6 #include "ToyBoxTracker.hxx"
7 #include <iostream>
8 //********************************************************************
9 P0dMassSystematics::P0dMassSystematics():EventWeightBase(1),BinnedParams(){
10  //********************************************************************
11 
12  BinnedParams::SetName("P0DMass");
13  BinnedParams::SetType(k1D_SYMMETRIC);
14 
15  char dirname[256];
16  sprintf(dirname,"%s/data",getenv("P0DNUMUCCANALYSISROOT"));
17  BinnedParams::Read(dirname);
18 
19  SetNParameters(2);//1: water 0: everything else
20 
21  Float_t corr,err;
22  GetParametersForBin(0,corr,err);
23  leadMass_err = err;
24  leadMass_corr = corr;
25  GetParametersForBin(1,corr,err);
26  brassMass_err = err;
27  brassMass_corr = corr;
28  GetParametersForBin(2,corr,err);
29  waterMass_err = err;
30  waterMass_corr = corr;
31  GetParametersForBin(3,corr,err);
32  otherMass_err = err;
33  otherMass_corr = corr;
34 }
35 
36 //********************************************************************
38 //********************************************************************
39 
40  (void)event;
41 
42  // Cast the ToyBox to the appropriate type
43  const ToyBoxTracker& box = *static_cast<const ToyBoxTracker*>(&boxB);
44 
45  Weight_h eventWeight=1;
46 
47  // True vertex associated to the recon vertex should exist
48  if (!box.Vertex->TrueVertex) return eventWeight;
49 
50 
51 
52  if (anaUtils::InDetVolume(SubDetId::kP0D, box.Vertex->TrueVertex->Position)){ // TrueVertex in P0D FV
53 
54 
55  // Get the geometry from the GeometryManager
56  TGeoManager* geom = ND::hgman().GeoManager();
57 
58  //Only load in the geometry if it has not already been loaded by the InputConverter. Use in this case the default file
59  if (!geom){
60  ND::hgman().LoadGeometry(); // Use default file
61  geom = ND::hgman().GeoManager();
62  }
63  AnaTrueVertexB* vert = box.Vertex->TrueVertex;
64  TString material = geom->FindNode(vert->Position[0],vert->Position[1],vert->Position[2])->GetMedium()->GetName();
65  Double_t err, corr;
66  Double_t weight=1;
67  if (material == "Water"){
68  err = waterMass_err;
69  corr = waterMass_corr;
70  weight *= corr*(1+err * toy.GetToyVariations(_index)->Variations[1]);
71  } else if (material == "Brass"){//Note: Where should "other material" category in TN-073 go? Here or in "other"?
72  err = brassMass_err;
73  corr = brassMass_corr;
74  weight *= corr * (1+err * toy.GetToyVariations(_index)->Variations[0]);
75  } else if (material == "Lead"){
76  err = leadMass_err;
77  corr = leadMass_corr;
78  weight *= corr *(1+err* toy.GetToyVariations(_index)->Variations[0]);
79  } else {//Carbon/epoxy/polystyrene/scintillator/ etc
80  err = otherMass_err;
81  corr = otherMass_corr;
82  weight *= corr*(1+err * toy.GetToyVariations(_index)->Variations[0]);
83  }
84 
85 
86 /* //Old Code based on target nucleus. Not much difference in neutrino selections (no hydrogen events) and should be much faster
87  Int_t target = ((AnaTrueVertex*)box.Vertex->TrueVertex)->TargetPDG;
88 // std::cout <<"P0D Target: "<<target<<std::endl;
89  Float_t corr, err;
90  if (target/10000 == 100082) {err = leadMass_err; corr = leadMass_corr;}
91  else if (target/10000 == 100029 || target/10000 == 100030) {err = brassMass_err; corr = brassMass_corr;}
92  else if (target/10000 == 100008) {err = waterMass_err;corr = waterMass_corr;}
93  else {err = otherMass_err; corr = otherMass_corr;}//Mostly carbon
94 */
95  eventWeight.Systematic *= (corr + err*toy.GetToyVariations(_index)->Variations[0]);
96  eventWeight.Correction *= (corr);
97  }
98 // }
99 // std::cout << "Event Weight: "<<eventWeight<<std::endl;
100 
101  return eventWeight;
102 
103 }
104 
AnaTrueVertexB * TrueVertex
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
Representation of a true Monte Carlo vertex.
void SetType(TypeEnum type)
Set the type.
void SetName(const std::string &name)
Set the name.
AnaVertexB * Vertex
For storing the reconstructed vertex.
Float_t Position[4]
The position the true interaction happened at.
Int_t _index
Index of the step in the selection.
Definition: StepBase.hxx:140
void Read(const std::string &inputDirName, const std::string &extension="")
Read from a file the systematic source values.
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
bool InDetVolume(SubDetId::SubDetEnum det, const Float_t *pos)
Weight_h ComputeWeight(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &box)
bool LoadGeometry(const std::string &file="", Int_t geomID=-1, const std::string &geomDir="")
Load the TGeoManager from the input root file. Returns true when the new geometry was loaded...