File indexing completed on 2024-04-06 12:18:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "HLTRPCTrigNoSyncFilter.h"
0019
0020
0021 #include <memory>
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 typedef struct {
0036 int id;
0037 int bx;
0038 GlobalPoint gp;
0039 } RPC4DHit;
0040
0041 bool bigmag(const RPC4DHit& Point1, const RPC4DHit& Point2) {
0042 if ((Point2).gp.mag() > (Point1).gp.mag())
0043 return true;
0044 else
0045 return false;
0046 }
0047
0048 HLTRPCTrigNoSyncFilter::HLTRPCTrigNoSyncFilter(const edm::ParameterSet& iConfig)
0049 : HLTFilter(iConfig), muonGeometryRecordToken_(esConsumes()) {
0050
0051 m_GMTInputTag = iConfig.getParameter<edm::InputTag>("GMTInputTag");
0052 rpcRecHitsLabel = iConfig.getParameter<edm::InputTag>("rpcRecHits");
0053 m_GMTInputToken = consumes<L1MuGMTReadoutCollection>(m_GMTInputTag);
0054 rpcRecHitsToken = consumes<RPCRecHitCollection>(rpcRecHitsLabel);
0055 }
0056
0057 HLTRPCTrigNoSyncFilter::~HLTRPCTrigNoSyncFilter() {
0058
0059
0060 }
0061
0062 void HLTRPCTrigNoSyncFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0063 edm::ParameterSetDescription desc;
0064 makeHLTFilterDescription(desc);
0065 desc.add<edm::InputTag>("GMTInputTag", edm::InputTag("hltGtDigis"));
0066 desc.add<edm::InputTag>("rpcRecHits", edm::InputTag("hltRpcRecHits"));
0067 descriptions.add("hltRPCTrigNoSyncFilter", desc);
0068 }
0069
0070
0071
0072
0073
0074
0075 bool HLTRPCTrigNoSyncFilter::hltFilter(edm::Event& iEvent,
0076 const edm::EventSetup& iSetup,
0077 trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0078 std::vector<RPC4DHit> GlobalRPC4DHits;
0079 std::vector<RPC4DHit> GlobalRPC4DHitsNoBx0;
0080
0081 edm::Handle<RPCRecHitCollection> rpcRecHits;
0082
0083
0084
0085 iEvent.getByToken(rpcRecHitsToken, rpcRecHits);
0086
0087 if (!rpcRecHits.isValid()) {
0088
0089
0090 return false;
0091 }
0092 if (rpcRecHits->begin() == rpcRecHits->end()) {
0093
0094
0095 return false;
0096 }
0097
0098 RPCRecHitCollection::const_iterator recHit;
0099
0100 auto const& rpcGeo = iSetup.getHandle(muonGeometryRecordToken_);
0101
0102 int k = 0;
0103
0104 for (recHit = rpcRecHits->begin(); recHit != rpcRecHits->end(); recHit++) {
0105 RPCDetId rollId = (RPCDetId)(*recHit).rpcId();
0106 LocalPoint recHitPos = recHit->localPosition();
0107 const RPCRoll* rollasociated = rpcGeo->roll(rollId);
0108 const BoundPlane& RPCSurface = rollasociated->surface();
0109 GlobalPoint RecHitInGlobal = RPCSurface.toGlobal(recHitPos);
0110
0111 int BX = recHit->BunchX();
0112
0113
0114 RPC4DHit ThisHit;
0115 ThisHit.bx = BX;
0116 ThisHit.gp = RecHitInGlobal;
0117 ThisHit.id = k;
0118 GlobalRPC4DHits.push_back(ThisHit);
0119 if (BX != 0)
0120 GlobalRPC4DHitsNoBx0.push_back(ThisHit);
0121 k++;
0122 }
0123
0124 if (GlobalRPC4DHitsNoBx0.empty()) {
0125
0126
0127 return false;
0128 }
0129
0130 if (GlobalRPC4DHitsNoBx0.size() > 100) {
0131
0132
0133 return false;
0134 }
0135
0136 edm::Handle<L1MuGMTReadoutCollection> gmtrc_handle;
0137 iEvent.getByToken(m_GMTInputToken, gmtrc_handle);
0138
0139 std::vector<L1MuGMTExtendedCand> gmt_candidates = (*gmtrc_handle).getRecord().getGMTCands();
0140
0141 std::vector<L1MuGMTExtendedCand>::const_iterator candidate;
0142
0143
0144 if (gmt_candidates.empty()) {
0145
0146 return false;
0147 }
0148
0149 for (candidate = gmt_candidates.begin(); candidate != gmt_candidates.end(); candidate++) {
0150 int qual = candidate->quality();
0151
0152 if (qual < 5)
0153 continue;
0154 float eta = candidate->etaValue();
0155 float phi = candidate->phiValue();
0156
0157
0158
0159
0160
0161 std::vector<RPC4DHit> PointsForGMT;
0162
0163 for (auto& Point : GlobalRPC4DHitsNoBx0) {
0164 float phiP = Point.gp.phi();
0165 float etaP = Point.gp.eta();
0166
0167
0168
0169 if (fabs(phi - phiP) <= 0.1 && fabs(eta - etaP) <= 0.20) {
0170 PointsForGMT.push_back(Point);
0171
0172 }
0173 }
0174
0175
0176
0177 if (PointsForGMT.empty()) {
0178
0179 continue;
0180 }
0181
0182 std::sort(PointsForGMT.begin(), PointsForGMT.end(), bigmag);
0183
0184
0185
0186
0187 int lastbx = -7;
0188 bool outOfTime = false;
0189 bool incr = true;
0190
0191
0192 for (auto point = PointsForGMT.begin(); point < PointsForGMT.end(); ++point) {
0193
0194 outOfTime |= (point->bx != 0);
0195 incr &= (point->bx >= lastbx);
0196 lastbx = point->bx;
0197 }
0198
0199
0200
0201
0202
0203
0204
0205 bool Candidate = (outOfTime && incr);
0206
0207 if (Candidate) {
0208
0209 return true;
0210 }
0211 }
0212
0213
0214 return false;
0215 }
0216
0217
0218 void HLTRPCTrigNoSyncFilter::beginJob() {}
0219
0220
0221 void HLTRPCTrigNoSyncFilter::endJob() {}
0222
0223
0224 DEFINE_FWK_MODULE(HLTRPCTrigNoSyncFilter);