Process the event and put new data products into it.
47 {
48 std::map<ldmx::TrigScintID, int> cell_pes, cell_min_p_es;
49 std::map<ldmx::TrigScintID, float> xpos, ypos, zpos, edep, time, beam_frac;
50 std::set<ldmx::TrigScintID> noise_hit_i_ds;
51
52 auto num_rec_hits{0};
53
54
59
60 int module{-1};
61 for (const auto &sim_hit : sim_hits) {
63
64
65
66
67 module = id.module();
68 std::vector<float> position = sim_hit.getPosition();
69 ldmx_log(trace) << " Module ID = " << id.raw();
70
71
72 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
73 auto contrib = sim_hit.getContrib(i);
74
75 ldmx_log(trace) << "contrib " << i << " trackID: " << contrib.track_id_
76 << " pdgID: " << contrib.pdg_code_
77 << " edep: " << contrib.edep_;
78 ldmx_log(trace) << "\t particle id: "
79 << particle_map[contrib.track_id_].getPdgID()
80 << " particle status: "
81 << particle_map[contrib.track_id_].getGenStatus();
82
83 if (particle_map[contrib.track_id_].getPdgID() == 11 &&
84 particle_map[contrib.track_id_].getGenStatus() == 1) {
85 if (beam_frac.find(id) == beam_frac.end()) {
86 beam_frac[id] = contrib.edep_;
87 } else {
88 beam_frac[id] += contrib.edep_;
89 }
90 }
91 }
92
93
94
95
96
97 if (edep.find(id) == edep.end()) {
98
99 edep[id] = sim_hit.getEdep();
100 time[id] = sim_hit.getTime() * sim_hit.getEdep();
101 xpos[id] = position[0] * sim_hit.getEdep();
102 ypos[id] = position[1] * sim_hit.getEdep();
103 zpos[id] = position[2] * sim_hit.getEdep();
104 num_rec_hits++;
105
106 } else {
107
108 xpos[id] += position[0] * sim_hit.getEdep();
109 ypos[id] += position[1] * sim_hit.getEdep();
110 zpos[id] += position[2] * sim_hit.getEdep();
111 edep[id] += sim_hit.getEdep();
112
113 time[id] += sim_hit.getTime() * sim_hit.getEdep();
114 }
115 }
116
117
118 std::vector<ldmx::TrigScintHit> trig_scint_hits;
119
120
121 for (std::map<ldmx::TrigScintID, float>::iterator it = edep.begin();
122 it != edep.end(); ++it) {
124
125 double dep_energy = edep[id];
126 time[id] = time[id] / edep[id];
127 xpos[id] = xpos[id] / edep[id];
128 ypos[id] = ypos[id] / edep[id];
129 zpos[id] = zpos[id] / edep[id];
130
132 std::poisson_distribution<int> poisson_dist(mean_pe +
mean_noise_);
133 cell_pes[id] = poisson_dist(
rng_);
134
135
137 double cell_energy = energy_per_pe * cell_pes[id];
138
139
140
141
142
143 if (cell_pes[id] >= 1) {
146 hit.
setPE(cell_pes[
id]);
158
159 trig_scint_hits.push_back(hit);
160 }
161
162 ldmx_log(debug) << " ID = " << id.raw() << " Edep: " << edep[id]
163 << " numPEs: " << cell_pes[id] << " time: " << time[id]
164 << " z: " << zpos[id] << "\t X: " << xpos[id]
165 << " Y: " << ypos[id] << " Z: " << zpos[id];
166 }
167
168
169
170
171
173 std::vector<double> noise_hits_pe =
175
177
178 for (auto &noise_hit_pe : noise_hits_pe) {
180
181 do {
182 temp_id = generateRandomID(module);
183 } while (edep.find(temp_id) != edep.end() ||
184 noise_hit_i_ds.find(temp_id) != noise_hit_i_ds.end());
185
187
188 noise_hit_i_ds.insert(noise_id);
190 hit.
setPE(noise_hit_pe);
202
203 trig_scint_hits.push_back(hit);
204 }
205
206
207
209}
void setYPos(float ypos)
Set the Y position of the hit [mm].
void setID(int id)
Set the detector ID.
void setZPos(float zpos)
Set the Z position of the hit [mm].
void setXPos(float xpos)
Set the X position of the hit [mm].
void setTime(float time)
Set the time of the hit [ns].
void setAmplitude(float amplitude)
Set the amplitude of the hit, which is proportional to the signal in the calorimeter cell without sam...
void setEnergy(float energy)
Set the calorimetric energy of the hit, corrected for sampling factors [MeV].
void setNoise(bool yes)
Set if this hit is a noise hit.
void setMinPE(float minpe)
Set the minimum number of photoelectrons estimated for this hit.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
void setPE(const float PE)
Set hit pe.
void setBarID(const int barID)
Set hit bar ID.
void setBeamEfrac(const float beamEfrac)
Set beam energy fraction of hit.
void setModuleID(const int moduleID)
Set hit module ID.
int bar() const
Get the value of the bar field from the ID.