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;
245 double CSCXCut = 0.001;
246 double CSCYCut = 0.001;
247 double countMuonCSCHits = 0;
251 double CSCcountAgreeingHits = 0;
253 if (!segmentCSC->isValid())
256 const vector<CSCRecHit2D>& CSCRechits2D = segmentCSC->specificRecHits();
257 countMuonCSCHits = 0;
258 CSCDetId myChamber((*segmentCSC).geographicalId().rawId());
260 bool segments =
false;
262 for (
auto const& hitC :
muon.recHits()) {
263 if (!hitC->isValid())
269 if (!hitC->isValid())
271 if (hitC->recHits().size() > 1)
275 DetId id = hitC->geographicalId();
279 if (!(myChamber.rawId() == cscDetIdHit.
rawId()))
283 LocalPoint positionLocalCSC = hitC->localPosition();
284 LocalPoint segLocalCSC = segmentCSC->localPosition();
285 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
286 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut))
287 pointerToCSCSegments.push_back(&(*segmentCSC));
291 if (!(cscDetIdHit.
ring() == myChamber.ring()))
293 if (!(cscDetIdHit.
station() == myChamber.station()))
295 if (!(cscDetIdHit.
endcap() == myChamber.endcap()))
297 if (!(cscDetIdHit.
chamber() == myChamber.chamber()))
302 LocalPoint positionLocalCSC = hitC->localPosition();
304 for (vector<CSCRecHit2D>::const_iterator hiti = CSCRechits2D.begin(); hiti != CSCRechits2D.end(); hiti++) {
305 if (!hiti->isValid())
309 if (hitC->geographicalId().rawId() != (hiti->geographicalId()).
rawId())
312 LocalPoint segLocalCSC = hiti->localPosition();
315 if ((fabs(positionLocalCSC.
x() - segLocalCSC.
x()) < CSCXCut) &&
316 (fabs(positionLocalCSC.
y() - segLocalCSC.
y()) < CSCYCut)) {
317 CSCcountAgreeingHits++;
323 matchRatioCSC = countMuonCSCHits == 0 ? 0 : CSCcountAgreeingHits / countMuonCSCHits;
325 if ((matchRatioCSC > 0.9) && ((countMuonCSCHits > 1) || !
cscTightMatch))
326 pointerToCSCSegments.push_back(&(*segmentCSC));
330 return pointerToCSCSegments;
339 vector<const RPCRecHit*> pointerToRPCRecHits;
340 double RPCCut = 0.001;
343 if (!hitRPC->isValid())
346 RPCDetId myChamber((*hitRPC).geographicalId().rawId());
347 LocalPoint posLocalRPC = hitRPC->localPosition();
350 for (
auto const& hitC :
muon.recHits()) {
351 if (!hitC->isValid())
357 if (!hitC->isValid())
361 DetId id = hitC->geographicalId();
364 if (rpcDetIdHit != myChamber)
366 LocalPoint posLocalMuon = hitC->localPosition();
370 if ((fabs(posLocalMuon.
x() - posLocalRPC.x()) < RPCCut)) {
377 pointerToRPCRecHits.push_back(&(*hitRPC));
380 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