1#include "TrigScint/TrigScintTrackProducer.h"
12 max_delta_ = ps.
get<
double>(
14 max_delta_vert_ = ps.
get<
double>(
17 seeding_collection_ = ps.
get<std::string>(
18 "seeding_collection");
19 input_collections_ = ps.
get<std::vector<std::string>>(
20 "further_input_collections");
22 output_collection_ = ps.
get<std::string>(
"output_collection");
23 pass_name_ = ps.
get<std::string>(
"input_pass_name");
24 verbose_ = ps.
get<
int>(
"verbosity");
25 vert_bar_start_idx_ = ps.
get<
int>(
"vertical_bar_start_index");
26 n_bars_y_ = ps.
get<
int>(
"number_horizontal_bars");
27 bar_width_y_ = ps.
get<
double>(
"horizontal_bar_width");
28 bar_gap_y_ = ps.
get<
double>(
"horizontal_bar_gap");
29 n_bars_x_ = ps.
get<
int>(
"number_vertical_bars");
30 bar_width_x_ = ps.
get<
double>(
"vertical_bar_width");
31 bar_gap_x_ = ps.
get<
double>(
"vertical_bar_gap");
32 skip_last_ = ps.
get<
bool>(
"allow_skip_last_collection");
33 bar_length_y_ = ps.
get<
double>(
34 "horizontal_bar_length");
35 lut_tracking_ = ps.
get<
bool>(
"lut_tracking");
36 std::string lut_file =
37 ps.
get<std::string>(
"lut_file");
42 ldmx_log(info) <<
"In TrigScintTrackProducer: configure done!" << std::endl;
43 ldmx_log(info) <<
"Got parameters: \nSeeding: " << seeding_collection_
44 <<
"\nTolerance: " << max_delta_
45 <<
"\nInput: " << input_collections_.at(0) <<
" and "
46 << input_collections_.at(1)
47 <<
"\nInput pass name: " << pass_name_
48 <<
"\nAllow tracks with no hit in last collection: "
50 <<
"\nUsing LUT Tracking Method: " << lut_tracking_
51 <<
"\nIf using LUT Method, LUT from: " << lut_file
52 <<
"\nVertical bar start index: " << vert_bar_start_idx_
53 <<
"\nNumber of horizontal bars: " << n_bars_y_
54 <<
"\nHorizontal bar width: " << bar_width_y_
55 <<
"\nHorizontal bar gap: " << bar_gap_y_
56 <<
"\nNumber of vertical bars: " << n_bars_x_
57 <<
"\nVertical bar width: " << bar_width_x_
58 <<
"\nVertical bar gap: " << bar_gap_x_
59 <<
"\nOutput: " << output_collection_
60 <<
"\nVerbosity: " << verbose_;
63 y_conv_factor_ = (bar_width_y_ + bar_gap_y_) / 2.;
65 y_start_ = -(n_bars_y_ * (bar_width_y_ + bar_gap_y_) - bar_gap_y_) / 2.;
67 x_conv_factor_ = bar_width_x_ + bar_gap_x_;
69 x_start_ = -(n_bars_x_ * (bar_width_x_ + bar_gap_x_) - bar_gap_x_) / 2.;
72 std::ifstream file(lut_file);
74 EXCEPTION_RAISE(
"TrigScintTrackProducer",
75 "LUT file '" + lut_file +
"' not found! Make sure it's in the directory from which just is executed!");
80 while (file >> a >> b >> c) {
84 lut_.insert({p1, p2, p3});
87 ldmx_log(info) <<
"Loaded LUT with size: " << lut_.size();
103 <<
"TrigScintTrackProducer: produce() starts! Event number: "
104 <<
event.getEventHeader().getEventNumber();
106 if (!event.
exists(seeding_collection_, pass_name_)) {
107 ldmx_log(info) <<
"No collection called " << seeding_collection_
108 <<
"; skipping event";
113 if (!event.
exists(seeding_collection_, pass_name_)) {
114 ldmx_log(info) <<
"No collection called " << seeding_collection_
115 <<
"; skipping event";
119 seeding_collection_, pass_name_)};
120 uint num_seeds = seeds.size();
123 ldmx_log(debug) <<
"Got track seeding cluster collection "
124 << seeding_collection_ <<
" with " << num_seeds
128 if (!event.
exists(input_collections_.at(0), pass_name_)) {
129 ldmx_log(info) <<
"No collection called " << input_collections_.at(0)
130 <<
"; skipping event";
136 input_collections_.at(0), pass_name_)};
138 if (!event.
exists(input_collections_.at(1), pass_name_)) {
139 ldmx_log(info) <<
"No collection called "
140 << input_collections_.at(1)
142 <<
"; skipping event";
143 std::vector<ldmx::TrigScintTrack> empty{};
144 event.add(output_collection_, empty);
149 input_collections_.at(1), pass_name_)};
152 ldmx_log(debug) <<
"Got the other two pad collections:"
153 << input_collections_.at(0) <<
" with "
154 << clusters_pad1.size() <<
" entries, and "
155 << input_collections_.at(1) <<
" with "
156 << clusters_pad2.size() <<
" entries.";
158 std::vector<ldmx::TrigScintTrack> cleaned_tracks;
159 std::vector<ldmx::TrigScintTrack> cleaned_tracks_y;
160 std::vector<ldmx::TrigScintTrack> cleaned_tracks_x;
165 if (num_seeds && clusters_pad1.size()) {
170 for (
const auto& seed : seeds) {
173 float centroid = seed.getCentroid();
175 std::vector<ldmx::TrigScintTrack> track_candidates;
178 ldmx_log(debug) <<
"Got seed with centroid " << centroid;
185 for (
const auto &cluster1 : clusters_pad1) {
186 for (
const auto &cluster2 : clusters_pad2) {
187 float seed_bin = seed.getCentroid();
188 float pad1_bin = cluster1.getCentroid();
189 float pad2_bin = cluster2.getCentroid();
191 LUTKey key{seed_bin, pad1_bin,
194 if (lut_.find(key) != lut_.end()) {
195 std::vector<ldmx::TrigScintCluster> three_cluster_vec = {
196 seed, cluster1, cluster2};
199 track_candidates.push_back(track);
207 for (
const auto &cluster1 : clusters_pad1) {
209 ldmx_log(debug) <<
"\tGot pad1 cluster with centroid "
210 << cluster1.getCentroid();
212 if ((fabs(cluster1.getCentroid() - centroid) < max_delta_ &&
213 centroid < vert_bar_start_idx_) ||
214 (centroid >= vert_bar_start_idx_ &&
215 cluster1.getCentroid() >= vert_bar_start_idx_ &&
216 seed.getCentroidX() == cluster1.getCentroidX())) {
220 if (centroid >= vert_bar_start_idx_ &&
221 seed.getCentroidY() < cluster1.getCentroidY()) {
224 <<
"\tSkipping impossible x cluster combination "
225 "with y flags (tag up) ("
226 << seed.getCentroidY() <<
" " << cluster1.getCentroidY()
234 ldmx_log(debug) <<
"\t\tIt is close enough!. Check pad2";
239 std::vector<ldmx::TrigScintCluster> cluster_vec = {seed, cluster1};
241 bool has_match_dn =
false;
243 for (
const auto &cluster2 : clusters_pad2) {
245 ldmx_log(debug) <<
"\tGot pad2 cluster with centroid "
246 << cluster2.getCentroid();
249 if ((fabs(cluster2.getCentroid() - centroid) < max_delta_ &&
250 centroid < vert_bar_start_idx_) ||
251 (centroid >= vert_bar_start_idx_ &&
252 cluster2.getCentroid() >= vert_bar_start_idx_ &&
253 fabs(seed.getCentroidX() - cluster2.getCentroidX()) <=
260 if (centroid >= vert_bar_start_idx_ &&
261 (seed.getCentroidY() < cluster2.getCentroidY() ||
262 cluster1.getCentroidY() >
263 cluster2.getCentroidY())) {
265 <<
"\tSkipping impossible x cluster combination with y "
266 "flags (tag up dn) ("
267 << seed.getCentroidY() <<
" " << cluster1.getCentroidY()
268 <<
" " << cluster2.getCentroidY() <<
")";
275 ldmx_log(debug) <<
"\t\tIt is close enough!. Make a track";
280 std::vector<ldmx::TrigScintCluster> three_cluster_vec = {
281 seed, cluster1, cluster2};
290 track_candidates.push_back(track);
296 if (!has_match_dn && skip_last_) {
299 track_candidates.push_back(track);
313 if (track_candidates.size() == 0)
continue;
316 float min_residual = 1000;
319 if (track_candidates.size() > 1) {
323 ldmx_log(debug) <<
"Got " << track_candidates.size()
324 <<
" tracks to check.";
327 for (uint idx = 0; idx < track_candidates.size(); idx++) {
328 if ((track_candidates.at(idx)).getResidual() < min_residual) {
331 (track_candidates.at(idx)).getResidual();
335 <<
"Track at index " << idx
336 <<
" has smallest residual so far: " << min_residual;
346 tracks_.push_back(track_candidates.at(keep_idx));
348 ldmx_log(debug) <<
"Kept track at index " << keep_idx;
349 ldmx_log(trace) << track_candidates.at(keep_idx);
355 if (tracks_.size() == 0) {
357 ldmx_log(debug) <<
"No tracks found!";
359 std::vector<ldmx::TrigScintTrack> empty{};
360 event.add(output_collection_, empty);
371 std::vector keep_indices(tracks_.size(), 1);
373 ldmx_log(debug) <<
"vector of indices to keep has size "
374 << keep_indices.size();
376 for (uint idx = tracks_.size() - 1; idx > 0; idx--) {
380 for (
int idx_comp = idx - 1; idx_comp >= 0; idx_comp--) {
382 ldmx_log(debug) <<
"In track disambiguation loop, idx points at "
383 << idx <<
" and prev idx points at " << idx_comp;
391 < vert_bar_start_idx_))
393 2 * max_delta_vert_) &&
398 std::vector<ldmx::TrigScintCluster> consts_1 =
400 std::vector<ldmx::TrigScintCluster> consts_2 =
404 <<
"In track disambiguation loop, got the two tracks, "
405 "with nConstituents "
406 << consts_1.size() <<
" and " << consts_2.size()
407 <<
", respectively. ";
410 if (((consts_1[1].getCentroid() == consts_2[1].getCentroid() ||
411 ((consts_1.size() > 2) && (consts_2.size() > 2) &&
412 (consts_1[2].getCentroid() == consts_2[2].getCentroid()))) &&
416 ((consts_1[1].getCentroidX() == consts_2[1].getCentroidX()) ||
417 (consts_1[2].getCentroidX() == consts_2[2].getCentroidX()) ||
418 (consts_1[0].getCentroidX() ==
419 consts_2[0].getCentroidX())))) {
422 ldmx_log(debug) <<
"Found overlap! Tracks at index " << idx
423 <<
" and " << idx_comp;
424 ldmx_log(trace) << tracks_.at(idx);
425 ldmx_log(trace) << tracks_.at(idx_comp);
428 if (((fabs((tracks_.at(idx)).getResidualX() -
429 (tracks_.at(idx_comp)).getResidualX())) < 0.01)
432 }
else if (((tracks_.at(idx)).getResidual() <
433 (tracks_.at(idx_comp)).getResidual() &&
435 ((tracks_.at(idx)).getResidualX() <
436 (tracks_.at(idx_comp)).getResidualX() &&
440 keep_indices.at(idx_comp) = 0;
444 keep_indices.at(idx) = 0;
462 for (uint idx = 0; idx < tracks_.size(); idx++) {
464 ldmx_log(debug) <<
"keep flag for idx " << idx <<
" is "
465 << keep_indices.at(idx);
467 if (keep_indices.at(idx)) {
469 cleaned_tracks.push_back(tracks_.at(idx));
472 ldmx_log(debug) <<
"After cleaning, keeping track at index " << idx
473 <<
": Centroid = " << (tracks_.at(idx)).getCentroid()
475 << (tracks_.at(idx)).getCentroidX()
477 << (tracks_.at(idx)).getCentroidY()
478 <<
"; track PE = " << (tracks_.at(idx)).getPE()
485 for (uint idx = 0; idx < tracks_.size(); idx++) {
486 ldmx_log(debug) <<
"Keeping track at index " << idx <<
":"
492 ldmx_log(debug) <<
"Running track x,y matching ";
495 if (cleaned_tracks.size() > 0) {
496 matchXYTracks(cleaned_tracks);
497 std::vector<ldmx::TrigScintTrack> matched_tracks =
503 for (
auto trk : matched_tracks) {
514 if (trk.getCentroid() >= vert_bar_start_idx_)
515 cleaned_tracks_x.push_back(trk);
517 cleaned_tracks_y.push_back(trk);
520 float centr = trk.getCentroid();
521 std::string coll_str = centr >= vert_bar_start_idx_ ?
"X" :
"Y";
522 coll_str = output_collection_ + coll_str;
523 ldmx_log(debug) <<
"saving track with centroid " << centr
524 <<
" to output track collection " << coll_str;
533 <<
"Not all pads had clusters; (maybe) skipping tracking attempt";
537 ldmx_log(debug) <<
"Done with tracking step. ";
540 event.add(output_collection_, cleaned_tracks);
543 event.add(output_collection_ +
"Y", cleaned_tracks_y);
544 event.add(output_collection_ +
"X", cleaned_tracks_x);
552 std::vector<ldmx::TrigScintCluster> clusters) {
559 float centroid_x = 0;
560 float centroid_y = 0;
561 float beam_efrac = 0;
563 for (uint i = 0; i < clusters.size(); i++) {
564 centroid += (clusters.at(i)).getCentroid();
565 centroid_x += (clusters.at(i)).getCentroidX();
566 centroid_y += (clusters.at(i)).getCentroidY();
568 beam_efrac += (clusters.at(i)).getBeamEfrac();
569 pe += (clusters.at(i)).getPE();
571 centroid /= clusters.size();
572 centroid_x /= clusters.size();
573 if (centroid >= vert_bar_start_idx_) {
576 <<
" -- In makeTrack made vertical bar track with centroid "
577 << centroid <<
" and y flag sum " << centroid_y;
589 centroid_y = (centroid_y + 1) * 2 * n_bars_y_ / 8.;
593 if (verbose_) ldmx_log(debug) <<
" -- new centroidY = " << centroid_y;
595 centroid_y /= clusters.size();
597 beam_efrac /= clusters.size();
598 pe /= clusters.size();
601 for (uint i = 0; i < clusters.size(); i++)
602 residual += ((clusters.at(i)).getCentroid() - centroid) *
603 ((clusters.at(i)).getCentroid() - centroid);
604 residual = sqrt(residual / clusters.size());
606 float residual_x = 0;
607 if (centroid >= vert_bar_start_idx_) {
608 for (uint i = 0; i < clusters.size(); i++)
609 residual_x += ((clusters.at(i)).getCentroidX() - centroid_x) *
610 ((clusters.at(i)).getCentroidX() - centroid_x);
611 residual_x = sqrt(residual_x / clusters.size());
623 ldmx_log(debug) <<
" -- In makeTrack made track with centroid "
624 << centroid <<
" and residual " << residual <<
" and pe "
625 << pe <<
" from clusters with centroids";
626 for (uint i = 0; i < clusters.size(); i++)
627 ldmx_log(debug) <<
"\tpad " << i <<
": centroid "
628 << (clusters.at(i)).getCentroid();
635void TrigScintTrackProducer::matchXYTracks(
636 std::vector<ldmx::TrigScintTrack>& tracks) {
638 std::multimap<int, int>
640 std::multimap<int, int> x_idx_quad_map;
642 std::multimap<int, ldmx::TrigScintTrack> y_quad_map;
643 std::multimap<int, ldmx::TrigScintTrack> x_quad_map;
646 std::map<ldmx::TrigScintTrack, int> y_track_map;
647 std::map<ldmx::TrigScintTrack, int> x_track_map;
650 for (
auto trk : tracks) {
653 if (trk.getCentroidX() == -1) {
655 ldmx_log(debug) <<
" -- In matchXYTracks found y track at "
656 << trk.getCentroidY() <<
"; mapping to quad "
657 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
658 <<
" with trk index " << trk_idx;
662 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
663 y_track_map[trk] = trk_idx;
664 y_idx_quad_map.insert(
665 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
670 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
671 x_track_map[trk] = trk_idx;
672 x_idx_quad_map.insert(
673 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
675 ldmx_log(debug) <<
" -- In matchXYTracks found x track at (x,y) = ("
676 << trk.getCentroidX() <<
", " << trk.getCentroidY()
677 <<
"); mapping to quad "
678 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
679 <<
" with trk index " << trk_idx;
694 float sx0 = fabs(x_start_);
695 float sx0_vert = fabs(bar_length_y_ / 2);
699 float sy0 = fabs(y_start_) / 4.;
703 for (
auto yitr = y_quad_map.begin(); yitr != y_quad_map.end(); ++yitr) {
704 int n_yin_quad = y_quad_map.count((*yitr).first);
705 int n_xin_quad = x_quad_map.count((*yitr).first);
706 float y{-9999.}, sy{-9999.}, x{-9999.}, x1{-9999.}, x2{-9999.}, sx1{-9999.},
707 sx2{-9999.}, y1{-9999.}, y2{-9999.}, sy1{-9999.}, sy2{-9999.};
709 float y0 = (((*yitr).first * 8) * y_conv_factor_) + y_start_ + sy0;
716 if (n_xin_quad == 0) {
721 ldmx_log(debug) <<
"\t\t\t no x info in quad " << (*yitr).first
722 <<
"; will set x to middle of pad, pad half-width as "
723 "precision: set (x, sx)=("
724 << x <<
", " << sx <<
")";
726 else if (n_xin_quad ==
731 auto xitr = x_quad_map.find((*yitr).first);
732 x = ((*xitr).second).getCentroidX() * x_conv_factor_ + x_start_;
735 ldmx_log(debug) <<
"\t\t\t 1 x in quad " << (*yitr).first
736 <<
", getting (x, sx)=(" << x <<
", " << sx <<
")";
738 else if (n_xin_quad == 2) {
743 auto xitr1 = x_quad_map.lower_bound((*yitr).first);
744 auto xitr2 = x_quad_map.upper_bound((*yitr).first);
747 if (xitr1 != xitr2) {
748 x1 = ((*xitr1).second).getCentroidX() * x_conv_factor_ + x_start_;
749 x2 = ((*xitr2).second).getCentroidX() * x_conv_factor_ + x_start_;
750 sx1 = x_conv_factor_ / 2.;
754 sx = fabs(x1 - x2) /2;
756 ldmx_log(debug) <<
"\t\t -- 2 x in quad: setting y track x "
757 "coordinate to midpoint";
761 if (n_xin_quad >= 3) {
766 <<
"\t\t\t currently no x info assigned in ambiguous case of "
767 << n_xin_quad <<
"vertical bar track candidates in quad "
769 <<
"; will set x to middle of pad, pad half-width as "
770 "precision: set (x, sx)=("
771 << x <<
", " << sx <<
")";
776 if (n_yin_quad == 1) {
778 y = ((*yitr).second).getCentroidY() * y_conv_factor_ + y_start_;
779 sy = ((*yitr).second).getResidual() * y_conv_factor_;
782 if (sy == 0) sy = 1. / 2 * y_conv_factor_;
784 if (n_xin_quad <= 1) {
788 if (n_xin_quad == 1) {
789 auto xidx = x_idx_quad_map.find((*yitr).first);
790 tracks.at((*xidx).second).setPosition(x, y);
791 tracks.at((*xidx).second).setSigmaXY(sx, sy);
794 ldmx_log(debug) <<
"\t\t\t in quad " << (*yitr).first
795 <<
", set (x, y) = (" << x <<
", " << y
796 <<
") and (sx, sy) = " << sx <<
", " << sy <<
")";
797 auto yidx = y_idx_quad_map.find((*yitr).first);
798 tracks.at((*yidx).second).setPosition(x, y);
799 tracks.at((*yidx).second).setSigmaXY(sx, sy);
805 ldmx_log(debug) <<
"\t\t in quad " << (*yitr).first
806 <<
", not single x,y tracks: " << n_xin_quad
807 <<
" of x and " << n_yin_quad <<
" of y";
809 if (n_yin_quad == 2) {
812 auto yitr1 = y_quad_map.lower_bound((*yitr).first);
813 auto yitr2 = y_quad_map.upper_bound((*yitr).first);
815 y1 = ((*yitr1).second).getCentroidY() * y_conv_factor_ + y_start_;
816 y2 = ((*yitr2).second).getCentroidY() * y_conv_factor_ + y_start_;
817 sy1 = ((*yitr1).second).getResidual() * y_conv_factor_;
818 sy2 = ((*yitr2).second).getResidual() * y_conv_factor_;
819 if (sy1 == 0) sy1 = 1. / 2 * y_conv_factor_;
820 if (sy2 == 0) sy2 = 1. / 2 * y_conv_factor_;
822 sy = fabs(y1 - y2) / 2;
825 <<
"\t\t -- 2 y in quad: setting x track y coordinate to midpoint";
828 if ((n_xin_quad == 0 || n_xin_quad >= 3) &&
830 if (n_xin_quad == 0) {
832 ldmx_log(debug) <<
"\t\t -- No x tracks but 2 y tracks in quad: "
835 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
836 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
838 tracks.at((*yidx1).second).setPosition(x, y1);
839 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
840 tracks.at((*yidx2).second).setPosition(x, y2);
841 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
845 if (n_yin_quad == 1 &&
851 auto yidx = y_idx_quad_map.find((*yitr).first);
852 tracks.at((*yidx).second).setPosition(x, y);
853 tracks.at((*yidx).second).setSigmaXY(sx, sy);
855 int min_overlap_pe = 250;
856 if (((*yitr).second).getPE() < min_overlap_pe) {
863 ldmx_log(debug) <<
"\t\t -- Can't tell which x track should be "
864 "matched to single y track. Setting both x track "
865 "coordinates to y quadrant value:";
868 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
869 << ((*yitr).second).getPE() <<
" > " << min_overlap_pe
870 <<
"), suggesting overlap! Setting both x track "
871 "coordinates to y track value:";
878 ldmx_log(debug) <<
"\t\t -- (x1, x2, y) = (" << x1 <<
", " << x2
879 <<
", " << y <<
") and (sx1, sx2, sy) = " << sx1 <<
", "
880 << sx2 <<
", " << sy <<
")";
883 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
884 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
886 tracks.at((*xidx1).second).setPosition(x1, y);
887 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
888 tracks.at((*xidx2).second).setPosition(x2, y);
889 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
892 else if (n_yin_quad == 2 && n_xin_quad == 1) {
897 auto xidx = x_idx_quad_map.find((*yitr).first);
898 tracks.at((*xidx).second).setPosition(x, y);
899 tracks.at((*xidx).second).setSigmaXY(sx, sy);
901 auto xitr = x_quad_map.lower_bound((*yitr).first);
902 int min_overlap_pe = 300;
903 if (((*xitr).second).getPE() < min_overlap_pe) {
906 <<
"\t\t just 1 x track with not-unusual PE in the quad -- can't "
907 "match; setting mid-point values for x ";
917 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
918 << ((*xitr).second).getPE() <<
" > " << min_overlap_pe
919 <<
") in x track, suggesting overlap! Setting both y "
920 "track coordinates to x track value:";
923 ldmx_log(debug) <<
"\t\t -- (x, y1, y2) = (" << x <<
", " << y1 <<
", "
924 << y2 <<
") and (sx, sy1, sy2) = " << sx <<
", " << sy1
925 <<
", " << sy2 <<
")";
927 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
928 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
930 tracks.at((*yidx1).second).setPosition(x, y1);
931 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
932 tracks.at((*yidx2).second).setPosition(x, y2);
933 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
936 else if (n_yin_quad == 2 && n_xin_quad == 2) {
938 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
939 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
941 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
942 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
945 if (y_idx_quad_map.find((*yitr).first) == y_idx_quad_map.end())
946 ldmx_log(error) <<
"The two y tracks in the same quadrant at "
948 <<
" appear to not be found in the y track map! "
949 "investigate. Note that yidx1.first = "
951 <<
" and yidx2.first = " << (*yidx2).first;
953 tracks.at((*xidx1).second).setPosition(x1, y);
954 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
955 tracks.at((*xidx2).second).setPosition(x2, y);
956 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
958 tracks.at((*yidx1).second).setPosition(x, y1);
959 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
960 tracks.at((*yidx2).second).setPosition(x, y2);
961 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
964 ldmx_log(debug) <<
"\t\t -- in a 2 x 2 situaiton; midpoint y: " << y
965 <<
" for both x tracks, midpoint x: " << x
966 <<
" for both y tracks";
970 if (n_xin_quad > 2) {
972 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 x tracks in the same quad "
973 "-- nothing done about the x,y coordinates in this "
974 "situation -- implement if needed!!";
976 if (n_yin_quad > 2) {
978 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 y tracks in the same quad "
979 "-- nothing done about the x,y coordinates in this "
980 "situation -- implement if needed!!";
992 ldmx_log(debug) <<
"Process starts!";
998 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,...