125 <<
"TrigScintClusterProducer: produce() starts! Event number: "
126 <<
event.getEventHeader().getEventNumber();
135 ldmx_log(debug) <<
"Got digi collection " << input_collection_ <<
"_"
136 << pass_name_ <<
" with " << digis.size() <<
" entries ";
140 bool do_duplicate =
true;
144 for (
const auto &digi : digis) {
152 int id = digi.getBarID();
158 hit_channel_map_.find((
id)) != hit_channel_map_.end()) {
160 std::map<int, int>::iterator itr = hit_channel_map_.find(idx);
161 double old_val = digis.at(itr->second).getPE();
163 ldmx_log(debug) <<
"Got duplicate digis for channel " << idx
164 <<
", with already inserted value " << old_val
165 <<
" and new " << digi.getPE();
167 if (digi.getPE() > old_val) {
168 hit_channel_map_.erase(itr->first);
171 <<
"Skipped duplicate digi with smaller value for channel "
178 if (digi.getTime() > pad_time_ + time_tolerance_) {
183 hit_channel_map_.insert(std::pair<int, int>(
id, i_digi));
187 ldmx_log(debug) <<
"Mapping digi hit nb " << i_digi
188 <<
" with energy = " << digi.getEnergy()
189 <<
" MeV, nPE = " << digi.getPE() <<
" > " << min_thr_
190 <<
" to key/channel " << id;
198 std::map<int, int>::iterator itr;
201 std::vector<ldmx::TrigScintCluster> trig_scint_clusters;
204 for (itr = hit_channel_map_.begin(); itr != hit_channel_map_.end(); ++itr) {
206 if (hit_channel_map_.find(itr->first) == hit_channel_map_.end()) {
208 ldmx_log(debug) <<
"Attempting to use removed hit at channel "
209 << itr->first <<
"; skipping.";
218 bool has_used =
false;
219 for (
const auto &index : v_used_indices_) {
220 if (index == itr->first) {
222 ldmx_log(warn) <<
"Attempting to re-use hit at channel " << itr->first
228 if (has_used)
continue;
230 ldmx_log(debug) <<
"\t At hit with channel nb " << itr->first <<
".";
233 if (hit_channel_map_.size() ==
237 ldmx_log(warn) <<
"Time flies, and all clusters have already been "
238 "removed! Unclear how we even got here; interfering "
239 "here to get out of the loop. ";
246 if (digi.
getPE() >= seed_) {
248 ldmx_log(debug) <<
"Seeding cluster with channel " << itr->first
249 <<
"; content " << digi.
getPE();
257 ldmx_log(debug) <<
"\t itr is pointing at hit with channel nb "
258 << itr->first <<
".";
265 std::map<int, int>::iterator itr_back =
266 hit_channel_map_.find(itr->first - 1);
268 bool has_backed =
false;
279 for (
const auto &index : v_used_indices_) {
280 if (index == itr_back->first) {
282 ldmx_log(warn) <<
"Attempting to re-use hit at channel "
283 << itr_back->first <<
"; skipping.";
292 addHit(itr_back->first, digi);
296 ldmx_log(debug) <<
"Added -1 channel " << itr_back->first
297 <<
" to cluster; content " << digi.
getPE();
298 ldmx_log(debug) <<
"\t itr is pointing at hit with channel nb "
299 << itr->first <<
".";
314 if (v_added_indices_.size() < max_width_) {
317 std::map<int, int>::iterator itr_neighb =
318 hit_channel_map_.find(itr->first + 1);
325 if (hit_channel_map_.find(itr_neighb->first + 1) !=
326 hit_channel_map_.end()) {
333 addHit(itr_neighb->first, digi);
337 <<
"No -1 hit. Added +1 channel " << itr_neighb->first
338 <<
" to cluster; content " << digi.
getPE();
339 ldmx_log(debug) <<
"\t itr is pointing at hit with channel nb "
340 << itr->first <<
".";
343 if (v_added_indices_.size() < max_width_) {
344 if (hit_channel_map_.find(itr_neighb->first + 2) ==
348 itr_neighb = hit_channel_map_.find(itr->first + 2);
350 addHit(itr_neighb->first, digi);
353 <<
"No +3 hit. Added +2 channel " << itr_neighb->first
354 <<
" to cluster; content " << digi.
getPE();
356 <<
"\t itr is pointing at hit with channel nb "
357 << itr->first <<
".";
368 addHit(itr_neighb->first, digi);
372 <<
"Added +1 channel " << itr_neighb->first
373 <<
" as last channel to cluster; content " << digi.
getPE();
374 ldmx_log(debug) <<
"\t itr is pointing at hit with channel nb "
375 << itr->first <<
".";
382 else if (has_backed &&
383 hit_channel_map_.find(itr_back->first - 1) !=
387 itr_back = hit_channel_map_.find(itr->first - 2);
389 addHit(itr_back->first, digi);
392 ldmx_log(debug) <<
"Added -2 channel " << itr_back->first
393 <<
" to cluster; content " << digi.
getPE();
396 ldmx_log(debug) <<
"\t itr is pointing at hit with channel nb "
397 << itr->first <<
".";
411 ldmx_log(debug) <<
"Now have " << v_added_indices_.size()
412 <<
" hits in the cluster ";
414 cluster.
setSeed(v_added_indices_.at(0));
415 cluster.
setIDs(v_added_indices_);
416 cluster.
setNHits(v_added_indices_.size());
419 float cy = centroid_;
422 if (centroid_ < vert_bar_start_idx_) {
428 cx = (int)((centroid_ - vert_bar_start_idx_) / 4);
429 cy = (int)centroid_ % 4;
437 trig_scint_clusters.push_back(cluster);
439 ldmx_log(trace) << cluster;
449 v_added_indices_.resize(0);
453 <<
"\t Finished processing of seeding hit with channel nb "
454 << itr->first <<
".";
459 if (hit_channel_map_.begin() == hit_channel_map_.end()) {
461 ldmx_log(warn) <<
"Time flies, and all clusters have already been "
462 "removed! Interfering here to get out of the loop. ";
467 if (trig_scint_clusters.size() > 0)
468 event.add(output_collection_, trig_scint_clusters);
470 hit_channel_map_.clear();
472 v_used_indices_.resize(0);