Process the event and put new data products into it.
81 {
83
84 clearProcessor();
85
87 "SimParticles", sim_particles_pass_name_)};
88
89
90
91
92
93 std::vector<double> gamma_p(3);
94 std::vector<double> gamma_x0(3);
95 if (recoil_from_tracking_) {
96 const auto &recoil_tracks{
97 event.getCollection<
ldmx::Track>(track_collection_, track_pass_name_)};
98
99 for (auto &track : recoil_tracks) {
100
101 auto trk_pos = track.getPositionAtTarget();
102 auto trk_mom = track.getMomentumAtTarget();
103 if (track.getCharge() == 1 && track.getNhits() == 5 &&
104 trk_pos.size() == 3 && trk_mom.size() == 3) {
105 gamma_x0 = trk_pos;
106 gamma_p[0] = -1. * trk_mom[0];
107 gamma_p[1] = -1. * trk_mom[1];
108 gamma_p[2] = beam_energy_mev_ - trk_mom[2];
109 }
110 }
111 } else {
112 if (event.
exists(sp_collection_, sp_pass_name_)) {
114 sp_collection_, sp_pass_name_);
115 for (auto const &it : particle_map) {
116 for (auto const &sphit : target_sp_hits) {
117 if (sphit.getPosition()[2] > 0) {
118 if (it.first == sphit.getTrackID()) {
119 if (it.second.getPdgID() == 11 &&
120 inList(it.second.getParents(), 0)) {
121
122
123
124 std::vector<float> x0_float = sphit.getPosition();
125 std::vector<double> x0_double(x0_float.begin(), x0_float.end());
126 gamma_x0 = x0_double;
127 gamma_p[0] = -1. * sphit.getMomentum()[0];
128 gamma_p[1] = -1. * sphit.getMomentum()[1];
129 gamma_p[2] = beam_energy_mev_ - sphit.getMomentum()[2];
130 }
131 }
132 }
133 }
134 }
135 }
136 }
137
138
139 const auto &hcal_rec_hits =
140 event.getCollection<
ldmx::HcalHit>(rec_coll_name_, rec_pass_name_);
141
142 double z_mean = 0.;
143 std::vector<int> layers_hit;
145 if (hit.getEnergy() > 0.) {
147 if (det_id.getSection() != 0) {
148 continue;
149 }
150 n_readout_hits_ += 1;
151 double hit_x = hit.getXPos();
152 double hit_y = hit.getYPos();
153 double hit_z = hit.getZPos();
154 double hit_r = sqrt(hit_x * hit_x + hit_y * hit_y);
155
156 summed_det_ += hit.getEnergy();
157
158 x_mean_ += hit_x * hit.getEnergy();
159 y_mean_ += hit_y * hit.getEnergy();
160 z_mean += hit_z * hit.getEnergy();
161 r_mean_ += hit_r * hit.getEnergy();
162
163
164 if (!(std::find(layers_hit.begin(), layers_hit.end(),
165 det_id.getLayerID()) != layers_hit.end())) {
166 layers_hit.push_back(det_id.getLayerID());
167 }
168
169 double proj_x =
170 gamma_x0[0] + (hit_z - gamma_x0[2]) * gamma_p[0] / gamma_p[2];
171 double proj_y =
172 gamma_x0[1] + (hit_z - gamma_x0[2]) * gamma_p[1] / gamma_p[2];
173
174 r_mean_from_photon_track_ +=
175 hit.getEnergy() * sqrt((hit_x - proj_x) * (hit_x - proj_x) +
176 (hit_y - proj_y) * (hit_y - proj_y));
177
178
179 double closest_point = 9999.;
181 if (hit2.getEnergy() > 0.) {
183 if (det_i_d2.getLayerID() == det_id.getLayerID()) {
184
185
186
187 if (hit.isOrientationX()) {
188 if (abs(hit2.getYPos() - hit_y) > 0) {
189 if (abs(hit2.getYPos() - hit_y) < closest_point) {
190 closest_point = abs(hit2.getYPos() - hit_y);
191 }
192 }
193 }
194 if (hit.isOrientationY()) {
195 if (abs(hit2.getXPos() - hit_x) > 0) {
196 if (abs(hit2.getXPos() - hit_x) < closest_point) {
197 closest_point = abs(hit2.getXPos() - hit_x);
198 }
199 }
200 }
201 }
202 }
203 }
204 if (closest_point > 50.) {
205 iso_hits_ += 1;
206 iso_energy_ += hit.getEnergy();
207 }
208 }
209 }
210
211 n_layers_hit_ = layers_hit.size();
212
213 if (summed_det_ > 0.) {
214 x_mean_ /= summed_det_;
215 y_mean_ /= summed_det_;
216 z_mean /= summed_det_;
217 r_mean_ /= summed_det_;
218
219 r_mean_from_photon_track_ /= summed_det_;
220 }
221
223 if (hit.getEnergy() > 0.) {
225 if (det_id.getSection() == 0) {
226 x_std_ += hit.getEnergy() * (hit.getXPos() - x_mean_) *
227 (hit.getXPos() - x_mean_);
228 y_std_ += hit.getEnergy() * (hit.getYPos() - y_mean_) *
229 (hit.getYPos() - y_mean_);
230 z_std_ += hit.getEnergy() * (hit.getZPos() - z_mean) *
231 (hit.getZPos() - z_mean);
232 }
233 }
234 }
235
236 if (summed_det_ > 0.) {
237 x_std_ = sqrt(x_std_ / summed_det_);
238 y_std_ = sqrt(y_std_ / summed_det_);
239 z_std_ = sqrt(z_std_ / summed_det_);
240 }
241
242 result.setVariables(n_layers_hit_, x_std_, y_std_, z_std_, x_mean_, y_mean_,
243 r_mean_, iso_hits_, iso_energy_, n_readout_hits_,
244 summed_det_, r_mean_from_photon_track_);
245
246 buildBDTFeatureVector(result);
247
248 ldmx::ort::FloatArrays inputs({bdt_features_});
249 float pred =
250 rt_->run({feature_list_name_}, inputs, {"probabilities"})[0].at(1);
251 ldmx_log(info) << " Visibles BDT was ran, score is " << pred;
252
253 event.add(collection_name_, result);
254}
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Stores reconstructed hit information from the HCAL.
Implements detector ids for HCal subdetector.
Class representing a simulated particle.
Represents a simulated tracker hit in the simulation.
Implementation of a track object.