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/ME0TPSelector.h"
0012
0013 using namespace emtf::phase2;
0014
0015 ME0TPSelector::ME0TPSelector(const EMTFContext& context, const int& endcap, const int& sector)
0016 : context_(context), endcap_(endcap), sector_(sector) {}
0017
0018 void ME0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
0019 emtf_assert(tp.subsystem() == L1TMuon::kME0);
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 ME0TPSelector::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_csc_id = tp_info.csc_id;
0044
0045
0046 auto tp_selection = TPSelection::kNone;
0047
0048 if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
0049 tp_selection = TPSelection::kNative;
0050 } else if (this->context_.config_.include_neighbor_en_ &&
0051 csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
0052 tp_selection = TPSelection::kNeighbor;
0053 } else {
0054 return ilink;
0055 }
0056
0057
0058 ilink = calcInputLink(tp_subsector, tp_csc_id, tp_selection);
0059
0060
0061 tp_info.ilink = ilink;
0062 tp_info.selection = tp_selection;
0063
0064 return ilink;
0065 }
0066
0067 int ME0TPSelector::calcInputLink(const int& tp_subsector, const int& tp_csc_id, const TPSelection& tp_selection) const {
0068 int ilink = -1;
0069
0070
0071
0072
0073
0074 if (tp_selection == TPSelection::kNative) {
0075 const int ilink_offset = 108;
0076
0077 ilink = ilink_offset + ((tp_subsector - 1) * 3) + (tp_csc_id - 1);
0078
0079 emtf_assert((108 <= ilink) && (ilink < 114));
0080 } else {
0081 const int ilink_offset = 114;
0082
0083 ilink = ilink_offset;
0084
0085 emtf_assert(ilink == ilink_offset);
0086 }
0087
0088 return ilink;
0089 }