44 dtRadius_(matchParameters.getParameter<double>(
"DTradius")),
66 vector<const DTRecSegment4D*> pointerTo4DSegments;
68 std::vector<TrackingRecHit const*> dtHits;
70 bool segments =
false;
73 for (
auto const&
hit :
muon.recHits()) {
80 if (!
hit->recHits().empty())
81 if ((*
hit->recHits().begin())->
recHits().size() > 1)
83 dtHits.push_back(
hit);
90 double matchRatioZ = 0;
91 double matchRatioPhi = 0;
94 LocalPoint pointLocal = rechit->localPosition();
98 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
100 DetId idT = (*hit)->geographicalId();
101 if (!(rechit->geographicalId().rawId() == idT.
rawId()))
105 LocalPoint segLocal = (*hit)->localPosition();
106 if ((fabs(pointLocal.
x() - segLocal.
x()) < ZCutParameter) &&
107 (fabs(pointLocal.
y() - segLocal.
y()) < ZCutParameter))
108 pointerTo4DSegments.push_back(&(*rechit));
116 if (rechit->hasZed()) {
117 double countMuonDTHits = 0;
118 double countAgreeingHits = 0;
122 nhitsZ = segmZ->
recHits().size();
128 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
129 if (!(*hit)->isValid())
132 DetId idT = (*hit)->geographicalId();
136 LocalPoint pointLocal = (*hit)->localPosition();
138 if ((chamberSegIdT == dtDetIdHitT) && (dtDetLayerIdHitT.superlayer() == 2))
141 for (vector<DTRecHit1D>::const_iterator hiti = hits1d.begin(); hiti != hits1d.end(); hiti++) {
142 if (!hiti->isValid())
146 if (!(hiti->geographicalId().rawId() == idT.
rawId()))
153 if ((fabs(pointLocal.x() - segLocal.
x()) < ZCutParameter) &&
154 (fabs(pointLocal.y() - segLocal.
y()) < ZCutParameter))
159 matchRatioZ = countMuonDTHits == 0 ? 0 : countAgreeingHits / countMuonDTHits;
161 if (countAgreeingHits / nhitsZ > matchRatioZ)
162 matchRatioZ = countAgreeingHits / nhitsZ;
165 if (rechit->hasPhi()) {
166 double countMuonDTHits = 0;
167 double countAgreeingHits = 0;
171 segmPhi =
dynamic_cast<const DTRecSegment2D*
>(rechit->phiSegment());
172 nhitsPhi = segmPhi->
recHits().size();
178 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
179 if (!(*hit)->isValid())
182 DetId idT = (*hit)->geographicalId();
190 if ((chamberSegIdT == dtDetIdHitT) &&
191 ((dtDetLayerIdHitT.superlayer() == 1) || (dtDetLayerIdHitT.superlayer() == 3)))
194 for (vector<DTRecHit1D>::const_iterator hiti = hits1d.begin(); hiti != hits1d.end(); hiti++) {
195 if (!hiti->isValid())
199 if (!(hiti->geographicalId().rawId() == idT.
rawId()))
207 if ((fabs(pointLocal.x() - segLocal.
x()) < PhiCutParameter) &&
208 (fabs(pointLocal.y() - segLocal.
y()) < PhiCutParameter))
213 matchRatioPhi = countMuonDTHits != 0 ? countAgreeingHits / countMuonDTHits : 0;
215 if (countAgreeingHits / nhitsPhi > matchRatioPhi)
216 matchRatioPhi = countAgreeingHits / nhitsPhi;
220 if ((matchRatioPhi > 0.9) && (matchRatioZ > 0.9)) {
222 pointerTo4DSegments.push_back(&(*rechit));
225 if ((matchRatioPhi > 0.9 && nhitsPhi) || (matchRatioZ > 0.9 && nhitsZ)) {
227 pointerTo4DSegments.push_back(&(*rechit));
233 return pointerTo4DSegments;
242 vector<const CSCSegment*> pointerToCSCSegments;
244 double matchRatioCSC = 0;
246 double CSCXCut = 0.001;
247 double CSCYCut = 0.001;
248 double countMuonCSCHits = 0;
252 double CSCcountAgreeingHits = 0;
254 if (!segmentCSC->isValid())
258 const vector<CSCRecHit2D>& CSCRechits2D = segmentCSC->specificRecHits();
259 countMuonCSCHits = 0;
260 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
262 bool segments =
false;
264 for (
auto const& hitC :
muon.recHits()) {
265 if (!hitC->isValid())
271 if (!hitC->isValid())
273 if (hitC->recHits().size() > 1)
277 DetId id = hitC->geographicalId();
281 if (!(myChamber.rawId() == cscDetIdHit.
rawId()))
285 LocalPoint positionLocalCSC = hitC->localPosition();
286 LocalPoint segLocalCSC = segmentCSC->localPosition();
287 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
288 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut))
289 pointerToCSCSegments.push_back(&(*segmentCSC));
293 if (!(cscDetIdHit.
ring() == myChamber.ring()))
295 if (!(cscDetIdHit.
station() == myChamber.station()))
297 if (!(cscDetIdHit.
endcap() == myChamber.endcap()))
299 if (!(cscDetIdHit.
chamber() == myChamber.chamber()))
304 LocalPoint positionLocalCSC = hitC->localPosition();
306 for (vector<CSCRecHit2D>::const_iterator hiti = CSCRechits2D.begin(); hiti != CSCRechits2D.end(); hiti++) {
307 if (!hiti->isValid())
309 CSCDetId cscDetId((hiti->geographicalId()).rawId());
311 if (hitC->geographicalId().rawId() != (hiti->geographicalId()).rawId())
314 LocalPoint segLocalCSC = hiti->localPosition();
317 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
318 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut)) {
319 CSCcountAgreeingHits++;
325 matchRatioCSC = countMuonCSCHits == 0 ? 0 : CSCcountAgreeingHits / countMuonCSCHits;
327 if ((matchRatioCSC > 0.9) && ((countMuonCSCHits > 1) || !
cscTightMatch))
328 pointerToCSCSegments.push_back(&(*segmentCSC));
332 return pointerToCSCSegments;
341 vector<const RPCRecHit*> pointerToRPCRecHits;
342 double RPCCut = 0.001;
345 if (!hitRPC->isValid())
348 RPCDetId myChamber((*hitRPC).geographicalId().rawId());
349 LocalPoint posLocalRPC = hitRPC->localPosition();
352 for (
auto const& hitC :
muon.recHits()) {
353 if (!hitC->isValid())
359 if (!hitC->isValid())
363 DetId id = hitC->geographicalId();
366 if (rpcDetIdHit != myChamber)
368 LocalPoint posLocalMuon = hitC->localPosition();
372 if ((fabs(posLocalMuon.
x() - posLocalRPC.x()) < RPCCut)) {
379 pointerToRPCRecHits.push_back(&(*hitRPC));
382 return pointerToRPCRecHits;
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< RPCRecHitCollection > rpcRecHitsToken
MuonSegmentMatcher(const edm::ParameterSet &, edm::ConsumesCollector &iC)
constructor with Parameter Set and MuonServiceProxy
std::vector< const CSCSegment * > matchCSC(const reco::Track &muon, const edm::Event &event)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
edm::InputTag RPCHitTags_
C::const_iterator const_iterator
constant access iterator type
edm::EDGetTokenT< CSCSegmentCollection > allSegmentsCSCToken
std::vector< const TrackingRecHit * > recHits() const override
Access to component RecHits (if any)
edm::InputTag DTSegmentTags_
edm::InputTag CSCSegmentTags_
std::vector< const RPCRecHit * > matchRPC(const reco::Track &muon, const edm::Event &event)
virtual ~MuonSegmentMatcher()
destructor
DetId geographicalId() const
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
constexpr uint32_t rawId() const
get the raw id
edm::EDGetTokenT< DTRecSegment4DCollection > dtRecHitsToken
std::vector< const DTRecSegment4D * > matchDT(const reco::Track &muon, const edm::Event &event)
perform the matching