Process the event and put new data products into it.
52 {
53 std::map<ldmx::TrigScintID, int> cell_pes, cell_min_p_es;
54 std::map<ldmx::TrigScintID, float> xpos, ypos, zpos, edep, time, beam_frac;
55 std::set<ldmx::TrigScintID> noise_hit_i_ds;
56
57 auto num_rec_hits{0};
58
59
64
65 int module{-1};
66 for (const auto& sim_hit : sim_hits) {
68
69
70
71
72 module = id.module();
73 std::vector<float> position = sim_hit.getPosition();
74 ldmx_log(trace) << " Module ID = " << id.raw();
75
76
77 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
78 auto contrib = sim_hit.getContrib(i);
79
80 ldmx_log(trace) << "contrib " << i << " trackID: " << contrib.track_id_
81 << " pdgID: " << contrib.pdg_code_
82 << " edep: " << contrib.edep_;
83 ldmx_log(trace) << "\t particle id: "
84 << particle_map[contrib.track_id_].getPdgID()
85 << " particle status: "
86 << particle_map[contrib.track_id_].getGenStatus();
87
88 if (particle_map[contrib.track_id_].getPdgID() == 11 &&
89 particle_map[contrib.track_id_].getGenStatus() == 1) {
90 if (beam_frac.find(id) == beam_frac.end()) {
91 beam_frac[id] = contrib.edep_;
92 } else {
93 beam_frac[id] += contrib.edep_;
94 }
95 }
96 }
97
98
99
100
101
102 if (edep.find(id) == edep.end()) {
103
104 edep[id] = sim_hit.getEdep();
105 time[id] = sim_hit.getTime() * sim_hit.getEdep();
106 xpos[id] = position[0] * sim_hit.getEdep();
107 ypos[id] = position[1] * sim_hit.getEdep();
108 zpos[id] = position[2] * sim_hit.getEdep();
109 num_rec_hits++;
110
111 } else {
112
113 xpos[id] += position[0] * sim_hit.getEdep();
114 ypos[id] += position[1] * sim_hit.getEdep();
115 zpos[id] += position[2] * sim_hit.getEdep();
116 edep[id] += sim_hit.getEdep();
117
118 time[id] += sim_hit.getTime() * sim_hit.getEdep();
119 }
120 }
121
122
123 std::vector<ldmx::TrigScintHit> trig_scint_hits;
124
125
126 for (std::map<ldmx::TrigScintID, float>::iterator it = edep.begin();
127 it != edep.end(); ++it) {
129
130 double dep_energy = edep[id];
131 time[id] = time[id] / edep[id];
132 xpos[id] = xpos[id] / edep[id];
133 ypos[id] = ypos[id] / edep[id];
134 zpos[id] = zpos[id] / edep[id];
135
137 std::poisson_distribution<int> poisson_dist(mean_pe +
mean_noise_);
138 cell_pes[id] = poisson_dist(
rng_);
139
140
142 double cell_energy = energy_per_pe * cell_pes[id];
143
144
145
146
147
148 if (cell_pes[id] >= 1) {
151 hit.
setPE(cell_pes[
id]);
163
164 trig_scint_hits.push_back(hit);
165 }
166
167 ldmx_log(debug) << " ID = " << id.raw() << " Edep: " << edep[id]
168 << " numPEs: " << cell_pes[id] << " time: " << time[id]
169 << " z: " << zpos[id] << "\t X: " << xpos[id]
170 << " Y: " << ypos[id] << " Z: " << zpos[id];
171 }
172
173
174
175
176
178 std::vector<double> noise_hits_pe =
180
182
183 for (auto& noise_hit_pe : noise_hits_pe) {
185
186 do {
187 temp_id = generateRandomID(module);
188 } while (edep.find(temp_id) != edep.end() ||
189 noise_hit_i_ds.find(temp_id) != noise_hit_i_ds.end());
190
192
193 noise_hit_i_ds.insert(noise_id);
195 hit.
setPE(noise_hit_pe);
207
208 trig_scint_hits.push_back(hit);
209 }
210
211
212
214}
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.