Process the event and put new data products into it.
46 {
47 std::map<ldmx::TrigScintID, int> cell_pes, cell_min_p_es;
48 std::map<ldmx::TrigScintID, float> xpos, ypos, zpos, edep, time, beam_frac;
49 std::set<ldmx::TrigScintID> noise_hit_i_ds;
50
51 auto num_rec_hits{0};
52
53
57 "SimParticles", sim_particles_passname_)};
58
59 int module{-1};
60 for (const auto &sim_hit : sim_hits) {
62
63
64
65
66 module = id.module();
67 std::vector<float> position = sim_hit.getPosition();
68 ldmx_log(trace) << " Module ID = " << id.raw();
69
70
71 for (int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
72 auto contrib = sim_hit.getContrib(i);
73
74 ldmx_log(trace) << "contrib " << i << " trackID: " << contrib.track_id_
75 << " pdgID: " << contrib.pdg_code_
76 << " edep: " << contrib.edep_;
77 ldmx_log(trace) << "\t particle id: "
78 << particle_map[contrib.track_id_].getPdgID()
79 << " particle status: "
80 << particle_map[contrib.track_id_].getGenStatus();
81
82 if (particle_map[contrib.track_id_].getPdgID() == 11 &&
83 particle_map[contrib.track_id_].getGenStatus() == 1) {
84 if (beam_frac.find(id) == beam_frac.end()) {
85 beam_frac[id] = contrib.edep_;
86 } else {
87 beam_frac[id] += contrib.edep_;
88 }
89 }
90 }
91
92
93
94
95
96 if (edep.find(id) == edep.end()) {
97
98 edep[id] = sim_hit.getEdep();
99 time[id] = sim_hit.getTime() * sim_hit.getEdep();
100 xpos[id] = position[0] * sim_hit.getEdep();
101 ypos[id] = position[1] * sim_hit.getEdep();
102 zpos[id] = position[2] * sim_hit.getEdep();
103 num_rec_hits++;
104
105 } else {
106
107 xpos[id] += position[0] * sim_hit.getEdep();
108 ypos[id] += position[1] * sim_hit.getEdep();
109 zpos[id] += position[2] * sim_hit.getEdep();
110 edep[id] += sim_hit.getEdep();
111
112 time[id] += sim_hit.getTime() * sim_hit.getEdep();
113 }
114 }
115
116
117 std::vector<ldmx::TrigScintHit> trig_scint_hits;
118
119
120 for (std::map<ldmx::TrigScintID, float>::iterator it = edep.begin();
121 it != edep.end(); ++it) {
123
124 double dep_energy = edep[id];
125 time[id] = time[id] / edep[id];
126 xpos[id] = xpos[id] / edep[id];
127 ypos[id] = ypos[id] / edep[id];
128 zpos[id] = zpos[id] / edep[id];
129
131 std::poisson_distribution<int> poisson_dist(mean_pe +
mean_noise_);
132 cell_pes[id] = poisson_dist(
rng_);
133
134
136 double cell_energy = energy_per_pe * cell_pes[id];
137
138
139
140
141
142 if (cell_pes[id] >= 1) {
145 hit.
setPE(cell_pes[
id]);
157
158 trig_scint_hits.push_back(hit);
159 }
160
161 ldmx_log(debug) << " ID = " << id.raw() << " Edep: " << edep[id]
162 << " numPEs: " << cell_pes[id] << " time: " << time[id]
163 << " z: " << zpos[id] << "\t X: " << xpos[id]
164 << " Y: " << ypos[id] << " Z: " << zpos[id];
165 }
166
167
168
169
170
172 std::vector<double> noise_hits_pe =
174
176
177 for (auto &noise_hit_pe : noise_hits_pe) {
179
180 do {
181 temp_id = generateRandomID(module);
182 } while (edep.find(temp_id) != edep.end() ||
183 noise_hit_i_ds.find(temp_id) != noise_hit_i_ds.end());
184
186
187 noise_hit_i_ds.insert(noise_id);
189 hit.
setPE(noise_hit_pe);
201
202 trig_scint_hits.push_back(hit);
203 }
204
205
206
208}
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.