HighLAND
PionInteractionSystematic.hxx
1 #ifndef PionInteractionSystematic_h
2 #define PionInteractionSystematic_h
3 
4 #include "Interaction.hxx"
5 #include "SelectionBase.hxx"
6 #include "PionCrossSections.hxx"
7 
8 //For geometry stuff.
9 #include <TGeoManager.h>
10 #include <TGeoNode.h>
11 #include <TGeoVolume.h>
12 #include <TGeoMaterial.h>
13 #include <TKey.h>
14 
15 #include <math.h>
16 
17 #include <string>
18 
19 //For getenv() for getting the geom file.
20 #include <stdlib.h>
21 
22 //Creating a class for easy storage of variables to
23 //pass them along.
25 
26 public:
27 
28  Float_t weightMCToData;
29 
30  Int_t nPions;
31 
32  Bool_t* pionType;
33 
34  Int_t totalSteps;
35 
36  Int_t* nSteps;
37 
38  Float_t* initMom;
39 
40  Float_t* stepLengths;
41 
42  Int_t nInteractions;
43 
44  Float_t* pInteraction;
45 
46  Int_t* typeInteraction;
47 
48  Float_t MCSumNSigmaStepLength;
49 
50  Float_t DataSumNSigmaStepLength;
51 
52  //Probability of no interaction in MC and data.
53  Float_t MCProbNoInt;
54 
55  Float_t DataProbNoInt;
56 
57  Int_t* pionID;
58 
59  AnaTrueParticleB** TrueParticles;
60  AnaTrueParticleB** InteractionTrueParticles;
61 
62  //The final position according to the stepping algorithm
63  //For testing/validation only.
64  //They are the momentum and position at the VOI exit point
65  //(either due to interaction, or leaving the VOI).
66  std::vector<Float_t> testFinalMom;
67  std::vector<TLorentzVector> testFinalPos;
68  std::vector<Int_t> testInteractionType;
69 
70  //Constructor
71  //Just set all the class variables individually.
73 
74  virtual ~PionInteractionSystematic();
75 
76 };
77 
78 //A class to contain the result of the stepping code.
80 
81 public:
82 
83  //The sum of MC N*sigma*stepLengths
84  Float_t MCSumNSigmaStepLength;
85 
86  //The sum of Data N*sigma*stepLengths
87  Float_t DataSumNSigmaStepLength;
88 
89  //The vector of step lengths.
90  std::vector<Float_t> stepLengths;
91 
92  //The Final Momentum according to the stepping.
93  Float_t finalMom;
94 
95  //The final position, according to the stepping.
96  TLorentzVector finalPos;
97 
98  //Constructor. Fill it all at once.
99  SteppingResult(Float_t, Float_t, std::vector<Float_t>,Float_t,TLorentzVector);
100 
101 };
102 
103 
104 
105 
106 Double_t DScattCentres(TGeoMixture* mixture);
107 
108 Int_t GetMaterialSeries(std::string matName);
109 
110 Double_t GetIElement(Int_t Z);
111 
112 Double_t GetZoverAMaterial(TGeoMixture* mat);
113 
114 Double_t GetIMaterial(TGeoMixture* mat, Double_t ZoverA);
115 
116 Double_t computeEkinFromMom(Double_t mom);
117 
118 Double_t Interpolate(double xsec1, double xsec2, double mom1, double mom);
119 
120 AnaTrueParticleB* GetParent(AnaTrueParticleB* track, AnaTrueParticleB* allTrajInTPCFGD[], Int_t nTraj);
121 
122 std::pair<TLorentzVector,TVector3> TakeSmallStep(Int_t charge,
123  TLorentzVector initPos,
124  TVector3 initMom,
125  Double_t stepLength, //in mm
126  TGeoMaterial* material,
127  std::string materialName,
128  TGeoMixture* mixture);
129 
130 /// Combine everything that may be analysis/selection dependent int a simple class,
131 /// so that can extended
133 
134 
135 public:
136 
137  /// ctor
139 
140  ///dtor
141  virtual ~PionSIManager(){}
142 
143  // Functions related to the volumes of interest to the analysis
144  virtual Bool_t InVOI(SubDetId_h det, Float_t* pos) const;
145  virtual Bool_t InVOI1(Float_t* pos) const;
146  virtual Bool_t InVOI2(Float_t* pos) const;
147  virtual Bool_t InVOIext(Float_t* pos) const;
148 
149 
150  SteppingResult StepBetweenPoints(SubDetId_h det, Int_t charge,
151  TLorentzVector initPos,
152  TVector3 initMom,
153  TLorentzVector finalPos,
154  Double_t stepLength,
155  TGeoManager* geom) const;
156 
157 
158  /// Calculates the information needed to compute an event weight,
159  /// as well as a weight correcting Geant4 to Data.
160  /// Returns a PionInteractionSystematic object containing all the needed information
161  /// The detector can be provided externally (not only through the selection since
162  /// for the moment the info is filled prior to any cuts sequence applied) to give more flexibility
163  PionInteractionSystematic* ComputePionWeightInfo(const AnaEventB& event, SubDetId_h det) const;
164 
165 
166  PionInteractionSystematic* ComputePionWeightInfo(const AnaEventB& event, const SelectionBase& sel, Int_t branch) const{
167  return ComputePionWeightInfo(event, sel.GetDetectorFV(branch));
168 
169  }
170 
171 };
172 
173 
174 //The detector geometry.
175 extern TGeoManager *pionSIGeom;
176 
177 //Pulls in the full detector geometry from a file that contains
178 //the full geometry.
179 TGeoManager* GetPionSIGeometry();
180 
181 #endif
Representation of a true Monte Carlo trajectory/particle.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.