CMS 3D CMS Logo

DuplicateRemovalLayer.cc
Go to the documentation of this file.
2 
6 
8 
9 using namespace emtf::phase2;
10 using namespace emtf::phase2::algo;
11 
13 
14 void DuplicateRemovalLayer::apply(std::vector<track_t>& tracks) const {
15  // ===========================================================================
16  // Unpack model
17  // ---------------------------------------------------------------------------
18  const auto& model = context_.model_;
19  const auto& model_reduced_sites = model.reduced_sites_;
20 
21  // ===========================================================================
22  // Build reduced tracks
23  // ---------------------------------------------------------------------------
24  std::vector<reduced_track_t> reduced_tracks;
25 
26  for (const auto& track : tracks) { // Begin loop tracks
27  // Fetch reduced track
28  auto& rtrk = reduced_tracks.emplace_back();
29  auto& rtrk_valid = rtrk.valid;
30 
31  // Initialize valid state
32  rtrk_valid = track.valid;
33 
34  // Fill reduced track with segments
35  for (const auto& model_rsite : model_reduced_sites) { // Begin loop reduced model sites
36 
37  // Get reduced site
38  int model_rsite_id = static_cast<int>(model_rsite.id);
39 
40  auto& rsite_seg = rtrk.site_segs[model_rsite_id];
41  auto& rsite_bit = rtrk.site_mask[model_rsite_id];
42 
43  // Init reduced site
44  rsite_seg = 0;
45  rsite_bit = 0;
46 
47  // Select the first segment available for the reduced site
48  for (const auto& model_rs_ts : model_rsite.trk_sites) { // Begin loop reduced site track sites
49  int trk_site_id = static_cast<int>(model_rs_ts);
50 
51  const auto& trk_site_seg = track.site_segs[trk_site_id];
52  const auto& trk_site_bit = track.site_mask[trk_site_id];
53 
54  if (trk_site_bit == 0) {
55  continue;
56  }
57 
58  // Attach segment
59  // If even one segment is attached
60  // the reduced track is considered valid
61  rtrk_valid = 1;
62  rsite_seg = trk_site_seg;
63  rsite_bit = 1;
64 
65  break;
66  } // End loop reduced site track sites
67  } // End loop reduced model sites
68  } // End loop tracks
69 
70  // ===========================================================================
71  // Find and invalidate duplicate tracks
72  // ---------------------------------------------------------------------------
73  for (unsigned int i_rtrk = 0; i_rtrk < reduced_tracks.size(); ++i_rtrk) { // Begin loop reduced tracks i
74 
75  auto& trk_i = tracks[i_rtrk];
76  const auto& rtrk_i = reduced_tracks[i_rtrk];
77 
78  if (rtrk_i.valid == 1) {
79  for (unsigned int j_rtrk = (i_rtrk + 1); j_rtrk < reduced_tracks.size();
80  ++j_rtrk) { // Begin loop reduced tracks j
81 
82  auto& rtrk_j = reduced_tracks[j_rtrk];
83 
84  // If the reduced track is already invalid, move on
85  if (rtrk_j.valid == 0)
86  continue;
87 
88  // Compare reduced track sites
89  for (unsigned int k_rsite = 0; k_rsite < v3::kNumTrackSitesRM; ++k_rsite) { // Begin loop reduced sites k
90  const auto& rtrk_site_mask_ik = rtrk_i.site_mask[k_rsite];
91  const auto& rtrk_site_mask_jk = rtrk_j.site_mask[k_rsite];
92 
93  // If one or both of the sites are missing, move on
94  if (!(rtrk_site_mask_ik & rtrk_site_mask_jk))
95  continue;
96 
97  // Compare segment_ids
98  const auto& rtrk_seg_id_ik = rtrk_i.site_segs[k_rsite];
99  const auto& rtrk_seg_id_jk = rtrk_j.site_segs[k_rsite];
100 
101  // If segment ids are differente, move on
102  if (rtrk_seg_id_ik != rtrk_seg_id_jk)
103  continue;
104 
105  // If there's even one collision, invalidate the track
106  rtrk_j.valid = 0;
107  } // End loop reduced sites k
108  } // End loop reduced tracks j
109  }
110 
111  // Propagate invalidation
112  trk_i.valid = rtrk_i.valid;
113 
114  // DEBUG
115  if (this->context_.config_.verbosity_ > 1) {
116  if (trk_i.valid) {
117  edm::LogInfo("L1TEMTFpp") << "Unique Track"
118  << " zone " << trk_i.zone << " col " << trk_i.col << " pat " << trk_i.pattern
119  << " qual " << trk_i.quality << " phi " << trk_i.phi << " theta " << trk_i.theta
120  << " valid " << trk_i.valid << std::endl;
121  }
122  }
123  } // End loop reduced tracks i
124 }
void apply(std::vector< track_t > &) const
Log< level::Info, false > LogInfo
constexpr int kNumTrackSitesRM
Definition: EMTFConstants.h:43
EMTFConfiguration config_
Definition: EMTFContext.h:39