File indexing completed on 2024-04-06 12:21:02
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003
0004 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConfiguration.h"
0005 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFConstants.h"
0006 #include "L1Trigger/L1TMuonEndCapPhase2/interface/EMTFContext.h"
0007 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/RPCTPCollector.h"
0008 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/SubsystemTags.h"
0009 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h"
0010 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/DebugUtils.h"
0011 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/RPCUtils.h"
0012
0013 using namespace emtf::phase2;
0014
0015 RPCTPCollector::RPCTPCollector(const EMTFContext& context, edm::ConsumesCollector& i_consumes_collector)
0016 : context_(context),
0017 input_token_(i_consumes_collector.consumes<RPCTag::rechit_collection_type>(context.config_.rpc_input_)) {}
0018
0019 void RPCTPCollector::collect(const edm::Event& i_event, BXTPCMap& bx_tpc_map) const {
0020
0021 static const int clus_width_cut = 4;
0022 static const int clus_width_cut_irpc = 6;
0023
0024
0025 TPCollection tpc;
0026
0027 edm::Handle<RPCTag::rechit_collection_type> rpc_digis;
0028 i_event.getByToken(input_token_, rpc_digis);
0029
0030 auto digi = rpc_digis->begin();
0031 auto digi_end = rpc_digis->end();
0032
0033 for (; digi != digi_end; ++digi) {
0034 tpc.emplace_back(digi->rpcId(), *digi);
0035 }
0036
0037
0038 for (auto& tp_entry : tpc) {
0039 const auto& tp_det_id = tp_entry.tp_.detId<RPCDetId>();
0040 const RPCData& tp_data = tp_entry.tp_.getRPCData();
0041
0042 const int tp_region = tp_det_id.region();
0043 const int tp_endcap = (tp_region == -1) ? 2 : tp_region;
0044 const int tp_endcap_pm = (tp_endcap == 2) ? -1 : tp_endcap;
0045
0046
0047
0048 const int tp_rpc_sector = tp_det_id.sector();
0049
0050
0051
0052 const int tp_rpc_subsector = tp_det_id.subsector();
0053
0054 const int tp_station = tp_det_id.station();
0055 const int tp_ring = tp_det_id.ring();
0056 const int tp_roll =
0057 tp_det_id.roll();
0058 const int tp_layer = tp_det_id.layer();
0059
0060 const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2;
0061 const int tp_strip_lo = tp_data.strip_low;
0062 const int tp_strip_hi = tp_data.strip_hi;
0063 const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1);
0064
0065 const bool tp_is_CPPF = tp_data.isCPPF;
0066
0067 const int tp_bx = tp_data.bx + this->context_.config_.rpc_bx_shift_;
0068
0069
0070 bool tp_is_substitute = (tp_ring == 3);
0071
0072
0073 const bool tp_is_barrel = (tp_region == 0);
0074
0075 rpc::Type tp_rpc_type;
0076
0077 if ((!tp_is_barrel) && (tp_station >= 3) && (tp_ring == 1)) {
0078 tp_rpc_type = rpc::Type::kiRPC;
0079 } else {
0080 tp_rpc_type = rpc::Type::kRPC;
0081 }
0082
0083
0084 if (tp_region == 0) {
0085 continue;
0086 }
0087
0088
0089 if (tp_station <= 2 && tp_ring == 3) {
0090 continue;
0091 }
0092
0093
0094 if (tp_rpc_type == rpc::Type::kiRPC) {
0095 if (tp_clus_width > clus_width_cut_irpc) {
0096 continue;
0097 }
0098 } else {
0099 if (tp_clus_width > clus_width_cut) {
0100 continue;
0101 }
0102 }
0103
0104
0105 int tp_chamber;
0106
0107 if (tp_rpc_type == rpc::Type::kiRPC) {
0108 tp_chamber = (tp_rpc_sector - 1) * 3 + tp_rpc_subsector;
0109 } else {
0110 tp_chamber = (tp_rpc_sector - 1) * 6 + tp_rpc_subsector;
0111 }
0112
0113 const int tp_sector = csc::getTriggerSector(tp_station, tp_ring, tp_chamber);
0114 const int tp_subsector = csc::getTriggerSubsector(tp_station, tp_chamber);
0115 const int tp_csc_id = csc::getId(tp_station, tp_ring, tp_chamber);
0116 const auto tp_csc_facing = csc::getFaceDirection(tp_station, tp_ring, tp_chamber);
0117
0118
0119 emtf_assert(kMinEndcap <= tp_endcap && tp_endcap <= kMaxEndcap);
0120 emtf_assert(kMinTrigSector <= tp_sector && tp_sector <= kMaxTrigSector);
0121 emtf_assert(0 <= tp_subsector && tp_subsector <= 2);
0122 emtf_assert(1 <= tp_station && tp_station <= 4);
0123 emtf_assert(1 <= tp_chamber && tp_chamber <= 36);
0124 emtf_assert((1 <= tp_csc_id) and (tp_csc_id <= 9));
0125
0126 if (tp_rpc_type == rpc::Type::kiRPC) {
0127 emtf_assert(tp_ring == 1);
0128 emtf_assert(1 <= tp_roll && tp_roll <= 5);
0129 emtf_assert(1 <= tp_strip && tp_strip <= 96);
0130 } else {
0131 emtf_assert(2 <= tp_ring && tp_ring <= 3);
0132 emtf_assert(1 <= tp_roll && tp_roll <= 3);
0133 emtf_assert(tp_is_CPPF || (1 <= tp_strip && tp_strip <= 32));
0134 }
0135
0136 emtf_assert(tp_data.valid);
0137
0138
0139 tp_entry.info_.bx = tp_bx;
0140
0141 tp_entry.info_.endcap = tp_endcap;
0142 tp_entry.info_.endcap_pm = tp_endcap_pm;
0143 tp_entry.info_.sector = tp_sector;
0144 tp_entry.info_.subsector = tp_subsector;
0145 tp_entry.info_.station = tp_station;
0146 tp_entry.info_.ring = tp_ring;
0147 tp_entry.info_.roll = tp_roll;
0148 tp_entry.info_.layer = tp_layer;
0149 tp_entry.info_.chamber = tp_chamber;
0150
0151 tp_entry.info_.csc_id = tp_csc_id;
0152 tp_entry.info_.csc_facing = tp_csc_facing;
0153
0154 tp_entry.info_.rpc_type = tp_rpc_type;
0155
0156 tp_entry.info_.flag_substitute = tp_is_substitute;
0157
0158 bx_tpc_map[tp_bx].push_back(tp_entry);
0159 }
0160 }