Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:50:14

0001 #include <DataFormats/L1CSCTrackFinder/interface/TrackStub.h>
0002 #include <DataFormats/L1CSCTrackFinder/interface/CSCBitWidths.h>
0003 #include <DataFormats/MuonDetId/interface/CSCTriggerNumbering.h>
0004 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
0005 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
0006 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h>
0007 
0008 namespace csctf {
0009 
0010   const double TrackStub::thePhiBinning = CSCTFConstants::SECTOR_RAD / (1 << CSCBitWidths::kGlobalPhiDataBitWidth);
0011   const double TrackStub::theEtaBinning = (CSCTFConstants::maxEta - CSCTFConstants::minEta) / (CSCTFConstants::etaBins);
0012 
0013   TrackStub::TrackStub(const CSCCorrelatedLCTDigi& aDigi, const DetId& aDetId)
0014       : CSCCorrelatedLCTDigi(aDigi), theDetId_(aDetId.rawId()), thePhi_(0), theEta_(0), link_(0) {}
0015 
0016   TrackStub::TrackStub(const CSCCorrelatedLCTDigi& aDigi, const DetId& aDetId, const unsigned& phi, const unsigned& eta)
0017       : CSCCorrelatedLCTDigi(aDigi), theDetId_(aDetId.rawId()), thePhi_(phi), theEta_(eta), link_(0) {}
0018 
0019   TrackStub::TrackStub(const TrackStub& aTrackStub)
0020       : CSCCorrelatedLCTDigi(aTrackStub),
0021         theDetId_(aTrackStub.theDetId_),
0022         thePhi_(aTrackStub.thePhi_),
0023         theEta_(aTrackStub.theEta_),
0024         link_(aTrackStub.link_) {}
0025 
0026   unsigned TrackStub::endcap() const {
0027     int e = 0;
0028 
0029     switch (DetId(theDetId_).subdetId()) {
0030       case (MuonSubdetId::DT):
0031         e = (DTChamberId(theDetId_).wheel() > 0) ? 1 : 2;
0032         break;
0033       case (MuonSubdetId::CSC):
0034         e = CSCDetId(theDetId_).endcap();
0035         break;
0036       default:
0037         break;
0038     }
0039 
0040     return e;
0041   }
0042 
0043   unsigned TrackStub::station() const {
0044     int s = 0;
0045 
0046     switch (DetId(theDetId_).subdetId()) {
0047       case (MuonSubdetId::DT):
0048         s = DTChamberId(theDetId_).station() + 4;
0049         break;
0050       case (MuonSubdetId::CSC):
0051         s = CSCDetId(theDetId_).station();
0052         break;
0053       default:
0054         break;
0055     }
0056 
0057     return s;
0058   }
0059 
0060   unsigned TrackStub::sector() const {
0061     int se = 0, temps = 0;
0062 
0063     switch (DetId(theDetId_).subdetId()) {
0064       case (MuonSubdetId::DT): {
0065         temps = DTChamberId(theDetId_).sector();
0066         const unsigned int dt2csc[12] = {6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6};
0067         se = dt2csc[temps - 1];
0068       } break;
0069       case (MuonSubdetId::CSC):
0070         se = CSCTriggerNumbering::triggerSectorFromLabels(CSCDetId(theDetId_));
0071         break;
0072       default:
0073         break;
0074     }
0075 
0076     return se;
0077   }
0078 
0079   unsigned TrackStub::subsector() const {
0080     int ss = 0;
0081 
0082     switch (DetId(theDetId_).subdetId()) {
0083       case (MuonSubdetId::DT): {
0084         ss = DTChamberId(theDetId_).sector();
0085         const unsigned int dt2csc_[12] = {2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1};
0086         ss = dt2csc_[ss - 1];
0087       } break;
0088       case (MuonSubdetId::CSC):
0089         ss = CSCTriggerNumbering::triggerSubSectorFromLabels(CSCDetId(theDetId_));
0090         break;
0091       default:
0092         break;
0093     }
0094 
0095     return ss;
0096   }
0097 
0098   unsigned TrackStub::cscid() const {
0099     if (DetId(theDetId_).subdetId() == MuonSubdetId::CSC)
0100       return CSCTriggerNumbering::triggerCscIdFromLabels(CSCDetId(theDetId_));
0101 
0102     return 0;  // DT chambers obviously don't have a csc id :-D
0103   }
0104 
0105   unsigned TrackStub::cscidSeparateME1a() const {
0106     if (DetId(theDetId_).subdetId() != MuonSubdetId::CSC)
0107       return 0;
0108     CSCDetId id(theDetId_);
0109     unsigned normal_cscid = CSCTriggerNumbering::triggerCscIdFromLabels(id);
0110     if (id.station() == 1 && id.ring() == 4)
0111       return normal_cscid + 9;  // 10,11,12 for ME1a
0112     return normal_cscid;
0113   }
0114 
0115   bool TrackStub::operator<(const TrackStub& rhs) const {
0116     return (rhs.isValid() && ((!(isValid())) || (getQuality() < rhs.getQuality()) ||
0117                               (getQuality() == rhs.getQuality() && cscid() < rhs.cscid()) ||
0118                               (getQuality() == rhs.getQuality() && cscid() == rhs.cscid() && (getTrknmb() == 2))));
0119   }
0120 
0121   bool TrackStub::operator>(const TrackStub& rhs) const {
0122     return (isValid() && ((!(rhs.isValid())) || (getQuality() > rhs.getQuality()) ||
0123                           (getQuality() == rhs.getQuality() && cscid() > rhs.cscid()) ||
0124                           (getQuality() == rhs.getQuality() && cscid() == rhs.cscid() && (getTrknmb() == 1))));
0125   }
0126 
0127 }  // namespace csctf