1#include "TrigScint/TrigScintTrackProducer.h"
11 max_delta_ = ps.
get<
double>(
13 max_delta_vert_ = ps.
get<
double>(
16 seeding_collection_ = ps.
get<std::string>(
17 "seeding_collection");
18 input_collections_ = ps.
get<std::vector<std::string>>(
19 "further_input_collections");
21 output_collection_ = ps.
get<std::string>(
"output_collection");
22 pass_name_ = ps.
get<std::string>(
"input_pass_name");
23 verbose_ = ps.
get<
int>(
"verbosity");
24 vert_bar_start_idx_ = ps.
get<
int>(
"vertical_bar_start_index");
25 n_bars_y_ = ps.
get<
int>(
"number_horizontal_bars");
26 bar_width_y_ = ps.
get<
double>(
"horizontal_bar_width");
27 bar_gap_y_ = ps.
get<
double>(
"horizontal_bar_gap");
28 n_bars_x_ = ps.
get<
int>(
"number_vertical_bars");
29 bar_width_x_ = ps.
get<
double>(
"vertical_bar_width");
30 bar_gap_x_ = ps.
get<
double>(
"vertical_bar_gap");
31 skip_last_ = ps.
get<
bool>(
"allow_skip_last_collection");
32 bar_length_y_ = ps.
get<
double>(
33 "horizontal_bar_length");
34 lut_tracking_ = ps.
get<
bool>(
"lut_tracking");
35 std::string lut_file =
36 ps.
get<std::string>(
"lut_file");
41 ldmx_log(info) <<
"In TrigScintTrackProducer: configure done!" << std::endl;
42 ldmx_log(info) <<
"Got parameters: \nSeeding: " << seeding_collection_
43 <<
"\nTolerance: " << max_delta_
44 <<
"\nInput: " << input_collections_.at(0) <<
" and "
45 << input_collections_.at(1)
46 <<
"\nInput pass name: " << pass_name_
47 <<
"\nAllow tracks with no hit in last collection: "
49 <<
"\nUsing LUT Tracking Method: " << lut_tracking_
50 <<
"\nIf using LUT Method, LUT from: " << lut_file
51 <<
"\nVertical bar start index: " << vert_bar_start_idx_
52 <<
"\nNumber of horizontal bars: " << n_bars_y_
53 <<
"\nHorizontal bar width: " << bar_width_y_
54 <<
"\nHorizontal bar gap: " << bar_gap_y_
55 <<
"\nNumber of vertical bars: " << n_bars_x_
56 <<
"\nVertical bar width: " << bar_width_x_
57 <<
"\nVertical bar gap: " << bar_gap_x_
58 <<
"\nOutput: " << output_collection_
59 <<
"\nVerbosity: " << verbose_;
62 y_conv_factor_ = (bar_width_y_ + bar_gap_y_) / 2.;
64 y_start_ = -(n_bars_y_ * (bar_width_y_ + bar_gap_y_) - bar_gap_y_) / 2.;
66 x_conv_factor_ = bar_width_x_ + bar_gap_x_;
68 x_start_ = -(n_bars_x_ * (bar_width_x_ + bar_gap_x_) - bar_gap_x_) / 2.;
71 std::ifstream file(lut_file);
73 EXCEPTION_RAISE(
"TrigScintTrackProducer",
74 "LUT file '" + lut_file +
75 "' not found! Make sure it's in the directory from "
76 "which just is executed!");
81 while (file >> a >> b >> c) {
85 lut_.insert({p1, p2, p3});
88 ldmx_log(info) <<
"Loaded LUT with size: " << lut_.size();
104 <<
"TrigScintTrackProducer: produce() starts! Event number: "
105 <<
event.getEventHeader().getEventNumber();
107 if (!event.
exists(seeding_collection_, pass_name_)) {
108 ldmx_log(info) <<
"No collection called " << seeding_collection_
109 <<
"; skipping event";
114 if (!event.
exists(seeding_collection_, pass_name_)) {
115 ldmx_log(info) <<
"No collection called " << seeding_collection_
116 <<
"; skipping event";
120 seeding_collection_, pass_name_)};
121 uint num_seeds = seeds.size();
124 ldmx_log(debug) <<
"Got track seeding cluster collection "
125 << seeding_collection_ <<
" with " << num_seeds
129 if (!event.
exists(input_collections_.at(0), pass_name_)) {
130 ldmx_log(info) <<
"No collection called " << input_collections_.at(0)
131 <<
"; skipping event";
137 input_collections_.at(0), pass_name_)};
139 if (!event.
exists(input_collections_.at(1), pass_name_)) {
140 ldmx_log(info) <<
"No collection called "
141 << input_collections_.at(1)
143 <<
"; skipping event";
144 std::vector<ldmx::TrigScintTrack> empty{};
145 event.add(output_collection_, empty);
146 event.add(output_collection_ +
"Y", empty);
147 event.add(output_collection_ +
"X", empty);
152 input_collections_.at(1), pass_name_)};
155 ldmx_log(debug) <<
"Got the other two pad collections:"
156 << input_collections_.at(0) <<
" with "
157 << clusters_pad1.size() <<
" entries, and "
158 << input_collections_.at(1) <<
" with "
159 << clusters_pad2.size() <<
" entries.";
161 std::vector<ldmx::TrigScintTrack> cleaned_tracks;
162 std::vector<ldmx::TrigScintTrack> cleaned_tracks_y;
163 std::vector<ldmx::TrigScintTrack> cleaned_tracks_x;
168 if (num_seeds && clusters_pad1.size()) {
173 for (
const auto& seed : seeds) {
176 float centroid = seed.getCentroid();
178 std::vector<ldmx::TrigScintTrack> track_candidates;
181 ldmx_log(debug) <<
"Got seed with centroid " << centroid;
188 for (
const auto& cluster1 : clusters_pad1) {
189 for (
const auto& cluster2 : clusters_pad2) {
190 float seed_bin = seed.getCentroid();
191 float pad1_bin = cluster1.getCentroid();
192 float pad2_bin = cluster2.getCentroid();
194 LUTKey key{seed_bin, pad1_bin,
197 if (lut_.find(key) != lut_.end()) {
198 std::vector<ldmx::TrigScintCluster> three_cluster_vec = {
199 seed, cluster1, cluster2};
202 track_candidates.push_back(track);
210 for (
const auto& cluster1 : clusters_pad1) {
212 ldmx_log(debug) <<
"\tGot pad1 cluster with centroid "
213 << cluster1.getCentroid();
215 if ((fabs(cluster1.getCentroid() - centroid) < max_delta_ &&
216 centroid < vert_bar_start_idx_) ||
217 (centroid >= vert_bar_start_idx_ &&
218 cluster1.getCentroid() >= vert_bar_start_idx_ &&
219 seed.getCentroidX() == cluster1.getCentroidX())) {
223 if (centroid >= vert_bar_start_idx_ &&
224 seed.getCentroidY() < cluster1.getCentroidY()) {
226 ldmx_log(warn) <<
"\tSkipping impossible x cluster combination "
227 "with y flags (tag up) ("
228 << seed.getCentroidY() <<
" "
229 << cluster1.getCentroidY() <<
")";
236 ldmx_log(debug) <<
"\t\tIt is close enough!. Check pad2";
241 std::vector<ldmx::TrigScintCluster> cluster_vec = {seed, cluster1};
243 bool has_match_dn =
false;
245 for (
const auto& cluster2 : clusters_pad2) {
247 ldmx_log(debug) <<
"\tGot pad2 cluster with centroid "
248 << cluster2.getCentroid();
251 if ((fabs(cluster2.getCentroid() - centroid) < max_delta_ &&
252 centroid < vert_bar_start_idx_) ||
253 (centroid >= vert_bar_start_idx_ &&
254 cluster2.getCentroid() >= vert_bar_start_idx_ &&
255 fabs(seed.getCentroidX() - cluster2.getCentroidX()) <=
261 if (centroid >= vert_bar_start_idx_ &&
262 (seed.getCentroidY() < cluster2.getCentroidY() ||
263 cluster1.getCentroidY() >
264 cluster2.getCentroidY())) {
266 <<
"\tSkipping impossible x cluster combination with y "
267 "flags (tag up dn) ("
268 << seed.getCentroidY() <<
" " << cluster1.getCentroidY()
269 <<
" " << cluster2.getCentroidY() <<
")";
276 ldmx_log(debug) <<
"\t\tIt is close enough!. Make a track";
281 std::vector<ldmx::TrigScintCluster> three_cluster_vec = {
282 seed, cluster1, cluster2};
291 track_candidates.push_back(track);
297 if (!has_match_dn && skip_last_) {
300 track_candidates.push_back(track);
314 if (track_candidates.size() == 0)
continue;
317 float min_residual = 1000;
320 if (track_candidates.size() > 1) {
324 ldmx_log(debug) <<
"Got " << track_candidates.size()
325 <<
" tracks to check.";
328 for (uint idx = 0; idx < track_candidates.size(); idx++) {
329 if ((track_candidates.at(idx)).getResidual() < min_residual) {
332 (track_candidates.at(idx)).getResidual();
336 <<
"Track at index " << idx
337 <<
" has smallest residual so far: " << min_residual;
347 tracks_.push_back(track_candidates.at(keep_idx));
349 ldmx_log(debug) <<
"Kept track at index " << keep_idx;
350 ldmx_log(trace) << track_candidates.at(keep_idx);
356 if (tracks_.size() == 0) {
358 ldmx_log(debug) <<
"No tracks found!";
360 std::vector<ldmx::TrigScintTrack> empty{};
361 event.add(output_collection_, empty);
362 event.add(output_collection_ +
"Y", empty);
363 event.add(output_collection_ +
"X", empty);
374 std::vector keep_indices(tracks_.size(), 1);
376 ldmx_log(debug) <<
"vector of indices to keep has size "
377 << keep_indices.size();
379 for (uint idx = tracks_.size() - 1; idx > 0; idx--) {
383 for (
int idx_comp = idx - 1; idx_comp >= 0; idx_comp--) {
385 ldmx_log(debug) <<
"In track disambiguation loop, idx points at "
386 << idx <<
" and prev idx points at " << idx_comp;
395 vert_bar_start_idx_))
397 2 * max_delta_vert_) &&
402 std::vector<ldmx::TrigScintCluster> consts_1 =
404 std::vector<ldmx::TrigScintCluster> consts_2 =
408 <<
"In track disambiguation loop, got the two tracks, "
409 "with nConstituents "
410 << consts_1.size() <<
" and " << consts_2.size()
411 <<
", respectively. ";
414 if (((consts_1[1].getCentroid() == consts_2[1].getCentroid() ||
415 ((consts_1.size() > 2) && (consts_2.size() > 2) &&
416 (consts_1[2].getCentroid() == consts_2[2].getCentroid()))) &&
420 ((consts_1[1].getCentroidX() == consts_2[1].getCentroidX()) ||
421 (consts_1[2].getCentroidX() == consts_2[2].getCentroidX()) ||
422 (consts_1[0].getCentroidX() ==
423 consts_2[0].getCentroidX())))) {
426 ldmx_log(debug) <<
"Found overlap! Tracks at index " << idx
427 <<
" and " << idx_comp;
428 ldmx_log(trace) << tracks_.at(idx);
429 ldmx_log(trace) << tracks_.at(idx_comp);
432 if (((fabs((tracks_.at(idx)).getResidualX() -
433 (tracks_.at(idx_comp)).getResidualX())) <
437 vert_bar_start_idx_)) {
439 }
else if (((tracks_.at(idx)).getResidual() <
440 (tracks_.at(idx_comp)).getResidual() &&
442 ((tracks_.at(idx)).getResidualX() <
443 (tracks_.at(idx_comp)).getResidualX() &&
447 keep_indices.at(idx_comp) = 0;
451 keep_indices.at(idx) = 0;
469 for (uint idx = 0; idx < tracks_.size(); idx++) {
471 ldmx_log(debug) <<
"keep flag for idx " << idx <<
" is "
472 << keep_indices.at(idx);
474 if (keep_indices.at(idx)) {
476 cleaned_tracks.push_back(tracks_.at(idx));
479 ldmx_log(debug) <<
"After cleaning, keeping track at index " << idx
480 <<
": Centroid = " << (tracks_.at(idx)).getCentroid()
482 << (tracks_.at(idx)).getCentroidX()
484 << (tracks_.at(idx)).getCentroidY()
485 <<
"; track PE = " << (tracks_.at(idx)).getPE()
492 for (uint idx = 0; idx < tracks_.size(); idx++) {
493 ldmx_log(debug) <<
"Keeping track at index " << idx <<
":"
499 ldmx_log(debug) <<
"Running track x,y matching ";
502 if (cleaned_tracks.size() > 0) {
503 matchXYTracks(cleaned_tracks);
504 std::vector<ldmx::TrigScintTrack> matched_tracks =
510 for (
auto trk : matched_tracks) {
521 if (trk.getCentroid() >= vert_bar_start_idx_)
522 cleaned_tracks_x.push_back(trk);
524 cleaned_tracks_y.push_back(trk);
527 float centr = trk.getCentroid();
528 std::string coll_str = centr >= vert_bar_start_idx_ ?
"X" :
"Y";
529 coll_str = output_collection_ + coll_str;
530 ldmx_log(debug) <<
"saving track with centroid " << centr
531 <<
" to output track collection " << coll_str;
540 <<
"Not all pads had clusters; (maybe) skipping tracking attempt";
544 ldmx_log(debug) <<
"Done with tracking step. ";
547 event.add(output_collection_, cleaned_tracks);
550 event.add(output_collection_ +
"Y", cleaned_tracks_y);
551 event.add(output_collection_ +
"X", cleaned_tracks_x);
559 std::vector<ldmx::TrigScintCluster> clusters) {
566 float centroid_x = 0;
567 float centroid_y = 0;
568 float beam_efrac = 0;
570 for (uint i = 0; i < clusters.size(); i++) {
571 centroid += (clusters.at(i)).getCentroid();
572 centroid_x += (clusters.at(i)).getCentroidX();
573 centroid_y += (clusters.at(i)).getCentroidY();
575 beam_efrac += (clusters.at(i)).getBeamEfrac();
576 pe += (clusters.at(i)).getPE();
578 centroid /= clusters.size();
579 centroid_x /= clusters.size();
580 if (centroid >= vert_bar_start_idx_) {
583 <<
" -- In makeTrack made vertical bar track with centroid "
584 << centroid <<
" and y flag sum " << centroid_y;
596 centroid_y = (centroid_y + 1) * 2 * n_bars_y_ / 8.;
600 if (verbose_) ldmx_log(debug) <<
" -- new centroidY = " << centroid_y;
602 centroid_y /= clusters.size();
604 beam_efrac /= clusters.size();
605 pe /= clusters.size();
608 for (uint i = 0; i < clusters.size(); i++)
609 residual += ((clusters.at(i)).getCentroid() - centroid) *
610 ((clusters.at(i)).getCentroid() - centroid);
611 residual = sqrt(residual / clusters.size());
613 float residual_x = 0;
614 if (centroid >= vert_bar_start_idx_) {
615 for (uint i = 0; i < clusters.size(); i++)
616 residual_x += ((clusters.at(i)).getCentroidX() - centroid_x) *
617 ((clusters.at(i)).getCentroidX() - centroid_x);
618 residual_x = sqrt(residual_x / clusters.size());
630 ldmx_log(debug) <<
" -- In makeTrack made track with centroid "
631 << centroid <<
" and residual " << residual <<
" and pe "
632 << pe <<
" from clusters with centroids";
633 for (uint i = 0; i < clusters.size(); i++)
634 ldmx_log(debug) <<
"\tpad " << i <<
": centroid "
635 << (clusters.at(i)).getCentroid();
642void TrigScintTrackProducer::matchXYTracks(
643 std::vector<ldmx::TrigScintTrack>& tracks) {
645 std::multimap<int, int>
647 std::multimap<int, int> x_idx_quad_map;
649 std::multimap<int, ldmx::TrigScintTrack> y_quad_map;
650 std::multimap<int, ldmx::TrigScintTrack> x_quad_map;
653 std::map<ldmx::TrigScintTrack, int> y_track_map;
654 std::map<ldmx::TrigScintTrack, int> x_track_map;
657 for (
auto trk : tracks) {
660 if (trk.getCentroidX() == -1) {
662 ldmx_log(debug) <<
" -- In matchXYTracks found y track at "
663 << trk.getCentroidY() <<
"; mapping to quad "
664 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
665 <<
" with trk index " << trk_idx;
669 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
670 y_track_map[trk] = trk_idx;
671 y_idx_quad_map.insert(
672 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
677 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
678 x_track_map[trk] = trk_idx;
679 x_idx_quad_map.insert(
680 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
682 ldmx_log(debug) <<
" -- In matchXYTracks found x track at (x,y) = ("
683 << trk.getCentroidX() <<
", " << trk.getCentroidY()
684 <<
"); mapping to quad "
685 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
686 <<
" with trk index " << trk_idx;
701 float sx0 = fabs(x_start_);
702 float sx0_vert = fabs(bar_length_y_ / 2);
706 float sy0 = fabs(y_start_) / 4.;
710 for (
auto yitr = y_quad_map.begin(); yitr != y_quad_map.end(); ++yitr) {
711 int n_yin_quad = y_quad_map.count((*yitr).first);
712 int n_xin_quad = x_quad_map.count((*yitr).first);
713 float y{-9999.}, sy{-9999.}, x{-9999.}, x1{-9999.}, x2{-9999.}, sx1{-9999.},
714 sx2{-9999.}, y1{-9999.}, y2{-9999.}, sy1{-9999.}, sy2{-9999.};
716 float y0 = (((*yitr).first * 8) * y_conv_factor_) + y_start_ + sy0;
723 if (n_xin_quad == 0) {
728 ldmx_log(debug) <<
"\t\t\t no x info in quad " << (*yitr).first
729 <<
"; will set x to middle of pad, pad half-width as "
730 "precision: set (x, sx)=("
731 << x <<
", " << sx <<
")";
733 else if (n_xin_quad ==
738 auto xitr = x_quad_map.find((*yitr).first);
739 x = ((*xitr).second).getCentroidX() * x_conv_factor_ + x_start_;
742 ldmx_log(debug) <<
"\t\t\t 1 x in quad " << (*yitr).first
743 <<
", getting (x, sx)=(" << x <<
", " << sx <<
")";
745 else if (n_xin_quad == 2) {
750 auto xitr1 = x_quad_map.lower_bound((*yitr).first);
751 auto xitr2 = x_quad_map.upper_bound((*yitr).first);
754 if (xitr1 != xitr2) {
755 x1 = ((*xitr1).second).getCentroidX() * x_conv_factor_ + x_start_;
756 x2 = ((*xitr2).second).getCentroidX() * x_conv_factor_ + x_start_;
757 sx1 = x_conv_factor_ / 2.;
761 sx = fabs(x1 - x2) / 2;
763 ldmx_log(debug) <<
"\t\t -- 2 x in quad: setting y track x "
764 "coordinate to midpoint";
768 if (n_xin_quad >= 3) {
773 <<
"\t\t\t currently no x info assigned in ambiguous case of "
774 << n_xin_quad <<
"vertical bar track candidates in quad "
776 <<
"; will set x to middle of pad, pad half-width as "
777 "precision: set (x, sx)=("
778 << x <<
", " << sx <<
")";
783 if (n_yin_quad == 1) {
785 y = ((*yitr).second).getCentroidY() * y_conv_factor_ + y_start_;
786 sy = ((*yitr).second).getResidual() * y_conv_factor_;
789 if (sy == 0) sy = 1. / 2 * y_conv_factor_;
791 if (n_xin_quad <= 1) {
795 if (n_xin_quad == 1) {
796 auto xidx = x_idx_quad_map.find((*yitr).first);
797 tracks.at((*xidx).second).setPosition(x, y);
798 tracks.at((*xidx).second).setSigmaXY(sx, sy);
801 ldmx_log(debug) <<
"\t\t\t in quad " << (*yitr).first
802 <<
", set (x, y) = (" << x <<
", " << y
803 <<
") and (sx, sy) = " << sx <<
", " << sy <<
")";
804 auto yidx = y_idx_quad_map.find((*yitr).first);
805 tracks.at((*yidx).second).setPosition(x, y);
806 tracks.at((*yidx).second).setSigmaXY(sx, sy);
812 ldmx_log(debug) <<
"\t\t in quad " << (*yitr).first
813 <<
", not single x,y tracks: " << n_xin_quad
814 <<
" of x and " << n_yin_quad <<
" of y";
816 if (n_yin_quad == 2) {
819 auto yitr1 = y_quad_map.lower_bound((*yitr).first);
820 auto yitr2 = y_quad_map.upper_bound((*yitr).first);
822 y1 = ((*yitr1).second).getCentroidY() * y_conv_factor_ + y_start_;
823 y2 = ((*yitr2).second).getCentroidY() * y_conv_factor_ + y_start_;
824 sy1 = ((*yitr1).second).getResidual() * y_conv_factor_;
825 sy2 = ((*yitr2).second).getResidual() * y_conv_factor_;
826 if (sy1 == 0) sy1 = 1. / 2 * y_conv_factor_;
827 if (sy2 == 0) sy2 = 1. / 2 * y_conv_factor_;
829 sy = fabs(y1 - y2) / 2;
832 <<
"\t\t -- 2 y in quad: setting x track y coordinate to midpoint";
835 if ((n_xin_quad == 0 || n_xin_quad >= 3) &&
837 if (n_xin_quad == 0) {
839 ldmx_log(debug) <<
"\t\t -- No x tracks but 2 y tracks in quad: "
842 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
843 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
845 tracks.at((*yidx1).second).setPosition(x, y1);
846 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
847 tracks.at((*yidx2).second).setPosition(x, y2);
848 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
852 if (n_yin_quad == 1 &&
858 auto yidx = y_idx_quad_map.find((*yitr).first);
859 tracks.at((*yidx).second).setPosition(x, y);
860 tracks.at((*yidx).second).setSigmaXY(sx, sy);
862 int min_overlap_pe = 250;
863 if (((*yitr).second).getPE() < min_overlap_pe) {
870 ldmx_log(debug) <<
"\t\t -- Can't tell which x track should be "
871 "matched to single y track. Setting both x track "
872 "coordinates to y quadrant value:";
875 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
876 << ((*yitr).second).getPE() <<
" > " << min_overlap_pe
877 <<
"), suggesting overlap! Setting both x track "
878 "coordinates to y track value:";
885 ldmx_log(debug) <<
"\t\t -- (x1, x2, y) = (" << x1 <<
", " << x2
886 <<
", " << y <<
") and (sx1, sx2, sy) = " << sx1 <<
", "
887 << sx2 <<
", " << sy <<
")";
890 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
891 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
893 tracks.at((*xidx1).second).setPosition(x1, y);
894 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
895 tracks.at((*xidx2).second).setPosition(x2, y);
896 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
899 else if (n_yin_quad == 2 && n_xin_quad == 1) {
904 auto xidx = x_idx_quad_map.find((*yitr).first);
905 tracks.at((*xidx).second).setPosition(x, y);
906 tracks.at((*xidx).second).setSigmaXY(sx, sy);
908 auto xitr = x_quad_map.lower_bound((*yitr).first);
909 int min_overlap_pe = 300;
910 if (((*xitr).second).getPE() < min_overlap_pe) {
913 <<
"\t\t just 1 x track with not-unusual PE in the quad -- can't "
914 "match; setting mid-point values for x ";
924 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
925 << ((*xitr).second).getPE() <<
" > " << min_overlap_pe
926 <<
") in x track, suggesting overlap! Setting both y "
927 "track coordinates to x track value:";
930 ldmx_log(debug) <<
"\t\t -- (x, y1, y2) = (" << x <<
", " << y1 <<
", "
931 << y2 <<
") and (sx, sy1, sy2) = " << sx <<
", " << sy1
932 <<
", " << sy2 <<
")";
934 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
935 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
937 tracks.at((*yidx1).second).setPosition(x, y1);
938 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
939 tracks.at((*yidx2).second).setPosition(x, y2);
940 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
943 else if (n_yin_quad == 2 && n_xin_quad == 2) {
945 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
946 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
948 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
949 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
952 if (y_idx_quad_map.find((*yitr).first) == y_idx_quad_map.end())
953 ldmx_log(error) <<
"The two y tracks in the same quadrant at "
955 <<
" appear to not be found in the y track map! "
956 "investigate. Note that yidx1.first = "
958 <<
" and yidx2.first = " << (*yidx2).first;
960 tracks.at((*xidx1).second).setPosition(x1, y);
961 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
962 tracks.at((*xidx2).second).setPosition(x2, y);
963 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
965 tracks.at((*yidx1).second).setPosition(x, y1);
966 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
967 tracks.at((*yidx2).second).setPosition(x, y2);
968 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
971 ldmx_log(debug) <<
"\t\t -- in a 2 x 2 situaiton; midpoint y: " << y
972 <<
" for both x tracks, midpoint x: " << x
973 <<
" for both y tracks";
977 if (n_xin_quad > 2) {
979 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 x tracks in the same quad "
980 "-- nothing done about the x,y coordinates in this "
981 "situation -- implement if needed!!";
983 if (n_yin_quad > 2) {
985 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 y tracks in the same quad "
986 "-- nothing done about the x,y coordinates in this "
987 "situation -- implement if needed!!";
999 ldmx_log(debug) <<
"Process starts!";
1005 ldmx_log(debug) <<
"Process ends!";
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Implements an event buffer system for storing event data.
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.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Stores cluster information from the trigger scintillator pads.
Represents a track of trigger scintillator clusters.
void setCentroidX(float centroid)
Set the x centroid of the track.
void setResidual(float resid)
Set the detector ID residual of the track.
float getCentroidX() const
Get the x centroid of the track.
void setCentroidY(float centroid)
Set the y centroid of the track.
void setPE(float pe)
Set the average cluster pe of the track.
float getCentroid() const
Get the detector ID centroid of the track.
void addConstituent(TrigScintCluster cl)
Add a cluster to the list of track constituents.
void setCentroid(float centroid)
Set the detector ID centroid of the track.
void setBeamEfrac(float e)
Set beam energy fraction of hit.
std::vector< ldmx::TrigScintCluster > getConstituents() const
Get the cluster constituents of the track.
void setResidualX(float resid)
Set the x residual of the track.
float getCentroidY() const
Get the y centroid of the track.
making tracks from trigger scintillator clusters
void configure(framework::config::Parameters &ps) override
Callback for the EventProcessor to configure itself from the given set of parameters.
void onProcessEnd() override
Callback for the EventProcessor to take any necessary action when the processing of events finishes,...
void produce(framework::Event &event) override
Process the event and put new data products into it.
void onProcessStart() override
Callback for the EventProcessor to take any necessary action when the processing of events starts,...