10 : doME1a(parm.getParameter<
bool>(
"ME1a")),
11 doOverlaps(parm.getParameter<
bool>(
"Overlap")),
12 doClustering(parm.getParameter<
bool>(
"Clustering")),
13 OverlapDPhi(parm.getParameter<double>(
"OverlapDPhi")),
15 ClusterDPhi(parm.getParameter<double>(
"ClusterDPhi")),
19 for (std::vector<reco::Muon>::iterator muonIter1 =
inputMuons->begin(); muonIter1 !=
inputMuons->end(); ++muonIter1) {
20 if (muonIter1->isTrackerMuon()) {
22 for (std::vector<reco::Muon>::iterator muonIter2 =
inputMuons->begin(); muonIter2 !=
inputMuons->end();
24 if (muonIter2->isTrackerMuon()) {
25 if (muonIter2 != muonIter1) {
27 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter1 = muonIter1->matches().begin();
28 chamberIter1 != muonIter1->matches().end();
30 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
31 segmentIter1 != chamberIter1->segmentMatches.end();
33 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter2 = muonIter2->matches().begin();
34 chamberIter2 != muonIter2->matches().end();
36 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter2 =
37 chamberIter2->segmentMatches.begin();
38 segmentIter2 != chamberIter2->segmentMatches.end();
42 bool addsegment(
false);
44 if (segmentIter1->cscSegmentRef.isNonnull() && segmentIter2->cscSegmentRef.isNonnull()) {
47 chamberIter1->id == chamberIter2->id) {
54 std::make_pair(
CSCDetId(chamberIter2->id), segmentIter2->cscSegmentRef))) {
61 std::make_pair(
CSCDetId(chamberIter2->id), segmentIter2->cscSegmentRef))) {
72 std::make_pair(&*muonIter2, std::make_pair(&*chamberIter2, &*segmentIter2))) ==
73 mesh_[&*muonIter1].end()) {
74 mesh_[&*muonIter1].push_back(
75 std::make_pair(&*muonIter2, std::make_pair(&*chamberIter2, &*segmentIter2)));
94 if (
mesh_.size() == 1) {
95 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
mesh_.begin()->first->matches().begin();
96 chamberIter1 !=
mesh_.begin()->first->matches().end();
98 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
99 segmentIter1 != chamberIter1->segmentMatches.end();
108 if (
mesh_.size() > 1) {
109 for (MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i) {
110 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
111 chamberIter1 !=
i->first->matches().end();
113 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
114 segmentIter1 != chamberIter1->segmentMatches.end();
118 for (AssociationType::iterator
j =
i->second.begin();
j !=
i->second.end(); ++
j) {
119 if (segmentIter1->cscSegmentRef.isNonnull() &&
j->second.second->cscSegmentRef.isNonnull()) {
122 CSCDetId segIterId(chamberIter1->id), shareId(
j->second.first->id);
125 std::make_pair(shareId,
j->second.second->cscSegmentRef)))
129 segIterId.ring() == 4 && shareId.
ring() == 4 && segIterId == segIterId)
134 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef)))
141 if (((segmentIter1->mask & 0x1e0000) == 0x1e0000 && !shared) ||
142 (chamberIter1->id.subdetId() ==
MuonSubdetId::DT && (segmentIter1->mask & 0x1e0000)))
152 for (MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i) {
153 for (AssociationType::iterator
j =
i->second.begin();
j !=
i->second.end(); ++
j) {
154 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
155 chamberIter1 !=
i->first->matches().end();
157 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
158 segmentIter1 != chamberIter1->segmentMatches.end();
160 if (
j->second.second->cscSegmentRef.isNonnull() && segmentIter1->cscSegmentRef.isNonnull()) {
166 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef))) {
174 j->first->numberOfMatches(
177 if ((segmentIter1->mask & 0x1e0000) >
178 (
j->second.second->mask & 0x1e0000)) {
195 chamberIter1->id ==
j->second.first->id) {
198 for (AssociationType::iterator AsscIter1 =
i->second.begin(); AsscIter1 !=
i->second.end();
200 if (AsscIter1->second.second->cscSegmentRef.isNonnull())
201 if (
j->first == AsscIter1->first &&
j->second.first == AsscIter1->second.first &&
202 isDuplicateOf(segmentIter1->cscSegmentRef, AsscIter1->second.second->cscSegmentRef)) {
203 AsscIter1->second.second->mask &= ~
reco::MuonSegmentMatch::BelongsToTrackByME1aClean;
209 i->first->numberOfMatches(
214 for (AssociationType::iterator AsscIter1 =
i->second.begin(); AsscIter1 !=
i->second.end();
216 if (AsscIter1->second.second->cscSegmentRef.isNonnull())
217 if (
j->first == AsscIter1->first &&
j->second.first == AsscIter1->second.first &&
218 isDuplicateOf(segmentIter1->cscSegmentRef, AsscIter1->second.second->cscSegmentRef) &&
219 (segmentIter1->mask & 0x1e0000) < (AsscIter1->second.second->mask & 0x1e0000))
224 for (AssociationType::iterator AsscIter1 =
i->second.begin(); AsscIter1 !=
i->second.end();
226 if (AsscIter1->second.second->cscSegmentRef.isNonnull())
227 if (
j->first == AsscIter1->first &&
j->second.first == AsscIter1->second.first &&
228 isDuplicateOf(segmentIter1->cscSegmentRef, AsscIter1->second.second->cscSegmentRef)) {
229 AsscIter1->second.second->mask &= ~
reco::MuonSegmentMatch::BelongsToTrackByME1aClean;
240 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef))) {
255 if ((segmentIter1->mask & 0x1e0000) >
256 (
j->second.second->mask & 0x1e0000)) {
262 }
else if ((segmentIter1->mask & 0x1e0000) < (
j->second.second->mask & 0x1e0000)) {
282 for (MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i) {
283 for (std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
284 chamberIter1 !=
i->first->matches().end();
286 for (std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
287 segmentIter1 != chamberIter1->segmentMatches.end();
302 if (!lhs->isME11a_duplicate())
305 std::vector<CSCSegment> lhs_duplicates = lhs->duplicateSegments();
307 if (fabs(lhs->localPosition().x() - rhs->localPosition().x()) < 1E-3 &&
308 fabs(lhs->localPosition().y() - rhs->localPosition().y()) < 1E-3 &&
309 fabs(lhs->localDirection().x() / lhs->localDirection().z() -
310 rhs->localDirection().x() / rhs->localDirection().z()) < 1E-3 &&
311 fabs(lhs->localDirection().y() / lhs->localDirection().z() -
312 rhs->localDirection().y() / rhs->localDirection().z()) < 1E-3 &&
313 fabs(lhs->localPositionError().xx() - rhs->localPositionError().xx()) < 1E-3 &&
314 fabs(lhs->localPositionError().yy() - rhs->localPositionError().yy()) < 1E-3 &&
315 fabs(lhs->localDirectionError().xx() - rhs->localDirectionError().xx()) < 1E-3 &&
316 fabs(lhs->localDirectionError().yy() - rhs->localDirectionError().yy()) < 1E-3)
319 for (std::vector<CSCSegment>::const_iterator segIter1 = lhs_duplicates.begin(); segIter1 != lhs_duplicates.end();
322 if (fabs(segIter1->localPosition().x() - rhs->localPosition().x()) < 1E-3 &&
323 fabs(segIter1->localPosition().y() - rhs->localPosition().y()) < 1E-3 &&
324 fabs(segIter1->localDirection().x() / segIter1->localDirection().z() -
325 rhs->localDirection().x() / rhs->localDirection().z()) < 1E-3 &&
326 fabs(segIter1->localDirection().y() / segIter1->localDirection().z() -
327 rhs->localDirection().y() / rhs->localDirection().z()) < 1E-3 &&
328 fabs(segIter1->localPositionError().xx() - rhs->localPositionError().xx()) < 1E-3 &&
329 fabs(segIter1->localPositionError().yy() - rhs->localPositionError().yy()) < 1E-3 &&
330 fabs(segIter1->localDirectionError().xx() - rhs->localDirectionError().xx()) < 1E-3 &&
331 fabs(segIter1->localDirectionError().yy() - rhs->localDirectionError().yy()) < 1E-3)
349 const std::pair<CSCDetId, CSCSegmentRef>& lhs)
357 if (rhs.first.endcap() == lhs.first.endcap() && rhs.first.station() == lhs.first.station() &&
358 rhs.first.ring() == lhs.first.ring()) {
366 unsigned modulus = ((rhs.first.ring() != 1 || rhs.first.station() == 1) ? 36 : 18);
367 int left_neighbor = (((rhs.first.chamber() - 1 + modulus) % modulus == 0)
369 : (rhs.first.chamber() - 1 + modulus) % modulus);
370 int right_neighbor = (((rhs.first.chamber() + 1) % modulus == 0) ? modulus : (rhs.first.chamber() + 1) % modulus);
372 if (lhs.first.chamber() == left_neighbor ||
373 lhs.first.chamber() == right_neighbor) {
375 std::vector<CSCSegment> thesegments;
376 thesegments.push_back(*(lhs.second));
397 double rhs_phi = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
phi();
398 double rhs_theta = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
theta();
399 double rhs_z = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
z();
401 for (std::vector<CSCSegment>::const_iterator ilhs = thesegments.begin(); ilhs != thesegments.end(); ++ilhs) {
413 double lhs_phi = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
phi();
414 double lhs_theta = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
theta();
415 double lhs_z = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
z();
431 (fabs(rhs_phi - lhs_phi) > 2 *
M_PI ? fabs(rhs_phi - lhs_phi) - 2 *
M_PI : fabs(rhs_phi - lhs_phi));
444 const std::pair<CSCDetId, CSCSegmentRef>& rhs)
const {
452 if (rhs.first.endcap() == lhs.first.endcap() && lhs.first.station() < rhs.first.station()) {
453 std::vector<CSCSegment> thesegments;
454 thesegments.push_back(*(lhs.second));
477 for (std::vector<CSCSegment>::const_iterator ilhs = thesegments.begin(); ilhs != thesegments.end(); ++ilhs) {
506 (fabs(rhs_phi - lhs_phi) > 2 *
M_PI ? fabs(rhs_phi - lhs_phi) - 2 *
M_PI : fabs(rhs_phi - lhs_phi));