Skip to content

Commit f560fac

Browse files
committed
Matching between GEMChambermatch and GEMRechit only allowed when they're at the same etapartition.
1 parent 852214b commit f560fac

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ MuonIdProducer::MuonIdProducer(const edm::ParameterSet& iConfig)
166166
//create mesh holder
167167
meshAlgo_ = std::make_unique<MuonMesh>(iConfig.getParameter<edm::ParameterSet>("arbitrationCleanerOptions"));
168168

169+
gemgeomToken_ = esConsumes<GEMGeometry, MuonGeometryRecord>();
169170
edm::InputTag rpcHitTag("rpcRecHits");
170171
rpcHitToken_ = consumes<RPCRecHitCollection>(rpcHitTag);
171172

@@ -274,6 +275,7 @@ void MuonIdProducer::init(edm::Event& iEvent, const edm::EventSetup& iSetup) {
274275
iEvent.getByToken(glbQualToken_, glbQualHandle_);
275276
if (selectHighPurity_)
276277
iEvent.getByToken(pvToken_, pvHandle_);
278+
gemgeom = &iSetup.getData(gemgeomToken_);
277279
}
278280

279281
reco::Muon MuonIdProducer::makeMuon(edm::Event& iEvent,
@@ -296,6 +298,24 @@ reco::Muon MuonIdProducer::makeMuon(edm::Event& iEvent,
296298
return aMuon;
297299
}
298300

301+
bool MuonIdProducer::checkBounds(const GeomDet* geomDet,
302+
const GlobalPoint& global_position,
303+
const float bordercut) {
304+
const TrapezoidalPlaneBounds* bounds = dynamic_cast<const TrapezoidalPlaneBounds*>(&geomDet->surface().bounds());
305+
LocalPoint localPoint = geomDet->surface().toLocal(global_position);
306+
float wideWidth = bounds->width();
307+
float narrowWidth = 2.f * bounds->widthAtHalfLength() - wideWidth;
308+
float length = bounds->length();
309+
float tangent = (wideWidth - narrowWidth) / (2.f * length);
310+
float halfWidthAtY = tangent * localPoint.y() + 0.25f * (narrowWidth + wideWidth);
311+
float distanceY = std::abs(localPoint.y()) - 0.5f * length;
312+
float distanceX = std::abs(localPoint.x()) - halfWidthAtY;
313+
if (distanceX < bordercut && distanceY < bordercut) {
314+
return true;
315+
}
316+
return false;
317+
}
318+
299319
reco::CaloMuon MuonIdProducer::makeCaloMuon(const reco::Muon& muon) {
300320
LogTrace("MuonIdentification") << "Creating a CaloMuon from a Muon";
301321

@@ -1121,9 +1141,23 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent,
11211141
gemHitMatch.x = gemRecHit.localPosition().x();
11221142
gemHitMatch.mask = 0;
11231143
gemHitMatch.bx = gemRecHit.BunchX();
1124-
1144+
1145+
const GeomDet* geomDet = gemgeom->idToDetUnit(chamber.id);
1146+
const GlobalPoint& global_position = geomDet->toGlobal(lPos);
1147+
bool GEMmatched = false;
1148+
int ieta = 0;
1149+
if (const GEMChamber* gemChamber = dynamic_cast<const GEMChamber*>(geomDet)) {
1150+
for (const GEMEtaPartition* eta_partition : gemChamber->etaPartitions()) {
1151+
ieta = eta_partition->id().ieta();
1152+
if (ieta == gemRecHit.gemId().ieta()) {
1153+
if (checkBounds(eta_partition, global_position, 2)) {
1154+
GEMmatched = true;
1155+
}
1156+
}
1157+
}
1158+
}
11251159
const double absDx = std::abs(gemRecHit.localPosition().x() - chamber.tState.localPosition().x());
1126-
if (absDx <= 5 or absDx * absDx <= 16 * localError.xx())
1160+
if ((absDx <= 5 or absDx * absDx <= 16 * localError.xx()) && GEMmatched)
11271161
matchedChamber.gemHitMatches.push_back(gemHitMatch);
11281162
}
11291163

RecoMuon/MuonIdentification/plugins/MuonIdProducer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include "RecoMuon/MuonIdentification/interface/MuonIdTruthInfo.h"
6262
#include "RecoMuon/MuonIdentification/interface/MuonArbitrationMethods.h"
6363
#include "DataFormats/Common/interface/ValueMap.h"
64+
#include "Geometry/GEMGeometry/interface/GEMGeometry.h"
6465

6566
class MuonMesh;
6667
class MuonKinkFinder;
@@ -79,6 +80,8 @@ class MuonIdProducer : public edm::stream::EDProducer<> {
7980
static double sectorPhi(const DetId& id);
8081

8182
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
83+
84+
bool checkBounds(const GeomDet* geomDet, const GlobalPoint& global_position, const float bordercut);
8285

8386
private:
8487
void fillMuonId(edm::Event&,
@@ -281,5 +284,8 @@ class MuonIdProducer : public edm::stream::EDProducer<> {
281284

282285
bool arbClean_;
283286
std::unique_ptr<MuonMesh> meshAlgo_;
287+
edm::ESGetToken<GEMGeometry, MuonGeometryRecord> gemgeomToken_;
288+
const GEMGeometry* gemgeom;
289+
double GEM_edgecut_;
284290
};
285291
#endif

0 commit comments

Comments
 (0)