CMS 3D CMS Logo

GEMTPSelector.cc
Go to the documentation of this file.
2 
10 
12 
13 using namespace emtf::phase2;
14 
16  : context_(context), endcap_(endcap), sector_(sector) {}
17 
18 void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
19  emtf_assert(tp.subsystem() == L1TMuon::kGEM);
20 
21  // Map GEM trigger primitives to input links
22  int ilink = getInputLink(tp, tp_info); // Returns GEM "link" index
23 
24  // Short-Circuit: Link not found (ilink = -1)
25  if (ilink < 0) {
26  return;
27  }
28 
29  ilink_tpc_map[ilink].emplace_back(tp, tp_info);
30 }
31 
32 // ===========================================================================
33 // Utils
34 // ===========================================================================
36  int ilink = -1;
37 
38  // Unpack detector info
39  const int tp_endcap = tp_info.endcap;
40  const int tp_sector = tp_info.sector;
41  const int tp_subsector = tp_info.subsector;
42  const int tp_station = tp_info.station;
43  const int tp_ring = tp_info.ring;
44  const int tp_csc_id = tp_info.csc_id;
45 
46  // Find selection type
47  auto tp_selection = TPSelection::kNone;
48 
49  if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
50  tp_selection = TPSelection::kNative;
51  } else if (this->context_.config_.include_neighbor_en_ &&
52  csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
53  tp_selection = TPSelection::kNeighbor;
54  } else { // Short-Circuit: tp_selection = TPSelection::kNone
55  return ilink;
56  }
57 
58  // Get chamber input link for this sector processor
59  ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection);
60 
61  // Add selection info
62  tp_info.ilink = ilink;
63  tp_info.selection = tp_selection;
64 
65  return ilink;
66 }
67 
68 int GEMTPSelector::calcInputLink(const int& tp_subsector,
69  const int& tp_station,
70  const int& tp_ring,
71  const int& tp_csc_id,
72  const TPSelection& tp_selection) const {
73  int ilink = -1;
74 
75  // Links
76  // RE1,2,3,4 + GE1,2 : 54..71, 72..80, 81..89, 90..98
77  // RE1,2,3,4 + GE1,2 (N) : 99..101, 102..103, 104..105, 106..107
78 
79  if (tp_selection == TPSelection::kNative) {
80  const int ilink_offset = 54;
81 
82  if (tp_station == 1) {
83  ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1);
84  } else {
85  ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1);
86  }
87 
88  emtf_assert((54 <= ilink) && (ilink < 99));
89  } else {
90  const int ilink_offset = 99;
91 
92  if (tp_station == 1) {
93  ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3);
94  } else if (tp_ring == 1) {
95  ilink = ilink_offset + ((tp_station - 1) * 2) + 1;
96  } else {
97  ilink = ilink_offset + ((tp_station - 1) * 2) + 2;
98  }
99 
100  emtf_assert((99 <= ilink) && (ilink < 108));
101  }
102 
103  return ilink;
104 }
bool isTPInSector(int match_endcap, int match_sector, int tp_endcap, int tp_sector)
Definition: CSCUtils.cc:17
std::map< int, TPCollection > ILinkTPCMap
Definition: EMTFTypes.h:23
TPSelection selection
Definition: TPrimitives.h:21
GEMTPSelector(const EMTFContext &, const int &, const int &)
#define emtf_assert(expr)
Definition: DebugTools.h:18
bool isTPInNeighborSector(int match_endcap, int match_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id)
Definition: CSCUtils.cc:21
int calcInputLink(const int &, const int &, const int &, const int &, const TPSelection &) const
const EMTFContext & context_
Definition: GEMTPSelector.h:20
void select(const TriggerPrimitive &, TPInfo, ILinkTPCMap &) const final
EMTFConfiguration config_
Definition: EMTFContext.h:39
int getInputLink(const TriggerPrimitive &, TPInfo &) const