File indexing completed on 2024-04-06 12:21:02
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002
0003 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h"
0004 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h"
0005 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h"
0006 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h"
0007 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h"
0008 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h"
0009 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h"
0010
0011 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GEMTPSelector.h"
0012
0013 using namespace emtf::phase2;
0014
0015 GEMTPSelector::GEMTPSelector(const EMTFContext& context, const int& endcap, const int& sector)
0016 : context_(context), endcap_(endcap), sector_(sector) {}
0017
0018 void GEMTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
0019 emtf_assert(tp.subsystem() == L1TMuon::kGEM);
0020
0021
0022 int ilink = getInputLink(tp, tp_info);
0023
0024
0025 if (ilink < 0) {
0026 return;
0027 }
0028
0029 ilink_tpc_map[ilink].emplace_back(tp, tp_info);
0030 }
0031
0032
0033
0034
0035 int GEMTPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const {
0036 int ilink = -1;
0037
0038
0039 const int tp_endcap = tp_info.endcap;
0040 const int tp_sector = tp_info.sector;
0041 const int tp_subsector = tp_info.subsector;
0042 const int tp_station = tp_info.station;
0043 const int tp_ring = tp_info.ring;
0044 const int tp_csc_id = tp_info.csc_id;
0045
0046
0047 auto tp_selection = TPSelection::kNone;
0048
0049 if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
0050 tp_selection = TPSelection::kNative;
0051 } else if (this->context_.config_.include_neighbor_en_ &&
0052 csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
0053 tp_selection = TPSelection::kNeighbor;
0054 } else {
0055 return ilink;
0056 }
0057
0058
0059 ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection);
0060
0061
0062 tp_info.ilink = ilink;
0063 tp_info.selection = tp_selection;
0064
0065 return ilink;
0066 }
0067
0068 int GEMTPSelector::calcInputLink(const int& tp_subsector,
0069 const int& tp_station,
0070 const int& tp_ring,
0071 const int& tp_csc_id,
0072 const TPSelection& tp_selection) const {
0073 int ilink = -1;
0074
0075
0076
0077
0078
0079 if (tp_selection == TPSelection::kNative) {
0080 const int ilink_offset = 54;
0081
0082 if (tp_station == 1) {
0083 ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1);
0084 } else {
0085 ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1);
0086 }
0087
0088 emtf_assert((54 <= ilink) && (ilink < 99));
0089 } else {
0090 const int ilink_offset = 99;
0091
0092 if (tp_station == 1) {
0093 ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3);
0094 } else if (tp_ring == 1) {
0095 ilink = ilink_offset + ((tp_station - 1) * 2) + 1;
0096 } else {
0097 ilink = ilink_offset + ((tp_station - 1) * 2) + 2;
0098 }
0099
0100 emtf_assert((99 <= ilink) && (ilink < 108));
0101 }
0102
0103 return ilink;
0104 }