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 
0011 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/GE0TPSelector.h"
0012 
0013 using namespace emtf::phase2;
0014 
0015 GE0TPSelector::GE0TPSelector(const EMTFContext& context, const int& endcap, const int& sector)
0016     : context_(context), endcap_(endcap), sector_(sector) {}
0017 
0018 void GE0TPSelector::select(const TriggerPrimitive& tp, TPInfo tp_info, ILinkTPCMap& ilink_tpc_map) const {
0019   emtf_assert(tp.subsystem() == L1TMuon::kME0);
0020 
0021   // Map GE0 trigger primitives to input links
0022   int ilink = getInputLink(tp, tp_info);  // Returns GE0 "link" index
0023 
0024   // Short-Circuit: Link not found (ilink = -1)
0025   if (ilink < 0) {
0026     return;
0027   }
0028 
0029   ilink_tpc_map[ilink].emplace_back(tp, tp_info);
0030 }
0031 
0032 // ===========================================================================
0033 // Utils
0034 // ===========================================================================
0035 int GE0TPSelector::getInputLink(const TriggerPrimitive& tp, TPInfo& tp_info) const {
0036   int ilink = -1;
0037 
0038   // Unpack detector info
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   // Find selection type
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 {  // Short-Circuit: tp_selection = TPSelection::kNone
0054     return ilink;
0055   }
0056 
0057   // Get chamber input link for this sector processor
0058   ilink = calcInputLink(tp_subsector, tp_csc_id, tp_selection);
0059 
0060   // Add selection info
0061   tp_info.ilink = ilink;
0062   tp_info.selection = tp_selection;
0063 
0064   return ilink;
0065 }
0066 
0067 int GE0TPSelector::calcInputLink(const int& tp_subsector, const int& tp_csc_id, const TPSelection& tp_selection) const {
0068   int ilink = -1;
0069 
0070   // Links
0071   // GE0                  : 108..113
0072   // GE0 (N)              : 114
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 }