FLSHit.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief A single unit of energy deposition in the liquid scintillator
3 ///
4 /// \author messier@indiana.edu
5 /// \date
6 ////////////////////////////////////////////////////////////////////////
7 #ifndef SIM_FLSHIT_H
8 #define SIM_FLSHIT_H
10 
11 #include <iosfwd>
12 #include <iostream>
13 #include <iomanip>
14 #include <numeric>
15 
16 
17 namespace sim {
18  /// A single unit of energy deposition in the liquid scintillator
19  class FLSHit {
20  public:
21  FLSHit();
22  ~FLSHit();
23 
24  bool operator==(const FLSHit& rhs) const;
25  bool operator<(const FLSHit& rhs) const;
26 
27  /// Clear the FLS hit
28  void Clear();
29 
30  /// Get total Energy deposited into the cell for the whole FLSHit
31  float GetEdep() const {return getSum(fVectorEdep);}
32  /// Get total Energy with Birks suppression deposited into the cell for the whole FLSHit
33  float GetEdepBirks() const {return getSum(fVectorEdepBirks);}
34  /// Get total N Cerenkov photons
35  float GetNCerenkov() const {return getSum(fVectorNCerenkov);}
36  /// Plane ID
37  int GetPlaneID() const {return fPlaneId;}
38  /// Cell ID
39  int GetCellID () const {return fCellId;}
40  /// Unique Cell ID
42  /// PDG
43  int GetPDG () const {return fPDG;}
44  /// Track ID
45  int GetTrackID() const {return fTrackId;}
46 
47  /// Entry point of the particle (position, time and energy)
48  float GetEntryX() const {return getFirst(fX);}
49  float GetEntryY() const {return getFirst(fY);}
50  float GetEntryZ() const {return getFirst(fZ);}
51  float GetEntryT() const {return getFirst(fT);}
52  float GetEntryEnergy() const {return getFirst(fEnergy);}
53  /// Exit point of the particle (position, time and energy)
54  float GetExitX() const {return getLast(fX);}
55  float GetExitY() const {return getLast(fY);}
56  float GetExitZ() const {return getLast(fZ);}
57  float GetExitT() const {return getLast(fT);}
58  float GetExitEnergy() const {return getLast(fEnergy);}
59 
60  /// Number of end points in FLSHit (could be Geant end points)
61  int GetNPoints() const { return fX.size();}
62  /// Number of steps in FLSHit. Should be equal to GetNPoints() - 1
63  int GetNSteps () const { return fVectorEdep.size();}
64 
65  /// Get path length of a particular step
66  float GetPathLength(const int step) const;
67  /// Get path length of all steps in FLSHit
68  float GetTotalPathLength() const;
69 
70  /// Get energy loss of a particular step
71  float GetEnergyLoss(const int step) const;
72  /// Get total energy loss in the entire FLSHit
73  float GetTotalEnergyLoss() const;
74 
75  /// Get X-average for the step. This is in local coordinates.
76  float GetXAverage(const int step) const {return GetXYZAverage(fX, step);}
77  /// Get Y-average for the step. This is in local coordinates.
78  float GetYAverage(const int step) const {return GetXYZAverage(fY, step);}
79  /// Get Z-average for the step. This is in local coordinates.
80  float GetZAverage(const int step) const {return GetXYZAverage(fZ, step);}
81  /// Get X-average for the FLSHit. This is in local coordinates.
82  float GetXAverage() const { return GetXYZAverage(fX);}
83  /// Get Y-average for the FLSHit. This is in local coordinates.
84  float GetYAverage() const { return GetXYZAverage(fY);}
85  /// Get Z-average for the FLSHit. This is in local coordinates.
86  float GetZAverage() const { return GetXYZAverage(fZ);}
87 
88 
89  /// Get a point of the particle in the FLSHit (position, time and energy)
90  float GetX (const int ipoint) const {return getElement(fX , ipoint);}
91  float GetY (const int ipoint) const {return getElement(fY , ipoint);}
92  float GetZ (const int ipoint) const {return getElement(fZ , ipoint);}
93  float GetT (const int ipoint) const {return getElement(fT , ipoint);}
94  float GetEnergy (const int ipoint) const {return getElement(fEnergy , ipoint);}
95  float GetEdep (const int ipoint) const {return getElement(fVectorEdep , ipoint);}
96  float GetEdepBirks(const int ipoint) const {return getElement(fVectorEdepBirks, ipoint);}
97  float GetNCerenkov(const int ipoint) const {return getElement(fVectorNCerenkov, ipoint);}
98 
99  /// Set methods
100  void SetPDG (const int pdg) { fPDG = pdg; }
101  void SetTrackId (const int trackid) { fTrackId = trackid; }
102  void SetPlane (const int ip) { fPlaneId = ip; }
103  void SetCell (const int ic) { fCellId = ic; }
104  void SetCellUniqueId(const geo::CellUniqueId& id) { fId = id;}
105  void AddEdep (const float edep) { fVectorEdep.push_back(edep); }
106  void AddEdepBirks (const float edepbirks) { fVectorEdepBirks.push_back(edepbirks);}
107  void AddNCerenkov (const float ncerenkov) { fVectorNCerenkov.push_back(ncerenkov); }
108  void AddPos (const float x, const float y, const float z, const double t, const float energy) {fX.push_back(x);fY.push_back(y);fZ.push_back(z);fT.push_back(t);fEnergy.push_back(energy);}
109 
110  /// Performs various checks on the size of the data and its content.
111  /// Has an option to print errors out, which is turned off by default.
112  bool IsFLSHitReasonable(const bool print_errors = false
113  ,std::ostream& error_printint_stream = std::cout) const;
114 
115  private:
116 
117  /// Sums over the array of the vector
118  template< class T>
119  T getSum(const std::vector<T>& input_vector) const{
120  const T sum = std::accumulate(input_vector.begin(), input_vector.end(), 0.0);
121  return sum;
122  }// end of getSum
123 
124  /// Gets i-th element of the vector
125  template< class T>
126  T getElement(const std::vector<T>& input_vector, const unsigned int ipoint) const{
127  return input_vector.at(ipoint);
128  }// end of getElement
129 
130  /// Gets the last element of the vector
131  template< class T>
132  T getFirst(const std::vector<T>& input_vector) const{
133  return getElement<T>(input_vector, 0);
134  }// end of getFirst
135 
136  /// Gets the last element of the vector
137  template< class T>
138  T getLast(const std::vector<T>& input_vector) const{
139  const int n_size = input_vector.size();
140  if(n_size == 0) return (T)(0.0);
141  return input_vector[n_size - 1];
142  }// end of getLast
143 
144  float GetXYZAverage(const std::vector<float>& xyz, const int step) const;
145  float GetXYZAverage(const std::vector<float>& xyz) const;
146 
147  /// Checks whether the input vector increases monotonically
148  template< class T>
149  bool DoesIncreaseMonotonically(const std::vector<T>& input_vector) const {
150 
151  const int n_size = input_vector.size();
152 
153  /// if size is less than 2, then it's monotonic, obviously
154  if(n_size < 2) return true;
155 
156  for(int i=1; i<n_size; ++i){
157  if(input_vector[i-1] > input_vector[i])
158  return false;
159  }
160 
161  return true;
162  }// end of DoesIncreaseMonotonically
163 
164  /// Checks whether the input vector decreases monotonically
165  template< class T>
166  bool DoesDecreaseMonotonically(const std::vector<T>& input_vector) const {
167 
168  const int n_size = input_vector.size();
169 
170  /// if size is less than 2, then it's monotonic, obviously
171  if(n_size < 2) return true;
172 
173  for(int i=1; i<n_size; ++i){
174  if(input_vector[i-1] < input_vector[i])
175  return false;
176  }
177 
178  return true;
179  }// end of DoesDecreaseMonotonically
180 
181 
182  private:
183 
184  geo::CellUniqueId fId; ///< Unique cell ID
185 
186  unsigned short int fPlaneId; ///< Plane number
187  unsigned short int fCellId; ///< Cell number
188  int fPDG; ///< PDG code of parent particle
189  int fTrackId; ///< Index number of the Global track producing hit
190 
191  std::vector<float> fX; ///< Start or end of the step inside scintillator. X position, cm
192  std::vector<float> fY; ///< Start or end of the step inside scintillator. Y position, cm
193  std::vector<float> fZ; ///< Start or end of the step inside scintillator. Z position, cm
194  std::vector<float> fEnergy; ///< Start or end of the step inside scintillator. Energy, GeV
195  std::vector<double> fT; ///< Start or end of the step inside scintillator. Time, ns
196 
197  std::vector<float> fVectorEdep; ///< Amount of energy deposited during a Geant4 step (GeV)
198  std::vector<float> fVectorEdepBirks; ///< Amount of energy deposited during a Geant4 step ; Birks weighted (GeV)
199  std::vector<float> fVectorNCerenkov; ///< Amount of Cerenkov light emitteded in scintillator
200  };
201 
202 
203  std::ostream& operator<< (std::ostream & o, const FLSHit & a);
204 
205 }
206 #endif
207 ////////////////////////////////////////////////////////////////////////
geo::CellUniqueId GetCellUniqueId() const
Unique Cell ID.
Definition: FLSHit.h:41
void AddNCerenkov(const float ncerenkov)
Definition: FLSHit.h:107
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
float GetNCerenkov(const int ipoint) const
Definition: FLSHit.h:97
float GetEntryX() const
Entry point of the particle (position, time and energy)
Definition: FLSHit.h:48
void SetTrackId(const int trackid)
Definition: FLSHit.h:101
std::vector< float > fY
Start or end of the step inside scintillator. Y position, cm.
Definition: FLSHit.h:192
int GetPlaneID() const
Plane ID.
Definition: FLSHit.h:37
float GetEnergyLoss(const int step) const
Get energy loss of a particular step.
Definition: FLSHit.cxx:84
float GetEntryEnergy() const
Definition: FLSHit.h:52
float GetPathLength(const int step) const
Get path length of a particular step.
Definition: FLSHit.cxx:60
int GetCellID() const
Cell ID.
Definition: FLSHit.h:39
float GetExitT() const
Definition: FLSHit.h:57
int GetNPoints() const
Number of end points in FLSHit (could be Geant end points)
Definition: FLSHit.h:61
std::vector< float > fZ
Start or end of the step inside scintillator. Z position, cm.
Definition: FLSHit.h:193
float GetTotalPathLength() const
Get path length of all steps in FLSHit.
Definition: FLSHit.cxx:70
int GetNSteps() const
Number of steps in FLSHit. Should be equal to GetNPoints() - 1.
Definition: FLSHit.h:63
float GetTotalEnergyLoss() const
Get total energy loss in the entire FLSHit.
Definition: FLSHit.cxx:90
std::vector< float > fVectorEdep
Amount of energy deposited during a Geant4 step (GeV)
Definition: FLSHit.h:197
unsigned short int fCellId
Cell number.
Definition: FLSHit.h:187
float GetNCerenkov() const
Get total N Cerenkov photons.
Definition: FLSHit.h:35
std::vector< double > fT
Start or end of the step inside scintillator. Time, ns.
Definition: FLSHit.h:195
std::vector< float > fVectorNCerenkov
Amount of Cerenkov light emitteded in scintillator.
Definition: FLSHit.h:199
TString ip
Definition: loadincs.C:5
A single unit of energy deposition in the liquid scintillator.
Definition: FLSHit.h:19
float GetExitX() const
Exit point of the particle (position, time and energy)
Definition: FLSHit.h:54
void SetCell(const int ic)
Definition: FLSHit.h:103
bool IsFLSHitReasonable(const bool print_errors=false, std::ostream &error_printint_stream=std::cout) const
Definition: FLSHit.cxx:119
Give every cell in the geometry a unique ID number based on the TGeo path to the node.
float GetXAverage() const
Get X-average for the FLSHit. This is in local coordinates.
Definition: FLSHit.h:82
void SetCellUniqueId(const geo::CellUniqueId &id)
Definition: FLSHit.h:104
bool operator<(const FLSHit &rhs) const
Definition: FLSHit.cxx:30
unsigned short int fPlaneId
Plane number.
Definition: FLSHit.h:186
int GetPDG() const
PDG.
Definition: FLSHit.h:43
geo::CellUniqueId fId
Unique cell ID.
Definition: FLSHit.h:184
std::ostream & operator<<(std::ostream &o, const FLSHit &a)
Definition: FLSHit.cxx:203
void SetPDG(const int pdg)
Set methods.
Definition: FLSHit.h:100
std::vector< float > fVectorEdepBirks
Amount of energy deposited during a Geant4 step ; Birks weighted (GeV)
Definition: FLSHit.h:198
const double a
float GetY(const int ipoint) const
Definition: FLSHit.h:91
float GetXAverage(const int step) const
Get X-average for the step. This is in local coordinates.
Definition: FLSHit.h:76
double energy
Definition: plottest35.C:25
Double_t edep
Definition: macro.C:13
Example routine for calculating the "ultimate e-m mother" of a particle in a simulated event...
Definition: FillTruth.h:15
z
Definition: test.py:28
float GetEdepBirks() const
Get total Energy with Birks suppression deposited into the cell for the whole FLSHit.
Definition: FLSHit.h:33
OStream cout
Definition: OStream.cxx:6
float GetT(const int ipoint) const
Definition: FLSHit.h:93
int fPDG
PDG code of parent particle.
Definition: FLSHit.h:188
float GetEntryZ() const
Definition: FLSHit.h:50
float GetExitEnergy() const
Definition: FLSHit.h:58
float GetEntryT() const
Definition: FLSHit.h:51
unsigned long long int CellUniqueId
Definition: CellUniqueId.h:15
void AddPos(const float x, const float y, const float z, const double t, const float energy)
Definition: FLSHit.h:108
bool operator==(const FLSHit &rhs) const
Definition: FLSHit.cxx:23
int fTrackId
Index number of the Global track producing hit.
Definition: FLSHit.h:189
void AddEdep(const float edep)
Definition: FLSHit.h:105
T getElement(const std::vector< T > &input_vector, const unsigned int ipoint) const
Gets i-th element of the vector.
Definition: FLSHit.h:126
int GetTrackID() const
Track ID.
Definition: FLSHit.h:45
void SetPlane(const int ip)
Definition: FLSHit.h:102
float GetZ(const int ipoint) const
Definition: FLSHit.h:92
float GetEdep(const int ipoint) const
Definition: FLSHit.h:95
float GetEdepBirks(const int ipoint) const
Definition: FLSHit.h:96
std::vector< float > fX
Start or end of the step inside scintillator. X position, cm.
Definition: FLSHit.h:191
void Clear()
Clear the FLS hit.
Definition: FLSHit.cxx:39
float GetYAverage() const
Get Y-average for the FLSHit. This is in local coordinates.
Definition: FLSHit.h:84
double T
Definition: Xdiff_gwt.C:5
float GetEdep() const
Get total Energy deposited into the cell for the whole FLSHit.
Definition: FLSHit.h:31
float GetExitY() const
Definition: FLSHit.h:55
float GetZAverage(const int step) const
Get Z-average for the step. This is in local coordinates.
Definition: FLSHit.h:80
float GetYAverage(const int step) const
Get Y-average for the step. This is in local coordinates.
Definition: FLSHit.h:78
Double_t sum
Definition: plot.C:31
float GetExitZ() const
Definition: FLSHit.h:56
float GetX(const int ipoint) const
Get a point of the particle in the FLSHit (position, time and energy)
Definition: FLSHit.h:90
T getFirst(const std::vector< T > &input_vector) const
Gets the last element of the vector.
Definition: FLSHit.h:132
void AddEdepBirks(const float edepbirks)
Definition: FLSHit.h:106
T getSum(const std::vector< T > &input_vector) const
Sums over the array of the vector.
Definition: FLSHit.h:119
float GetXYZAverage(const std::vector< float > &xyz, const int step) const
Definition: FLSHit.cxx:95
bool DoesDecreaseMonotonically(const std::vector< T > &input_vector) const
Checks whether the input vector decreases monotonically.
Definition: FLSHit.h:166
float GetZAverage() const
Get Z-average for the FLSHit. This is in local coordinates.
Definition: FLSHit.h:86
float GetEntryY() const
Definition: FLSHit.h:49
std::vector< float > fEnergy
Start or end of the step inside scintillator. Energy, GeV.
Definition: FLSHit.h:194
T getLast(const std::vector< T > &input_vector) const
Gets the last element of the vector.
Definition: FLSHit.h:138
float GetEnergy(const int ipoint) const
Definition: FLSHit.h:94
bool DoesIncreaseMonotonically(const std::vector< T > &input_vector) const
Checks whether the input vector increases monotonically.
Definition: FLSHit.h:149