CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PrimitiveMatching Class Reference

#include <PrimitiveMatching.h>

Public Types

typedef EMTFHitCollection::const_iterator hit_ptr_t
 
typedef std::pair< int, hit_ptr_thit_sort_pair_t
 

Public Member Functions

void configure (int verbose, int endcap, int sector, int bx, bool fixZonePhi, bool useNewZones, bool bugSt2PhDiff, bool bugME11Dupes)
 
void insert_hits (hit_ptr_t conv_hit_ptr, const EMTFHitCollection &conv_hits, EMTFTrack &track) const
 
void process (const std::deque< EMTFHitCollection > &extended_conv_hits, const emtf::zone_array< EMTFRoadCollection > &zone_roads, emtf::zone_array< EMTFTrackCollection > &zone_tracks) const
 
void process_single_zone_station (int zone, int station, const EMTFRoadCollection &roads, const EMTFHitCollection &conv_hits, std::vector< hit_sort_pair_t > &phi_differences) const
 

Private Attributes

bool bugME11Dupes_
 
bool bugSt2PhDiff_
 
int bx_
 
int endcap_
 
bool fixZonePhi_
 
int sector_
 
bool useNewZones_
 
int verbose_
 

Detailed Description

Definition at line 6 of file PrimitiveMatching.h.

Member Typedef Documentation

◆ hit_ptr_t

typedef EMTFHitCollection::const_iterator PrimitiveMatching::hit_ptr_t

Definition at line 8 of file PrimitiveMatching.h.

◆ hit_sort_pair_t

Definition at line 9 of file PrimitiveMatching.h.

Member Function Documentation

◆ configure()

void PrimitiveMatching::configure ( int  verbose,
int  endcap,
int  sector,
int  bx,
bool  fixZonePhi,
bool  useNewZones,
bool  bugSt2PhDiff,
bool  bugME11Dupes 
)

Definition at line 11 of file PrimitiveMatching.cc.

18  {
19  verbose_ = verbose;
20  endcap_ = endcap;
21  sector_ = sector;
22  bx_ = bx;
23 
24  fixZonePhi_ = fixZonePhi;
25  useNewZones_ = useNewZones;
26  bugSt2PhDiff_ = bugSt2PhDiff;
27  bugME11Dupes_ = bugME11Dupes;
28 }

References bugME11Dupes_, bugSt2PhDiff_, l1GtPatternGenerator_cfi::bx, bx_, makeMuonMisalignmentScenario::endcap, endcap_, fixZonePhi_, sector_, useNewZones_, verbose, and verbose_.

Referenced by SectorProcessor::process_single_bx().

◆ insert_hits()

void PrimitiveMatching::insert_hits ( hit_ptr_t  conv_hit_ptr,
const EMTFHitCollection conv_hits,
EMTFTrack track 
) const

Definition at line 433 of file PrimitiveMatching.cc.

435  {
436  EMTFHitCollection::const_iterator conv_hits_it = conv_hits.begin();
437  EMTFHitCollection::const_iterator conv_hits_end = conv_hits.end();
438 
439  const bool is_csc_me11 = (conv_hit_ptr->Subsystem() == TriggerPrimitive::kCSC) && (conv_hit_ptr->Station() == 1) &&
440  (conv_hit_ptr->Ring() == 1 || conv_hit_ptr->Ring() == 4);
441 
442  // Find all possible duplicated hits, insert them
443  for (; conv_hits_it != conv_hits_end; ++conv_hits_it) {
444  const EMTFHit& conv_hit_i = *conv_hits_it;
445  const EMTFHit& conv_hit_j = *conv_hit_ptr;
446 
447  // All these must match: [bx_history][station][chamber][segment]
448  if ((conv_hit_i.Subsystem() == conv_hit_j.Subsystem()) && (conv_hit_i.PC_station() == conv_hit_j.PC_station()) &&
449  (conv_hit_i.PC_chamber() == conv_hit_j.PC_chamber()) &&
450  (conv_hit_i.Ring() == conv_hit_j.Ring()) && // because of ME1/1
451  (conv_hit_i.Strip() == conv_hit_j.Strip()) &&
452  //(conv_hit_i.Wire() == conv_hit_j.Wire()) &&
453  (conv_hit_i.Pattern() == conv_hit_j.Pattern()) && (conv_hit_i.BX() == conv_hit_j.BX()) &&
454  ((conv_hit_i.Is_RPC() == false) ||
455  ((conv_hit_i.Strip_low() == conv_hit_j.Strip_low()) && (conv_hit_i.Strip_hi() == conv_hit_j.Strip_hi()) &&
456  (conv_hit_i.Roll() == conv_hit_j.Roll()) && (conv_hit_i.Phi_fp() == conv_hit_j.Phi_fp()) &&
457  (conv_hit_i.Theta_fp() == conv_hit_j.Theta_fp()))) &&
458  true) {
459  // All duplicates with the same strip but different wire must have same phi_fp
460  emtf_assert(conv_hit_i.Phi_fp() == conv_hit_j.Phi_fp());
461 
462  track.push_Hit(conv_hit_i);
463 
464  } else if ((bugME11Dupes_ &&
465  is_csc_me11) && // if reproduce ME1/1 theta duplication bug, do not check 'ring', 'strip' and 'pattern'
466  (conv_hit_i.Subsystem() == conv_hit_j.Subsystem()) &&
467  (conv_hit_i.PC_station() == conv_hit_j.PC_station()) &&
468  (conv_hit_i.PC_chamber() == conv_hit_j.PC_chamber()) &&
469  //(conv_hit_i.Ring() == conv_hit_j.Ring()) && // because of ME1/1
470  //(conv_hit_i.Strip() == conv_hit_j.Strip()) &&
471  //(conv_hit_i.Wire() == conv_hit_j.Wire()) &&
472  //(conv_hit_i.Pattern() == conv_hit_j.Pattern()) &&
473  (conv_hit_i.BX() == conv_hit_j.BX()) &&
474  //(conv_hit_i.Strip_low() == conv_hit_j.Strip_low()) && // For RPC clusters
475  //(conv_hit_i.Strip_hi() == conv_hit_j.Strip_hi()) && // For RPC clusters
476  //(conv_hit_i.Roll() == conv_hit_j.Roll()) && // For RPC clusters
477  true) {
478  // Dirty hack
479  EMTFHit tmp_hit = conv_hit_j;
480  tmp_hit.set_theta_fp(conv_hit_i.Theta_fp());
481  track.push_Hit(tmp_hit);
482  }
483  }
484 
485  // Sort by station
486  struct {
487  typedef EMTFHit value_type;
488  bool operator()(const value_type& lhs, const value_type& rhs) const { return lhs.Station() < rhs.Station(); }
489  } less_station_cmp;
490 
491  EMTFHitCollection tmp_hits = track.Hits();
492  std::stable_sort(tmp_hits.begin(), tmp_hits.end(), less_station_cmp);
493  track.set_Hits(tmp_hits);
494 }

References bugME11Dupes_, l1t::EMTFHit::BX(), emtf_assert, l1t::EMTFHit::Is_RPC(), L1TMuon::TriggerPrimitive::kCSC, l1t::EMTFHit::Pattern(), l1t::EMTFHit::PC_chamber(), l1t::EMTFHit::PC_station(), l1t::EMTFHit::Phi_fp(), l1t::EMTFHit::Ring(), l1t::EMTFHit::Roll(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::Strip(), l1t::EMTFHit::Strip_hi(), l1t::EMTFHit::Strip_low(), l1t::EMTFHit::Subsystem(), l1t::EMTFHit::Theta_fp(), and HLT_2018_cff::track.

Referenced by process().

◆ process()

void PrimitiveMatching::process ( const std::deque< EMTFHitCollection > &  extended_conv_hits,
const emtf::zone_array< EMTFRoadCollection > &  zone_roads,
emtf::zone_array< EMTFTrackCollection > &  zone_tracks 
) const

Definition at line 30 of file PrimitiveMatching.cc.

32  {
33  // Function to update fs_history encoded in fs_segment
34  auto update_fs_history = [](int fs_segment, int this_bx, int hit_bx) {
35  // 0 for current BX, 1 for previous BX, 2 for BX before that
36  int fs_history = this_bx - hit_bx;
37  fs_segment |= ((fs_history & 0x3) << 4);
38  return fs_segment;
39  };
40 
41  // Function to update bt_history encoded in bt_segment
42  auto update_bt_history = [](int bt_segment, int this_bx, int hit_bx) {
43  // 0 for current BX, 1 for previous BX, 2 for BX before that
44  int bt_history = this_bx - hit_bx;
45  bt_segment |= ((bt_history & 0x3) << 5);
46  return bt_segment;
47  };
48 
49  // Exit if no roads
50  int num_roads = 0;
51  for (const auto& roads : zone_roads)
52  num_roads += roads.size();
53  bool early_exit = (num_roads == 0);
54 
55  if (early_exit)
56  return;
57 
58  if (verbose_ > 0) { // debug
59  for (const auto& roads : zone_roads) {
60  for (const auto& road : roads) {
61  std::cout << "pattern on match input: z: " << road.Zone() - 1 << " r: " << road.Winner()
62  << " ph_num: " << road.Key_zhit() << " ph_q: " << to_hex(road.Quality_code())
63  << " ly: " << to_binary(road.Layer_code(), 3) << " str: " << to_binary(road.Straightness(), 3)
64  << std::endl;
65  }
66  }
67  }
68 
69  // Organize converted hits by (zone, station)
70  std::array<EMTFHitCollection, emtf::NUM_ZONES * emtf::NUM_STATIONS> zs_conv_hits;
71 
72  bool use_fs_zone_code = true; // use zone code as in firmware find_segment module
73 
74  std::deque<EMTFHitCollection>::const_iterator ext_conv_hits_it = extended_conv_hits.begin();
75  std::deque<EMTFHitCollection>::const_iterator ext_conv_hits_end = extended_conv_hits.end();
76 
77  for (; ext_conv_hits_it != ext_conv_hits_end; ++ext_conv_hits_it) {
78  EMTFHitCollection::const_iterator conv_hits_it = ext_conv_hits_it->begin();
79  EMTFHitCollection::const_iterator conv_hits_end = ext_conv_hits_it->end();
80 
81  for (; conv_hits_it != conv_hits_end; ++conv_hits_it) {
82  int istation = conv_hits_it->Station() - 1;
83  int zone_code = conv_hits_it->Zone_code(); // decide based on original zone code
84  if (use_fs_zone_code)
85  zone_code = conv_hits_it->FS_zone_code(); // decide based on new zone code
86 
87  // A hit can go into multiple zones
88  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
89  if (!zone_roads.at(izone).empty()) {
90  if (zone_code & (1 << izone)) {
91  const int zs = (izone * emtf::NUM_STATIONS) + istation;
92  zs_conv_hits.at(zs).push_back(*conv_hits_it);
93 
94  // Update fs_history and bt_history depending on the processor BX
95  // This update only goes into the hits associated to a track, it does not affect the original hit collection
96  EMTFHit& conv_hit = zs_conv_hits.at(zs).back(); // pass by reference
97  int old_fs_segment = conv_hit.FS_segment();
98  int new_fs_segment = update_fs_history(old_fs_segment, bx_, conv_hit.BX());
99  conv_hit.set_fs_segment(new_fs_segment);
100 
101  int old_bt_segment = conv_hit.BT_segment();
102  int new_bt_segment = update_bt_history(old_bt_segment, bx_, conv_hit.BX());
103  conv_hit.set_bt_segment(new_bt_segment);
104  }
105  }
106  }
107 
108  } // end loop over conv_hits
109  } // end loop over extended_conv_hits
110 
111  if (verbose_ > 1) { // debug
112  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
113  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
114  const int zs = (izone * emtf::NUM_STATIONS) + istation;
115  for (const auto& conv_hit : zs_conv_hits.at(zs)) {
116  std::cout << "z: " << izone << " st: " << istation + 1 << " cscid: " << conv_hit.CSC_ID()
117  << " ph_zone_phi: " << conv_hit.Zone_hit() << " ph_low_prec: " << (conv_hit.Zone_hit() << 5)
118  << " ph_high_prec: " << conv_hit.Phi_fp()
119  << " ph_high_low_diff: " << (conv_hit.Phi_fp() - (conv_hit.Zone_hit() << 5)) << std::endl;
120  }
121  }
122  }
123  }
124 
125  // Keep the best phi difference for every road by (zone, station)
126  std::array<std::vector<hit_sort_pair_t>, emtf::NUM_ZONES * emtf::NUM_STATIONS> zs_phi_differences;
127 
128  // Get the best-matching hits by comparing phi difference between
129  // pattern and segment
130  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
131  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
132  const int zs = (izone * emtf::NUM_STATIONS) + istation;
133 
134  // This leaves zone_roads.at(izone) and zs_conv_hits.at(zs) unchanged
135  // zs_phi_differences.at(zs) gets filled with a pair of <phi_diff, conv_hit> for the
136  // conv_hit with the lowest phi_diff from the pattern in this station and zone
138  izone + 1, istation + 1, zone_roads.at(izone), zs_conv_hits.at(zs), zs_phi_differences.at(zs));
139  emtf_assert(zone_roads.at(izone).size() == zs_phi_differences.at(zs).size());
140  } // end loop over stations
141  } // end loop over zones
142 
143  if (verbose_ > 1) { // debug
144  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
145  const auto& roads = zone_roads.at(izone);
146  for (unsigned iroad = 0; iroad < roads.size(); ++iroad) {
147  const auto& road = roads.at(iroad);
148  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
149  const int zs = (izone * emtf::NUM_STATIONS) + istation;
150  int ph_diff = zs_phi_differences.at(zs).at(iroad).first;
151  std::cout << "find seg: z: " << road.Zone() - 1 << " r: " << road.Winner() << " st: " << istation
152  << " ph_diff: " << ph_diff << std::endl;
153  }
154  }
155  }
156  }
157 
158  // Build all tracks in each zone
159  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
160  const EMTFRoadCollection& roads = zone_roads.at(izone);
161 
162  for (unsigned iroad = 0; iroad < roads.size(); ++iroad) {
163  const EMTFRoad& road = roads.at(iroad);
164 
165  // Create a track
167  track.set_endcap(road.Endcap());
168  track.set_sector(road.Sector());
169  track.set_sector_idx(road.Sector_idx());
170  track.set_bx(road.BX());
171  track.set_zone(road.Zone());
172  track.set_ph_num(road.Key_zhit());
173  track.set_ph_q(road.Quality_code());
174  track.set_rank(road.Quality_code());
175  track.set_winner(road.Winner());
176 
177  track.clear_Hits();
178 
179  // Insert hits
180  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
181  const int zs = (izone * emtf::NUM_STATIONS) + istation;
182 
183  const EMTFHitCollection& conv_hits = zs_conv_hits.at(zs);
184  int ph_diff = zs_phi_differences.at(zs).at(iroad).first;
185  hit_ptr_t conv_hit_ptr = zs_phi_differences.at(zs).at(iroad).second;
186 
187  if (ph_diff != invalid_ph_diff) {
188  // Inserts the conv_hit with the lowest phi_diff, as well as its duplicate
189  // (same strip and phi, different wire and theta), if a duplicate exists
190  insert_hits(conv_hit_ptr, conv_hits, track);
191  }
192  }
193 
194  if (fixZonePhi_) {
195  emtf_assert(!track.Hits().empty());
196  }
197 
198  // Output track
199  zone_tracks.at(izone).push_back(track);
200 
201  } // end loop over roads
202  } // end loop over zones
203 
204  if (verbose_ > 0) { // debug
205  for (const auto& tracks : zone_tracks) {
206  for (const auto& track : tracks) {
207  for (const auto& hit : track.Hits()) {
208  std::cout << "match seg: z: " << track.Zone() - 1 << " pat: " << track.Winner() << " st: " << hit.Station()
209  << " vi: " << to_binary(0b1, 2) << " hi: " << ((hit.FS_segment() >> 4) & 0x3)
210  << " ci: " << ((hit.FS_segment() >> 1) & 0x7) << " si: " << (hit.FS_segment() & 0x1)
211  << " ph: " << hit.Phi_fp() << " th: " << hit.Theta_fp() << std::endl;
212  }
213  }
214  }
215  }
216 }

References b1, l1t::EMTFHit::BT_segment(), l1t::EMTFRoad::BX(), l1t::EMTFHit::BX(), bx_, gather_cfg::cout, emtf_assert, l1t::EMTFRoad::Endcap(), fixZonePhi_, l1t::EMTFHit::FS_segment(), insert_hits(), l1t::EMTFRoad::Key_zhit(), emtf::NUM_STATIONS, emtf::NUM_ZONES, process_single_zone_station(), l1t::EMTFRoad::Quality_code(), l1t::EMTFRoad::Sector(), l1t::EMTFRoad::Sector_idx(), l1t::EMTFHit::set_bt_segment(), l1t::EMTFHit::set_fs_segment(), to_hex(), HLT_2018_cff::track, PDWG_EXOHSCP_cff::tracks, verbose_, l1t::EMTFRoad::Winner(), and l1t::EMTFRoad::Zone().

Referenced by SectorProcessor::process_single_bx().

◆ process_single_zone_station()

void PrimitiveMatching::process_single_zone_station ( int  zone,
int  station,
const EMTFRoadCollection roads,
const EMTFHitCollection conv_hits,
std::vector< hit_sort_pair_t > &  phi_differences 
) const

Definition at line 218 of file PrimitiveMatching.cc.

222  {
223  // max phi difference between pattern and segment
224  // This doesn't depend on the pattern straightness - any hit within the max phi difference may match
225  int max_ph_diff = (station == 1) ? 15 : 7;
226  //int bw_ph_diff = (station == 1) ? 5 : 4; // ph difference bit width
227  //int invalid_ph_diff = (station == 1) ? 31 : 15; // invalid difference
228 
229  if (fixZonePhi_) {
230  if (station == 1) {
231  max_ph_diff = 496; // width of pattern in ME1 + rounding error 15*32+16
232  //bw_ph_diff = 9;
233  //invalid_ph_diff = 0x1ff;
234  } else if (station == 2) {
235  if (bugSt2PhDiff_)
236  max_ph_diff = 16; // just rounding error for ME2 (pattern must match ME2 hit phi if there was one)
237  else
238  max_ph_diff = 240; // same as ME3,4
239  //bw_ph_diff = 5;
240  //invalid_ph_diff = 0x1f;
241  } else {
242  max_ph_diff = 240; // width of pattern in ME3,4 + rounding error 7*32+16
243  //bw_ph_diff = 8;
244  //invalid_ph_diff = 0xff;
245  }
246  }
247 
248  auto abs_diff = [](int a, int b) { return std::abs(a - b); };
249 
250  // Simple sort by ph_diff
251  struct {
252  typedef hit_sort_pair_t value_type;
253  bool operator()(const value_type& lhs, const value_type& rhs) const { return lhs.first <= rhs.first; }
254  } less_ph_diff_cmp;
255 
256  // Emulation of FW sorting with 3-way comparator
257  struct {
258  typedef hit_sort_pair_t value_type;
259  int operator()(const value_type& a, const value_type& b, const value_type& c) const {
260  int r = 0;
261  r |= bool(a.first <= b.first);
262  r <<= 1;
263  r |= bool(b.first <= c.first);
264  r <<= 1;
265  r |= bool(c.first <= a.first);
266 
267  int rr = 0;
268  switch (r) {
269  //case 0b000 : rr = 3; break; // invalid
270  case 0b001:
271  rr = 2;
272  break; // c
273  case 0b010:
274  rr = 1;
275  break; // b
276  case 0b011:
277  rr = 1;
278  break; // b
279  case 0b100:
280  rr = 0;
281  break; // a
282  case 0b101:
283  rr = 2;
284  break; // c
285  case 0b110:
286  rr = 0;
287  break; // a
288  //case 0b111 : rr = 0; break; // invalid
289  default:
290  rr = 0;
291  break;
292  }
293  return rr;
294  }
295  } less_ph_diff_cmp3;
296 
297  // ___________________________________________________________________________
298  // For each road, find the segment with min phi difference in every station
299 
300  EMTFRoadCollection::const_iterator roads_it = roads.begin();
301  EMTFRoadCollection::const_iterator roads_end = roads.end();
302 
303  for (; roads_it != roads_end; ++roads_it) {
304  int ph_pat = roads_it->Key_zhit(); // pattern key phi value
305  int ph_q = roads_it->Quality_code(); // pattern quality code
306  emtf_assert(ph_pat >= 0 && ph_q > 0);
307 
308  if (fixZonePhi_) {
309  ph_pat <<= 5; // add missing 5 lower bits to pattern phi
310  }
311 
312  std::vector<hit_sort_pair_t> tmp_phi_differences;
313 
314  EMTFHitCollection::const_iterator conv_hits_it = conv_hits.begin();
315  EMTFHitCollection::const_iterator conv_hits_end = conv_hits.end();
316 
317  for (; conv_hits_it != conv_hits_end; ++conv_hits_it) {
318  int ph_seg = conv_hits_it->Phi_fp(); // ph from segments
319  int ph_seg_red = ph_seg >> (bw_fph - bpow - 1); // remove unused low bits
320  emtf_assert(ph_seg >= 0);
321 
322  if (fixZonePhi_) {
323  ph_seg_red = ph_seg; // use full-precision phi
324  }
325 
326  // Get abs phi difference
327  int ph_diff = abs_diff(ph_pat, ph_seg_red);
328  if (ph_diff > max_ph_diff)
329  ph_diff = invalid_ph_diff; // difference is too high, cannot be the same pattern
330 
331  if (ph_diff != invalid_ph_diff)
332  tmp_phi_differences.push_back(std::make_pair(ph_diff, conv_hits_it)); // make a key-value pair
333  }
334 
335  // _________________________________________________________________________
336  // Sort to find the segment with min phi difference
337 
338  if (!tmp_phi_differences.empty()) {
339  // Because the sorting is sensitive to FW ordering, use the exact FW sorting.
340  // This implementation still slightly differs from FW because I prefer to
341  // use a sorting function that is as generic as possible.
342  bool use_fw_sorting = true;
343 
344  if (useNewZones_)
345  use_fw_sorting = false;
346 
347  if (use_fw_sorting) {
348  // zone_cham = 4 for [fs_01, fs_02, fs_03, fs_11], or 7 otherwise
349  // tot_diff = 27 or 45 in FW; it is 27 or 54 in the C++ merge_sort3 impl
350  const int max_drift = 3; // should use bxWindow from the config
351  const int zone_cham = ((zone == 1 && (2 <= station && station <= 4)) || (zone == 2 && station == 2)) ? 4 : 7;
352  const int seg_ch = 2;
353  const int tot_diff =
354  (max_drift * zone_cham * seg_ch) + ((zone_cham == 4) ? 3 : 12); // provide padding for 3-input comparators
355 
356  std::vector<hit_sort_pair_t> fw_sort_array(tot_diff, std::make_pair(invalid_ph_diff, conv_hits_end));
357 
358  // FW doesn't check if the hit is CSC or RPC
359  std::vector<hit_sort_pair_t>::const_iterator phdiffs_it = tmp_phi_differences.begin();
360  std::vector<hit_sort_pair_t>::const_iterator phdiffs_end = tmp_phi_differences.end();
361 
362  for (; phdiffs_it != phdiffs_end; ++phdiffs_it) {
363  //int ph_diff = phdiffs_it->first;
364  int fs_segment = phdiffs_it->second->FS_segment();
365 
366  // Calculate the index to put into the fw_sort_array
367  int fs_history = ((fs_segment >> 4) & 0x3);
368  int fs_chamber = ((fs_segment >> 1) & 0x7);
369  fs_segment = (fs_segment & 0x1);
370  unsigned fw_sort_array_index = (fs_history * zone_cham * seg_ch) + (fs_chamber * seg_ch) + fs_segment;
371 
372  emtf_assert(fs_history < max_drift && fs_chamber < zone_cham && fs_segment < seg_ch);
373  emtf_assert(fw_sort_array_index < fw_sort_array.size());
374  fw_sort_array.at(fw_sort_array_index) = *phdiffs_it;
375  }
376 
377  // Debug
378  //std::cout << "phdiffs" << std::endl;
379  //for (unsigned i = 0; i < fw_sort_array.size(); ++i)
380  // std::cout << fw_sort_array.at(i).first << " ";
381  //std::cout << std::endl;
382 
383  // Debug
384  //std::cout << "Before sort" << std::endl;
385  //for (unsigned i = 0; i < fw_sort_array.size(); ++i)
386  // std::cout << fw_sort_array.at(i).second->FS_segment() << " ";
387  //std::cout << std::endl;
388 
389  // Find the best phi difference according to FW sorting
390  //merge_sort3(fw_sort_array.begin(), fw_sort_array.end(), less_ph_diff_cmp, less_ph_diff_cmp3);
391  merge_sort3_with_hint(fw_sort_array.begin(),
392  fw_sort_array.end(),
393  less_ph_diff_cmp,
394  less_ph_diff_cmp3,
395  ((tot_diff == 54) ? tot_diff / 2 : tot_diff / 3));
396 
397  // Store the best phi difference
398  phi_differences.push_back(fw_sort_array.front());
399 
400  // Debug
401  //std::cout << "After sort" << std::endl;
402  //for (unsigned i = 0; i < fw_sort_array.size(); ++i)
403  // std::cout << fw_sort_array.at(i).second->FS_segment() << " ";
404  //std::cout << std::endl;
405 
406  } else { // use C++ sorting
407  struct {
408  typedef hit_sort_pair_t value_type;
409  bool operator()(const value_type& lhs, const value_type& rhs) const {
410  // If different types, prefer CSC over RPC; else prefer the closer hit in dPhi
411  if (lhs.second->Subsystem() != rhs.second->Subsystem())
412  return (lhs.second->Subsystem() == TriggerPrimitive::kCSC);
413  else
414  return lhs.first <= rhs.first;
415  }
416  } tmp_less_ph_diff_cmp;
417 
418  // Find best phi difference
419  std::stable_sort(tmp_phi_differences.begin(), tmp_phi_differences.end(), tmp_less_ph_diff_cmp);
420 
421  // Store the best phi difference
422  phi_differences.push_back(tmp_phi_differences.front());
423  }
424 
425  } else {
426  // No segment found
427  phi_differences.push_back(std::make_pair(invalid_ph_diff, conv_hits_end)); // make a key-value pair
428  }
429 
430  } // end loop over roads
431 }

References a, funct::abs(), b, electrons_cff::bool, bugSt2PhDiff_, HltBtagPostValidation_cff::c, emtf_assert, fixZonePhi_, L1TMuon::TriggerPrimitive::kCSC, alignCSCRings::r, findQualityFiles::rr, relativeConstraints::station, and useNewZones_.

Referenced by process().

Member Data Documentation

◆ bugME11Dupes_

bool PrimitiveMatching::bugME11Dupes_
private

Definition at line 36 of file PrimitiveMatching.h.

Referenced by configure(), and insert_hits().

◆ bugSt2PhDiff_

bool PrimitiveMatching::bugSt2PhDiff_
private

Definition at line 36 of file PrimitiveMatching.h.

Referenced by configure(), and process_single_zone_station().

◆ bx_

int PrimitiveMatching::bx_
private

Definition at line 33 of file PrimitiveMatching.h.

Referenced by configure(), and process().

◆ endcap_

int PrimitiveMatching::endcap_
private

Definition at line 33 of file PrimitiveMatching.h.

Referenced by configure().

◆ fixZonePhi_

bool PrimitiveMatching::fixZonePhi_
private

Definition at line 35 of file PrimitiveMatching.h.

Referenced by configure(), process(), and process_single_zone_station().

◆ sector_

int PrimitiveMatching::sector_
private

Definition at line 33 of file PrimitiveMatching.h.

Referenced by configure().

◆ useNewZones_

bool PrimitiveMatching::useNewZones_
private

Definition at line 35 of file PrimitiveMatching.h.

Referenced by configure(), and process_single_zone_station().

◆ verbose_

int PrimitiveMatching::verbose_
private

Definition at line 33 of file PrimitiveMatching.h.

Referenced by configure(), and process().

PrimitiveMatching::fixZonePhi_
bool fixZonePhi_
Definition: PrimitiveMatching.h:35
PrimitiveMatching::hit_sort_pair_t
std::pair< int, hit_ptr_t > hit_sort_pair_t
Definition: PrimitiveMatching.h:9
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:372
l1t::EMTFHit::BT_segment
int BT_segment() const
Definition: EMTFHit.h:215
l1t::EMTFHit::FS_segment
int FS_segment() const
Definition: EMTFHit.h:212
l1t::EMTFHit::CSC_ID
int CSC_ID() const
Definition: EMTFHit.h:186
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
relativeConstraints.station
station
Definition: relativeConstraints.py:67
EMTFRoadCollection
l1t::EMTFRoadCollection EMTFRoadCollection
Definition: Common.h:25
gather_cfg.cout
cout
Definition: gather_cfg.py:144
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::EMTFRoad
Definition: EMTFRoad.h:9
PrimitiveMatching::verbose_
int verbose_
Definition: PrimitiveMatching.h:33
l1t::EMTFHit::Strip_hi
int Strip_hi() const
Definition: EMTFHit.h:197
l1t::EMTFRoad::Key_zhit
int Key_zhit() const
Definition: EMTFRoad.h:43
PrimitiveMatching::bugME11Dupes_
bool bugME11Dupes_
Definition: PrimitiveMatching.h:36
l1t::EMTFHit::set_fs_segment
void set_fs_segment(int bits)
Definition: EMTFHit.h:159
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
L1TMuon::TriggerPrimitive::kCSC
Definition: MuonTriggerPrimitive.h:59
l1t::EMTFHit::BX
int BX() const
Definition: EMTFHit.h:206
b1
static constexpr float b1
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
l1t::EMTFHit::Strip_low
int Strip_low() const
Definition: EMTFHit.h:198
emtf::NUM_STATIONS
constexpr int NUM_STATIONS
Definition: Common.h:58
l1t::EMTFHit::Zone_hit
int Zone_hit() const
Definition: EMTFHit.h:210
PrimitiveMatching::hit_ptr_t
EMTFHitCollection::const_iterator hit_ptr_t
Definition: PrimitiveMatching.h:8
l1t::EMTFHit::Roll
int Roll() const
Definition: EMTFHit.h:188
EMTFHitCollection
l1t::EMTFHitCollection EMTFHitCollection
Definition: Common.h:23
l1t::EMTFHit::Theta_fp
int Theta_fp() const
Definition: EMTFHit.h:209
l1t::EMTFHit::PC_station
int PC_station() const
Definition: EMTFHit.h:192
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
l1t::EMTFRoad::Endcap
int Endcap() const
Definition: EMTFRoad.h:38
b
double b
Definition: hdecay.h:118
l1t::EMTFTrack
Definition: EMTFTrack.h:34
l1t::EMTFRoad::Zone
int Zone() const
Definition: EMTFRoad.h:42
l1t::EMTFRoad::Quality_code
int Quality_code() const
Definition: EMTFRoad.h:47
a
double a
Definition: hdecay.h:119
l1t::EMTFHit::PC_chamber
int PC_chamber() const
Definition: EMTFHit.h:193
PrimitiveMatching::useNewZones_
bool useNewZones_
Definition: PrimitiveMatching.h:35
l1t::EMTFHit
Definition: EMTFHit.h:22
to_hex
static char to_hex(unsigned int i)
Definition: types.cc:27
l1t::EMTFHit::set_theta_fp
void set_theta_fp(int bits)
Definition: EMTFHit.h:156
l1t::EMTFHit::Is_RPC
bool Is_RPC() const
Definition: EMTFHit.h:232
PrimitiveMatching::bugSt2PhDiff_
bool bugSt2PhDiff_
Definition: PrimitiveMatching.h:36
l1t::EMTFHit::Subsystem
int Subsystem() const
Definition: EMTFHit.h:176
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PrimitiveMatching::endcap_
int endcap_
Definition: PrimitiveMatching.h:33
l1t::EMTFRoad::BX
int BX() const
Definition: EMTFRoad.h:41
PrimitiveMatching::sector_
int sector_
Definition: PrimitiveMatching.h:33
PrimitiveMatching::process_single_zone_station
void process_single_zone_station(int zone, int station, const EMTFRoadCollection &roads, const EMTFHitCollection &conv_hits, std::vector< hit_sort_pair_t > &phi_differences) const
Definition: PrimitiveMatching.cc:218
l1t::EMTFHit::Ring
int Ring() const
Definition: EMTFHit.h:179
emtf::NUM_ZONES
constexpr int NUM_ZONES
Definition: Common.h:54
l1t::EMTFRoad::Winner
int Winner() const
Definition: EMTFRoad.h:48
emtf_assert
#define emtf_assert(expr)
Definition: DebugTools.h:18
l1t::EMTFHit::Pattern
int Pattern() const
Definition: EMTFHit.h:201
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
l1t::EMTFRoad::Sector
int Sector() const
Definition: EMTFRoad.h:39
l1t::EMTFHit::set_bt_segment
void set_bt_segment(int bits)
Definition: EMTFHit.h:162
PrimitiveMatching::insert_hits
void insert_hits(hit_ptr_t conv_hit_ptr, const EMTFHitCollection &conv_hits, EMTFTrack &track) const
Definition: PrimitiveMatching.cc:433
hit
Definition: SiStripHitEffFromCalibTree.cc:88
l1t::EMTFHit::Phi_fp
int Phi_fp() const
Definition: EMTFHit.h:208
l1t::EMTFRoad::Sector_idx
int Sector_idx() const
Definition: EMTFRoad.h:40
l1t::EMTFHit::Strip
int Strip() const
Definition: EMTFHit.h:196
PrimitiveMatching::bx_
int bx_
Definition: PrimitiveMatching.h:33