CMS 3D CMS Logo

PrimitiveSelection.cc
Go to the documentation of this file.
2 
7 
8 #include "helper.h" // adjacent_cluster
9 
10 #define NUM_CSC_CHAMBERS 6*9 // 18 in ME1; 9 in ME2,3,4; 9 from neighbor sector.
11  // Arranged in FW as 6 stations, 9 chambers per station.
12 #define NUM_RPC_CHAMBERS 7*6 // 6 in RE1,2; 12 in RE3,4; 6 from neighbor sector.
13  // Arranged in FW as 7 stations, 6 chambers per station.
14 #define NUM_GEM_CHAMBERS 6*9 // 6 in GE1/1; 3 in GE2/1; 2 from neighbor sector.
15  // Arranged in FW as 6 stations, 9 chambers per station, mimicking CSC. (unconfirmed!)
16 
17 
19  int verbose, int endcap, int sector, int bx,
20  int bxShiftCSC, int bxShiftRPC, int bxShiftGEM,
21  bool includeNeighbor, bool duplicateTheta,
22  bool bugME11Dupes
23 ) {
24  verbose_ = verbose;
25  endcap_ = endcap;
26  sector_ = sector;
27  bx_ = bx;
28 
29  bxShiftCSC_ = bxShiftCSC;
30  bxShiftRPC_ = bxShiftRPC;
31  bxShiftGEM_ = bxShiftGEM;
32 
33  includeNeighbor_ = includeNeighbor;
34  duplicateTheta_ = duplicateTheta;
35  bugME11Dupes_ = bugME11Dupes;
36 }
37 
38 
39 // _____________________________________________________________________________
40 // Specialized process() for CSC
41 template<>
43  CSCTag tag,
44  const TriggerPrimitiveCollection& muon_primitives,
45  std::map<int, TriggerPrimitiveCollection>& selected_csc_map
46 ) const {
47  TriggerPrimitiveCollection::const_iterator tp_it = muon_primitives.begin();
48  TriggerPrimitiveCollection::const_iterator tp_end = muon_primitives.end();
49 
50  for (; tp_it != tp_end; ++tp_it) {
51  TriggerPrimitive new_tp = *tp_it; // make a copy and apply patches to this copy
52 
53  // Patch the CLCT pattern number
54  // It should be 0-10, see: L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
55  bool patchPattern = true;
56  if (patchPattern) {
57  if (new_tp.getCSCData().pattern == 11 || new_tp.getCSCData().pattern == 12) { // 11, 12 -> 10
58  edm::LogWarning("L1T") << "\nEMTF emulator patching corrupt CSC LCT pattern: changing " << new_tp.getCSCData().pattern << " to 10\n";
59  new_tp.accessCSCData().pattern = 10;
60  }
61  }
62 
63  // Patch the LCT quality number
64  // It should be 1-15, see: L1Trigger/CSCTriggerPrimitives/src/CSCMotherboard.cc
65  bool patchQuality = true;
66  if (patchQuality) {
67  if (new_tp.subsystem() == TriggerPrimitive::kCSC && new_tp.getCSCData().quality == 0) { // 0 -> 1
68  edm::LogWarning("L1T") << "\nEMTF emulator patching corrupt CSC LCT quality: changing " << new_tp.getCSCData().quality << " to 1\n";
69  new_tp.accessCSCData().quality = 1;
70  }
71  }
72 
73  int selected_csc = select_csc(new_tp); // Returns CSC "link" index (0 - 53)
74 
75  if (selected_csc >= 0) {
76  if (not(selected_csc < NUM_CSC_CHAMBERS))
77  { edm::LogError("L1T") << "selected_csc = " << selected_csc << ", NUM_CSC_CHAMBERS = " << NUM_CSC_CHAMBERS; return; }
78 
79  if (selected_csc_map[selected_csc].size() < 2) {
80  selected_csc_map[selected_csc].push_back(new_tp);
81  }
82  else {
83  edm::LogWarning("L1T") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
84  edm::LogWarning("L1T") << "Found 3 CSC trigger primitives in the same chamber";
85  for (int ii = 0; ii < 3; ii++) {
86  TriggerPrimitive tp_err = (ii < 2 ? selected_csc_map[selected_csc].at(ii) : new_tp);
87  edm::LogWarning("L1T") << "LCT #" << ii+1 << ": BX " << tp_err.getBX()
88  << ", endcap " << tp_err.detId<CSCDetId>().endcap() << ", sector " << tp_err.detId<CSCDetId>().triggerSector()
89  << ", station " << tp_err.detId<CSCDetId>().station() << ", ring " << tp_err.detId<CSCDetId>().ring()
90  << ", chamber " << tp_err.detId<CSCDetId>().chamber() << ", CSC ID " << tp_err.getCSCData().cscID
91  << ": strip " << tp_err.getStrip() << ", wire " << tp_err.getWire();
92  }
93  edm::LogWarning("L1T") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
94  }
95 
96  } // End conditional: if (selected_csc >= 0)
97  } // End loop: for (; tp_it != tp_end; ++tp_it)
98 
99  // Duplicate CSC muon primitives
100  // If there are 2 LCTs in the same chamber with (strip, wire) = (s1, w1) and (s2, w2)
101  // make all combinations with (s1, w1), (s2, w1), (s1, w2), (s2, w2)
102  if (duplicateTheta_) {
103  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_csc_map.begin();
104  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_csc_map.end();
105 
106  for (; map_tp_it != map_tp_end; ++map_tp_it) {
107  int selected = map_tp_it->first;
108  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
109  if (not(tmp_primitives.size() <= 2)) // at most 2 hits
110  { edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size() ; return; }
111 
112  if (tmp_primitives.size() == 2) {
113  if (
114  (tmp_primitives.at(0).getStrip() != tmp_primitives.at(1).getStrip()) &&
115  (tmp_primitives.at(0).getWire() != tmp_primitives.at(1).getWire())
116  ) {
117  // Swap wire numbers
118  TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
119  TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
120  uint16_t tmp_keywire = tp0.accessCSCData().keywire;
121  tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
122  tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
123 
124  tmp_primitives.insert(tmp_primitives.begin()+1, tp1); // (s2,w1) at 2nd pos
125  tmp_primitives.insert(tmp_primitives.begin()+2, tp0); // (s1,w2) at 3rd pos
126  }
127 
128  const bool is_csc_me11 = (0 <= selected && selected <= 2) || (9 <= selected && selected <= 11) || (selected == 45); // ME1/1 sub 1 or ME1/1 sub 2 or ME1/1 from neighbor
129 
130  if (bugME11Dupes_ && is_csc_me11) {
131  // For ME1/1, always make 4 LCTs without checking strip & wire combination
132  if (tmp_primitives.size() == 2) {
133  // Swap wire numbers
134  TriggerPrimitive tp0 = tmp_primitives.at(0); // (s1,w1)
135  TriggerPrimitive tp1 = tmp_primitives.at(1); // (s2,w2)
136  uint16_t tmp_keywire = tp0.accessCSCData().keywire;
137  tp0.accessCSCData().keywire = tp1.accessCSCData().keywire; // (s1,w2)
138  tp1.accessCSCData().keywire = tmp_keywire; // (s2,w1)
139 
140  tmp_primitives.insert(tmp_primitives.begin()+1, tp1); // (s2,w1) at 2nd pos
141  tmp_primitives.insert(tmp_primitives.begin()+2, tp0); // (s1,w2) at 3rd pos
142  }
143  if (not(tmp_primitives.size() == 1 || tmp_primitives.size() == 4))
144  { edm::LogError("L1T") << "tmp_primitives.size() = " << tmp_primitives.size(); return; }
145  }
146 
147  } // end if tmp_primitives.size() == 2
148  } // end loop over selected_csc_map
149  } // end if duplicate theta
150 }
151 
152 
153 // _____________________________________________________________________________
154 // Specialized process() for RPC
155 template<>
157  RPCTag tag,
158  const TriggerPrimitiveCollection& muon_primitives,
159  std::map<int, TriggerPrimitiveCollection>& selected_rpc_map
160 ) const {
161  // Cluster the RPC digis.
162  // Technically this is done by the CPPF, before the EMTF.
163  TriggerPrimitiveCollection clus_muon_primitives;
164  cluster_rpc(muon_primitives, clus_muon_primitives);
165 
166  TriggerPrimitiveCollection::const_iterator tp_it = clus_muon_primitives.begin();
167  TriggerPrimitiveCollection::const_iterator tp_end = clus_muon_primitives.end();
168 
169  for (; tp_it != tp_end; ++tp_it) {
170  int selected_rpc = select_rpc(*tp_it); // Returns RPC "link" index (0 - 41)
171 
172  if (selected_rpc >= 0) {
173  if (not(selected_rpc < NUM_RPC_CHAMBERS))
174  { edm::LogError("L1T") << "selected_rpc = " << selected_rpc << ", NUM_RPC_CHAMBERS = " << NUM_RPC_CHAMBERS; return; }
175  selected_rpc_map[selected_rpc].push_back(*tp_it);
176  }
177  }
178 
179  // Apply truncation as in firmware: keep first 2 clusters, max cluster
180  // size = 3 strips.
181  // According to Karol Bunkowski, for one chamber (so 3 eta rolls) only up
182  // to 2 hits (cluster centres) are produced. First two 'first' clusters are
183  // chosen, and only after the cut on the cluster size is applied. So if
184  // there are 1 large cluster and 2 small clusters, it is possible that
185  // one of the two small clusters is discarded first, and the large cluster
186  // then is removed by the cluster size cut, leaving only one cluster.
187  bool apply_truncation = true;
188  if (apply_truncation) {
189  struct {
191  bool operator()(const value_type& x) const {
192  int sz = x.getRPCData().strip_hi - x.getRPCData().strip_low + 1;
193  return sz > 3;
194  }
195  } cluster_size_cut;
196 
197  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
198  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
199 
200  for (; map_tp_it != map_tp_end; ++map_tp_it) {
201  //int selected = map_tp_it->first;
202  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
203 
204  // Keep the first two clusters
205  if (tmp_primitives.size() > 2)
206  tmp_primitives.erase(tmp_primitives.begin()+2, tmp_primitives.end());
207 
208  // Apply cluster size cut
209  tmp_primitives.erase(
210  std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
211  tmp_primitives.end()
212  );
213  }
214  } // end if apply_truncation
215 
216  // Map RPC subsector and chamber to CSC chambers
217  // Note: RE3/2 & RE3/3 are considered as one chamber; RE4/2 & RE4/3 too.
218  bool map_rpc_to_csc = true;
219  if (map_rpc_to_csc) {
220  std::map<int, TriggerPrimitiveCollection> tmp_selected_rpc_map;
221 
222  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_rpc_map.begin();
223  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_rpc_map.end();
224 
225  for (; map_tp_it != map_tp_end; ++map_tp_it) {
226  int selected = map_tp_it->first;
227  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
228 
229  int rpc_sub = selected / 6;
230  int rpc_chm = selected % 6;
231 
232  int pc_station = -1;
233  int pc_chamber = -1;
234 
235  if (rpc_sub != 6) { // native
236  if (rpc_chm == 0) { // RE1/2
237  if (0 <= rpc_sub && rpc_sub < 3) {
238  pc_station = 0;
239  pc_chamber = 3 + rpc_sub;
240  } else if (3 <= rpc_sub && rpc_sub < 6) {
241  pc_station = 1;
242  pc_chamber = 3 + (rpc_sub - 3);
243  }
244  } else if (rpc_chm == 1) { // RE2/2
245  pc_station = 2;
246  pc_chamber = 3 + rpc_sub;
247  } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3
248  pc_station = 3;
249  pc_chamber = 3 + rpc_sub;
250  } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3
251  pc_station = 4;
252  pc_chamber = 3 + rpc_sub;
253  }
254 
255  } else { // neighbor
256  pc_station = 5;
257  if (rpc_chm == 0) { // RE1/2
258  pc_chamber = 1;
259  } else if (rpc_chm == 1) { // RE2/2
260  pc_chamber = 4;
261  } else if (2 <= rpc_chm && rpc_chm <= 3) { // RE3/2, RE3/3
262  pc_chamber = 6;
263  } else if (4 <= rpc_chm && rpc_chm <= 5) { // RE4/2, RE4/3
264  pc_chamber = 8;
265  }
266  }
267 
268  if (not(pc_station != -1 && pc_chamber != -1))
269  { edm::LogError("L1T") << "pc_station = " << pc_station << ", pc_chamber = " << pc_chamber; return; }
270 
271  selected = (pc_station * 9) + pc_chamber;
272 
273  bool ignore_this_rpc_chm = false;
274  if (rpc_chm == 3 || rpc_chm == 5) { // special case of RE34/2 and RE34/3 chambers
275  // if RE34/2 exists, ignore RE34/3. In C++, this assumes that the loop
276  // over selected_rpc_map will always find RE34/2 before RE34/3
277  if (tmp_selected_rpc_map.find(selected) != tmp_selected_rpc_map.end())
278  ignore_this_rpc_chm = true;
279  }
280 
281  if (!ignore_this_rpc_chm) {
282  if (not(tmp_selected_rpc_map.find(selected) == tmp_selected_rpc_map.end())) // make sure it does not exist
283  { edm::LogError("L1T") << "tmp_selected_rpc_map.find(selected) != tmp_selected_rpc_map.end()"; return; }
284  tmp_selected_rpc_map[selected] = tmp_primitives;
285  }
286  else { // If both RE34/2 and RE34/3 exist, keep both for now - remove ring 3 hits in PrimitiveSelection::merge()
287  tmp_selected_rpc_map[selected].insert(tmp_selected_rpc_map[selected].end(), tmp_primitives.begin(), tmp_primitives.end());
288  }
289 
290  } // end loop over selected_rpc_map
291 
292  std::swap(selected_rpc_map, tmp_selected_rpc_map); // replace the original map
293  } // end if map_rpc_to_csc
294 }
295 
296 
297 // _____________________________________________________________________________
298 // Specialized process() for GEM
299 template<>
301  GEMTag tag,
302  const TriggerPrimitiveCollection& muon_primitives,
303  std::map<int, TriggerPrimitiveCollection>& selected_gem_map
304 ) const {
305  // Cluster the GEM digis.
306  // Technically this is done before the EMTF.
307  TriggerPrimitiveCollection clus_muon_primitives;
308  cluster_gem(muon_primitives, clus_muon_primitives);
309 
310  TriggerPrimitiveCollection::const_iterator tp_it = clus_muon_primitives.begin();
311  TriggerPrimitiveCollection::const_iterator tp_end = clus_muon_primitives.end();
312 
313  for (; tp_it != tp_end; ++tp_it) {
314  int selected_gem = select_gem(*tp_it); // Returns GEM "link" index (0 - 53)
315 
316  if (selected_gem >= 0) {
317  if (not(selected_gem < NUM_GEM_CHAMBERS))
318  { edm::LogError("L1T") << "selected_gem = " << selected_gem << ", NUM_GEM_CHAMBERS = " << NUM_GEM_CHAMBERS; return; }
319  selected_gem_map[selected_gem].push_back(*tp_it);
320  }
321  }
322 
323  // Apply truncation: max cluster size = 8 pads, keep first 8 clusters.
324  bool apply_truncation = true;
325  if (apply_truncation) {
326  struct {
328  bool operator()(const value_type& x) const {
329  int sz = x.getRPCData().strip_hi - x.getRPCData().strip_low + 1;
330  return sz > 8;
331  }
332  } cluster_size_cut;
333 
334  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_it = selected_gem_map.begin();
335  std::map<int, TriggerPrimitiveCollection>::iterator map_tp_end = selected_gem_map.end();
336 
337  for (; map_tp_it != map_tp_end; ++map_tp_it) {
338  //int selected = map_tp_it->first;
339  TriggerPrimitiveCollection& tmp_primitives = map_tp_it->second; // pass by reference
340 
341  // Apply cluster size cut
342  tmp_primitives.erase(
343  std::remove_if(tmp_primitives.begin(), tmp_primitives.end(), cluster_size_cut),
344  tmp_primitives.end()
345  );
346 
347  // Keep the first two clusters
348  if (tmp_primitives.size() > 8)
349  tmp_primitives.erase(tmp_primitives.begin()+8, tmp_primitives.end());
350  }
351  } // end if apply_truncation
352 
353  //FIXME: What to do about the two layers?
354 }
355 
356 
357 // _____________________________________________________________________________
358 // Put the hits from CSC, RPC, GEM together in one collection
359 
360 // Notes from Alex (2017-03-28):
361 //
362 // The RPC inclusion logic is very simple currently:
363 // - each CSC is analyzed for having track stubs in each BX
364 // - IF a CSC chamber is missing at least one track stub,
365 // AND there is an RPC overlapping with it in phi and theta,
366 // AND that RPC has hits,
367 // THEN RPC hit is inserted instead of missing CSC stub.
368 //
369 // This is done at the output of coord_delay module, so such
370 // inserted RPC hits can be matched to patterns by match_ph_segments
371 // module, just like any CSC stubs. Note that substitution of missing
372 // CSC stubs with RPC hits happens regardless of what's going on in
373 // other chambers, regardless of whether a pattern has been detected
374 // or not, basically regardless of anything. RPCs are treated as a
375 // supplemental source of stubs for CSCs.
376 
378  std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
379  std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
380  std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
381  std::map<int, TriggerPrimitiveCollection>& selected_prim_map
382 ) const {
383 
384  // First, put CSC hits
385  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_csc_map.begin();
386  std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_csc_map.end();
387 
388  for (; map_tp_it != map_tp_end; ++map_tp_it) {
389  int selected_csc = map_tp_it->first;
390  const TriggerPrimitiveCollection& csc_primitives = map_tp_it->second;
391  if (not(csc_primitives.size() <= 4)) // at most 4 hits, including duplicated hits
392  { edm::LogError("L1T") << "csc_primitives.size() = " << csc_primitives.size(); return; }
393 
394  // Insert all CSC hits
395  selected_prim_map[selected_csc] = csc_primitives;
396  }
397 
398  // Second, insert RPC stubs if there is no CSC hits
399  map_tp_it = selected_rpc_map.begin();
400  map_tp_end = selected_rpc_map.end();
401 
402  for (; map_tp_it != map_tp_end; ++map_tp_it) {
403  int selected_rpc = map_tp_it->first;
404  const TriggerPrimitiveCollection& rpc_primitives = map_tp_it->second;
405  if (rpc_primitives.empty()) continue;
406  if (not(rpc_primitives.size() <= 4)) // at most 4 hits
407  { edm::LogError("L1T") << "rpc_primitives.size() = " << rpc_primitives.size(); return; }
408 
409  bool found = (selected_prim_map.find(selected_rpc) != selected_prim_map.end());
410  if (!found) {
411 
412  int pc_station = selected_rpc / 9;
413  int pc_chamber = selected_rpc % 9;
414  int station = std::max(1, (pc_station < 5 ? pc_station : pc_chamber / 2));
415 
416  // For station 1 and 2 RPC chambers, insert all RPC hits
417  if ( station <= 2 )
418  selected_prim_map[selected_rpc] = rpc_primitives;
419  // Special case of RE34/2 and RE34/3 chambers: if RE34/2 exists, ignore RE34/3
420  else {
421  bool RPC_in_ring_2 = false; // >= 1 RPC hit found in ring 2
422  bool RPC_in_ring_3 = false; // >= 1 RPC hit found in ring 3
423 
424  for (const auto& tp_it : rpc_primitives) {
425  if (tp_it.detId<RPCDetId>().ring() == 2) RPC_in_ring_2 = true;
426  if (tp_it.detId<RPCDetId>().ring() == 3) RPC_in_ring_3 = true;
427  }
428 
429  if (!RPC_in_ring_2 || !RPC_in_ring_3) // RPCs not found in both rings
430  selected_prim_map[selected_rpc] = rpc_primitives;
431  else {
432  TriggerPrimitiveCollection rpc_primitives_ring_2; // RPC hits in ring 2
433  for (const auto& tp_it : rpc_primitives) {
434  if (tp_it.detId<RPCDetId>().ring() == 2) {
435  rpc_primitives_ring_2.push_back(tp_it);
436  }
437  }
438  selected_prim_map[selected_rpc] = rpc_primitives_ring_2;
439  }
440  }
441 
442  if (not(selected_prim_map[selected_rpc].size() <= 2)) // at most 2 hits
443  { edm::LogError("L1T") << "selected_prim_map[selected_rpc].size() = " << selected_prim_map[selected_rpc].size(); return; }
444 
445  } // End conditional: if (!found)
446  // else { // Initial FW in 2017; was disabled on June 7
447  // // If only one CSC hit, insert the first RPC hit
448  // TriggerPrimitiveCollection& tmp_primitives = selected_prim_map[selected_rpc]; // pass by reference
449 
450  // if (tmp_primitives.size() < 2) {
451  // tmp_primitives.push_back(rpc_primitives.front());
452  // }
453  // }
454  }
455 
456  // Third, insert GEM stubs if there is no CSC/RPC hits
457  map_tp_it = selected_gem_map.begin();
458  map_tp_end = selected_gem_map.end();
459 
460  for (; map_tp_it != map_tp_end; ++map_tp_it) {
461  int selected_gem = map_tp_it->first;
462  const TriggerPrimitiveCollection& gem_primitives = map_tp_it->second;
463  if (gem_primitives.empty()) continue;
464  if (not(gem_primitives.size() <= 2)) // at most 2 hits
465  { edm::LogError("L1T") << "gem_primitives.size() = " << gem_primitives.size(); return; }
466 
467  bool found = (selected_prim_map.find(selected_gem) != selected_prim_map.end());
468  if (!found) {
469  // No CSC/RPC hits, insert all GEM hits
470  selected_prim_map[selected_gem] = gem_primitives;
471 
472  } else {
473  // If only one CSC/RPC hit, insert the first GEM hit
474  TriggerPrimitiveCollection& tmp_primitives = selected_prim_map[selected_gem]; // pass by reference
475 
476  if (tmp_primitives.size() < 2) {
477  tmp_primitives.push_back(gem_primitives.front());
478  }
479  }
480  }
481 }
482 
484  std::map<int, TriggerPrimitiveCollection>& selected_csc_map,
485  std::map<int, TriggerPrimitiveCollection>& selected_rpc_map,
486  std::map<int, TriggerPrimitiveCollection>& selected_gem_map,
487  std::map<int, TriggerPrimitiveCollection>& selected_prim_map
488 ) const {
489  // First, put CSC hits
490  merge_map_into_map(selected_csc_map, selected_prim_map);
491 
492  // Second, insert GEM hits
493  merge_map_into_map(selected_gem_map, selected_prim_map);
494 
495  // Third, insert RPC hits
496  merge_map_into_map(selected_rpc_map, selected_prim_map);
497 
498  // Finally, clear the input maps to save memory
499  selected_csc_map.clear();
500  selected_rpc_map.clear();
501  selected_gem_map.clear();
502 }
503 
504 
505 // _____________________________________________________________________________
506 // CSC functions
507 int PrimitiveSelection::select_csc(const TriggerPrimitive& muon_primitive) const {
508  int selected = -1;
509 
510  if (muon_primitive.subsystem() == TriggerPrimitive::kCSC) {
511  const CSCDetId& tp_detId = muon_primitive.detId<CSCDetId>();
512  const CSCData& tp_data = muon_primitive.getCSCData();
513 
514  int tp_endcap = tp_detId.endcap();
515  int tp_sector = tp_detId.triggerSector();
516  int tp_station = tp_detId.station();
517  int tp_ring = tp_detId.ring();
518  int tp_chamber = tp_detId.chamber();
519 
520  int tp_bx = tp_data.bx;
521  int tp_csc_ID = tp_data.cscID;
522 
523  if ( !(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP) ) {
524  edm::LogWarning("L1T") << "EMTF CSC format error: tp_endcap = " << tp_endcap; return selected; }
525  if ( !(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR) ) {
526  edm::LogWarning("L1T") << "EMTF CSC format error: tp_sector = " << tp_sector; return selected; }
527  if ( !(1 <= tp_station && tp_station <= 4) ) {
528  edm::LogWarning("L1T") << "EMTF CSC format error: tp_station = " << tp_station; return selected; }
529  if ( !(1 <= tp_csc_ID && tp_csc_ID <= 9) ) {
530  edm::LogWarning("L1T") << "EMTF CSC format error: tp_csc_ID = " << tp_csc_ID; return selected; }
531  if ( !(tp_data.valid == true) ) {
532  edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.valid = " << tp_data.valid ; return selected; }
533  if ( !(tp_data.pattern <= 10) ) {
534  edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.pattern = " << tp_data.pattern; return selected; }
535  if ( !(tp_data.quality > 0) ) {
536  edm::LogWarning("L1T") << "EMTF CSC format error: tp_data.quality = " << tp_data.quality; return selected; }
537 
538  int max_strip = 0;
539  int max_wire = 0;
540  if (tp_station == 1 && tp_ring == 4) { // ME1/1a
541  max_strip = 96;
542  max_wire = 48;
543  } else if (tp_station == 1 && tp_ring == 1) { // ME1/1b
544  max_strip = 128;
545  max_wire = 48;
546  } else if (tp_station == 1 && tp_ring == 2) { // ME1/2
547  max_strip = 160;
548  max_wire = 64;
549  } else if (tp_station == 1 && tp_ring == 3) { // ME1/3
550  max_strip = 128;
551  max_wire = 32;
552  } else if (tp_station == 2 && tp_ring == 1) { // ME2/1
553  max_strip = 160;
554  max_wire = 112;
555  } else if (tp_station >= 3 && tp_ring == 1) { // ME3/1, ME4/1
556  max_strip = 160;
557  max_wire = 96;
558  } else if (tp_station >= 2 && tp_ring == 2) { // ME2/2, ME3/2, ME4/2
559  max_strip = 160;
560  max_wire = 64;
561  }
562 
563  if ( !(tp_data.strip < max_strip) ) {
564  edm::LogWarning("L1T") << "EMTF CSC format error in station " << tp_station << ", ring " << tp_ring
565  << ": tp_data.strip = " << tp_data.strip << " (max = " << max_strip - 1 << ")" << std::endl;
566  return selected; }
567  if ( !(tp_data.keywire < max_wire) ) {
568  edm::LogWarning("L1T") << "EMTF CSC format error in station " << tp_station << ", ring " << tp_ring
569  << ": tp_data.keywire = " << tp_data.keywire << " (max = " << max_wire - 1 << ")" << std::endl;
570  return selected; }
571 
572 
573  // station 1 --> subsector 1 or 2
574  // station 2,3,4 --> subsector 0
575  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber%6 > 2) ? 1 : 2);
576 
577  // Selection
578  if (is_in_bx_csc(tp_bx)) {
579  if (is_in_sector_csc(tp_endcap, tp_sector)) {
580  selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, false);
581  } else if (is_in_neighbor_sector_csc(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
582  selected = get_index_csc(tp_subsector, tp_station, tp_csc_ID, true);
583  }
584  }
585  }
586  return selected;
587 }
588 
589 bool PrimitiveSelection::is_in_sector_csc(int tp_endcap, int tp_sector) const {
590  return ((endcap_ == tp_endcap) && (sector_ == tp_sector));
591 }
592 
593 bool PrimitiveSelection::is_in_neighbor_sector_csc(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
594  auto get_neighbor = [](int sector) {
595  return (sector == 1) ? 6 : sector - 1;
596  };
597 
598  if (includeNeighbor_) {
599  if ((endcap_ == tp_endcap) && (get_neighbor(sector_) == tp_sector)) {
600  if (tp_station == 1) {
601  if ((tp_subsector == 2) && (tp_csc_ID == 3 || tp_csc_ID == 6 || tp_csc_ID == 9))
602  return true;
603 
604  } else {
605  if (tp_csc_ID == 3 || tp_csc_ID == 9)
606  return true;
607  }
608  }
609  }
610  return false;
611 }
612 
613 bool PrimitiveSelection::is_in_bx_csc(int tp_bx) const {
614  tp_bx += bxShiftCSC_;
615  return (bx_ == tp_bx);
616 }
617 
618 // Returns CSC input "link". Index used by FW for unique chamber identification.
619 int PrimitiveSelection::get_index_csc(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const {
620  int selected = -1;
621 
622  if (!is_neighbor) {
623  if (tp_station == 1) { // ME1: 0 - 8, 9 - 17
624  selected = (tp_subsector-1) * 9 + (tp_csc_ID-1);
625  } else { // ME2,3,4: 18 - 26, 27 - 35, 36 - 44
626  selected = (tp_station) * 9 + (tp_csc_ID-1);
627  }
628 
629  } else {
630  if (tp_station == 1) { // ME1: 45 - 47
631  selected = (5) * 9 + (tp_csc_ID-1)/3;
632  } else { // ME2,3,4: 48 - 53
633  selected = (5) * 9 + (tp_station) * 2 - 1 + (tp_csc_ID-1 < 3 ? 0 : 1);
634  }
635  }
636  return selected;
637 }
638 
639 
640 // _____________________________________________________________________________
641 // RPC functions
642 void PrimitiveSelection::cluster_rpc(const TriggerPrimitiveCollection& muon_primitives, TriggerPrimitiveCollection& clus_muon_primitives) const {
643  // Define operator to select RPC digis
644  struct {
646  bool operator()(const value_type& x) const {
647  return (x.subsystem() == TriggerPrimitive::kRPC);
648  }
649  } rpc_digi_select;
650 
651  // Define operator to sort the RPC digis prior to clustering.
652  // Use rawId, bx and strip as the sorting id. RPC rawId fully specifies
653  // sector, subsector, endcap, station, ring, layer, roll. Strip is used as
654  // the least significant sorting id.
655  struct {
657  bool operator()(const value_type& lhs, const value_type& rhs) const {
658  bool cmp = (
659  std::make_pair(std::make_pair(lhs.rawId(), lhs.getRPCData().bx), lhs.getRPCData().strip) <
660  std::make_pair(std::make_pair(rhs.rawId(), rhs.getRPCData().bx), rhs.getRPCData().strip)
661  );
662  return cmp;
663  }
664  } rpc_digi_less;
665 
666  struct {
668  bool operator()(const value_type& lhs, const value_type& rhs) const {
669  bool cmp = (
670  std::make_pair(std::make_pair(lhs.rawId(), lhs.getRPCData().bx), lhs.getRPCData().strip) ==
671  std::make_pair(std::make_pair(rhs.rawId(), rhs.getRPCData().bx), rhs.getRPCData().strip)
672  );
673  return cmp;
674  }
675  } rpc_digi_equal;
676 
677  // Define operators for the nearest-neighbor clustering algorithm.
678  // If two digis are next to each other (check strip_hi on the 'left', and
679  // strip_low on the 'right'), cluster them (increment strip_hi on the 'left')
680  struct {
682  bool operator()(const value_type& lhs, const value_type& rhs) const {
683  bool cmp = (
684  (lhs.rawId() == rhs.rawId()) &&
685  (lhs.getRPCData().bx == rhs.getRPCData().bx) &&
686  (lhs.getRPCData().strip_hi+1 == rhs.getRPCData().strip_low)
687  );
688  return cmp;
689  }
690  } rpc_digi_adjacent;
691 
692  struct {
694  void operator()(value_type& lhs, value_type& rhs) { // pass by reference
695  lhs.accessRPCData().strip_hi += 1;
696  }
697  } rpc_digi_cluster;
698 
699  // ___________________________________________________________________________
700  // Do clustering using C++ <algorithm> functions
701 
702  // 1. Select RPC digis
703  std::copy_if(muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), rpc_digi_select);
704 
705  // 2. Sort
706  std::sort(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_less);
707 
708  // 3. Remove duplicates
709  clus_muon_primitives.erase(
710  std::unique(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_equal),
711  clus_muon_primitives.end()
712  );
713 
714  // 4. Cluster adjacent digis
715  clus_muon_primitives.erase(
716  adjacent_cluster(clus_muon_primitives.begin(), clus_muon_primitives.end(), rpc_digi_adjacent, rpc_digi_cluster),
717  clus_muon_primitives.end()
718  );
719 }
720 
721 int PrimitiveSelection::select_rpc(const TriggerPrimitive& muon_primitive) const {
722  int selected = -1;
723 
724  if (muon_primitive.subsystem() == TriggerPrimitive::kRPC) {
725  const RPCDetId& tp_detId = muon_primitive.detId<RPCDetId>();
726  const RPCData& tp_data = muon_primitive.getRPCData();
727 
728  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
729  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
730  int tp_sector = tp_detId.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg)
731  int tp_subsector = tp_detId.subsector(); // 1 - 6 (10 degrees in phi; staggered in z)
732  int tp_station = tp_detId.station(); // 1 - 4
733  int tp_ring = tp_detId.ring(); // 2 - 3 (increasing theta)
734  int tp_roll = tp_detId.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp)
735  //int tp_layer = tp_detId.layer();
736 
737  int tp_bx = tp_data.bx;
738  int tp_strip = tp_data.strip;
739 
740  if ( !(tp_region != 0) ) {
741  edm::LogWarning("L1T") << "EMTF RPC format error: tp_region = " << tp_region; return selected; }
742  if ( !(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP) ) {
743  edm::LogWarning("L1T") << "EMTF RPC format error: tp_endcap = " << tp_endcap; return selected; }
744  if ( !(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR) ) {
745  edm::LogWarning("L1T") << "EMTF RPC format error: tp_sector = " << tp_sector; return selected; }
746  if ( !(1 <= tp_subsector && tp_subsector <= 6) ) {
747  edm::LogWarning("L1T") << "EMTF RPC format error: tp_subsector = " << tp_subsector; return selected; }
748  if ( !(1 <= tp_station && tp_station <= 4) ) {
749  edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station; return selected; }
750  if ( !(2 <= tp_ring && tp_ring <= 3) ) {
751  edm::LogWarning("L1T") << "EMTF RPC format error: tp_ring = " << tp_ring; return selected; }
752  if ( !(1 <= tp_roll && tp_roll <= 3) ) {
753  edm::LogWarning("L1T") << "EMTF RPC format error: tp_roll = " << tp_roll; return selected; }
754  if ( !(1 <= tp_strip && tp_strip <= 32) ) {
755  edm::LogWarning("L1T") << "EMTF RPC format error: tp_data.strip = " << tp_data.strip; return selected; }
756  if ( !(tp_station > 2 || tp_ring != 3) ) {
757  edm::LogWarning("L1T") << "EMTF RPC format error: tp_station = " << tp_station << ", tp_ring = " << tp_ring; return selected; }
758 
759 
760  // Selection
761  if (is_in_bx_rpc(tp_bx)) {
762  if (is_in_sector_rpc(tp_endcap, tp_sector, tp_subsector)) {
763  selected = get_index_rpc(tp_station, tp_ring, tp_subsector, false);
764  } else if (is_in_neighbor_sector_rpc(tp_endcap, tp_sector, tp_subsector)) {
765  selected = get_index_rpc(tp_station, tp_ring, tp_subsector, true);
766  }
767  }
768  }
769  return selected;
770 }
771 
772 bool PrimitiveSelection::is_in_sector_rpc(int tp_endcap, int tp_sector, int tp_subsector) const {
773  // RPC sector X, subsectors 1-2 corresponds to CSC sector X-1
774  // RPC sector X, subsectors 3-6 corresponds to CSC sector X
775  auto get_real_sector = [](int sector, int subsector) {
776  int corr = (subsector < 3) ? (sector == 1 ? +5 : -1) : 0;
777  return sector + corr;
778  };
779  return ((endcap_ == tp_endcap) && (sector_ == get_real_sector(tp_sector, tp_subsector)));
780 }
781 
782 bool PrimitiveSelection::is_in_neighbor_sector_rpc(int tp_endcap, int tp_sector, int tp_subsector) const {
783  return (includeNeighbor_ && (endcap_ == tp_endcap) && (sector_ == tp_sector) && (tp_subsector == 2));
784 }
785 
786 bool PrimitiveSelection::is_in_bx_rpc(int tp_bx) const {
787  tp_bx += bxShiftRPC_;
788  return (bx_ == tp_bx);
789 }
790 
791 int PrimitiveSelection::get_index_rpc(int tp_station, int tp_ring, int tp_subsector, bool is_neighbor) const {
792  int selected = -1;
793 
794  // CPPF RX data come in 3 frames x 64 bits, for 7 links. Each 64-bit data
795  // carry 2 words of 32 bits. Each word carries phi (11 bits) and theta (5 bits)
796  // of 2 segments (x2).
797  //
798  // Firmware uses 'rpc_sub' as RPC subsector index and 'rpc_chm' as RPC chamber index
799  // rpc_sub [0,6] = RPC subsector 3, 4, 5, 6, 1 from neighbor, 2 from neighbor, 2. They correspond to
800  // CSC sector phi 0-10 deg, 10-20, 20-30, 30-40, 40-50, 50-60, 50-60 from neighbor
801  // rpc_chm [0,5] = RPC chamber RE1/2, RE2/2, RE3/2, RE3/3, RE4/2, RE4/3
802  //
803  int rpc_sub = -1;
804  int rpc_chm = -1;
805 
806  if (!is_neighbor) {
807  rpc_sub = ((tp_subsector + 3) % 6);
808  } else {
809  rpc_sub = 6;
810  }
811 
812  if (tp_station <= 2) {
813  rpc_chm = (tp_station - 1);
814  } else {
815  rpc_chm = 2 + (tp_station - 3)*2 + (tp_ring - 2);
816  }
817 
818  if (not(rpc_sub != -1 && rpc_chm != -1))
819  { edm::LogError("L1T") << "rpc_sub = " << rpc_sub << ", rpc_chm = " << rpc_chm; return selected; }
820 
821  selected = (rpc_sub * 6) + rpc_chm;
822  return selected;
823 }
824 
825 
826 // _____________________________________________________________________________
827 // GEM functions
828 void PrimitiveSelection::cluster_gem(const TriggerPrimitiveCollection& muon_primitives, TriggerPrimitiveCollection& clus_muon_primitives) const {
829  // Define operator to select GEM digis
830  struct {
832  bool operator()(const value_type& x) const {
833  return (x.subsystem() == TriggerPrimitive::kGEM);
834  }
835  } gem_digi_select;
836 
837  // Define operator to sort the GEM digis prior to clustering.
838  // Use rawId, bx and pad as the sorting id. GEM rawId fully specifies
839  // endcap, station, ring, layer, roll, chamber. Pad is used as
840  // the least significant sorting id.
841  struct {
843  bool operator()(const value_type& lhs, const value_type& rhs) const {
844  bool cmp = (
845  std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) <
846  std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)
847  );
848  return cmp;
849  }
850  } gem_digi_less;
851 
852  struct {
854  bool operator()(const value_type& lhs, const value_type& rhs) const {
855  bool cmp = (
856  std::make_pair(std::make_pair(lhs.rawId(), lhs.getGEMData().bx), lhs.getGEMData().pad) ==
857  std::make_pair(std::make_pair(rhs.rawId(), rhs.getGEMData().bx), rhs.getGEMData().pad)
858  );
859  return cmp;
860  }
861  } gem_digi_equal;
862 
863  // Define operators for the nearest-neighbor clustering algorithm.
864  // If two digis are next to each other (check pad_hi on the 'left', and
865  // pad_low on the 'right'), cluster them (increment pad_hi on the 'left')
866  struct {
868  bool operator()(const value_type& lhs, const value_type& rhs) const {
869  bool cmp = (
870  (lhs.rawId() == rhs.rawId()) &&
871  (lhs.getGEMData().bx == rhs.getGEMData().bx) &&
872  (lhs.getGEMData().pad_hi+1 == rhs.getGEMData().pad_low)
873  );
874  return cmp;
875  }
876  } gem_digi_adjacent;
877 
878  struct {
880  void operator()(value_type& lhs, value_type& rhs) { // pass by reference
881  lhs.accessGEMData().pad_hi += 1;
882  }
883  } gem_digi_cluster;
884 
885  // ___________________________________________________________________________
886  // Do clustering using C++ <algorithm> functions
887 
888  // 1. Select GEM digis
889  std::copy_if(muon_primitives.begin(), muon_primitives.end(), std::back_inserter(clus_muon_primitives), gem_digi_select);
890 
891  // 2. Sort
892  std::sort(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_less);
893 
894  // 3. Remove duplicates
895  clus_muon_primitives.erase(
896  std::unique(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_equal),
897  clus_muon_primitives.end()
898  );
899 
900  // 4. Cluster adjacent digis
901  clus_muon_primitives.erase(
902  adjacent_cluster(clus_muon_primitives.begin(), clus_muon_primitives.end(), gem_digi_adjacent, gem_digi_cluster),
903  clus_muon_primitives.end()
904  );
905 }
906 
907 int PrimitiveSelection::select_gem(const TriggerPrimitive& muon_primitive) const {
908  int selected = -1;
909 
910  if (muon_primitive.subsystem() == TriggerPrimitive::kGEM) {
911  const GEMDetId& tp_detId = muon_primitive.detId<GEMDetId>();
912  const GEMData& tp_data = muon_primitive.getGEMData();
913 
914  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
915  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
916  int tp_station = tp_detId.station();
917  int tp_ring = tp_detId.ring();
918  int tp_roll = tp_detId.roll();
919  int tp_layer = tp_detId.layer();
920  int tp_chamber = tp_detId.chamber();
921 
922  int tp_bx = tp_data.bx;
923  int tp_pad = tp_data.pad;
924 
925  // Use CSC trigger sector definitions
926  // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
927  auto get_trigger_sector = [](int ring, int station, int chamber) {
928  int result = 0;
929  if( station > 1 && ring > 1 ) {
930  result = ((static_cast<unsigned>(chamber-3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
931  }
932  else {
933  result = (station != 1) ? ((static_cast<unsigned>(chamber-2) & 0x1f) / 3) + 1 : // ch 2-4-> 1, 5-7->2, ...
934  ((static_cast<unsigned>(chamber-3) & 0x7f) / 6) + 1;
935  }
936  return (result <= 6) ? result : 6; // max sector is 6, some calculations give a value greater than six but this is expected.
937  };
938 
939  // Use CSC trigger "CSC ID" definitions
940  // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
941  auto get_trigger_csc_ID = [](int ring, int station, int chamber) {
942  int result = 0;
943  if( station == 1 ) {
944  result = (chamber) % 3 + 1; // 1,2,3
945  switch (ring) {
946  case 1:
947  break;
948  case 2:
949  result += 3; // 4,5,6
950  break;
951  case 3:
952  result += 6; // 7,8,9
953  break;
954  }
955  }
956  else {
957  if( ring == 1 ) {
958  result = (chamber+1) % 3 + 1; // 1,2,3
959  }
960  else {
961  result = (chamber+3) % 6 + 4; // 4,5,6,7,8,9
962  }
963  }
964  return result;
965  };
966 
967  int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber);
968  int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
969 
970  // station 1 --> subsector 1 or 2
971  // station 2,3,4 --> subsector 0
972  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber%6 > 2) ? 1 : 2);
973 
974 
975  if ( !(emtf::MIN_ENDCAP <= tp_endcap && tp_endcap <= emtf::MAX_ENDCAP) ) {
976  edm::LogWarning("L1T") << "EMTF GEM format error: tp_endcap = " << tp_endcap; return selected; }
977  if ( !(emtf::MIN_TRIGSECTOR <= tp_sector && tp_sector <= emtf::MAX_TRIGSECTOR) ) {
978  edm::LogWarning("L1T") << "EMTF GEM format error: tp_sector = " << tp_sector; return selected; }
979  if ( !(1 <= tp_station && tp_station <= 2) ) {
980  edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station; return selected; }
981  if ( !(1 <= tp_ring && tp_ring <= 1) ) {
982  edm::LogWarning("L1T") << "EMTF GEM format error: tp_ring = " << tp_ring; return selected; }
983  if ( !(1 <= tp_csc_ID && tp_csc_ID <= 9) ) {
984  edm::LogWarning("L1T") << "EMTF GEM format error: tp_csc_ID = " << tp_csc_ID; return selected; }
985  if (!(tp_station == 1 && 1 <= tp_roll && tp_roll <= 8) || (tp_station != 1)) {
986  edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station
987  << ", tp_roll = " << tp_roll; return selected; }
988  if ( !(tp_station == 2 && 1 <= tp_roll && tp_roll <= 12) || (tp_station != 2)) {
989  edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station
990  << ", tp_roll = " << tp_roll; return selected; }
991  if ( !(1 <= tp_layer && tp_layer <= 2)) {
992  edm::LogWarning("L1T") << "EMTF GEM format error: tp_layer = " << tp_layer; return selected; }
993  if ( !((tp_station == 1 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 1))) {
994  edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station
995  << ", tp_pad = " << tp_pad; return selected; }
996  if ( !((tp_station == 2 && 1 <= tp_pad && tp_pad <= 192) || (tp_station != 2))) {
997  edm::LogWarning("L1T") << "EMTF GEM format error: tp_station = " << tp_station
998  << ", tp_pad = " << tp_pad; return selected; }
999 
1000  // Selection
1001  if (is_in_bx_gem(tp_bx)) {
1002  if (is_in_sector_gem(tp_endcap, tp_sector)) {
1003  selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, false);
1004  } else if (is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID)) {
1005  selected = get_index_gem(tp_subsector, tp_station, tp_csc_ID, true);
1006  }
1007  }
1008  }
1009  return selected;
1010 }
1011 
1012 bool PrimitiveSelection::is_in_sector_gem(int tp_endcap, int tp_sector) const {
1013  // Identical to the corresponding CSC function
1014  return is_in_sector_csc(tp_endcap, tp_sector);
1015 }
1016 
1017 bool PrimitiveSelection::is_in_neighbor_sector_gem(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const {
1018  // Identical to the corresponding CSC function
1019  return is_in_neighbor_sector_gem(tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_ID);
1020 }
1021 
1022 bool PrimitiveSelection::is_in_bx_gem(int tp_bx) const {
1023  tp_bx += bxShiftGEM_;
1024  return (bx_ == tp_bx);
1025 }
1026 
1027 int PrimitiveSelection::get_index_gem(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const {
1028  // Identical to the corresponding CSC function
1029  return get_index_csc(tp_subsector, tp_station, tp_csc_ID, is_neighbor);
1030 }
size
Write out results.
int chamber() const
Definition: CSCDetId.h:68
int MAX_TRIGSECTOR
Definition: Common.h:53
const subsystem_type subsystem() const
bool is_in_sector_csc(int tp_endcap, int tp_sector) const
bool verbose
void cluster_rpc(const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
const GEMData getGEMData() const
#define NUM_GEM_CHAMBERS
int MIN_ENDCAP
Definition: Common.h:48
int get_index_gem(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const
int roll() const
Definition: GEMDetId.h:80
#define NUM_RPC_CHAMBERS
int ring() const
Definition: GEMDetId.h:59
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
Definition: GEMDetId.h:74
const CSCData getCSCData() const
int select_gem(const TriggerPrimitive &muon_primitive) const
bool is_in_sector_gem(int tp_endcap, int tp_sector) const
const RPCData getRPCData() const
void configure(int verbose, int endcap, int sector, int bx, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, bool includeNeighbor, bool duplicateTheta, bool bugME11Dupes)
int endcap() const
Definition: CSCDetId.h:93
bool is_in_bx_gem(int tp_bx) const
int roll() const
Definition: RPCDetId.h:120
int MIN_TRIGSECTOR
Definition: Common.h:52
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
int ring() const
Definition: RPCDetId.h:72
def unique(seq, keepstr=True)
Definition: tier0.py:24
int layer() const
Layer id: each station have two layers of chambers: layer 1 is the inner chamber and layer 2 is the o...
Definition: GEMDetId.h:69
int select_rpc(const TriggerPrimitive &muon_primitive) const
int station() const
Station id : the station is the pair of chambers at same disk.
Definition: GEMDetId.h:64
int select_csc(const TriggerPrimitive &muon_primitive) const
void process(T tag, const TriggerPrimitiveCollection &muon_primitives, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
void merge_no_truncate(std::map< int, TriggerPrimitiveCollection > &selected_csc_map, std::map< int, TriggerPrimitiveCollection > &selected_rpc_map, std::map< int, TriggerPrimitiveCollection > &selected_gem_map, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
#define end
Definition: vmac.h:39
bool is_in_neighbor_sector_csc(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const
bool is_in_bx_csc(int tp_bx) const
bool is_in_neighbor_sector_rpc(int tp_endcap, int tp_sector, int tp_subsector) const
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
Definition: GEMDetId.h:53
int get_index_csc(int tp_subsector, int tp_station, int tp_csc_ID, bool is_neighbor) const
JetCorrectorParameters corr
Definition: classes.h:5
ii
Definition: cuy.py:588
int ring() const
Definition: CSCDetId.h:75
bool is_in_bx_rpc(int tp_bx) const
L1TMuon::TriggerPrimitiveCollection TriggerPrimitiveCollection
Definition: Common.h:30
bool is_in_sector_rpc(int tp_endcap, int tp_sector, int tp_subsector) const
int triggerSector() const
Definition: CSCDetId.cc:3
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:102
int MAX_ENDCAP
Definition: Common.h:49
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:114
int station() const
Definition: CSCDetId.h:86
int get_index_rpc(int tp_station, int tp_ring, int tp_subsector, bool is_neighbor) const
void merge(std::map< int, TriggerPrimitiveCollection > &selected_csc_map, std::map< int, TriggerPrimitiveCollection > &selected_rpc_map, std::map< int, TriggerPrimitiveCollection > &selected_gem_map, std::map< int, TriggerPrimitiveCollection > &selected_prim_map) const
void cluster_gem(const TriggerPrimitiveCollection &muon_primitives, TriggerPrimitiveCollection &clus_muon_primitives) const
#define NUM_CSC_CHAMBERS
Int_t triggerSector(Int_t station, Int_t ring, Int_t chamber) const
bool is_in_neighbor_sector_gem(int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_csc_ID) const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
int station() const
Definition: RPCDetId.h:96