Back to home page

Project CMSSW displayed by LXR

 
 

    


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 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h"
0011 
0012 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPSelector.h"
0013 
0014 using namespace emtf::phase2;
0015 
0016 RPCTPSelector::RPCTPSelector(const EMTFContext& context, const int& endcap, const int& sector)
0017     : context_(context), endcap_(endcap), sector_(sector) {}
0018 
0019 void RPCTPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
0020   emtf_assert(tp.subsystem() == L1TMuon::kRPC);
0021 
0022   // Map RPC trigger primitives to input links
0023   int ilink = getInputLink(tp, tp_info);  // Returns RPC "link" index
0024 
0025   // Short-Circuit: Link not found (ilink = -1)
0026   if (ilink < 0) {
0027     return;
0028   }
0029 
0030   ilink_tpc_map[ilink].emplace_back(tp, tp_info);
0031 }
0032 
0033 // ===========================================================================
0034 // Utils
0035 // ===========================================================================
0036 int RPCTPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const {
0037   int ilink = -1;
0038 
0039   // Unpack detector info
0040   const int tp_endcap = tp_info.endcap;
0041   const int tp_sector = tp_info.sector;
0042   const int tp_subsector = tp_info.subsector;
0043   const int tp_station = tp_info.station;
0044   const int tp_ring = tp_info.ring;
0045   const int tp_csc_id = tp_info.csc_id;
0046 
0047   const RPCData& tp_data = tp.getRPCData();
0048   const int tp_emtf_sect = tp_data.emtf_sector;
0049   const bool tp_is_CPPF = tp_data.isCPPF;
0050 
0051   // Short-Circuit: In neighbor chambers, have two separate CPPFDigis for the two EMTF sectors
0052   if (tp_is_CPPF && (tp_emtf_sect != sector_))
0053     return ilink;
0054 
0055   // Find selection type
0056   auto tp_selection = TPSelection::kNone;
0057 
0058   if (csc::isTPInSector(endcap_, sector_, tp_endcap, tp_sector)) {
0059     tp_selection = TPSelection::kNative;
0060   } else if (this->context_.config_.include_neighbor_en_ &&
0061              csc::isTPInNeighborSector(endcap_, sector_, tp_endcap, tp_sector, tp_subsector, tp_station, tp_csc_id)) {
0062     tp_selection = TPSelection::kNeighbor;
0063   } else {  // Short-Circuit: tp_selection = TPSelection::kNone
0064     return ilink;
0065   }
0066 
0067   // Get chamber input link for this sector processor
0068   ilink = calcInputLink(tp_subsector, tp_station, tp_ring, tp_csc_id, tp_selection);
0069 
0070   // Add selection info
0071   tp_info.ilink = ilink;
0072   tp_info.selection = tp_selection;
0073 
0074   return ilink;
0075 }
0076 
0077 int RPCTPSelector::calcInputLink(const int& tp_subsector,
0078                                  const int& tp_station,
0079                                  const int& tp_ring,
0080                                  const int& tp_csc_id,
0081                                  const TPSelection& tp_selection) const {
0082   int ilink = -1;
0083 
0084   // Links
0085   // RE1,2,3,4 + GE1,2        : 54..71, 72..80, 81..89, 90..98
0086   // RE1,2,3,4 + GE1,2 (N)    : 99..101, 102..103, 104..105, 106..107
0087 
0088   if (tp_selection == TPSelection::kNative) {
0089     const int ilink_offset = 54;
0090 
0091     if (tp_station == 1) {
0092       ilink = ilink_offset + (tp_subsector - 1) * 9 + (tp_csc_id - 1);
0093     } else {
0094       ilink = ilink_offset + tp_station * 9 + (tp_csc_id - 1);
0095     }
0096 
0097     emtf_assert((54 <= ilink) && (ilink < 99));
0098   } else {
0099     const int ilink_offset = 99;
0100 
0101     if (tp_station == 1) {
0102       ilink = ilink_offset + ((tp_station - 1) * 2) + ((tp_csc_id - 1) / 3);
0103     } else if (tp_ring == 1) {
0104       ilink = ilink_offset + ((tp_station - 1) * 2) + 1;
0105     } else {
0106       ilink = ilink_offset + ((tp_station - 1) * 2) + 2;
0107     }
0108 
0109     emtf_assert((99 <= ilink) && (ilink < 108));
0110   }
0111 
0112   return ilink;
0113 }