00001 #include <DataFormats/L1CSCTrackFinder/interface/TrackStub.h>
00002 #include <DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h>
00003 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
00004 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00005 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00006 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h>
00007
00008 namespace csctf
00009 {
00010
00011 const double TrackStub::thePhiBinning = CSCTFConstants::SECTOR_RAD/(1<<CSCBitWidths::kGlobalPhiDataBitWidth);
00012 const double TrackStub::theEtaBinning = (CSCTFConstants::maxEta - CSCTFConstants::minEta)/(CSCTFConstants::etaBins);
00013
00014 TrackStub::TrackStub(const CSCCorrelatedLCTDigi& aDigi,
00015 const DetId& aDetId): CSCCorrelatedLCTDigi(aDigi),
00016 theDetId_(aDetId.rawId()),
00017 thePhi_(0),
00018 theEta_(0),
00019 link_(0)
00020 {}
00021
00022 TrackStub::TrackStub(const CSCCorrelatedLCTDigi& aDigi,
00023 const DetId& aDetId,
00024 const unsigned& phi, const unsigned& eta): CSCCorrelatedLCTDigi(aDigi),
00025 theDetId_(aDetId.rawId()),
00026 thePhi_(phi),
00027 theEta_(eta),
00028 link_(0)
00029 {}
00030
00031
00032
00033 TrackStub::TrackStub(const TrackStub& aTrackStub): CSCCorrelatedLCTDigi(aTrackStub),
00034 theDetId_(aTrackStub.theDetId_),
00035 thePhi_(aTrackStub.thePhi_),
00036 theEta_(aTrackStub.theEta_),
00037 link_(aTrackStub.link_)
00038 {}
00039
00040 unsigned TrackStub::endcap() const
00041 {
00042 int e = 0;
00043
00044 switch(DetId(theDetId_).subdetId())
00045 {
00046 case (MuonSubdetId::DT):
00047 e = (DTChamberId(theDetId_).wheel() > 0) ? 1 : 2;
00048 break;
00049 case (MuonSubdetId::CSC):
00050 e = CSCDetId(theDetId_).endcap();
00051 break;
00052 default:
00053 break;
00054 }
00055
00056 return e;
00057 }
00058
00059 unsigned TrackStub::station() const
00060 {
00061 int s = 0;
00062
00063 switch(DetId(theDetId_).subdetId())
00064 {
00065 case (MuonSubdetId::DT):
00066 s = DTChamberId(theDetId_).station() + 4;
00067 break;
00068 case (MuonSubdetId::CSC):
00069 s = CSCDetId(theDetId_).station();
00070 break;
00071 default:
00072 break;
00073 }
00074
00075 return s;
00076 }
00077
00078 unsigned TrackStub::sector() const
00079 {
00080 int se = 0, temps = 0;
00081
00082 switch(DetId(theDetId_).subdetId())
00083 {
00084 case (MuonSubdetId::DT):
00085 temps = DTChamberId(theDetId_).sector();
00086 se = (temps + 1)/2;
00087 break;
00088 case (MuonSubdetId::CSC):
00089 se = CSCTriggerNumbering::triggerSectorFromLabels(CSCDetId(theDetId_));
00090 break;
00091 default:
00092 break;
00093 }
00094
00095 return se;
00096 }
00097
00098 unsigned TrackStub::subsector() const
00099 {
00100 int ss = 0;
00101
00102 switch(DetId(theDetId_).subdetId())
00103 {
00104 case (MuonSubdetId::DT):
00105 ss = DTChamberId(theDetId_).sector();
00106 break;
00107 case (MuonSubdetId::CSC):
00108 ss = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(theDetId_));
00109 break;
00110 default:
00111 break;
00112 }
00113
00114 return ss;
00115 }
00116
00117 unsigned TrackStub::cscid() const
00118 {
00119 if(DetId(theDetId_).subdetId() == MuonSubdetId::CSC)
00120 return CSCTriggerNumbering::triggerCscIdFromLabels(CSCDetId(theDetId_));
00121
00122 return 0;
00123 }
00124
00125 bool TrackStub::operator<(const TrackStub& rhs) const
00126 {
00127 return ( rhs.isValid() && ( (!(isValid())) || (getQuality() < rhs.getQuality()) ||
00128 (getQuality() == rhs.getQuality() && cscid() < rhs.cscid()) ||
00129 (getQuality() == rhs.getQuality() && cscid() == rhs.cscid() &&
00130 (getTrknmb() == 2)) ) );
00131 }
00132
00133 bool TrackStub::operator>(const TrackStub& rhs) const
00134 {
00135 return ( isValid() && ( (!(rhs.isValid())) || (getQuality() > rhs.getQuality()) ||
00136 (getQuality() == rhs.getQuality() && cscid() > rhs.cscid()) ||
00137 (getQuality() == rhs.getQuality() && cscid() == rhs.cscid() &&
00138 (getTrknmb() == 1)) ) );
00139 }
00140
00141 }