CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/RecoMuon/MuonIdentification/interface/MuonArbitrationMethods.h

Go to the documentation of this file.
00001 #ifndef MuonIdentification_MuonArbitrationMethods_h
00002 #define MuonIdentification_MuonArbitrationMethods_h
00003 
00004 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00005 
00006 // Author: Jake Ribnik (UCSB)
00007 
00009 struct SortMuonSegmentMatches {
00011    SortMuonSegmentMatches( unsigned int flag ) {
00012       flag_ = flag;
00013    }
00015    bool operator() ( std::pair<reco::MuonChamberMatch*,reco::MuonSegmentMatch*> p1,
00016          std::pair<reco::MuonChamberMatch*,reco::MuonSegmentMatch*> p2 )
00017    {
00018       reco::MuonChamberMatch* cm1 = p1.first;
00019       reco::MuonSegmentMatch* sm1 = p1.second;
00020       reco::MuonChamberMatch* cm2 = p2.first;
00021       reco::MuonSegmentMatch* sm2 = p2.second;
00022 
00023       if(flag_ == reco::MuonSegmentMatch::BestInChamberByDX ||
00024          flag_ == reco::MuonSegmentMatch::BestInStationByDX ||
00025          flag_ == reco::MuonSegmentMatch::BelongsToTrackByDX)
00026          return fabs(sm1->x-cm1->x) < fabs(sm2->x-cm2->x);
00027       if(flag_ == reco::MuonSegmentMatch::BestInChamberByDR ||
00028          flag_ == reco::MuonSegmentMatch::BestInStationByDR || 
00029          flag_ == reco::MuonSegmentMatch::BelongsToTrackByDR)
00030       {
00031          if((! sm1->hasZed()) || (! sm2->hasZed())) // no y information so return dx
00032             return fabs(sm1->x-cm1->x) < fabs(sm2->x-cm2->x);
00033          return sqrt(pow(sm1->x-cm1->x,2)+pow(sm1->y-cm1->y,2)) <
00034             sqrt(pow(sm2->x-cm2->x,2)+pow(sm2->y-cm2->y,2)); 
00035       }
00036       if(flag_ == reco::MuonSegmentMatch::BestInChamberByDXSlope ||
00037          flag_ == reco::MuonSegmentMatch::BestInStationByDXSlope ||
00038          flag_ == reco::MuonSegmentMatch::BelongsToTrackByDXSlope)
00039          return fabs(sm1->dXdZ-cm1->dXdZ) < fabs(sm2->dXdZ-cm2->dXdZ);
00040       if(flag_ == reco::MuonSegmentMatch::BestInChamberByDRSlope ||
00041          flag_ == reco::MuonSegmentMatch::BestInStationByDRSlope ||
00042          flag_ == reco::MuonSegmentMatch::BelongsToTrackByDRSlope)
00043       {
00044          if((! sm1->hasZed()) || (! sm2->hasZed())) // no y information so return dx
00045             return fabs(sm1->dXdZ-cm1->dXdZ) < fabs(sm2->dXdZ-cm2->dXdZ);
00046          return sqrt(pow(sm1->dXdZ-cm1->dXdZ,2)+pow(sm1->dYdZ-cm1->dYdZ,2)) <
00047             sqrt(pow(sm2->dXdZ-cm2->dXdZ,2)+pow(sm2->dYdZ-cm2->dYdZ,2)); 
00048       }
00049 
00050       return false; // is this appropriate? fix this
00051    }
00052 
00053    unsigned int flag_;
00054 };
00055 
00056 #endif