CMS 3D CMS Logo

CSCTPSelector.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 CSCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
19  emtf_assert(tp.subsystem() == L1TMuon::kCSC);
20 
21  // Map CSC trigger primitives to input links
22  int ilink = getInputLink(tp, tp_info); // Returns CSC "link" index (0 - 53)
23 
24  // Short-Circuit: Link not found (ilink = -1)
25  if (ilink < 0) {
26  return;
27  }
28 
29  // Should have at most 2 TP
30  if (ilink_tpc_map[ilink].size() < 2) {
31  ilink_tpc_map[ilink].emplace_back(tp, tp_info);
32  } else {
33  edm::LogWarning("L1TEMTFpp") << "\n******************* EMTF EMULATOR: SUPER-BIZZARE CASE *******************";
34  edm::LogWarning("L1TEMTFpp") << "Found 3 CSC trigger primitives in the same chamber";
35 
36  for (unsigned int i_tp = 0; i_tp < 3; i_tp++) {
37  const auto& tp_err = ((i_tp < 2) ? ilink_tpc_map[ilink].at(i_tp).tp_ : tp);
38 
39  edm::LogWarning("L1TEMTFpp") << "LCT #" << i_tp + 1 << ": BX " << tp_err.getBX() << ", endcap "
40  << tp_err.detId<CSCDetId>().endcap() << ", sector "
41  << tp_err.detId<CSCDetId>().triggerSector() << ", station "
42  << tp_err.detId<CSCDetId>().station() << ", ring " << tp_err.detId<CSCDetId>().ring()
43  << ", chamber " << tp_err.detId<CSCDetId>().chamber() << ", CSC ID "
44  << tp_err.getCSCData().cscID << ": strip " << tp_err.getStrip() << ", wire "
45  << tp_err.getWire();
46  }
47 
48  edm::LogWarning("L1TEMTFpp") << "************************* ONLY KEEP FIRST TWO *************************\n\n";
49  }
50 }
51 
52 // ===========================================================================
53 // Utils
54 // ===========================================================================
56  int ilink = -1;
57 
58  // Unpack detector info
59  const int tp_endcap = tp_info.endcap;
60  const int tp_sector = tp_info.sector;
61  const int tp_subsector = tp_info.subsector;
62  const int tp_station = tp_info.station;
63  const int tp_ring = tp_info.ring;
64  const int tp_csc_id = tp_info.csc_id;
65 
66  // Find selection type
67  auto tp_selection = TPSelection::kNone;
68 
69  if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
70  tp_selection = TPSelection::kNative;
71  } else if (this->context_.config_.include_neighbor_en_ &&
72  csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
73  tp_selection = TPSelection::kNeighbor;
74  } else { // Short-Circuit: tp_selection = TPSelection::kNone
75  return ilink;
76  }
77 
78  // Get chamber input link for this sector processor
79  ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection);
80 
81  // Add selection info
82  tp_info.ilink = ilink;
83  tp_info.selection = tp_selection;
84 
85  return ilink;
86 }
87 
88 // Returns CSC input "link". Index used by FW for unique chamber identification.
89 int CSCTPSelector::calcInputLink(const int& tp_subsector,
90  const int& tp_station,
91  const int& tp_ring,
92  const int& tp_csc_id,
93  const TPSelection& tp_selection) const {
94  int ilink = -1;
95 
96  // Links
97  // ME1,2,3,4 : 0..17, 18..26, 27..35, 36..44
98  // ME1,2,3,4 (N) : 45..47, 48..49, 50..51, 52..53
99 
100  if (tp_selection == TPSelection::kNative) {
101  const int ilink_offset = 0;
102 
103  if (tp_station == 1) {
104  ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1);
105  } else {
106  ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1);
107  }
108 
109  emtf_assert((0 <= ilink) && (ilink < 45));
110  } else {
111  const int ilink_offset = 45;
112 
113  if (tp_station == 1) {
114  ilink = ilink_offset + ((tp_station - 1) * 2) + (tp_csc_id - 1) / 3;
115  } else if (tp_ring == 1) {
116  ilink = ilink_offset + ((tp_station - 1) * 2) + 1;
117  } else {
118  ilink = ilink_offset + ((tp_station - 1) * 2) + 2;
119  }
120 
121  emtf_assert((45 <= ilink) && (ilink < 54));
122  }
123 
124  return ilink;
125 }
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
int getInputLink(const TriggerPrimitive &, TPInfo &) const
int calcInputLink(const int &, const int &, const int &, const int &, const TPSelection &) const
TPSelection selection
Definition: TPrimitives.h:21
void select(const TriggerPrimitive &, TPInfo, ILinkTPCMap &) const final
#define emtf_assert(expr)
Definition: DebugTools.h:18
CSCTPSelector(const EMTFContext &, const int &, const int &)
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
const EMTFContext & context_
Definition: CSCTPSelector.h:20
Log< level::Warning, false > LogWarning
Int_t triggerSector(Int_t station, Int_t ring, Int_t chamber) const
EMTFConfiguration config_
Definition: EMTFContext.h:39