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 +
76 "' not found! Make sure it's in the directory from "
77 "which just is executed!");
82 while (file >> a >> b >> c) {
86 lut_.insert({p1, p2, p3});
89 ldmx_log(info) <<
"Loaded LUT with size: " << lut_.size();
105 <<
"TrigScintTrackProducer: produce() starts! Event number: "
106 <<
event.getEventHeader().getEventNumber();
108 if (!event.
exists(seeding_collection_, pass_name_)) {
109 ldmx_log(info) <<
"No collection called " << seeding_collection_
110 <<
"; skipping event";
115 if (!event.
exists(seeding_collection_, pass_name_)) {
116 ldmx_log(info) <<
"No collection called " << seeding_collection_
117 <<
"; skipping event";
121 seeding_collection_, pass_name_)};
122 uint num_seeds = seeds.size();
125 ldmx_log(debug) <<
"Got track seeding cluster collection "
126 << seeding_collection_ <<
" with " << num_seeds
130 if (!event.
exists(input_collections_.at(0), pass_name_)) {
131 ldmx_log(info) <<
"No collection called " << input_collections_.at(0)
132 <<
"; skipping event";
138 input_collections_.at(0), pass_name_)};
140 if (!event.
exists(input_collections_.at(1), pass_name_)) {
141 ldmx_log(info) <<
"No collection called "
142 << input_collections_.at(1)
144 <<
"; skipping event";
145 std::vector<ldmx::TrigScintTrack> empty{};
146 event.add(output_collection_, empty);
151 input_collections_.at(1), pass_name_)};
154 ldmx_log(debug) <<
"Got the other two pad collections:"
155 << input_collections_.at(0) <<
" with "
156 << clusters_pad1.size() <<
" entries, and "
157 << input_collections_.at(1) <<
" with "
158 << clusters_pad2.size() <<
" entries.";
160 std::vector<ldmx::TrigScintTrack> cleaned_tracks;
161 std::vector<ldmx::TrigScintTrack> cleaned_tracks_y;
162 std::vector<ldmx::TrigScintTrack> cleaned_tracks_x;
167 if (num_seeds && clusters_pad1.size()) {
172 for (
const auto& seed : seeds) {
175 float centroid = seed.getCentroid();
177 std::vector<ldmx::TrigScintTrack> track_candidates;
180 ldmx_log(debug) <<
"Got seed with centroid " << centroid;
187 for (
const auto& cluster1 : clusters_pad1) {
188 for (
const auto& cluster2 : clusters_pad2) {
189 float seed_bin = seed.getCentroid();
190 float pad1_bin = cluster1.getCentroid();
191 float pad2_bin = cluster2.getCentroid();
193 LUTKey key{seed_bin, pad1_bin,
196 if (lut_.find(key) != lut_.end()) {
197 std::vector<ldmx::TrigScintCluster> three_cluster_vec = {
198 seed, cluster1, cluster2};
201 track_candidates.push_back(track);
209 for (
const auto& cluster1 : clusters_pad1) {
211 ldmx_log(debug) <<
"\tGot pad1 cluster with centroid "
212 << cluster1.getCentroid();
214 if ((fabs(cluster1.getCentroid() - centroid) < max_delta_ &&
215 centroid < vert_bar_start_idx_) ||
216 (centroid >= vert_bar_start_idx_ &&
217 cluster1.getCentroid() >= vert_bar_start_idx_ &&
218 seed.getCentroidX() == cluster1.getCentroidX())) {
222 if (centroid >= vert_bar_start_idx_ &&
223 seed.getCentroidY() < cluster1.getCentroidY()) {
225 ldmx_log(warn) <<
"\tSkipping impossible x cluster combination "
226 "with y flags (tag up) ("
227 << seed.getCentroidY() <<
" "
228 << cluster1.getCentroidY() <<
")";
235 ldmx_log(debug) <<
"\t\tIt is close enough!. Check pad2";
240 std::vector<ldmx::TrigScintCluster> cluster_vec = {seed, cluster1};
242 bool has_match_dn =
false;
244 for (
const auto& cluster2 : clusters_pad2) {
246 ldmx_log(debug) <<
"\tGot pad2 cluster with centroid "
247 << cluster2.getCentroid();
250 if ((fabs(cluster2.getCentroid() - centroid) < max_delta_ &&
251 centroid < vert_bar_start_idx_) ||
252 (centroid >= vert_bar_start_idx_ &&
253 cluster2.getCentroid() >= vert_bar_start_idx_ &&
254 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;
392 vert_bar_start_idx_))
394 2 * max_delta_vert_) &&
399 std::vector<ldmx::TrigScintCluster> consts_1 =
401 std::vector<ldmx::TrigScintCluster> consts_2 =
405 <<
"In track disambiguation loop, got the two tracks, "
406 "with nConstituents "
407 << consts_1.size() <<
" and " << consts_2.size()
408 <<
", respectively. ";
411 if (((consts_1[1].getCentroid() == consts_2[1].getCentroid() ||
412 ((consts_1.size() > 2) && (consts_2.size() > 2) &&
413 (consts_1[2].getCentroid() == consts_2[2].getCentroid()))) &&
417 ((consts_1[1].getCentroidX() == consts_2[1].getCentroidX()) ||
418 (consts_1[2].getCentroidX() == consts_2[2].getCentroidX()) ||
419 (consts_1[0].getCentroidX() ==
420 consts_2[0].getCentroidX())))) {
423 ldmx_log(debug) <<
"Found overlap! Tracks at index " << idx
424 <<
" and " << idx_comp;
425 ldmx_log(trace) << tracks_.at(idx);
426 ldmx_log(trace) << tracks_.at(idx_comp);
429 if (((fabs((tracks_.at(idx)).getResidualX() -
430 (tracks_.at(idx_comp)).getResidualX())) <
434 vert_bar_start_idx_)) {
436 }
else if (((tracks_.at(idx)).getResidual() <
437 (tracks_.at(idx_comp)).getResidual() &&
439 ((tracks_.at(idx)).getResidualX() <
440 (tracks_.at(idx_comp)).getResidualX() &&
444 keep_indices.at(idx_comp) = 0;
448 keep_indices.at(idx) = 0;
466 for (uint idx = 0; idx < tracks_.size(); idx++) {
468 ldmx_log(debug) <<
"keep flag for idx " << idx <<
" is "
469 << keep_indices.at(idx);
471 if (keep_indices.at(idx)) {
473 cleaned_tracks.push_back(tracks_.at(idx));
476 ldmx_log(debug) <<
"After cleaning, keeping track at index " << idx
477 <<
": Centroid = " << (tracks_.at(idx)).getCentroid()
479 << (tracks_.at(idx)).getCentroidX()
481 << (tracks_.at(idx)).getCentroidY()
482 <<
"; track PE = " << (tracks_.at(idx)).getPE()
489 for (uint idx = 0; idx < tracks_.size(); idx++) {
490 ldmx_log(debug) <<
"Keeping track at index " << idx <<
":"
496 ldmx_log(debug) <<
"Running track x,y matching ";
499 if (cleaned_tracks.size() > 0) {
500 matchXYTracks(cleaned_tracks);
501 std::vector<ldmx::TrigScintTrack> matched_tracks =
507 for (
auto trk : matched_tracks) {
518 if (trk.getCentroid() >= vert_bar_start_idx_)
519 cleaned_tracks_x.push_back(trk);
521 cleaned_tracks_y.push_back(trk);
524 float centr = trk.getCentroid();
525 std::string coll_str = centr >= vert_bar_start_idx_ ?
"X" :
"Y";
526 coll_str = output_collection_ + coll_str;
527 ldmx_log(debug) <<
"saving track with centroid " << centr
528 <<
" to output track collection " << coll_str;
537 <<
"Not all pads had clusters; (maybe) skipping tracking attempt";
541 ldmx_log(debug) <<
"Done with tracking step. ";
544 event.add(output_collection_, cleaned_tracks);
547 event.add(output_collection_ +
"Y", cleaned_tracks_y);
548 event.add(output_collection_ +
"X", cleaned_tracks_x);
556 std::vector<ldmx::TrigScintCluster> clusters) {
563 float centroid_x = 0;
564 float centroid_y = 0;
565 float beam_efrac = 0;
567 for (uint i = 0; i < clusters.size(); i++) {
568 centroid += (clusters.at(i)).getCentroid();
569 centroid_x += (clusters.at(i)).getCentroidX();
570 centroid_y += (clusters.at(i)).getCentroidY();
572 beam_efrac += (clusters.at(i)).getBeamEfrac();
573 pe += (clusters.at(i)).getPE();
575 centroid /= clusters.size();
576 centroid_x /= clusters.size();
577 if (centroid >= vert_bar_start_idx_) {
580 <<
" -- In makeTrack made vertical bar track with centroid "
581 << centroid <<
" and y flag sum " << centroid_y;
593 centroid_y = (centroid_y + 1) * 2 * n_bars_y_ / 8.;
597 if (verbose_) ldmx_log(debug) <<
" -- new centroidY = " << centroid_y;
599 centroid_y /= clusters.size();
601 beam_efrac /= clusters.size();
602 pe /= clusters.size();
605 for (uint i = 0; i < clusters.size(); i++)
606 residual += ((clusters.at(i)).getCentroid() - centroid) *
607 ((clusters.at(i)).getCentroid() - centroid);
608 residual = sqrt(residual / clusters.size());
610 float residual_x = 0;
611 if (centroid >= vert_bar_start_idx_) {
612 for (uint i = 0; i < clusters.size(); i++)
613 residual_x += ((clusters.at(i)).getCentroidX() - centroid_x) *
614 ((clusters.at(i)).getCentroidX() - centroid_x);
615 residual_x = sqrt(residual_x / clusters.size());
627 ldmx_log(debug) <<
" -- In makeTrack made track with centroid "
628 << centroid <<
" and residual " << residual <<
" and pe "
629 << pe <<
" from clusters with centroids";
630 for (uint i = 0; i < clusters.size(); i++)
631 ldmx_log(debug) <<
"\tpad " << i <<
": centroid "
632 << (clusters.at(i)).getCentroid();
639void TrigScintTrackProducer::matchXYTracks(
640 std::vector<ldmx::TrigScintTrack>& tracks) {
642 std::multimap<int, int>
644 std::multimap<int, int> x_idx_quad_map;
646 std::multimap<int, ldmx::TrigScintTrack> y_quad_map;
647 std::multimap<int, ldmx::TrigScintTrack> x_quad_map;
650 std::map<ldmx::TrigScintTrack, int> y_track_map;
651 std::map<ldmx::TrigScintTrack, int> x_track_map;
654 for (
auto trk : tracks) {
657 if (trk.getCentroidX() == -1) {
659 ldmx_log(debug) <<
" -- In matchXYTracks found y track at "
660 << trk.getCentroidY() <<
"; mapping to quad "
661 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
662 <<
" with trk index " << trk_idx;
666 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
667 y_track_map[trk] = trk_idx;
668 y_idx_quad_map.insert(
669 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
674 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk));
675 x_track_map[trk] = trk_idx;
676 x_idx_quad_map.insert(
677 std::make_pair((
int)(trk.getCentroidY() / (n_bars_y_ / 2)), trk_idx));
679 ldmx_log(debug) <<
" -- In matchXYTracks found x track at (x,y) = ("
680 << trk.getCentroidX() <<
", " << trk.getCentroidY()
681 <<
"); mapping to quad "
682 << (int)trk.getCentroidY() / (n_bars_y_ / 2)
683 <<
" with trk index " << trk_idx;
698 float sx0 = fabs(x_start_);
699 float sx0_vert = fabs(bar_length_y_ / 2);
703 float sy0 = fabs(y_start_) / 4.;
707 for (
auto yitr = y_quad_map.begin(); yitr != y_quad_map.end(); ++yitr) {
708 int n_yin_quad = y_quad_map.count((*yitr).first);
709 int n_xin_quad = x_quad_map.count((*yitr).first);
710 float y{-9999.}, sy{-9999.}, x{-9999.}, x1{-9999.}, x2{-9999.}, sx1{-9999.},
711 sx2{-9999.}, y1{-9999.}, y2{-9999.}, sy1{-9999.}, sy2{-9999.};
713 float y0 = (((*yitr).first * 8) * y_conv_factor_) + y_start_ + sy0;
720 if (n_xin_quad == 0) {
725 ldmx_log(debug) <<
"\t\t\t no x info in quad " << (*yitr).first
726 <<
"; will set x to middle of pad, pad half-width as "
727 "precision: set (x, sx)=("
728 << x <<
", " << sx <<
")";
730 else if (n_xin_quad ==
735 auto xitr = x_quad_map.find((*yitr).first);
736 x = ((*xitr).second).getCentroidX() * x_conv_factor_ + x_start_;
739 ldmx_log(debug) <<
"\t\t\t 1 x in quad " << (*yitr).first
740 <<
", getting (x, sx)=(" << x <<
", " << sx <<
")";
742 else if (n_xin_quad == 2) {
747 auto xitr1 = x_quad_map.lower_bound((*yitr).first);
748 auto xitr2 = x_quad_map.upper_bound((*yitr).first);
751 if (xitr1 != xitr2) {
752 x1 = ((*xitr1).second).getCentroidX() * x_conv_factor_ + x_start_;
753 x2 = ((*xitr2).second).getCentroidX() * x_conv_factor_ + x_start_;
754 sx1 = x_conv_factor_ / 2.;
758 sx = fabs(x1 - x2) / 2;
760 ldmx_log(debug) <<
"\t\t -- 2 x in quad: setting y track x "
761 "coordinate to midpoint";
765 if (n_xin_quad >= 3) {
770 <<
"\t\t\t currently no x info assigned in ambiguous case of "
771 << n_xin_quad <<
"vertical bar track candidates in quad "
773 <<
"; will set x to middle of pad, pad half-width as "
774 "precision: set (x, sx)=("
775 << x <<
", " << sx <<
")";
780 if (n_yin_quad == 1) {
782 y = ((*yitr).second).getCentroidY() * y_conv_factor_ + y_start_;
783 sy = ((*yitr).second).getResidual() * y_conv_factor_;
786 if (sy == 0) sy = 1. / 2 * y_conv_factor_;
788 if (n_xin_quad <= 1) {
792 if (n_xin_quad == 1) {
793 auto xidx = x_idx_quad_map.find((*yitr).first);
794 tracks.at((*xidx).second).setPosition(x, y);
795 tracks.at((*xidx).second).setSigmaXY(sx, sy);
798 ldmx_log(debug) <<
"\t\t\t in quad " << (*yitr).first
799 <<
", set (x, y) = (" << x <<
", " << y
800 <<
") and (sx, sy) = " << sx <<
", " << sy <<
")";
801 auto yidx = y_idx_quad_map.find((*yitr).first);
802 tracks.at((*yidx).second).setPosition(x, y);
803 tracks.at((*yidx).second).setSigmaXY(sx, sy);
809 ldmx_log(debug) <<
"\t\t in quad " << (*yitr).first
810 <<
", not single x,y tracks: " << n_xin_quad
811 <<
" of x and " << n_yin_quad <<
" of y";
813 if (n_yin_quad == 2) {
816 auto yitr1 = y_quad_map.lower_bound((*yitr).first);
817 auto yitr2 = y_quad_map.upper_bound((*yitr).first);
819 y1 = ((*yitr1).second).getCentroidY() * y_conv_factor_ + y_start_;
820 y2 = ((*yitr2).second).getCentroidY() * y_conv_factor_ + y_start_;
821 sy1 = ((*yitr1).second).getResidual() * y_conv_factor_;
822 sy2 = ((*yitr2).second).getResidual() * y_conv_factor_;
823 if (sy1 == 0) sy1 = 1. / 2 * y_conv_factor_;
824 if (sy2 == 0) sy2 = 1. / 2 * y_conv_factor_;
826 sy = fabs(y1 - y2) / 2;
829 <<
"\t\t -- 2 y in quad: setting x track y coordinate to midpoint";
832 if ((n_xin_quad == 0 || n_xin_quad >= 3) &&
834 if (n_xin_quad == 0) {
836 ldmx_log(debug) <<
"\t\t -- No x tracks but 2 y tracks in quad: "
839 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
840 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
842 tracks.at((*yidx1).second).setPosition(x, y1);
843 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
844 tracks.at((*yidx2).second).setPosition(x, y2);
845 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
849 if (n_yin_quad == 1 &&
855 auto yidx = y_idx_quad_map.find((*yitr).first);
856 tracks.at((*yidx).second).setPosition(x, y);
857 tracks.at((*yidx).second).setSigmaXY(sx, sy);
859 int min_overlap_pe = 250;
860 if (((*yitr).second).getPE() < min_overlap_pe) {
867 ldmx_log(debug) <<
"\t\t -- Can't tell which x track should be "
868 "matched to single y track. Setting both x track "
869 "coordinates to y quadrant value:";
872 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
873 << ((*yitr).second).getPE() <<
" > " << min_overlap_pe
874 <<
"), suggesting overlap! Setting both x track "
875 "coordinates to y track value:";
882 ldmx_log(debug) <<
"\t\t -- (x1, x2, y) = (" << x1 <<
", " << x2
883 <<
", " << y <<
") and (sx1, sx2, sy) = " << sx1 <<
", "
884 << sx2 <<
", " << sy <<
")";
887 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
888 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
890 tracks.at((*xidx1).second).setPosition(x1, y);
891 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
892 tracks.at((*xidx2).second).setPosition(x2, y);
893 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
896 else if (n_yin_quad == 2 && n_xin_quad == 1) {
901 auto xidx = x_idx_quad_map.find((*yitr).first);
902 tracks.at((*xidx).second).setPosition(x, y);
903 tracks.at((*xidx).second).setSigmaXY(sx, sy);
905 auto xitr = x_quad_map.lower_bound((*yitr).first);
906 int min_overlap_pe = 300;
907 if (((*xitr).second).getPE() < min_overlap_pe) {
910 <<
"\t\t just 1 x track with not-unusual PE in the quad -- can't "
911 "match; setting mid-point values for x ";
921 ldmx_log(debug) <<
"\t\t -- Found large PE count ("
922 << ((*xitr).second).getPE() <<
" > " << min_overlap_pe
923 <<
") in x track, suggesting overlap! Setting both y "
924 "track coordinates to x track value:";
927 ldmx_log(debug) <<
"\t\t -- (x, y1, y2) = (" << x <<
", " << y1 <<
", "
928 << y2 <<
") and (sx, sy1, sy2) = " << sx <<
", " << sy1
929 <<
", " << sy2 <<
")";
931 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
932 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
934 tracks.at((*yidx1).second).setPosition(x, y1);
935 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
936 tracks.at((*yidx2).second).setPosition(x, y2);
937 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
940 else if (n_yin_quad == 2 && n_xin_quad == 2) {
942 auto xidx1 = x_idx_quad_map.lower_bound((*yitr).first);
943 auto xidx2 = x_idx_quad_map.upper_bound((*yitr).first);
945 auto yidx1 = y_idx_quad_map.lower_bound((*yitr).first);
946 auto yidx2 = y_idx_quad_map.upper_bound((*yitr).first);
949 if (y_idx_quad_map.find((*yitr).first) == y_idx_quad_map.end())
950 ldmx_log(error) <<
"The two y tracks in the same quadrant at "
952 <<
" appear to not be found in the y track map! "
953 "investigate. Note that yidx1.first = "
955 <<
" and yidx2.first = " << (*yidx2).first;
957 tracks.at((*xidx1).second).setPosition(x1, y);
958 tracks.at((*xidx1).second).setSigmaXY(sx1, sy);
959 tracks.at((*xidx2).second).setPosition(x2, y);
960 tracks.at((*xidx2).second).setSigmaXY(sx2, sy);
962 tracks.at((*yidx1).second).setPosition(x, y1);
963 tracks.at((*yidx1).second).setSigmaXY(sx, sy1);
964 tracks.at((*yidx2).second).setPosition(x, y2);
965 tracks.at((*yidx2).second).setSigmaXY(sx, sy2);
968 ldmx_log(debug) <<
"\t\t -- in a 2 x 2 situaiton; midpoint y: " << y
969 <<
" for both x tracks, midpoint x: " << x
970 <<
" for both y tracks";
974 if (n_xin_quad > 2) {
976 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 x tracks in the same quad "
977 "-- nothing done about the x,y coordinates in this "
978 "situation -- implement if needed!!";
980 if (n_yin_quad > 2) {
982 ldmx_log(debug) <<
"\t\t -*-*-*- more than 2 y tracks in the same quad "
983 "-- nothing done about the x,y coordinates in this "
984 "situation -- implement if needed!!";
996 ldmx_log(debug) <<
"Process starts!";
1002 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,...