Skip to content

Commit c4b959a

Browse files
committed
Ian's suggestions on making cleaner code
1 parent df6698f commit c4b959a

File tree

1 file changed

+16
-24
lines changed

1 file changed

+16
-24
lines changed

RecoMuon/MuonIdentification/plugins/MuonIdProducer.cc

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,34 +1126,26 @@ void MuonIdProducer::fillMuonId(edm::Event& iEvent,
11261126

11271127
const GeomDet* geomDet = gemgeom->idToDetUnit(chamber.id);
11281128
const GlobalPoint& global_position = geomDet->toGlobal(lPos);
1129-
bool GEMmatched = false;
1130-
int ieta = 0;
11311129
if (const GEMChamber* gemChamber = dynamic_cast<const GEMChamber*>(geomDet)) {
1132-
for (const GEMEtaPartition* eta_partition : gemChamber->etaPartitions()) {
1133-
bool bounds = false;
1134-
ieta = eta_partition->id().ieta();
1135-
if (ieta == gemRecHit.gemId().ieta()) {
1136-
float bordercut = 2;
1137-
const TrapezoidalPlaneBounds* bounds = dynamic_cast<const TrapezoidalPlaneBounds*>(&eta_partition->surface().bounds());
1138-
LocalPoint localPoint = eta_partition->surface().toLocal(global_position);
1139-
float wideWidth = bounds->width();
1140-
float narrowWidth = 2.f * bounds->widthAtHalfLength() - wideWidth;
1141-
float length = bounds->length();
1142-
float tangent = (wideWidth - narrowWidth) / (2.f * length);
1143-
float halfWidthAtY = tangent * localPoint.y() + 0.25f * (narrowWidth + wideWidth);
1144-
float distanceY = std::abs(localPoint.y()) - 0.5f * length;
1145-
float distanceX = std::abs(localPoint.x()) - halfWidthAtY;
1146-
if (distanceX < bordercut && distanceY < bordercut) {
1147-
GEMmatched = true;
1148-
}
1149-
}
1130+
const GeomDet* eta_geomdet = gemChamber->component(gemRecHit.gemId());
1131+
const GEMEtaPartition* eta_partition = dynamic_cast<const GEMEtaPartition*>(eta_geomdet);
1132+
float bordercut = 2;
1133+
const TrapezoidalPlaneBounds* bounds = dynamic_cast<const TrapezoidalPlaneBounds*>(&eta_partition->surface().bounds());
1134+
LocalPoint localPoint = eta_partition->surface().toLocal(global_position);
1135+
float wideWidth = bounds->width();
1136+
float narrowWidth = 2.f * bounds->widthAtHalfLength() - wideWidth;
1137+
float length = bounds->length();
1138+
float tangent = (wideWidth - narrowWidth) / (2.f * length);
1139+
float halfWidthAtY = tangent * localPoint.y() + 0.25f * (narrowWidth + wideWidth);
1140+
float distanceY = std::abs(localPoint.y()) - 0.5f * length;
1141+
float distanceX = std::abs(localPoint.x()) - halfWidthAtY;
1142+
if (distanceX < bordercut && distanceY < bordercut) {
1143+
const double absDx = std::abs(gemRecHit.localPosition().x() - chamber.tState.localPosition().x());
1144+
if (absDx <= 5 or absDx * absDx <= 16 * localError.xx())
1145+
matchedChamber.gemHitMatches.push_back(gemHitMatch);
11501146
}
11511147
}
1152-
const double absDx = std::abs(gemRecHit.localPosition().x() - chamber.tState.localPosition().x());
1153-
if ((absDx <= 5 or absDx * absDx <= 16 * localError.xx()) && GEMmatched)
1154-
matchedChamber.gemHitMatches.push_back(gemHitMatch);
11551148
}
1156-
11571149
muonChamberMatches.push_back(matchedChamber);
11581150
}
11591151
}

0 commit comments

Comments
 (0)