10 doOverlaps(parm.getParameter<bool>(
"Overlap")),
11 doClustering(parm.getParameter<bool>(
"Clustering")),
12 OverlapDPhi(parm.getParameter<double>(
"OverlapDPhi")),
13 OverlapDTheta(parm.getParameter<double>(
"OverlapDTheta")),
14 ClusterDPhi(parm.getParameter<double>(
"ClusterDPhi")),
15 ClusterDTheta(parm.getParameter<double>(
"ClusterDTheta")) {
20 for(std::vector<reco::Muon>::iterator muonIter1 = inputMuons->begin();
21 muonIter1 != inputMuons->end();
23 if(muonIter1->isTrackerMuon()){
26 for(std::vector<reco::Muon>::iterator muonIter2 = inputMuons->begin();
27 muonIter2 != inputMuons->end();
29 if(muonIter2->isTrackerMuon()) {
30 if(muonIter2 != muonIter1) {
33 for(std::vector<reco::MuonChamberMatch>::iterator chamberIter1 = muonIter1->matches().begin();
34 chamberIter1 != muonIter1->matches().end();
36 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
37 segmentIter1 != chamberIter1->segmentMatches.end();
39 for(std::vector<reco::MuonChamberMatch>::iterator chamberIter2 = muonIter2->matches().begin();
40 chamberIter2 != muonIter2->matches().end();
42 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter2 = chamberIter2->segmentMatches.begin();
43 segmentIter2 != chamberIter2->segmentMatches.end();
49 bool addsegment(
false);
51 if( segmentIter1->cscSegmentRef.isNonnull() && segmentIter2->cscSegmentRef.isNonnull() ) {
54 isDuplicateOf(segmentIter1->cscSegmentRef,segmentIter2->cscSegmentRef) &&
55 CSCDetId(chamberIter1->id).ring() == 4 &&
CSCDetId(chamberIter2->id).ring() == 4 &&
56 chamberIter1->id == chamberIter2->id ) {
63 std::make_pair(
CSCDetId(chamberIter2->id),segmentIter2->cscSegmentRef)) ) {
70 std::make_pair(
CSCDetId(chamberIter2->id),segmentIter2->cscSegmentRef)) ) {
81 std::make_pair(&*muonIter2,
82 std::make_pair(&*chamberIter2,
85 ) ==
mesh_[&*muonIter1].end()) {
86 mesh_[&*muonIter1].push_back(std::make_pair(&*muonIter2,
87 std::make_pair(&*chamberIter2,
109 if(
mesh_.size() == 1) {
110 for(std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
mesh_.begin()->first->matches().begin();
111 chamberIter1 !=
mesh_.begin()->first->matches().end();
113 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
114 segmentIter1 != chamberIter1->segmentMatches.end();
123 if(
mesh_.size() > 1) {
124 for( MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i ) {
125 for( std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
126 chamberIter1 !=
i->first->matches().end();
128 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
129 segmentIter1 != chamberIter1->segmentMatches.end();
134 for( AssociationType::iterator
j =
i->second.begin();
135 j !=
i->second.end();
138 if( segmentIter1->cscSegmentRef.isNonnull() &&
139 j->second.second->cscSegmentRef.isNonnull() ) {
142 CSCDetId segIterId(chamberIter1->id), shareId(
j->second.first->id);
145 isDuplicateOf(std::make_pair(segIterId,segmentIter1->cscSegmentRef),
146 std::make_pair(shareId,
j->second.second->cscSegmentRef)) )
150 isDuplicateOf(segmentIter1->cscSegmentRef,
j->second.second->cscSegmentRef) &&
151 segIterId.ring() == 4 && shareId.
ring() == 4 &&
152 segIterId == segIterId)
157 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef)) )
164 if( ((segmentIter1->mask&0x1e0000) == 0x1e0000 && !shared) ||
165 (chamberIter1->id.subdetId() ==
MuonSubdetId::DT && (segmentIter1->mask&0x1e0000)) )
177 for( MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i ) {
179 for( AssociationType::iterator
j =
i->second.begin();
180 j !=
i->second.end();
183 for( std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
184 chamberIter1 !=
i->first->matches().end();
186 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
187 segmentIter1 != chamberIter1->segmentMatches.end();
190 if(
j->second.second->cscSegmentRef.isNonnull() && segmentIter1->cscSegmentRef.isNonnull()) {
197 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef)) ) {
209 if((segmentIter1->mask & 0x1e0000) > (
j->second.second->mask & 0x1e0000)) {
225 isDuplicateOf(segmentIter1->cscSegmentRef,
j->second.second->cscSegmentRef) &&
227 chamberIter1->id ==
j->second.first->id ) {
232 for(AssociationType::iterator AsscIter1 =
i->second.begin();
233 AsscIter1 !=
i->second.end();
235 if(AsscIter1->second.second->cscSegmentRef.isNonnull())
236 if(
j->first == AsscIter1->first &&
237 j->second.first == AsscIter1->second.first &&
238 isDuplicateOf(segmentIter1->cscSegmentRef,AsscIter1->second.second->cscSegmentRef)) {
239 AsscIter1->second.second->mask &= ~
reco::MuonSegmentMatch::BelongsToTrackByME1aClean;
249 for(AssociationType::iterator AsscIter1 =
i->second.begin();
250 AsscIter1 !=
i->second.end();
252 if(AsscIter1->second.second->cscSegmentRef.isNonnull())
253 if(
j->first == AsscIter1->first &&
254 j->second.first == AsscIter1->second.first &&
255 isDuplicateOf(segmentIter1->cscSegmentRef,AsscIter1->second.second->cscSegmentRef) &&
256 (segmentIter1->mask & 0x1e0000) < (AsscIter1->second.second->mask & 0x1e0000))
262 for(AssociationType::iterator AsscIter1 =
i->second.begin();
263 AsscIter1 !=
i->second.end();
265 if(AsscIter1->second.second->cscSegmentRef.isNonnull())
266 if(
j->first == AsscIter1->first &&
267 j->second.first == AsscIter1->second.first &&
268 isDuplicateOf(segmentIter1->cscSegmentRef,AsscIter1->second.second->cscSegmentRef)) {
269 AsscIter1->second.second->mask &= ~
reco::MuonSegmentMatch::BelongsToTrackByME1aClean;
281 std::make_pair(
CSCDetId(
j->second.first->id),
j->second.second->cscSegmentRef))) {
299 if((segmentIter1->mask & 0x1e0000) > (
j->second.second->mask & 0x1e0000)) {
305 }
else if ((segmentIter1->mask & 0x1e0000) < (
j->second.second->mask & 0x1e0000)){
325 for( MeshType::iterator
i =
mesh_.begin();
i !=
mesh_.end(); ++
i ) {
326 for( std::vector<reco::MuonChamberMatch>::iterator chamberIter1 =
i->first->matches().begin();
327 chamberIter1 !=
i->first->matches().end();
329 for(std::vector<reco::MuonSegmentMatch>::iterator segmentIter1 = chamberIter1->segmentMatches.begin();
330 segmentIter1 != chamberIter1->segmentMatches.end();
334 segmentIter1->isMask(0xe00000) )
346 if(!lhs->isME11a_duplicate())
349 std::vector<CSCSegment> lhs_duplicates = lhs->duplicateSegments();
351 if(fabs(lhs->localPosition().x() - rhs->localPosition().x() ) < 1E-3 &&
352 fabs(lhs->localPosition().y() - rhs->localPosition().y() ) < 1E-3 &&
353 fabs(lhs->localDirection().x()/lhs->localDirection().z() - rhs->localDirection().x()/rhs->localDirection().z() ) < 1E-3 &&
354 fabs(lhs->localDirection().y()/lhs->localDirection().z() - rhs->localDirection().y()/rhs->localDirection().z() ) < 1E-3 &&
355 fabs(lhs->localPositionError().xx() - rhs->localPositionError().xx() ) < 1E-3 &&
356 fabs(lhs->localPositionError().yy() - rhs->localPositionError().yy() ) < 1E-3 &&
357 fabs(lhs->localDirectionError().xx() - rhs->localDirectionError().xx()) < 1E-3 &&
358 fabs(lhs->localDirectionError().yy() - rhs->localDirectionError().yy()) < 1E-3)
361 for( std::vector<CSCSegment>::const_iterator segIter1 = lhs_duplicates.begin();
362 segIter1 != lhs_duplicates.end();
365 if(fabs(segIter1->localPosition().x() - rhs->localPosition().x() ) < 1E-3 &&
366 fabs(segIter1->localPosition().y() - rhs->localPosition().y() ) < 1E-3 &&
367 fabs(segIter1->localDirection().x()/segIter1->localDirection().z() - rhs->localDirection().x()/rhs->localDirection().z() ) < 1E-3 &&
368 fabs(segIter1->localDirection().y()/segIter1->localDirection().z() - rhs->localDirection().y()/rhs->localDirection().z() ) < 1E-3 &&
369 fabs(segIter1->localPositionError().xx() - rhs->localPositionError().xx() ) < 1E-3 &&
370 fabs(segIter1->localPositionError().yy() - rhs->localPositionError().yy() ) < 1E-3 &&
371 fabs(segIter1->localDirectionError().xx() - rhs->localDirectionError().xx()) < 1E-3 &&
372 fabs(segIter1->localDirectionError().yy() - rhs->localDirectionError().yy()) < 1E-3)
390 const std::pair<CSCDetId,CSCSegmentRef>& lhs)
const
397 if(rhs.first.endcap() == lhs.first.endcap() &&
398 rhs.first.station() == lhs.first.station() &&
399 rhs.first.ring() == lhs.first.ring()) {
407 unsigned modulus = ((rhs.first.ring() != 1 || rhs.first.station() == 1) ? 36 : 18);
408 int left_neighbor = (((rhs.first.chamber() - 1 + modulus)%modulus == 0 ) ? modulus : (rhs.first.chamber() - 1 + modulus)%modulus );
409 int right_neighbor = (((rhs.first.chamber() + 1)%modulus == 0 ) ? modulus : (rhs.first.chamber() + 1)%modulus );
411 if(lhs.first.chamber() == left_neighbor ||
412 lhs.first.chamber() == right_neighbor) {
414 std::vector<CSCSegment> thesegments;
415 thesegments.push_back(*(lhs.second));
436 double rhs_phi = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
phi();
437 double rhs_theta = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
theta();
438 double rhs_z = geometry_->chamber(rhs.first)->toGlobal(rhs.second->localPosition()).
z();
440 for(std::vector<CSCSegment>::const_iterator ilhs = thesegments.begin(); ilhs != thesegments.end(); ++ilhs) {
453 double lhs_phi = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
phi();
454 double lhs_theta = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
theta();
455 double lhs_z = geometry_->chamber(lhs.first)->toGlobal(ilhs->localPosition()).
z();
470 double phidiff = (fabs(rhs_phi - lhs_phi) > 2*
M_PI ? fabs(rhs_phi - lhs_phi) - 2*
M_PI : fabs(rhs_phi - lhs_phi));
472 if(phidiff < OverlapDPhi && fabs(rhs_theta - lhs_theta) < OverlapDTheta &&
473 fabs(rhs_z) < fabs(lhs_z) && rhs_z*lhs_z > 0)
483 const std::pair<CSCDetId,CSCSegmentRef>& rhs)
const
492 if(rhs.first.endcap() == lhs.first.endcap() && lhs.first.station() < rhs.first.station()) {
494 std::vector<CSCSegment> thesegments;
495 thesegments.push_back(*(lhs.second));
518 for(std::vector<CSCSegment>::const_iterator ilhs = thesegments.begin(); ilhs != thesegments.end(); ++ilhs) {
547 double phidiff = (fabs(rhs_phi - lhs_phi) > 2*
M_PI ? fabs(rhs_phi - lhs_phi) - 2*
M_PI : fabs(rhs_phi - lhs_phi));
const double ClusterDTheta
const CSCGeometry * geometry_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Theta< T > theta() const
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool isClusteredWith(const std::pair< CSCDetId, CSCSegmentRef > &lhs, const std::pair< CSCDetId, CSCSegmentRef > &rhs) const
MuonMesh(const edm::ParameterSet &)
ArbitrationType
define arbitration schemes
void fillMesh(std::vector< reco::Muon > *)
static const unsigned int BelongsToTrackByCleaning
static const unsigned int BelongsToTrackByOvlClean
bool isDuplicateOf(const CSCSegmentRef &lhs, const CSCSegmentRef &rhs) const
const CSCChamber * chamber(CSCDetId id) const
Return the chamber corresponding to given DetId.
Geom::Phi< T > phi() const
static const unsigned int BelongsToTrackByClusClean