LDMX Software
SimCalorimeterHit.cxx
2
3// STL
4#include <iostream>
5
7
8namespace ldmx {
9const std::string SimCalorimeterHit::ECAL_COLLECTION = "EcalSimHits";
10
11const std::string SimCalorimeterHit::HCAL_COLLECTION = "HcalSimHits";
12
15 track_id_contribs_.clear();
16 pdg_code_contribs_.clear();
17 edep_contribs_.clear();
18 time_contribs_.clear();
19
20 n_contribs_ = 0;
21 id_ = 0;
22 edep_ = 0;
23 x_ = 0;
24 y_ = 0;
25 z_ = 0;
26 time_ = 0;
27}
28
29std::ostream& operator<<(std::ostream& o, const SimCalorimeterHit& hit) {
30 return o << "SimCalorimeterHit { " << "id: " << hit.id_
31 << ", edep: " << hit.edep_
32 << ", "
33 "position: ( "
34 << hit.x_ << ", " << hit.y_ << ", " << hit.z_
35 << " ), num contribs: " << hit.n_contribs_ << " }";
36}
37
38void SimCalorimeterHit::addContrib(int incidentID, int trackID, int pdgCode,
39 float edep, float time, int originID) {
40 incident_id_contribs_.push_back(incidentID);
41 track_id_contribs_.push_back(trackID);
42 pdg_code_contribs_.push_back(pdgCode);
43 edep_contribs_.push_back(edep);
44 time_contribs_.push_back(time);
45 origin_contribs_.push_back(originID);
46 edep_ += edep;
47 if (time < time_ || time_ == 0) {
48 time_ = time;
49 }
51}
52
54 Contrib contrib;
55 contrib.incident_id_ = incident_id_contribs_.at(i);
56 contrib.track_id_ = track_id_contribs_.at(i);
57 contrib.edep_ = edep_contribs_.at(i);
58 contrib.time_ = time_contribs_.at(i);
59 contrib.pdg_code_ = pdg_code_contribs_.at(i);
60 contrib.origin_id_ = origin_contribs_.at(i);
61 return contrib;
62}
63
64int SimCalorimeterHit::findContribIndex(int trackID, int pdgCode) const {
65 int contrib_index = -1;
66 for (int i_contrib = 0; i_contrib < n_contribs_; i_contrib++) {
67 Contrib contrib = getContrib(i_contrib);
68 if (contrib.track_id_ == trackID && contrib.pdg_code_ == pdgCode) {
69 contrib_index = i_contrib;
70 break;
71 }
72 }
73 return contrib_index;
74}
75
76void SimCalorimeterHit::updateContrib(int i, float edep, float time) {
77 this->edep_contribs_[i] += edep;
78 if (time < this->time_contribs_.at(i)) {
79 this->time_contribs_[i] = time;
80 }
81 edep_ += edep;
82}
83} // namespace ldmx
Class which stores simulated calorimeter hit information.
Stores simulated calorimeter hit information.
float edep_
The energy deposition.
void clear()
Clear the data in the object.
std::vector< float > time_contribs_
The list of times contributing to the hit.
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 time_
The global time of the hit.
float y_
The Y position.
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.
static const std::string HCAL_COLLECTION
name of the hcal sim collection, should match gdml
float x_
The X position.
std::vector< int > incident_id_contribs_
The list of incident IDs contributing to the hit.
Contrib getContrib(int i) const
Get a hit contribution by index_.
void addContrib(int incidentID, int trackID, int pdgCode, float edep, float time, int originID=-1)
Add a hit contribution from a SimParticle.
std::vector< int > pdg_code_contribs_
The list of PDG codes contributing to the hit.
unsigned n_contribs_
The number of hit contributions.
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 ...
int id_
Member variables used in all calorimeter types.
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.