CMS 3D CMS Logo

PrimitiveSelection.cc
Go to the documentation of this file.
2 
3 #include "helper.h" // merge_map_into_map
4 
5 // 18 in ME1; 9x3 in ME2,3,4; 9 from neighbor sector.
6 // Arranged in FW as 6 stations, 9 chambers per station.
7 #define NUM_CSC_CHAMBERS 6 * 9
8 // 6x2 in RE1,2; 12x2 in RE3,4; 6 from neighbor sector.
9 // Arranged in FW as 7 stations, 6 chambers per station.
10 // For Phase 2, add RE1/3, RE2/3, RE3/1, RE4/1 -> 10 chambers per station
11 #define NUM_RPC_CHAMBERS 7 * 10
12 // 6 in GE1/1; 3 in GE2/1; 3 in ME0; 3 from neighbor sector. (unconfirmed!)
13 #define NUM_GEM_CHAMBERS 15
14 // 2x4 in MB1,2,3,4; 4 from neighbor sector. (unconfirmed!)
15 #define NUM_DT_CHAMBERS 3 * 4
16 
18  int endcap,
19  int sector,
20  int bx,
21  int bxShiftCSC,
22  int bxShiftRPC,
23  int bxShiftGEM,
24  int bxShiftME0,
25  bool includeNeighbor,
26  bool duplicateTheta,
27  bool bugME11Dupes) {
28  verbose_ = verbose;
29  endcap_ = endcap;
30  sector_ = sector;
31  bx_ = bx;
32 
33  bxShiftCSC_ = bxShiftCSC;
34  bxShiftRPC_ = bxShiftRPC;
35  bxShiftGEM_ = bxShiftGEM;
36  bxShiftME0_ = bxShiftME0;
37 
38  includeNeighbor_ = includeNeighbor;
39  duplicateTheta_ = duplicateTheta;
40  bugME11Dupes_ = bugME11Dupes;
41 }
42 
43 // _____________________________________________________________________________
44 // Specialized process() for CSC
45 template <>
47  const TriggerPrimitiveCollection& muon_primitives,
48  std::map<int, TriggerPrimitiveCollection>& selected_csc_map) const {
49  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
50  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
51 
52  for (; tp_it != tp_end; ++tp_it) {
53  int selected_csc = select_csc(*tp_it); // Returns CSC "link" index (0 - 53)
54 
55  if (selected_csc >= 0) {
56  emtf_assert(selected_csc < NUM_CSC_CHAMBERS);
57 
58  //FIXME
59  if (selected_csc_map[selected_csc].size() < 2) {
60  selected_csc_map[selected_csc].push_back(*tp_it);
61  } else {
62  edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
63  edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber";
64  for (int ii = 0; ii < 3; ii++) {
65  TriggerPrimitive tp_err = (ii < 2 ? selected_csc_map[selected_csc].at(ii) : *tp_it);
66  edm::LogWarning("L1T") << "LCT #" << ii + 1 << ": BX " << tp_err.getBX() << ", endcap "
67  << tp_err.detId<CSCDetId>().endcap() << ", sector "
68  << tp_err.detId<CSCDetId>().triggerSector() << ", station "
69  << tp_err.detId<CSCDetId>().station() << ", ring " << tp_err.detId<CSCDetId>().ring()
70  << ", chamber " << tp_err.detId<CSCDetId>().chamber() << ", CSC ID "
71  << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire "
72  << tp_err.getWire();
73  }
74  edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
75  }
76 
77  } // End conditional: if (selected_csc >= 0)
78  } // End loop: for (; tp_it != tp_end; ++tp_it)
79 
80  // Duplicate CSC muon primitives
81  // If there are 2 LCTs in the same chamber with (strip, wire) = (s1, w1) and (s2, w2)
82  // make all combinations with (s1, w1), (s2, w1), (s1, w2), (s2, w2)
83  if (duplicateTheta_) {
84  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_csc_map.begin();
85  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_csc_map.end();
86 
87  for (; map_tp_it != map_tp_end; ++map_tp_it) {
88  int selected = map_tp_it->first;
89  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
90 
91  if (tmp_primitives.size() >= 4) {
92  edm::LogWarning("L1T") << "EMTF found 4 or more CSC LCTs in one chamber: keeping only two";
93  tmp_primitives.erase(tmp_primitives.begin() + 4, tmp_primitives.end()); // erase 5th element++
94  tmp_primitives.erase(tmp_primitives.begin() + 2); // erase 3rd element
95  tmp_primitives.erase(tmp_primitives.begin() + 1); // erase 2nd element
96  } else if (tmp_primitives.size() == 3) {
97  edm::LogWarning("L1T") << "EMTF found 3 CSC LCTs in one chamber: keeping only two";
98  tmp_primitives.erase(tmp_primitives.begin() + 2); // erase 3rd element
99  }
100  emtf_assert(tmp_primitives.size() <= 2); // at most 2 hits
101 
102  if (tmp_primitives.size() == 2) {
103  if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) &&
104  (tmp_primitives.at(0).getWire() != tmp_primitives.at(1).getWire())) {
105  // Swap wire numbers
106  TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
107  TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
108  uint16_t tmp_keywire = tp0.accessCSCData().keywire;
109  tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
110  tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
111 
112  tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos
113  tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos
114  }
115 
116  const bool is_csc_me11 = (0 <= selected && selected <= 2) || (9 <= selected && selected <= 11) ||
117  (selected == 45); // ME1/1 sub 1 or ME1/1 sub 2 or ME1/1 from neighbor
118 
119  if (bugME11Dupes_ && is_csc_me11) {
120  // For ME1/1, always make 4 LCTs without checking strip & wire combination
121  if (tmp_primitives.size() == 2) {
122  // Swap wire numbers
123  TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
124  TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
125  uint16_t tmp_keywire = tp0.accessCSCData().keywire;
126  tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
127  tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
128 
129  tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos
130  tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos
131  }
132  emtf_assert(tmp_primitives.size() == 1 || tmp_primitives.size() == 4);
133  }
134 
135  } // end if tmp_primitives.size() == 2
136  } // end loop over selected_csc_map
137  } // end if duplicate theta
138 }
139 
140 // _____________________________________________________________________________
141 // Specialized process() for RPC
142 template <>
144  const TriggerPrimitiveCollection& muon_primitives,
145  std::map<int, TriggerPrimitiveCollection>& selected_rpc_map) const {
146  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
147  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
148 
149  for (; tp_it != tp_end; ++tp_it) {
150  int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index
151 
152  if (selected_rpc >= 0) {
153  emtf_assert(selected_rpc < NUM_RPC_CHAMBERS);
154  selected_rpc_map[selected_rpc].push_back(*tp_it);
155  }
156  }
157 
158  // Apply truncation as in firmware: keep first 2 clusters, max cluster
159  // size = 3 strips.
160  // According to Karol Bunkowski, for one chamber (so 3 eta rolls) only up
161  // to 2 hits (cluster centres) are produced. First two 'first' clusters are
162  // chosen, and only after the cut on the cluster size is applied. So if
163  // there are 1 large cluster and 2 small clusters, it is possible that
164  // one of the two small clusters is discarded first, and the large cluster
165  // then is removed by the cluster size cut, leaving only one cluster.
166  // Note: this needs to be modified for Phase 2 with additional iRPC chambers.
167  bool apply_truncation = true;
168  if (apply_truncation) {
169  struct {
171  bool operator()(const value_type& x) const {
172  // Skip cluster size cut if primitives are from CPPF emulator or EMTF unpacker (already clustered)
173  if (x.getRPCData().isCPPF)
174  return false;
175 
176  int sz = x.getRPCData().strip_hi - x.getRPCData().strip_low + 1;
177 
178  const RPCDetId& tp_detId = x.detId<RPCDetId>();
179  int tp_station = tp_detId.station();
180  int tp_ring = tp_detId.ring();
181  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
182  if (is_irpc)
183  return sz > 6; // iRPC strip pitch is 1.5 times smaller than traditional RPC
184  return sz > 3;
185  }
186  } cluster_size_cut;
187 
188  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
189  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
190 
191  for (; map_tp_it != map_tp_end; ++map_tp_it) {
192  int selected = map_tp_it->first;
193  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
194 
195  //FIXME
196  // Check to see if unpacked CPPF digis have <= 2 digis per chamber, as expected
197  if (tmp_primitives.size() > 2 && tmp_primitives.at(0).getRPCData().isCPPF) {
198  edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
199  edm::LogWarning("L1T") << "Found " << tmp_primitives.size() << " CPPF digis in the same chamber";
200  for (const auto& tp : tmp_primitives)
201  tp.print(std::cout);
202  edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
203  }
204 
205  if ((selected % 10) == 8 || (selected % 10) == 9) { // RE3/1 or RE4/1 (iRPC)
206  // Keep the first 4 clusters
207  if (tmp_primitives.size() > 4)
208  tmp_primitives.erase(tmp_primitives.begin() + 4, tmp_primitives.end());
209  } else {
210  // Keep the first 2 clusters
211  if (tmp_primitives.size() > 2)
212  tmp_primitives.erase(tmp_primitives.begin() + 2, tmp_primitives.end());
213  }
214 
215  // Apply cluster size cut
216  tmp_primitives.erase(std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
217  tmp_primitives.end());
218  }
219  } // end if apply_truncation
220 
221  // Map RPC subsector and chamber to CSC chambers
222  // Note: RE3/2 & RE3/3 are considered as one chamber; RE4/2 & RE4/3 too.
223  bool map_rpc_to_csc = true;
224  if (map_rpc_to_csc) {
225  std::map<int, TriggerPrimitiveCollection> tmp_selected_rpc_map;
226 
227  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
228  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
229 
230  for (; map_tp_it != map_tp_end; ++map_tp_it) {
231  int selected = map_tp_it->first;
232  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
233 
234  int rpc_sub = selected / 10;
235  int rpc_chm = selected % 10;
236 
237  int pc_station = -1;
238  int pc_chamber = -1;
239 
240  if (rpc_sub != 6) { // native
241  if (rpc_chm == 0) { // RE1/2: 3-5, 12-14
242  if (0 <= rpc_sub && rpc_sub < 3) {
243  pc_station = 0;
244  pc_chamber = 3 + rpc_sub;
245  } else if (3 <= rpc_sub && rpc_sub < 6) {
246  pc_station = 1;
247  pc_chamber = 3 + (rpc_sub - 3);
248  }
249  } else if (rpc_chm == 6) { // RE1/3: 6-8, 15-17
250  if (0 <= rpc_sub && rpc_sub < 3) {
251  pc_station = 0;
252  pc_chamber = 6 + rpc_sub;
253  } else if (3 <= rpc_sub && rpc_sub < 6) {
254  pc_station = 1;
255  pc_chamber = 6 + (rpc_sub - 3);
256  }
257  } else if (rpc_chm == 1 || rpc_chm == 7) { // RE2/2, RE2/3: 21-26
258  pc_station = 2;
259  pc_chamber = 3 + rpc_sub;
260  } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3: 30-35
261  pc_station = 3;
262  pc_chamber = 3 + rpc_sub;
263  } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3: 39-44
264  pc_station = 4;
265  pc_chamber = 3 + rpc_sub;
266  } else if (rpc_chm == 8) { // RE3/1: 27-29
267  pc_station = 3;
268  pc_chamber = rpc_sub;
269  } else if (rpc_chm == 9) { // RE4/1: 36-38
270  pc_station = 4;
271  pc_chamber = rpc_sub;
272  }
273 
274  } else { // neighbor
275  pc_station = 5;
276  if (rpc_chm == 0) { // RE1/2: 46
277  pc_chamber = 1;
278  } else if (rpc_chm == 6) { // RE1/3: 47
279  pc_chamber = 2;
280  } else if (rpc_chm == 1 || rpc_chm == 7) { // RE2/2, RE2/3: 49
281  pc_chamber = 4;
282  } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3: 51
283  pc_chamber = 6;
284  } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3: 53
285  pc_chamber = 8;
286  } else if (rpc_chm == 8) { // RE3/1: 50
287  pc_chamber = 5;
288  } else if (rpc_chm == 9) { // RE4/1: 52
289  pc_chamber = 7;
290  }
291  }
292  emtf_assert(pc_station != -1 && pc_chamber != -1);
293  emtf_assert(pc_station < 6 && pc_chamber < 9);
294 
295  selected = (pc_station * 9) + pc_chamber;
296 
297  bool ignore_this_rpc_chm = false;
298  if (rpc_chm == 3 || rpc_chm == 5) { // special case of RE3,4/2 and RE3,4/3 chambers
299  // if RE3,4/2 exists, ignore RE3,4/3. In C++, this assumes that the loop
300  // over selected_rpc_map will always find RE3,4/2 before RE3,4/3
301  if (tmp_selected_rpc_map.find(selected) != tmp_selected_rpc_map.end())
302  ignore_this_rpc_chm = true;
303  }
304 
305  if (rpc_chm == 6 || rpc_chm == 7) { // RE1/3 and RE2/3 chambers are not part of EMTF
306  ignore_this_rpc_chm = true;
307  }
308 
309  if (rpc_chm == 8 || rpc_chm == 9) { // RE3/1 and RE4/1 chambers are not available until Phase-2
310  ignore_this_rpc_chm = true;
311  }
312 
313  if (ignore_this_rpc_chm) {
314  // Set RPC stubs as invalid, but we keep them
315  for (auto&& tp : tmp_primitives) {
316  tp.accessRPCData().valid = 0;
317  }
318  }
319 
320  // Keep the stubs in the temporary map
321  if (tmp_selected_rpc_map.find(selected) == tmp_selected_rpc_map.end()) {
322  tmp_selected_rpc_map[selected] = tmp_primitives;
323  } else {
324  tmp_selected_rpc_map[selected].insert(
325  tmp_selected_rpc_map[selected].end(), tmp_primitives.begin(), tmp_primitives.end());
326  }
327  } // end loop over selected_rpc_map
328 
329  std::swap(selected_rpc_map, tmp_selected_rpc_map); // replace the original map
330  } // end if map_rpc_to_csc
331 }
332 
333 // _____________________________________________________________________________
334 // Specialized process() for GEM
335 template <>
337  const TriggerPrimitiveCollection& muon_primitives,
338  std::map<int, TriggerPrimitiveCollection>& selected_gem_map) const {
339  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
340  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
341 
342  for (; tp_it != tp_end; ++tp_it) {
343  int selected_gem = select_gem(*tp_it); // Returns GEM "link" index
344 
345  if (selected_gem >= 0) {
346  emtf_assert(selected_gem < NUM_GEM_CHAMBERS);
347  selected_gem_map[selected_gem].push_back(*tp_it);
348  }
349  }
350 
351  // Apply truncation: max cluster size = 8 pads, keep first 8 clusters.
352  bool apply_truncation = true;
353  if (apply_truncation) {
354  struct {
356  bool operator()(const value_type& x) const {
357  int sz = x.getGEMData().pad_hi - x.getGEMData().pad_low + 1;
358  return sz > 8;
359  }
360  } cluster_size_cut;
361 
362  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_gem_map.begin();
363  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_gem_map.end();
364 
365  for (; map_tp_it != map_tp_end; ++map_tp_it) {
366  //int selected = map_tp_it->first;
367  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
368 
369  // Apply cluster size cut
370  tmp_primitives.erase(std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
371  tmp_primitives.end());
372 
373  // Keep the first 8 clusters
374  if (tmp_primitives.size() > 8)
375  tmp_primitives.erase(tmp_primitives.begin() + 8, tmp_primitives.end());
376  }
377  } // end if apply_truncation
378 }
379 
380 // _____________________________________________________________________________
381 // Specialized process() for ME0
382 template <>
384  const TriggerPrimitiveCollection& muon_primitives,
385  std::map<int, TriggerPrimitiveCollection>& selected_me0_map) const {
386  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
387  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
388 
389  for (; tp_it != tp_end; ++tp_it) {
390  int selected_me0 = select_me0(*tp_it); // Returns ME0 "link" index
391 
392  if (selected_me0 >= 0) {
393  emtf_assert(selected_me0 < NUM_GEM_CHAMBERS);
394  selected_me0_map[selected_me0].push_back(*tp_it);
395  }
396  }
397 
398  // Apply truncation
399  bool apply_truncation = true;
400  if (apply_truncation) {
401  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_me0_map.begin();
402  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_me0_map.end();
403 
404  for (; map_tp_it != map_tp_end; ++map_tp_it) {
405  //int selected = map_tp_it->first;
406  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
407 
408  // Keep the first 20 clusters
409  if (tmp_primitives.size() > 20)
410  tmp_primitives.erase(tmp_primitives.begin() + 20, tmp_primitives.end());
411  }
412  }
413 }
414 
415 // _____________________________________________________________________________
416 // Specialized process() for DT
417 template <>
419  const TriggerPrimitiveCollection& muon_primitives,
420  std::map<int, TriggerPrimitiveCollection>& selected_dt_map) const {
421  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
422  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
423 
424  for (; tp_it != tp_end; ++tp_it) {
425  int selected_dt = select_dt(*tp_it); // Returns DT "link" index
426 
427  if (selected_dt >= 0) {
428  emtf_assert(selected_dt < NUM_DT_CHAMBERS);
429  selected_dt_map[selected_dt].push_back(*tp_it);
430  }
431  }
432 
433  // Duplicate DT muon primitives
434  if (duplicateTheta_) {
435  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_dt_map.begin();
436  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_dt_map.end();
437 
438  for (; map_tp_it != map_tp_end; ++map_tp_it) {
439  //int selected = map_tp_it->first;
440  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
441 
442  emtf_assert(tmp_primitives.size() <= 2); // at most 2 hits
443 
444  if (tmp_primitives.size() == 2) {
445  if ((tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) &&
446  (tmp_primitives.at(0).getWire() != tmp_primitives.at(1).getWire())) {
447  // Swap wire numbers
448  TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
449  TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
450  uint16_t tmp_keywire = tp0.accessDTData().theta_bti_group;
451  tp0.accessDTData().theta_bti_group = tp1.accessDTData().theta_bti_group; // (s1,w2)
452  tp1.accessDTData().theta_bti_group = tmp_keywire; // (s2,w1)
453 
454  tmp_primitives.insert(tmp_primitives.begin() + 1, tp1); // (s2,w1) at 2nd pos
455  tmp_primitives.insert(tmp_primitives.begin() + 2, tp0); // (s1,w2) at 3rd pos
456  }
457  } // end if tmp_primitives.size() == 2
458  } // end loop over selected_dt_map
459  } // end if duplicate theta
460 }
461 
462 // _____________________________________________________________________________
463 // Put the hits from DT, CSC, RPC, GEM, ME0 together in one collection
464 
465 // Notes from Alex (2017-03-28):
466 //
467 // The RPC inclusion logic is very simple currently:
468 // - each CSC is analyzed for having track stubs in each BX
469 // - IF a CSC chamber is missing at least one track stub,
470 // AND there is an RPC overlapping with it in phi and theta,
471 // AND that RPC has hits,
472 // THEN RPC hit is inserted instead of missing CSC stub.
473 //
474 // This is done at the output of coord_delay module, so such
475 // inserted RPC hits can be matched to patterns by match_ph_segments
476 // module, just like any CSC stubs. Note that substitution of missing
477 // CSC stubs with RPC hits happens regardless of what's going on in
478 // other chambers, regardless of whether a pattern has been detected
479 // or not, basically regardless of anything. RPCs are treated as a
480 // supplemental source of stubs for CSCs.
481 
482 void PrimitiveSelection::merge(const std::map<int, TriggerPrimitiveCollection>& selected_dt_map,
483  const std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
484  const std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
485  const std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
486  const std::map<int, TriggerPrimitiveCollection>& selected_me0_map,
487  std::map<int, TriggerPrimitiveCollection>& selected_prim_map) const {
488  // First, put CSC hits
489  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_csc_map.begin();
490  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_csc_map.end();
491 
492  for (; map_tp_it != map_tp_end; ++map_tp_it) {
493  int selected_csc = map_tp_it->first;
494  const TriggerPrimitiveCollection& csc_primitives = map_tp_it->second;
495  emtf_assert(csc_primitives.size() <= 4); // at most 4 hits, including duplicated hits
496 
497  // Insert all CSC hits
498  selected_prim_map[selected_csc] = csc_primitives;
499  }
500 
501  // Second, insert GEM stubs if there is no CSC hits
502  map_tp_it = selected_gem_map.begin();
503  map_tp_end = selected_gem_map.end();
504 
505  for (; map_tp_it != map_tp_end; ++map_tp_it) {
506  int selected_gem = map_tp_it->first;
507  const TriggerPrimitiveCollection& gem_primitives = map_tp_it->second;
508  if (gem_primitives.empty())
509  continue;
510  emtf_assert(gem_primitives.size() <= 8); // at most 8 hits
511 
512  bool found = (selected_prim_map.find(selected_gem) != selected_prim_map.end());
513  if (!found) {
514  // No CSC hits, insert all GEM hits
515  selected_prim_map[selected_gem] = gem_primitives;
516 
517  } else {
518  // Do nothing
519  }
520  }
521 
522  // Third, insert RPC stubs if there is no CSC/GEM hits
523  map_tp_it = selected_rpc_map.begin();
524  map_tp_end = selected_rpc_map.end();
525 
526  for (; map_tp_it != map_tp_end; ++map_tp_it) {
527  int selected_rpc = map_tp_it->first;
528  const TriggerPrimitiveCollection& rpc_primitives = map_tp_it->second;
529  if (rpc_primitives.empty())
530  continue;
531  emtf_assert(rpc_primitives.size() <= 4); // at most 4 hits
532 
533  bool found = (selected_prim_map.find(selected_rpc) != selected_prim_map.end());
534  if (!found) {
535  // No CSC/GEM hits, insert all RPC hits
536  //selected_prim_map[selected_rpc] = rpc_primitives;
537 
538  // No CSC/GEM hits, insert the valid RPC hits
539  TriggerPrimitiveCollection tmp_rpc_primitives;
540  for (const auto& tp : rpc_primitives) {
541  if (tp.getRPCData().valid != 0) {
542  tmp_rpc_primitives.push_back(tp);
543  }
544  }
545  emtf_assert(tmp_rpc_primitives.size() <= 2); // at most 2 hits
546 
547  selected_prim_map[selected_rpc] = tmp_rpc_primitives;
548 
549  } else {
550  // Initial FW in 2017; was disabled on June 7.
551  // If only one CSC/GEM hit, insert the first RPC hit
552  //TriggerPrimitiveCollection& tmp_primitives = selected_prim_map[selected_rpc]; // pass by reference
553 
554  //if (tmp_primitives.size() < 2) {
555  // tmp_primitives.push_back(rpc_primitives.front());
556  //}
557  }
558  }
559 }
560 
561 void PrimitiveSelection::merge_no_truncate(const std::map<int, TriggerPrimitiveCollection>& selected_dt_map,
562  const std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
563  const std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
564  const std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
565  const std::map<int, TriggerPrimitiveCollection>& selected_me0_map,
566  std::map<int, TriggerPrimitiveCollection>& selected_prim_map) const {
567  // First, put CSC hits
568  merge_map_into_map(selected_csc_map, selected_prim_map);
569 
570  // Second, insert ME0 hits
571  merge_map_into_map(selected_me0_map, selected_prim_map);
572 
573  // Third, insert GEM hits
574  merge_map_into_map(selected_gem_map, selected_prim_map);
575 
576  // Fourth, insert RPC hits
577  merge_map_into_map(selected_rpc_map, selected_prim_map);
578 
579  // Fifth, insert DT hits
580  merge_map_into_map(selected_dt_map, selected_prim_map);
581 }
582 
583 // _____________________________________________________________________________
584 // CSC functions
585 int PrimitiveSelection::select_csc(const TriggerPrimitive& muon_primitive) const {
586  int selected = -1;
587 
588  if (muon_primitive.subsystem() == TriggerPrimitive::kCSC) {
589  const CSCDetId& tp_detId = muon_primitive.detId<CSCDetId>();
590  const CSCData& tp_data = muon_primitive.getCSCData();
591 
592  int tp_endcap = tp_detId.endcap();
593  int tp_sector = tp_detId.triggerSector();
594  int tp_station = tp_detId.station();
595  int tp_ring = tp_detId.ring();
596  int tp_chamber = tp_detId.chamber();
597 
598  int tp_bx = tp_data.bx;
599  int tp_csc_ID = tp_data.cscID;
600 
601  const auto& [max_strip, max_wire] = emtf::get_csc_max_strip_and_wire(tp_station, tp_ring);
602  const auto& [max_pattern, max_quality] = emtf::get_csc_max_pattern_and_quality(tp_station, tp_ring);
603 
604  if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once
605  emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP);
606  emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR);
607  emtf_assert(1 <= tp_station && tp_station <= 4);
608  emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 9);
609  emtf_assert(tp_data.strip < max_strip);
610  emtf_assert(tp_data.keywire < max_wire);
611  emtf_assert(tp_data.valid == true);
612  emtf_assert(tp_data.pattern < max_pattern);
613  emtf_assert(0 < tp_data.quality && tp_data.quality < max_quality);
614  }
615 
616  // Check for corrupted LCT data. Data corruption could occur due to software or hardware issues, If corrupted, reject the LCT.
617  // Note that the checks are performed in every sector processor for every BX. As a result, the same LCT may be reported multiple times by all 12 sector processors from BX=-3 to BX=+3.
618  {
619  if (!(tp_data.strip < max_strip)) {
620  edm::LogWarning("L1T") << "Found error in LCT strip: " << tp_data.strip << " (allowed range: 0-"
621  << max_strip - 1 << ").";
622  edm::LogWarning("L1T")
623  << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring "
624  << tp_ring << ", cscid " << tp_csc_ID
625  << ". (Note that this LCT may be reported multiple times. See source code for explanations.)";
626  return selected;
627  }
628 
629  if (!(tp_data.keywire < max_wire)) {
630  edm::LogWarning("L1T") << "Found error in LCT wire: " << tp_data.keywire << " (allowed range: 0-"
631  << max_wire - 1 << ").";
632  edm::LogWarning("L1T")
633  << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring "
634  << tp_ring << ", cscid " << tp_csc_ID
635  << ". (Note that this LCT may be reported multiple times. See source code for explanations.)";
636  return selected;
637  }
638 
639  if (!(tp_data.valid == true)) {
640  edm::LogWarning("L1T") << "Found error in LCT valid: " << tp_data.valid << " (allowed value: 1).";
641  edm::LogWarning("L1T")
642  << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring "
643  << tp_ring << ", cscid " << tp_csc_ID
644  << ". (Note that this LCT may be reported multiple times. See source code for explanations.)";
645  return selected;
646  }
647 
648  if (!(tp_data.pattern < max_pattern)) {
649  edm::LogWarning("L1T") << "Found error in LCT pattern: " << tp_data.pattern << " (allowed range: 0-"
650  << max_pattern - 1 << ").";
651  edm::LogWarning("L1T")
652  << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring "
653  << tp_ring << ", cscid " << tp_csc_ID
654  << ". (Note that this LCT may be reported multiple times. See source code for explanations.)";
655  return selected;
656  }
657 
658  if (!(0 < tp_data.quality && tp_data.quality < max_quality)) {
659  edm::LogWarning("L1T") << "Found error in LCT quality: " << tp_data.quality << " (allowed range: 1-"
660  << max_quality - 1 << ").";
661  edm::LogWarning("L1T")
662  << "From endcap " << tp_endcap << ", sector " << tp_sector << ", station " << tp_station << ", ring "
663  << tp_ring << ", cscid " << tp_csc_ID
664  << ". (Note that this LCT may be reported multiple times. See source code for explanations.)";
665  return selected;
666  }
667  } // end check for corrupted LCT data
668 
669  // station 1 --> subsector 1 or 2
670  // station 2,3,4 --> subsector 0
671  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
672 
673  // Check if the chamber belongs to this sector processor at this BX.
674  selected = get_index_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx);
675  }
676  return selected;
677 }
678 
679 bool PrimitiveSelection::is_in_sector_csc(int tp_endcap, int tp_sector) const {
680  return ((endcap_ == tp_endcap) && (sector_ == tp_sector));
681 }
682 
684  int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
685  auto get_neighbor = [](int sector) { return (sector == 1) ? 6 : sector - 1; };
686 
687  if (includeNeighbor_) {
688  if ((endcap_ == tp_endcap) && (get_neighbor(sector_) == tp_sector)) {
689  if (tp_station == 1) {
690  if ((tp_subsector == 2) && (tp_csc_ID == 3 || tp_csc_ID == 6 || tp_csc_ID == 9))
691  return true;
692 
693  } else {
694  if (tp_csc_ID == 3 || tp_csc_ID == 9)
695  return true;
696  }
697  }
698  }
699  return false;
700 }
701 
702 bool PrimitiveSelection::is_in_bx_csc(int tp_bx) const {
703  tp_bx += bxShiftCSC_;
704  return (bx_ == tp_bx);
705 }
706 
707 // Returns CSC input "link". Index used by FW for unique chamber identification.
709  int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const {
710  int selected = -1;
711 
712  bool is_native = false;
713  bool is_neighbor = false;
714  if (is_in_bx_csc(tp_bx)) {
715  if (is_in_sector_csc(tp_endcap, tp_sector)) {
716  is_native = true;
717  } else if (is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
718  is_neighbor = true;
719  }
720  }
721  if (!is_native && !is_neighbor)
722  return selected;
723 
724  if (!is_neighbor) {
725  if (tp_station == 1) { // ME1: 0 - 8, 9 - 17
726  selected = (tp_subsector - 1) * 9 + (tp_csc_ID - 1);
727  } else { // ME2,3,4: 18 - 26, 27 - 35, 36 - 44
728  selected = (tp_station)*9 + (tp_csc_ID - 1);
729  }
730 
731  } else {
732  if (tp_station == 1) { // ME1n: 45 - 47
733  selected = (5) * 9 + (tp_csc_ID - 1) / 3;
734  } else { // ME2n,3n,4n: 48 - 53
735  selected = (5) * 9 + (tp_station)*2 - 1 + (tp_csc_ID - 1 < 3 ? 0 : 1);
736  }
737  }
738  emtf_assert(selected != -1);
739  return selected;
740 }
741 
742 // _____________________________________________________________________________
743 // RPC functions
744 int PrimitiveSelection::select_rpc(const TriggerPrimitive& muon_primitive) const {
745  int selected = -1;
746 
747  if (muon_primitive.subsystem() == TriggerPrimitive::kRPC) {
748  const RPCDetId& tp_detId = muon_primitive.detId<RPCDetId>();
749  const RPCData& tp_data = muon_primitive.getRPCData();
750 
751  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
752  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
753  int tp_sector = tp_detId.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg)
754  int tp_subsector = tp_detId.subsector(); // 1 - 6 (10 degrees in phi; staggered in z)
755  int tp_station = tp_detId.station(); // 1 - 4
756  int tp_ring = tp_detId.ring(); // 2 - 3 (increasing theta)
757  int tp_roll = tp_detId.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp)
758  //int tp_layer = tp_detId.layer();
759 
760  int tp_bx = tp_data.bx;
761  int tp_strip = tp_data.strip;
762  int tp_emtf_sect = tp_data.emtf_sector;
763  bool tp_CPPF = tp_data.isCPPF;
764 
765  // In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors
766  if (tp_CPPF && (tp_emtf_sect != sector_))
767  return selected;
768 
769  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
770 
771  if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once
772  emtf_assert(tp_region != 0);
773  emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP);
774  emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR);
775  emtf_assert(1 <= tp_subsector && tp_subsector <= 6);
776  emtf_assert(1 <= tp_station && tp_station <= 4);
777  emtf_assert((!is_irpc && 2 <= tp_ring && tp_ring <= 3) || (is_irpc && tp_ring == 1));
778  emtf_assert((!is_irpc && 1 <= tp_roll && tp_roll <= 3) || (is_irpc && 1 <= tp_roll && tp_roll <= 5));
779  //emtf_assert((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) || (is_irpc && 1 <= tp_strip && tp_strip <= 96));
780  emtf_assert((!is_irpc && (tp_CPPF || (1 <= tp_strip && tp_strip <= 32))) ||
781  (is_irpc && 1 <= tp_strip && tp_strip <= 96 * 2)); // in CMSSW, the iRPC chamber has 192 strips
782  //emtf_assert(tp_station > 2 || tp_ring != 3); // stations 1 and 2 do not receive RPCs from ring 3
783  emtf_assert(tp_data.valid == true);
784  }
785 
786  // Check if the chamber belongs to this sector processor at this BX.
787  selected = get_index_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector, tp_bx);
788  }
789  return selected;
790 }
791 
793  int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const {
794  // RPC sector X, subsectors 1-2 correspond to CSC sector X-1
795  // RPC sector X, subsectors 3-6 correspond to CSC sector X
796  // iRPC sector X, subsectors 1 correspond to CSC sector X-1
797  // iRPC sector X, subsectors 2-3 correspind to CSC sector X
798  auto get_csc_sector = [](int tp_station, int tp_ring, int tp_sector, int tp_subsector) {
799  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
800  if (is_irpc) {
801  // 20 degree chamber
802  int corr = (tp_subsector < 2) ? (tp_sector == 1 ? +5 : -1) : 0;
803  return tp_sector + corr;
804  } else {
805  // 10 degree chamber
806  int corr = (tp_subsector < 3) ? (tp_sector == 1 ? +5 : -1) : 0;
807  return tp_sector + corr;
808  }
809  };
810  return ((endcap_ == tp_endcap) && (sector_ == get_csc_sector(tp_station, tp_ring, tp_sector, tp_subsector)));
811 }
812 
814  int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const {
815  auto get_neighbor_subsector = [](int tp_station, int tp_ring) {
816  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
817  if (is_irpc) {
818  // 20 degree chamber
819  return 1;
820  } else {
821  // 10 degree chamber
822  return 2;
823  }
824  };
825  return (includeNeighbor_ && (endcap_ == tp_endcap) && (sector_ == tp_sector) &&
826  (tp_subsector == get_neighbor_subsector(tp_station, tp_ring)));
827 }
828 
829 bool PrimitiveSelection::is_in_bx_rpc(int tp_bx) const {
830  tp_bx += bxShiftRPC_;
831  return (bx_ == tp_bx);
832 }
833 
835  int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector, int tp_bx) const {
836  int selected = -1;
837 
838  bool is_native = false;
839  bool is_neighbor = false;
840  if (is_in_bx_rpc(tp_bx)) {
841  if (is_in_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) {
842  is_native = true;
843  } else if (is_in_neighbor_sector_rpc(tp_endcap, tp_station, tp_ring, tp_sector, tp_subsector)) {
844  is_neighbor = true;
845  }
846  }
847  if (!is_native && !is_neighbor)
848  return selected;
849 
850  // CPPF RX data come in 3 frames x 64 bits, for 7 links. Each 64-bit data
851  // carry 2 words of 32 bits. Each word carries phi (11 bits) and theta (5 bits)
852  // of 2 segments (x2).
853  //
854  // Firmware uses 'rpc_sub' as RPC subsector index and 'rpc_chm' as RPC chamber index
855  // rpc_sub [0,6] = RPC subsector 3, 4, 5, 6, 1 from neighbor, 2 from neighbor, 2. They correspond to
856  // CSC sector phi 0-10 deg, 10-20, 20-30, 30-40, 40-50, 50-60, 50-60 from neighbor
857  // rpc_chm [0,5] = RPC chamber RE1/2, RE2/2, RE3/2, RE3/3, RE4/2, RE4/3
858  // For Phase 2, add RE1/3, RE2/3, RE3/1, RE4/1 -> rpc_chm [0,9]
859  //
860  int rpc_sub = -1;
861  int rpc_chm = -1;
862 
863  const bool is_irpc = (tp_station == 3 || tp_station == 4) && (tp_ring == 1);
864 
865  if (!is_neighbor) {
866  if (!is_irpc) {
867  rpc_sub = ((tp_subsector + 3) % 6);
868  } else {
869  rpc_sub = ((tp_subsector + 1) % 3);
870  }
871  } else {
872  rpc_sub = 6;
873  }
874 
875  if (tp_station <= 2 && tp_ring == 2) { // RE1/2, RE2/2
876  rpc_chm = (tp_station - 1);
877  } else if (tp_station >= 3 && tp_ring >= 2) { // RE3/2, RE3/3, RE4/2, RE4/3
878  rpc_chm = 2 + (tp_station - 3) * 2 + (tp_ring - 2);
879  } else if (tp_station <= 2 && tp_ring == 3) { // RE1/3, RE2/3
880  rpc_chm = 6 + (tp_station - 1);
881  } else if (tp_station >= 3 && tp_ring == 1) { // RE3/1, RE4/1
882  rpc_chm = 8 + (tp_station - 3);
883  }
884 
885  selected = (rpc_sub * 10) + rpc_chm;
886  emtf_assert(selected != -1);
887  return selected;
888 }
889 
890 // _____________________________________________________________________________
891 // GEM functions
892 //
893 // According to what I know at the moment
894 // - GE1/1: 10 degree chamber, 8 rolls, 384 strips = 192 pads
895 // - GE2/1: 20 degree chamber, 8 rolls, 768 strips = 384 pads
896 int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const {
897  int selected = -1;
898 
899  if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) {
900  const GEMDetId& tp_detId = muon_primitive.detId<GEMDetId>();
901  const GEMData& tp_data = muon_primitive.getGEMData();
902 
903  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
904  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
905  int tp_station = tp_detId.station();
906  int tp_ring = tp_detId.ring();
907  int tp_roll = tp_detId.roll();
908  int tp_layer = tp_detId.layer();
909  int tp_chamber = tp_detId.chamber();
910 
911  int tp_bx = tp_data.bx;
912  int tp_pad = ((tp_data.pad_low + tp_data.pad_hi) / 2);
913 
914  int tp_sector = emtf::get_trigger_sector(tp_ring, tp_station, tp_chamber);
915  int tp_csc_ID = emtf::get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
916 
917  // station 1 --> subsector 1 or 2
918  // station 2,3,4 --> subsector 0
919  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
920 
921  if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once
922  emtf_assert(tp_region != 0);
923  emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP);
924  emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR);
925  emtf_assert(1 <= tp_station && tp_station <= 2);
926  emtf_assert(tp_ring == 1);
927  emtf_assert(1 <= tp_roll && tp_roll <= 8);
928  emtf_assert(1 <= tp_layer && tp_layer <= 2);
929  emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 3);
930  emtf_assert((tp_station == 1 && 0 <= tp_pad && tp_pad <= 191) || (tp_station != 1));
931  emtf_assert((tp_station == 2 && 0 <= tp_pad && tp_pad <= 383) || (tp_station != 2));
932  }
933 
934  // Check if the chamber belongs to this sector processor at this BX.
935  selected = get_index_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx);
936  }
937  return selected;
938 }
939 
940 bool PrimitiveSelection::is_in_sector_gem(int tp_endcap, int tp_sector) const {
941  // Identical to the corresponding CSC function
942  return is_in_sector_csc(tp_endcap, tp_sector);
943 }
944 
946  int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
947  // Identical to the corresponding CSC function
948  return is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID);
949 }
950 
951 bool PrimitiveSelection::is_in_bx_gem(int tp_bx) const {
952  tp_bx += bxShiftGEM_;
953  return (bx_ == tp_bx);
954 }
955 
957  int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const {
958  int selected = -1;
959 
960  bool is_native = false;
961  bool is_neighbor = false;
962  if (is_in_bx_gem(tp_bx)) {
963  if (is_in_sector_gem(tp_endcap, tp_sector)) {
964  is_native = true;
965  } else if (is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
966  is_neighbor = true;
967  }
968  }
969  if (!is_native && !is_neighbor)
970  return selected;
971 
972  if (!is_neighbor) {
973  if (tp_station == 1) { // GE1/1: 0 - 5
974  selected = (tp_subsector - 1) * 3 + (tp_csc_ID - 1);
975  } else { // GE2/1: 6 - 8
976  selected = 6 + (tp_csc_ID - 1);
977  }
978 
979  } else {
980  if (tp_station == 1) { // GE1/1n: 12
981  selected = 12;
982  } else { // GE2/1n: 13
983  selected = 13;
984  }
985  }
986  emtf_assert(selected != -1);
987  return selected;
988 }
989 
990 // _____________________________________________________________________________
991 // ME0 functions
992 //
993 // According to what I know at the moment
994 // - ME0: 20 degree chamber, 8 rolls, 384 strips = 192 pads
995 int PrimitiveSelection::select_me0(const TriggerPrimitive& muon_primitive) const {
996  int selected = -1;
997 
998  if (muon_primitive.subsystem() == TriggerPrimitive::kME0) {
999  const ME0DetId& tp_detId = muon_primitive.detId<ME0DetId>();
1000  const ME0Data& tp_data = muon_primitive.getME0Data();
1001 
1002  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
1003  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
1004  int tp_station = tp_detId.station();
1005  int tp_ring = 1; // tp_detId.ring() does not exist
1006  //int tp_roll = tp_detId.roll();
1007  //int tp_layer = tp_detId.layer();
1008  int tp_chamber = tp_detId.chamber();
1009 
1010  int tp_bx = tp_data.bx;
1011  int tp_pad = tp_data.phiposition;
1012  int tp_partition = tp_data.partition;
1013 
1014  // The ME0 geometry is similar to ME2/1, so I use tp_station = 2, tp_ring = 1
1015  // when calling get_trigger_sector() and get_trigger_csc_ID()
1016  int tp_sector = emtf::get_trigger_sector(1, 2, tp_chamber);
1017  int tp_csc_ID = emtf::get_trigger_csc_ID(1, 2, tp_chamber);
1018  int tp_subsector = 0;
1019 
1020  if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once
1021  emtf_assert(tp_region != 0);
1022  emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP);
1023  emtf_assert(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR);
1024  emtf_assert(tp_station == 1);
1025  emtf_assert(tp_ring == 1);
1026  //emtf_assert(1 <= tp_roll && tp_roll <= 8); // not set
1027  //emtf_assert(1 <= tp_layer && tp_layer <= 6); // not set
1028  emtf_assert(1 <= tp_csc_ID && tp_csc_ID <= 3);
1029  emtf_assert(0 <= tp_pad && tp_pad <= 767);
1030  emtf_assert(0 <= tp_partition && tp_partition <= 15);
1031  }
1032 
1033  // Check if the chamber belongs to this sector processor at this BX.
1034  selected = get_index_me0(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_pad, tp_bx);
1035  }
1036  return selected;
1037 }
1038 
1039 bool PrimitiveSelection::is_in_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const {
1040  // Similar to the corresponding CSC function, but requires a 5 deg shift
1041  // because the CSC chamber 1 starts at -5 deg, but the ME0 chamber 1 starts
1042  // at -10 deg.
1043  // This means that in sector 1, CSC chambers cover 15 to 75 deg, but ME0
1044  // chambers cover 10 to 70 deg. 5 deg (1/4 of chamber) needs to be added
1045  // to cover 70 to 75 deg, and 5 deg needs to be subtracted from 10 to 15 deg.
1046  auto get_other_neighbor = [](int sector) { return (sector == 6) ? 1 : sector + 1; };
1047 
1048  bool add5deg = false;
1049  bool sub5deg = false;
1050  if (includeNeighbor_) {
1051  if ((endcap_ == tp_endcap) && (get_other_neighbor(sector_) == tp_sector)) {
1052  if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber
1053  add5deg = true;
1054  } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber
1055  add5deg = true;
1056  }
1057  }
1058  if ((endcap_ == tp_endcap) && (sector_ == tp_sector)) {
1059  if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber
1060  sub5deg = true;
1061  } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber
1062  sub5deg = true;
1063  }
1064  }
1065  }
1066  return (is_in_sector_csc(tp_endcap, tp_sector) && !sub5deg) || add5deg;
1067 }
1068 
1069 bool PrimitiveSelection::is_in_neighbor_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const {
1070  // Similar to the corresponding CSC function, but requires a 5 deg shift
1071  // because the CSC chamber 1 starts at -5 deg, but the ME0 chamber 1 starts
1072  // at -10 deg.
1073  // This means that in sector 1, CSC chamber from the neighbor sector
1074  // covers -5 to 15 deg, but ME0 chamber from the neighbor sector covers
1075  // -10 to 10 deg. 5 deg (1/4 of chamber) needs to be subtracted from
1076  // -10 to -5 deg, and 5 deg needs to be added to cover 10 to 15 deg.
1077  auto get_neighbor = [](int sector) { return (sector == 1) ? 6 : sector - 1; };
1078 
1079  bool add5deg = false;
1080  bool sub5deg = false;
1081  if (includeNeighbor_) {
1082  if ((endcap_ == tp_endcap) && (get_neighbor(sector_) == tp_sector)) {
1083  if (tp_csc_ID == 3 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber
1084  sub5deg = true;
1085  } else if (tp_csc_ID == 3 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber
1086  sub5deg = true;
1087  }
1088  }
1089  if ((endcap_ == tp_endcap) && (sector_ == tp_sector)) {
1090  if (tp_csc_ID == 1 && tp_endcap == 1 && tp_pad >= (767 - 192)) { // higher 1/4 of chamber
1091  add5deg = true;
1092  } else if (tp_csc_ID == 1 && tp_endcap == 2 && tp_pad <= 191) { // lower 1/4 of chamber
1093  add5deg = true;
1094  }
1095  }
1096  }
1097  // (Note: use tp_subsector = 0, tp_station = 2)
1098  return (is_in_neighbor_sector_csc(tp_endcap, tp_sector, 0, 2, tp_csc_ID) && !sub5deg) || add5deg;
1099 }
1100 
1101 bool PrimitiveSelection::is_in_bx_me0(int tp_bx) const {
1102  tp_bx += bxShiftME0_;
1103  return (bx_ == tp_bx);
1104 }
1105 
1107  int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_pad, int tp_bx) const {
1108  int selected = -1;
1109 
1110  bool is_native = false;
1111  bool is_neighbor = false;
1112  if (is_in_bx_me0(tp_bx)) {
1113  if (is_in_sector_me0(tp_endcap, tp_sector, tp_csc_ID, tp_pad)) {
1114  is_native = true;
1115  } else if (is_in_neighbor_sector_me0(tp_endcap, tp_sector, tp_csc_ID, tp_pad)) {
1116  is_neighbor = true;
1117  }
1118  }
1119  if (!is_native && !is_neighbor)
1120  return selected;
1121 
1122  if (!is_neighbor) { // ME0: 9 - 11
1123  selected = 9 + (tp_csc_ID - 1);
1124  } else { // ME0n: 14
1125  selected = 14;
1126  }
1127  emtf_assert(selected != -1);
1128  return selected;
1129 }
1130 
1131 // _____________________________________________________________________________
1132 // DT functions
1133 int PrimitiveSelection::select_dt(const TriggerPrimitive& muon_primitive) const {
1134  int selected = -1;
1135 
1136  if (muon_primitive.subsystem() == TriggerPrimitive::kDT) {
1137  const DTChamberId& tp_detId = muon_primitive.detId<DTChamberId>();
1138  const DTData& tp_data = muon_primitive.getDTData();
1139 
1140  int tp_wheel = tp_detId.wheel();
1141  int tp_station = tp_detId.station();
1142  int tp_sector = tp_detId.sector(); // sectors are 1-12, starting at phi=0 and increasing with phi
1143 
1144  // In station 4, where the top and bottom sectors are made of two chambers,
1145  // two additional sector numbers are used, 13 (after sector 4, top)
1146  // and 14 (after sector 10, bottom).
1147  if (tp_station == 4) {
1148  if (tp_sector == 13)
1149  tp_sector = 4;
1150  else if (tp_sector == 14)
1151  tp_sector = 10;
1152  }
1153 
1154  int tp_bx = tp_data.bx;
1155  int tp_phi = tp_data.radialAngle;
1156  //int tp_phiB = tp_data.bendingAngle;
1157 
1158  // Mimic 10 deg CSC chamber. I use tp_station = 2, tp_ring = 2
1159  // when calling get_trigger_sector() and get_trigger_csc_ID()
1160  int tp_chamber =
1161  tp_sector * 3 - 1; // DT chambers are 30 deg. Multiply sector number by 3 to mimic 10 deg CSC chamber number
1162  int tp_endcap = (tp_wheel > 0) ? 1 : ((tp_wheel < 0) ? 2 : 0);
1163  int csc_tp_sector = emtf::get_trigger_sector(2, 2, tp_chamber);
1164  int tp_csc_ID = emtf::get_trigger_csc_ID(2, 2, tp_chamber);
1165  int tp_subsector = 0;
1166 
1167  if (endcap_ == 1 && sector_ == 1 && bx_ == -3) { // do assertion checks only once
1168  //emtf_assert(-2 <= tp_wheel && tp_wheel <= +2);
1169  emtf_assert(tp_wheel == -2 || tp_wheel == +2); // do not include wheels -1, 0, +1
1170  //emtf_assert(1 <= tp_station && tp_station <= 4);
1171  emtf_assert(1 <= tp_station && tp_station <= 3); // do not include MB4
1172  emtf_assert(1 <= tp_sector && tp_sector <= 12);
1173  emtf_assert(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP);
1174  emtf_assert(emtf::MIN_TRIGSECTOR <= csc_tp_sector && csc_tp_sector <= emtf::MAX_TRIGSECTOR);
1175  //emtf_assert(4 <= tp_csc_ID && tp_csc_ID <= 9);
1176  emtf_assert(tp_csc_ID == 6 || tp_csc_ID == 9);
1177  emtf_assert(-2048 <= tp_phi && tp_phi <= 2047); // 12-bit
1178  //emtf_assert(-512 <= tp_phiB && tp_phiB <= 511); // 10-bit
1179  }
1180 
1181  // Check if the chamber belongs to this sector processor at this BX.
1182  selected = get_index_dt(tp_endcap, csc_tp_sector, tp_subsector, tp_station, tp_csc_ID, tp_bx);
1183  }
1184  return selected;
1185 }
1186 
1187 bool PrimitiveSelection::is_in_sector_dt(int tp_endcap, int tp_sector) const {
1188  // Identical to the corresponding CSC function
1189  return is_in_sector_csc(tp_endcap, tp_sector);
1190 }
1191 
1192 bool PrimitiveSelection::is_in_neighbor_sector_dt(int tp_endcap, int tp_sector, int tp_csc_ID) const {
1193  // Identical to the corresponding CSC function
1194  // (Note: use tp_subsector = 0, tp_station = 2)
1195  return is_in_neighbor_sector_csc(tp_endcap, tp_sector, 0, 2, tp_csc_ID);
1196 }
1197 
1198 bool PrimitiveSelection::is_in_bx_dt(int tp_bx) const {
1199  //tp_bx += bxShiftDT_;
1200  return (bx_ == tp_bx);
1201 }
1202 
1204  int tp_endcap, int csc_tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const {
1205  int selected = -1;
1206 
1207  bool is_native = false;
1208  bool is_neighbor = false;
1209  if (is_in_bx_dt(tp_bx)) {
1210  if (is_in_sector_dt(tp_endcap, csc_tp_sector)) {
1211  is_native = true;
1212  } else if (is_in_neighbor_sector_dt(tp_endcap, csc_tp_sector, tp_csc_ID)) {
1213  is_neighbor = true;
1214  }
1215  }
1216  if (!is_native && !is_neighbor)
1217  return selected;
1218 
1219  if (!is_neighbor) { // MB1,2,3,4: 0-7
1220  selected = (tp_station - 1) * 2 + (tp_csc_ID - 6) / 3; // tp_csc_ID should be either 6 or 9
1221  } else { // ME1,2,3,4n: 8-11
1222  selected = 8 + (tp_station - 1);
1223  }
1224  emtf_assert(selected != -1);
1225  return selected;
1226 }
PrimitiveSelection::select_me0
int select_me0(const TriggerPrimitive &muon_primitive) const
Definition: PrimitiveSelection.cc:995
PrimitiveSelection::verbose_
int verbose_
Definition: PrimitiveSelection.h:110
PrimitiveSelection::duplicateTheta_
bool duplicateTheta_
Definition: PrimitiveSelection.h:114
PrimitiveSelection::is_in_bx_gem
bool is_in_bx_gem(int tp_bx) const
Definition: PrimitiveSelection.cc:951
L1TMuon::TriggerPrimitive::getWire
int getWire() const
Definition: MuonTriggerPrimitive.cc:377
RPCData
Definition: RPCData.h:42
emtf::CSCTag
Definition: EMTFSubsystemTag.h:31
PrimitiveSelection::get_index_rpc
int get_index_rpc(int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector, int tp_bx) const
Definition: PrimitiveSelection.cc:834
PrimitiveSelection::bxShiftME0_
int bxShiftME0_
Definition: PrimitiveSelection.h:112
PrimitiveSelection::is_in_bx_csc
bool is_in_bx_csc(int tp_bx) const
Definition: PrimitiveSelection.cc:702
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
GEMDetId::ring
constexpr int ring() const
Definition: GEMDetId.h:170
L1TMuon::TriggerPrimitive::accessCSCData
CSCData & accessCSCData()
Definition: MuonTriggerPrimitive.h:260
RPCDetId::subsector
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel,...
Definition: RPCDetId.h:88
PrimitiveSelection::bx_
int bx_
Definition: PrimitiveSelection.h:110
emtf::MIN_TRIGSECTOR
constexpr int MIN_TRIGSECTOR
Definition: Common.h:49
GEMDetId::layer
constexpr int layer() const
Definition: GEMDetId.h:184
PrimitiveSelection::endcap_
int endcap_
Definition: PrimitiveSelection.h:110
emtf::GEMTag
Definition: EMTFSubsystemTag.h:57
PrimitiveSelection::select_dt
int select_dt(const TriggerPrimitive &muon_primitive) const
Definition: PrimitiveSelection.cc:1133
GEMDetId::region
constexpr int region() const
Definition: GEMDetId.h:165
relativeConstraints.station
station
Definition: relativeConstraints.py:67
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
PrimitiveSelection::is_in_sector_dt
bool is_in_sector_dt(int tp_endcap, int tp_sector) const
Definition: PrimitiveSelection.cc:1187
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PrimitiveSelection::is_in_sector_me0
bool is_in_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const
Definition: PrimitiveSelection.cc:1039
emtf::get_trigger_csc_ID
int get_trigger_csc_ID(int ring, int station, int chamber)
Definition: TrackTools.cc:100
L1TMuon::TriggerPrimitive::getRPCData
RPCData getRPCData() const
Definition: MuonTriggerPrimitive.h:255
L1TMuon::TriggerPrimitive::getCSCData
CSCData getCSCData() const
Definition: MuonTriggerPrimitive.h:254
emtf::MAX_ENDCAP
constexpr int MAX_ENDCAP
Definition: Common.h:46
NUM_RPC_CHAMBERS
#define NUM_RPC_CHAMBERS
Definition: PrimitiveSelection.cc:11
NUM_GEM_CHAMBERS
#define NUM_GEM_CHAMBERS
Definition: PrimitiveSelection.cc:13
PrimitiveSelection::get_index_dt
int get_index_dt(int tp_endcap, int csc_tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const
Definition: PrimitiveSelection.cc:1203
PrimitiveSelection::select_gem
int select_gem(const TriggerPrimitive &muon_primitive) const
Definition: PrimitiveSelection.cc:896
DDAxes::x
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
PrimitiveSelection::process
void process(T tag, const TriggerPrimitiveCollection &muon_primitives, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
L1TMuon::TriggerPrimitive::kCSC
Definition: MuonTriggerPrimitive.h:59
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
PrimitiveSelection::select_rpc
int select_rpc(const TriggerPrimitive &muon_primitive) const
Definition: PrimitiveSelection.cc:744
PrimitiveSelection.h
end
#define end
Definition: vmac.h:39
emtf::MAX_TRIGSECTOR
constexpr int MAX_TRIGSECTOR
Definition: Common.h:50
simKBmtfDigis_cfi.bx
bx
Definition: simKBmtfDigis_cfi.py:55
PrimitiveSelection::get_index_gem
int get_index_gem(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const
Definition: PrimitiveSelection.cc:956
NUM_DT_CHAMBERS
#define NUM_DT_CHAMBERS
Definition: PrimitiveSelection.cc:15
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
PrimitiveSelection::bxShiftRPC_
int bxShiftRPC_
Definition: PrimitiveSelection.h:112
L1TMuon::TriggerPrimitive::kGEM
Definition: MuonTriggerPrimitive.h:59
L1TMuon::TriggerPrimitive::DTData::theta_bti_group
int theta_bti_group
Definition: MuonTriggerPrimitive.h:160
emtf::MIN_ENDCAP
constexpr int MIN_ENDCAP
Definition: Common.h:45
L1TMuon::TriggerPrimitive::kDT
Definition: MuonTriggerPrimitive.h:59
emtf::get_csc_max_strip_and_wire
std::pair< int, int > get_csc_max_strip_and_wire(int station, int ring)
Definition: TrackTools.cc:141
L1TMuon::TriggerPrimitive::accessDTData
DTData & accessDTData()
Definition: MuonTriggerPrimitive.h:259
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
PrimitiveSelection::bxShiftGEM_
int bxShiftGEM_
Definition: PrimitiveSelection.h:112
L1TMuon::TriggerPrimitive
Definition: MuonTriggerPrimitive.h:56
PrimitiveSelection::get_index_me0
int get_index_me0(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_pad, int tp_bx) const
Definition: PrimitiveSelection.cc:1106
emtf::ME0Tag
Definition: EMTFSubsystemTag.h:62
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
L1TMuon::TriggerPrimitive::ME0Data
Definition: MuonTriggerPrimitive.h:176
edm::LogWarning
Definition: MessageLogger.h:141
CSCDetId::triggerSector
int triggerSector() const
Definition: CSCDetId.cc:3
RPCDetId::roll
int roll() const
Definition: RPCDetId.h:92
GEMDetId::chamber
constexpr int chamber() const
Definition: GEMDetId.h:177
emtf::RPCTag
Definition: EMTFSubsystemTag.h:38
PrimitiveSelection::is_in_neighbor_sector_csc
bool is_in_neighbor_sector_csc(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const
Definition: PrimitiveSelection.cc:683
TriggerPrimitiveCollection
L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection
Definition: Common.h:32
PrimitiveSelection::is_in_sector_gem
bool is_in_sector_gem(int tp_endcap, int tp_sector) const
Definition: PrimitiveSelection.cc:940
L1TMuon::TriggerPrimitive::DTData
Definition: MuonTriggerPrimitive.h:127
GEMDetId::roll
constexpr int roll() const
Definition: GEMDetId.h:188
GEMDetId
Definition: GEMDetId.h:17
CSCDetId
Definition: CSCDetId.h:26
PrimitiveSelection::sector_
int sector_
Definition: PrimitiveSelection.h:110
ME0DetId::station
int station() const
Definition: ME0DetId.h:58
L1TMuon::TriggerPrimitive::detId
IDType detId() const
Definition: MuonTriggerPrimitive.h:242
emtf::get_trigger_sector
int get_trigger_sector(int ring, int station, int chamber)
Definition: TrackTools.cc:85
L1TMuon::TriggerPrimitive::getDTData
DTData getDTData() const
Definition: MuonTriggerPrimitive.h:253
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
ME0DetId
Definition: ME0DetId.h:16
emtf::DTTag
Definition: EMTFSubsystemTag.h:24
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
emtf::get_csc_max_pattern_and_quality
std::pair< int, int > get_csc_max_pattern_and_quality(int station, int ring)
Definition: TrackTools.cc:169
PrimitiveSelection::is_in_bx_rpc
bool is_in_bx_rpc(int tp_bx) const
Definition: PrimitiveSelection.cc:829
PrimitiveSelection::is_in_sector_csc
bool is_in_sector_csc(int tp_endcap, int tp_sector) const
Definition: PrimitiveSelection.cc:679
L1TMuon::TriggerPrimitive::subsystem
subsystem_type subsystem() const
Definition: MuonTriggerPrimitive.h:220
PrimitiveSelection::bugME11Dupes_
bool bugME11Dupes_
Definition: PrimitiveSelection.h:116
L1TMuon::TriggerPrimitive::CSCData::keywire
uint16_t keywire
Definition: MuonTriggerPrimitive.h:114
RPCDetId::ring
int ring() const
Definition: RPCDetId.h:59
L1TMuon::TriggerPrimitive::kME0
Definition: MuonTriggerPrimitive.h:59
L1TMuon::TriggerPrimitive::getGEMData
GEMData getGEMData() const
Definition: MuonTriggerPrimitive.h:256
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
L1TMuon::TriggerPrimitive::CSCData::cscID
uint16_t cscID
Definition: MuonTriggerPrimitive.h:122
PrimitiveSelection::bxShiftCSC_
int bxShiftCSC_
Definition: PrimitiveSelection.h:112
PrimitiveSelection::is_in_neighbor_sector_dt
bool is_in_neighbor_sector_dt(int tp_endcap, int tp_sector, int tp_csc_ID) const
Definition: PrimitiveSelection.cc:1192
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
PrimitiveSelection::merge_no_truncate
void merge_no_truncate(const std::map< int, TriggerPrimitiveCollection > &selected_dt_map, const std::map< int, TriggerPrimitiveCollection > &selected_csc_map, const std::map< int, TriggerPrimitiveCollection > &selected_rpc_map, const std::map< int, TriggerPrimitiveCollection > &selected_gem_map, const std::map< int, TriggerPrimitiveCollection > &selected_me0_map, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
Definition: PrimitiveSelection.cc:561
RPCDetId::sector
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
L1TMuon::TriggerPrimitive::GEMData
Definition: MuonTriggerPrimitive.h:167
ME0DetId::chamber
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: ME0DetId.h:41
PrimitiveSelection::merge
void merge(const std::map< int, TriggerPrimitiveCollection > &selected_dt_map, const std::map< int, TriggerPrimitiveCollection > &selected_csc_map, const std::map< int, TriggerPrimitiveCollection > &selected_rpc_map, const std::map< int, TriggerPrimitiveCollection > &selected_gem_map, const std::map< int, TriggerPrimitiveCollection > &selected_me0_map, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
Definition: PrimitiveSelection.cc:482
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
PrimitiveSelection::is_in_bx_me0
bool is_in_bx_me0(int tp_bx) const
Definition: PrimitiveSelection.cc:1101
PrimitiveSelection::is_in_neighbor_sector_rpc
bool is_in_neighbor_sector_rpc(int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const
Definition: PrimitiveSelection.cc:813
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
PrimitiveSelection::includeNeighbor_
bool includeNeighbor_
Definition: PrimitiveSelection.h:114
PrimitiveSelection::is_in_bx_dt
bool is_in_bx_dt(int tp_bx) const
Definition: PrimitiveSelection.cc:1198
emtf_assert
#define emtf_assert(expr)
Definition: DebugTools.h:18
PrimitiveSelection::get_index_csc
int get_index_csc(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID, int tp_bx) const
Definition: PrimitiveSelection.cc:708
PrimitiveSelection::configure
void configure(int verbose, int endcap, int sector, int bx, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, int bxShiftME0, bool includeNeighbor, bool duplicateTheta, bool bugME11Dupes)
Definition: PrimitiveSelection.cc:17
GEMDetId::station
constexpr int station() const
Definition: GEMDetId.h:173
DTChamberId
Definition: DTChamberId.h:14
helper.h
L1TMuon::TriggerPrimitive::getStrip
int getStrip() const
Definition: MuonTriggerPrimitive.cc:358
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
L1TMuon::TriggerPrimitive::getBX
int getBX() const
Definition: MuonTriggerPrimitive.cc:339
L1TMuon::TriggerPrimitive::CSCData
Definition: MuonTriggerPrimitive.h:95
ME0DetId::region
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: ME0DetId.h:38
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
cuy.ii
ii
Definition: cuy.py:590
PrimitiveSelection::is_in_sector_rpc
bool is_in_sector_rpc(int tp_endcap, int tp_station, int tp_ring, int tp_sector, int tp_subsector) const
Definition: PrimitiveSelection.cc:792
NUM_CSC_CHAMBERS
#define NUM_CSC_CHAMBERS
Definition: PrimitiveSelection.cc:7
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
L1TMuon::TriggerPrimitive::getME0Data
ME0Data getME0Data() const
Definition: MuonTriggerPrimitive.h:257
PrimitiveSelection::is_in_neighbor_sector_gem
bool is_in_neighbor_sector_gem(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const
Definition: PrimitiveSelection.cc:945
triggerSector
Int_t triggerSector(Int_t station, Int_t ring, Int_t chamber) const
Definition: triggerCscIdSector.h:3
PrimitiveSelection::select_csc
int select_csc(const TriggerPrimitive &muon_primitive) const
Definition: PrimitiveSelection.cc:585
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
PrimitiveSelection::is_in_neighbor_sector_me0
bool is_in_neighbor_sector_me0(int tp_endcap, int tp_sector, int tp_csc_ID, int tp_pad) const
Definition: PrimitiveSelection.cc:1069
L1TMuon::TriggerPrimitive::kRPC
Definition: MuonTriggerPrimitive.h:59