CMS 3D CMS Logo

ME0TPSelector.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 ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
19  emtf_assert(tp.subsystem() == L1TMuon::kME0);
20 
21  // Map ME0 trigger primitives to input links
22  int ilink = getInputLink(tp, tp_info); // Returns ME0 "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_csc_id = tp_info.csc_id;
44 
45  // Find selection type
46  auto tp_selection = TPSelection::kNone;
47 
48  if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
49  tp_selection = TPSelection::kNative;
50  } else if (this->context_.config_.include_neighbor_en_ &&
51  csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
52  tp_selection = TPSelection::kNeighbor;
53  } else { // Short-Circuit: tp_selection = TPSelection::kNone
54  return ilink;
55  }
56 
57  // Get chamber input link for this sector processor
58  ilink = calcInputLink(tp_subsector, tp_csc_id, tp_selection);
59 
60  // Add selection info
61  tp_info.ilink = ilink;
62  tp_info.selection = tp_selection;
63 
64  return ilink;
65 }
66 
67 int ME0TPSelector::calcInputLink(const int& tp_subsector, const int& tp_csc_id, const TPSelection& tp_selection) const {
68  int ilink = -1;
69 
70  // Links
71  // ME0 : 108..113
72  // ME0 (N) : 114
73 
74  if (tp_selection == TPSelection::kNative) {
75  const int ilink_offset = 108;
76 
77  ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1);
78 
79  emtf_assert((108 <= ilink) && (ilink < 114));
80  } else {
81  const int ilink_offset = 114;
82 
83  ilink = ilink_offset;
84 
85  emtf_assert(ilink == ilink_offset);
86  }
87 
88  return ilink;
89 }
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
ME0TPSelector(const EMTFContext &, const int &, const int &)
void select(const TriggerPrimitive &, TPInfo, ILinkTPCMap &) const final
TPSelection selection
Definition: TPrimitives.h:21
const EMTFContext & context_
Definition: ME0TPSelector.h:20
int getInputLink(const TriggerPrimitive &, TPInfo &) const
#define emtf_assert(expr)
Definition: DebugTools.h:18
int calcInputLink(const int &, const int &, const TPSelection &) const
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
EMTFConfiguration config_
Definition: EMTFContext.h:39