LDMX Software
SimCalorimeterHit.h
Go to the documentation of this file.
1
8#ifndef SIMCORE_EVENT_SIMCALORIMETERHIT_H_
9#define SIMCORE_EVENT_SIMCALORIMETERHIT_H_
10
11// C++
12#include <functional> // for track ID encodings
13
14// ROOT
15#include "TObject.h" //For ClassDef
16
17// LDMX
18#include "SimCore/Event/SimParticle.h"
19
20namespace ldmx {
21
36 public:
38 static const std::string ECAL_COLLECTION;
39
41 static const std::string HCAL_COLLECTION;
42
47 struct Contrib {
59 int incident_id_{-1};
60
62 int track_id_{-1};
63
65 int pdg_code_{0};
66
68 float edep_{0};
69
71 float time_{0};
72
74 int origin_id_{-1};
75 };
76
80 SimCalorimeterHit() = default;
81
85 virtual ~SimCalorimeterHit() = default;
86
90 void clear();
91
95 friend std::ostream &operator<<(std::ostream &o, const SimCalorimeterHit &d);
96
97 /*
98 * Print out a contributor.
99 */
100 friend std::ostream &operator<<(std::ostream &o,
101 const SimCalorimeterHit::Contrib &contrib);
102
107 int getID() const { return id_; }
108
113 void setID(const int id) { this->id_ = id; }
114
119 float getEdep() const { return edep_; }
120
125 void setEdep(const float edep) { this->edep_ = edep; }
126
131 std::vector<float> getPosition() const { return {x_, y_, z_}; }
132
138 std::vector<float> getPreStepPosition() const {
139 return {pre_step_x_, pre_step_y_, pre_step_z_};
140 }
146 std::vector<float> getPostStepPosition() const {
147 return {post_step_x_, post_step_y_, post_step_z_};
148 }
155 void setPosition(const float x, const float y, const float z) {
156 this->x_ = x;
157 this->y_ = y;
158 this->z_ = z;
159 }
167 void setPreStepPosition(const float x, const float y, const float z) {
168 pre_step_x_ = x;
169 pre_step_y_ = y;
170 pre_step_z_ = z;
171 }
179 void setPostStepPosition(const float x, const float y, const float z) {
180 post_step_x_ = x;
181 post_step_y_ = y;
182 post_step_z_ = z;
183 }
184
189 void setPathLength(const float length) { path_length_ = length; }
194 float getPathLength() const { return path_length_; }
199 void setPreStepTime(const float time) { pre_step_time_ = time; }
204 void setPostStepTime(const float time) { post_step_time_ = time; }
205
210 void setVelocity(float velocity) { velocity_ = velocity; }
211
216 float getTime() const { return time_; }
221 float getPreStepTime() const { return pre_step_time_; }
226 float getPostStepTime() const { return post_step_time_; }
227
232 float getVelocity() const { return velocity_; }
233
238 void setTime(const float time) { this->time_ = time; }
239
244 unsigned getNumberOfContribs() const { return n_contribs_; }
245
255 void addContrib(int incidentID, int trackID, int pdgCode, float edep,
256 float time, int originID = -1);
257
263 Contrib getContrib(int i) const;
264
271 int findContribIndex(int trackID, int pdgCode) const;
272
280 void updateContrib(int i, float edep, float time);
281
290 void encodeTracks(
291 std::function<int(int, unsigned int, unsigned int)> encodeFunc,
292 const unsigned int encoding_version, const unsigned int event_index = 0);
293
297 bool operator<(const SimCalorimeterHit &rhs) const {
298 return this->getTime() < rhs.getTime();
299 }
300
304 std::vector<int> getTrackIds() const { return track_id_contribs_; }
308 std::vector<int> getIncidentIds() const { return incident_id_contribs_; }
309
313 std::vector<int> getPdgIds() const { return pdg_code_contribs_; }
314
318 std::vector<float> getEdeps() const { return edep_contribs_; }
319
323 std::vector<float> getTimes() const { return time_contribs_; }
324
325 private:
332 int id_{0};
333
337 float edep_{0};
338
342 float x_{0};
343
347 float y_{0};
348
352 float z_{0};
353
357 float time_{0};
358
362 std::vector<int> track_id_contribs_;
363
367 std::vector<int> incident_id_contribs_;
368
372 std::vector<int> pdg_code_contribs_;
373
377 std::vector<float> edep_contribs_;
378
382 std::vector<float> time_contribs_;
383
387 std::vector<int> origin_contribs_;
388
392 unsigned n_contribs_{0};
393
394 /*
395 * Parameters used only for hits corresponding to a single interactions
396 * (currently Hcal and TS).
397 */
398
403 float path_length_{-1};
404
409 float pre_step_x_{0};
410 float pre_step_y_{0};
411 float pre_step_z_{0};
420 float post_step_x_{0};
421 float post_step_y_{0};
422 float post_step_z_{0};
427
431 float velocity_{-1};
432
437};
438} // namespace ldmx
439
440#endif
Stores simulated calorimeter hit information.
float edep_
The energy deposition.
virtual ~SimCalorimeterHit()=default
Class destructor.
void setPreStepTime(const float time)
Set global pre-step time of the hit [ns].
float getVelocity() const
Get the track velocity of the hit [mm/ns].
float getPathLength() const
Get the physical path length for the interaction [mm].
void clear()
Clear the data in the object.
void setPathLength(const float length)
Set the physical path length for the interaction [mm].
std::vector< float > getPostStepPosition() const
Get the XYZ post-step position of the hit in the coordinate frame of the sensitive volume [mm].
ClassDef(SimCalorimeterHit, 8)
ROOT class definition.
void encodeTracks(std::function< int(int, unsigned int, unsigned int)> encodeFunc, const unsigned int encoding_version, const unsigned int event_index=0)
Encodes all Track IDs in the SimCalorimeterHit object according to the schema provided in the 'encode...
std::vector< float > time_contribs_
The list of times contributing to the hit.
float getPostStepTime() const
Get the post-step time of the hit [ns].
float velocity_
The track velocity [mm/ns].
int findContribIndex(int trackID, int pdgCode) const
Find the index of a hit contribution from a SimParticle and PDG code.
float z_
The Z position.
float pre_step_time_
The global time before the interaction [ns].
std::vector< float > getEdeps() const
Get the list of energy depositions contributing to the hit.
unsigned getNumberOfContribs() const
Get the number of hit contributions.
float time_
The global time of the hit.
float y_
The Y position.
float getTime() const
Get the global time of the hit [ns].
void setEdep(const float edep)
Set the energy deposition of the hit [MeV].
friend std::ostream & operator<<(std::ostream &o, const SimCalorimeterHit &d)
Print out the object.
void setPosition(const float x, const float y, const float z)
Set the XYZ position of the hit [mm].
std::vector< int > getPdgIds() const
Get the list of PDG codes contributing to the hit.
std::vector< float > edep_contribs_
The list of energy depositions contributing to the hit.
std::vector< int > track_id_contribs_
The list of track IDs contributing to the hit.
SimCalorimeterHit()=default
Class constructor.
float pre_step_x_
The X, Y, and Z positions [mm] before the interaction in the coordinate frame of the sensitive volume...
void setPostStepPosition(const float x, const float y, const float z)
Set the XYZ post-step position of the hit in the coordinate frame of the sensitive volume [mm].
static const std::string HCAL_COLLECTION
name of the hcal sim collection, should match gdml
float x_
The X position.
void setID(const int id)
Set the detector ID.
std::vector< int > getIncidentIds() const
Get the list of incident IDs contributing to the hit.
std::vector< float > getPosition() const
Get the XYZ position of the hit [mm].
std::vector< int > incident_id_contribs_
The list of incident IDs contributing to the hit.
float path_length_
The true path length [mm].
Contrib getContrib(int i) const
Get a hit contribution by index_.
int getID() const
Get the detector ID.
void setPostStepTime(const float time)
Set global post-step time of the hit [ns].
bool operator<(const SimCalorimeterHit &rhs) const
Sort by time of hit.
void addContrib(int incidentID, int trackID, int pdgCode, float edep, float time, int originID=-1)
Add a hit contribution from a SimParticle.
void setTime(const float time)
Set the time of the hit [ns].
std::vector< int > pdg_code_contribs_
The list of PDG codes contributing to the hit.
std::vector< float > getPreStepPosition() const
Get the XYZ pre-step position of the hit in the coordinate frame of the sensitive volume [mm].
unsigned n_contribs_
The number of hit contributions.
float getEdep() const
Get the energy deposition of the hit [MeV].
std::vector< int > origin_contribs_
The list of origin IDs contributing to the hit.
static const std::string ECAL_COLLECTION
name of the ecal sim collection, should match gdml
void updateContrib(int i, float edep, float time)
Update an existing hit contribution by incrementing its edep and setting the time if the new time is ...
std::vector< float > getTimes() const
Get the list of times contributing to the hit.
float post_step_x_
The X, Y, and Z positions [mm] after the interaction in the coordinate frame of the sensitive volume.
int id_
Member variables used in all calorimeter types.
void setPreStepPosition(const float x, const float y, const float z)
Set the XYZ pre-step position of the hit in the coordinate frame of the sensitive volume [mm].
std::vector< int > getTrackIds() const
Get the list of track IDs contributing to the hit.
float post_step_time_
The global time after the interaction [ns].
void setVelocity(float velocity)
Set the velocity of the track [mm/ns].
float getPreStepTime() const
Get the pre-step time of the hit [ns].
Information about a contribution to the hit in the associated cell.
float time_
Time this contributor made the hit (global Geant4 time)
float edep_
Energy depostied by this contributor.
int track_id_
track ID of this contributor
int incident_id_
trackID of incident particle that is an ancestor of the contributor
int origin_id_
Saves ID of electron incident particle came from.
int pdg_code_
PDG ID of this contributor.