LDMX Software
SimCalorimeterHit.cxx
2
3// STL
4#include <iostream>
5
7
8 namespace ldmx {
9 const std::string SimCalorimeterHit::ECAL_COLLECTION = "EcalSimHits";
10
11 const std::string SimCalorimeterHit::HCAL_COLLECTION = "HcalSimHits";
12
14 incidentIDContribs_.clear();
15 trackIDContribs_.clear();
16 pdgCodeContribs_.clear();
17 edepContribs_.clear();
18 timeContribs_.clear();
19
20 nContribs_ = 0;
21 id_ = 0;
22 edep_ = 0;
23 x_ = 0;
24 y_ = 0;
25 z_ = 0;
26 time_ = 0;
27 }
28
29 void SimCalorimeterHit::Print() const {
30 std::cout << "SimCalorimeterHit { "
31 << "id: " << id_ << ", edep: " << edep_
32 << ", "
33 "position: ( "
34 << x_ << ", " << y_ << ", " << z_
35 << " ), num contribs: " << nContribs_ << " }" << std::endl;
36 }
37
38 void SimCalorimeterHit::addContrib(int incidentID, int trackID, int pdgCode,
39 float edep, float time) {
40 incidentIDContribs_.push_back(incidentID);
41 trackIDContribs_.push_back(trackID);
42 pdgCodeContribs_.push_back(pdgCode);
43 edepContribs_.push_back(edep);
44 timeContribs_.push_back(time);
45 edep_ += edep;
46 if (time < time_ || time_ == 0) {
47 time_ = time;
48 }
49 ++nContribs_;
50 }
51
52 SimCalorimeterHit::Contrib SimCalorimeterHit::getContrib(int i) const {
53 Contrib contrib;
54 contrib.incidentID = incidentIDContribs_.at(i);
55 contrib.trackID = trackIDContribs_.at(i);
56 contrib.edep = edepContribs_.at(i);
57 contrib.time = timeContribs_.at(i);
58 contrib.pdgCode = pdgCodeContribs_.at(i);
59 return contrib;
60 }
61
62 int SimCalorimeterHit::findContribIndex(int trackID, int pdgCode) const {
63 int contribIndex = -1;
64 for (int iContrib = 0; iContrib < nContribs_; iContrib++) {
65 Contrib contrib = getContrib(iContrib);
66 if (contrib.trackID == trackID && contrib.pdgCode == pdgCode) {
67 contribIndex = iContrib;
68 break;
69 }
70 }
71 return contribIndex;
72 }
73
74 void SimCalorimeterHit::updateContrib(int i, float edep, float time) {
75 this->edepContribs_[i] += edep;
76 if (time < this->timeContribs_.at(i)) {
77 this->timeContribs_[i] = time;
78 }
79 edep_ += edep;
80 }
81} // 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< int > incidentIDContribs_
The list of incident IDs 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.
Contrib getContrib(int i) const
Get a hit contribution by index.
unsigned nContribs_
The number of hit contributions.
void addContrib(int incidentID, int trackID, int pdgCode, float edep, float time)
Add a hit contribution from a SimParticle.
std::vector< float > timeContribs_
The list of times 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 > trackIDContribs_
The list of track IDs contributing to the hit.
std::vector< int > pdgCodeContribs_
The list of PDG codes contributing to the hit.
std::vector< float > edepContribs_
The list of energy depositions 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.
void Print() const
Print out the object.
int incidentID
trackID of incident particle that is an ancestor of the contributor