45 dtRadius_(matchParameters.getParameter<double>(
"DTradius")),
67 vector<const DTRecSegment4D*> pointerTo4DSegments;
69 std::vector<TrackingRecHit const*> dtHits;
71 bool segments =
false;
74 for (
auto const&
hit :
muon.recHits()) {
81 if (!
hit->recHits().empty())
82 if ((*
hit->recHits().begin())->
recHits().size() > 1)
84 dtHits.push_back(
hit);
91 double matchRatioZ = 0;
92 double matchRatioPhi = 0;
95 LocalPoint pointLocal = rechit->localPosition();
99 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
101 DetId idT = (*hit)->geographicalId();
102 if (!(rechit->geographicalId().rawId() == idT.
rawId()))
106 LocalPoint segLocal = (*hit)->localPosition();
107 if ((fabs(pointLocal.
x() - segLocal.
x()) < ZCutParameter) &&
108 (fabs(pointLocal.
y() - segLocal.
y()) < ZCutParameter))
109 pointerTo4DSegments.push_back(&(*rechit));
117 if (rechit->hasZed()) {
118 double countMuonDTHits = 0;
119 double countAgreeingHits = 0;
122 segmZ = dynamic_cast<const DTRecSegment2D*>(rechit->zSegment());
123 nhitsZ = segmZ->
recHits().size();
129 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
130 if (!(*hit)->isValid())
133 DetId idT = (*hit)->geographicalId();
137 LocalPoint pointLocal = (*hit)->localPosition();
139 if ((chamberSegIdT == dtDetIdHitT) && (dtDetLayerIdHitT.superlayer() == 2))
142 for (vector<DTRecHit1D>::const_iterator hiti = hits1d.begin(); hiti != hits1d.end(); hiti++) {
143 if (!hiti->isValid())
147 if (!(hiti->geographicalId().rawId() == idT.
rawId()))
154 if ((fabs(pointLocal.x() - segLocal.
x()) < ZCutParameter) &&
155 (fabs(pointLocal.y() - segLocal.
y()) < ZCutParameter))
160 matchRatioZ = countMuonDTHits == 0 ? 0 : countAgreeingHits / countMuonDTHits;
162 if (countAgreeingHits / nhitsZ > matchRatioZ)
163 matchRatioZ = countAgreeingHits / nhitsZ;
166 if (rechit->hasPhi()) {
167 double countMuonDTHits = 0;
168 double countAgreeingHits = 0;
172 segmPhi = dynamic_cast<const DTRecSegment2D*>(rechit->phiSegment());
173 nhitsPhi = segmPhi->
recHits().size();
179 for (
auto hit = dtHits.begin();
hit != dtHits.end(); ++
hit) {
180 if (!(*hit)->isValid())
183 DetId idT = (*hit)->geographicalId();
191 if ((chamberSegIdT == dtDetIdHitT) &&
192 ((dtDetLayerIdHitT.superlayer() == 1) || (dtDetLayerIdHitT.superlayer() == 3)))
195 for (vector<DTRecHit1D>::const_iterator hiti = hits1d.begin(); hiti != hits1d.end(); hiti++) {
196 if (!hiti->isValid())
200 if (!(hiti->geographicalId().rawId() == idT.
rawId()))
208 if ((fabs(pointLocal.x() - segLocal.
x()) < PhiCutParameter) &&
209 (fabs(pointLocal.y() - segLocal.
y()) < PhiCutParameter))
214 matchRatioPhi = countMuonDTHits != 0 ? countAgreeingHits / countMuonDTHits : 0;
216 if (countAgreeingHits / nhitsPhi > matchRatioPhi)
217 matchRatioPhi = countAgreeingHits / nhitsPhi;
221 if ((matchRatioPhi > 0.9) && (matchRatioZ > 0.9)) {
223 pointerTo4DSegments.push_back(&(*rechit));
226 if ((matchRatioPhi > 0.9 && nhitsPhi) || (matchRatioZ > 0.9 && nhitsZ)) {
228 pointerTo4DSegments.push_back(&(*rechit));
234 return pointerTo4DSegments;
243 vector<const CSCSegment*> pointerToCSCSegments;
245 double matchRatioCSC = 0;
247 double CSCXCut = 0.001;
248 double CSCYCut = 0.001;
249 double countMuonCSCHits = 0;
253 double CSCcountAgreeingHits = 0;
255 if (!segmentCSC->isValid())
259 const vector<CSCRecHit2D>& CSCRechits2D = segmentCSC->specificRecHits();
260 countMuonCSCHits = 0;
261 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
263 bool segments =
false;
265 for (
auto const& hitC :
muon.recHits()) {
266 if (!hitC->isValid())
272 if (!hitC->isValid())
274 if (hitC->recHits().size() > 1)
278 DetId id = hitC->geographicalId();
282 if (!(myChamber.rawId() == cscDetIdHit.
rawId()))
286 LocalPoint positionLocalCSC = hitC->localPosition();
287 LocalPoint segLocalCSC = segmentCSC->localPosition();
288 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
289 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut))
290 pointerToCSCSegments.push_back(&(*segmentCSC));
294 if (!(cscDetIdHit.
ring() == myChamber.ring()))
296 if (!(cscDetIdHit.
station() == myChamber.station()))
298 if (!(cscDetIdHit.
endcap() == myChamber.endcap()))
300 if (!(cscDetIdHit.
chamber() == myChamber.chamber()))
305 LocalPoint positionLocalCSC = hitC->localPosition();
307 for (vector<CSCRecHit2D>::const_iterator hiti = CSCRechits2D.begin(); hiti != CSCRechits2D.end(); hiti++) {
308 if (!hiti->isValid())
310 CSCDetId cscDetId((hiti->geographicalId()).rawId());
312 if (hitC->geographicalId().rawId() != (hiti->geographicalId()).rawId())
315 LocalPoint segLocalCSC = hiti->localPosition();
318 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
319 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut)) {
320 CSCcountAgreeingHits++;
326 matchRatioCSC = countMuonCSCHits == 0 ? 0 : CSCcountAgreeingHits / countMuonCSCHits;
328 if ((matchRatioCSC > 0.9) && ((countMuonCSCHits > 1) || !
cscTightMatch))
329 pointerToCSCSegments.push_back(&(*segmentCSC));
333 return pointerToCSCSegments;
342 vector<const RPCRecHit*> pointerToRPCRecHits;
343 double RPCCut = 0.001;
346 if (!hitRPC->isValid())
349 RPCDetId myChamber((*hitRPC).geographicalId().rawId());
350 LocalPoint posLocalRPC = hitRPC->localPosition();
353 for (
auto const& hitC :
muon.recHits()) {
354 if (!hitC->isValid())
360 if (!hitC->isValid())
364 DetId id = hitC->geographicalId();
367 if (rpcDetIdHit != myChamber)
369 LocalPoint posLocalMuon = hitC->localPosition();
373 if ((fabs(posLocalMuon.
x() - posLocalRPC.x()) < RPCCut)) {
380 pointerToRPCRecHits.push_back(&(*hitRPC));
383 return pointerToRPCRecHits;