Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-04 00:11:04

0001 #include "DataFormats/L1CSCTrackFinder/interface/L1Track.h"
0002 #include <iostream>
0003 
0004 namespace csc {
0005 
0006   L1Track::L1Track(const csc::L1TrackId& id) : m_name("csc::L1Track") {
0007     m_endcap = id.endcap();
0008     m_sector = id.sector();
0009     setType(2);
0010     setPtPacked(0);
0011   }
0012 
0013   L1Track::L1Track(const csc::L1Track& rhs)
0014       : L1MuRegionalCand(rhs.type_idx(),
0015                          rhs.phi_packed(),
0016                          rhs.eta_packed(),
0017                          rhs.pt_packed(),
0018                          rhs.charge_packed(),
0019                          rhs.charge_valid_packed(),
0020                          rhs.finehalo_packed(),
0021                          rhs.quality_packed(),
0022                          rhs.bx()),
0023         m_name(rhs.m_name) {
0024     this->setBx(rhs.bx());
0025     this->setDataWord(rhs.getDataWord());
0026     m_name = rhs.m_name;
0027     this->setType(rhs.type_idx());
0028     this->setPhiPacked(rhs.phi_packed());
0029     this->setEtaPacked(rhs.eta_packed());
0030     this->setPtPacked(rhs.pt_packed());
0031     this->setChargePacked(rhs.charge_packed());
0032     this->setChargeValidPacked(rhs.charge_valid_packed());
0033     this->setFineHaloPacked(rhs.finehalo_packed());
0034     this->setQualityPacked(rhs.quality_packed());
0035     m_empty = rhs.m_empty;
0036     m_lphi = rhs.m_lphi;
0037     m_endcap = rhs.m_endcap;
0038     m_sector = rhs.m_sector;
0039     m_ptAddress = rhs.m_ptAddress;
0040     m_rank = rhs.m_rank;
0041     me1_id = rhs.me1_id;
0042     me2_id = rhs.me2_id;
0043     me3_id = rhs.me3_id;
0044     me4_id = rhs.me4_id;
0045     mb1_id = rhs.mb1_id;
0046     m_me1Tbin = rhs.m_me1Tbin;
0047     m_me2Tbin = rhs.m_me2Tbin;
0048     m_me3Tbin = rhs.m_me3Tbin;
0049     m_me4Tbin = rhs.m_me4Tbin;
0050     m_mbTbin = rhs.m_mbTbin;
0051     m_output_link = rhs.m_output_link;
0052     m_winner = rhs.m_winner;
0053     m_fr = rhs.m_fr;
0054     m_se = rhs.m_se;
0055     m_bx0 = rhs.m_bx0;
0056     m_bc0 = rhs.m_bc0;
0057   }
0058 
0059   L1Track::~L1Track() {}
0060 
0061   const csc::L1Track& L1Track::operator=(const csc::L1Track& rhs) {
0062     if (this != &rhs) {
0063       m_fr = rhs.m_fr;
0064       m_se = rhs.m_se;
0065       m_bx0 = rhs.m_bx0;
0066       m_bc0 = rhs.m_bc0;
0067       m_empty = rhs.m_empty;
0068       this->setBx(rhs.bx());
0069       this->setDataWord(rhs.getDataWord());
0070       m_name = rhs.m_name;
0071       m_lphi = rhs.m_lphi;
0072       this->setType(rhs.type_idx());
0073       this->setPhiPacked(rhs.phi_packed());
0074       this->setEtaPacked(rhs.eta_packed());
0075       this->setPtPacked(rhs.pt_packed());
0076       this->setChargePacked(rhs.charge_packed());
0077       this->setChargeValidPacked(rhs.charge_valid_packed());
0078       this->setFineHaloPacked(rhs.finehalo_packed());
0079       this->setQualityPacked(rhs.quality_packed());
0080       m_endcap = rhs.m_endcap;
0081       m_sector = rhs.m_sector;
0082       m_ptAddress = rhs.m_ptAddress;
0083       m_rank = rhs.m_rank;
0084       me1_id = rhs.me1_id;
0085       me2_id = rhs.me2_id;
0086       me3_id = rhs.me3_id;
0087       me4_id = rhs.me4_id;
0088       mb1_id = rhs.mb1_id;
0089       m_me1Tbin = rhs.m_me1Tbin;
0090       m_me2Tbin = rhs.m_me2Tbin;
0091       m_me3Tbin = rhs.m_me3Tbin;
0092       m_me4Tbin = rhs.m_me4Tbin;
0093       m_mbTbin = rhs.m_mbTbin;
0094       m_output_link = rhs.m_output_link;
0095       m_winner = rhs.m_winner;
0096     }
0097     return *this;
0098   }
0099 
0100   unsigned L1Track::rank() const { return m_rank; }
0101 
0102   void L1Track::setStationIds(
0103       const unsigned& me1, const unsigned& me2, const unsigned& me3, const unsigned& me4, const unsigned& mb1) {
0104     me1_id = me1;
0105     me2_id = me2;
0106     me3_id = me3;
0107     me4_id = me4;
0108     mb1_id = mb1;
0109   }
0110 
0111   unsigned L1Track::encodeRank(const unsigned& pt, const unsigned& quality) {
0112     if (pt == 0)
0113       return 0;
0114     return pt | (quality << L1MuRegionalCand::PT_LENGTH);
0115   }
0116 
0117   void L1Track::decodeRank(const unsigned& rank, unsigned& pt, unsigned& quality) {
0118     if (rank == 0) {
0119       quality = 0;
0120       pt = 0;
0121     } else {
0122       quality = rank >> L1MuRegionalCand::PT_LENGTH;
0123       pt = rank & ((1 << L1MuRegionalCand::PT_LENGTH) - 1);
0124     }
0125   }
0126 
0127   bool L1Track::operator>(const csc::L1Track& rhs) const { return (rank() > rhs.rank()); }
0128 
0129   bool L1Track::operator<(const csc::L1Track& rhs) const { return (rank() < rhs.rank()); }
0130 
0131   bool L1Track::operator>=(const csc::L1Track& rhs) const { return (rank() >= rhs.rank()); }
0132 
0133   bool L1Track::operator<=(const csc::L1Track& rhs) const { return (rank() <= rhs.rank()); }
0134 
0135   bool L1Track::operator==(const csc::L1Track& rhs) const { return (rank() == rhs.rank()); }
0136 
0137   bool L1Track::operator!=(const csc::L1Track& rhs) const { return (rank() != rhs.rank()); }
0138 
0139   void L1Track::Print() const {
0140     if (!empty()) {
0141       std::cout << "\t  Pt(int): "
0142                 << " " << pt_packed() << " Phi(int): "
0143                 << " " << phi_packed() << " Eta(int): "
0144                 << " " << eta_packed() << " Quality: "
0145                 << " " << quality_packed() << " charge: "
0146                 << " " << charge_packed() << " side: "
0147                 << " " << endcap() << " bx: "
0148                 << " " << BX() << " Winner: "
0149                 << " " << winner() << std::endl;
0150     } else {
0151       std::cout << "\t  Empty track!\n";
0152       std::cout << "\t  Pt(int): "
0153                 << " "
0154                 << "unassigned or zero"
0155                 << " Phi(int): "
0156                 << " " << phi_packed() << " Eta(int): "
0157                 << " " << eta_packed() << " Quality: "
0158                 << " "
0159                 << "unassigned or zero"
0160                 << " charge: "
0161                 << " " << charge_packed() << " side: "
0162                 << " " << endcap() << " bx: "
0163                 << " " << BX() << " Winner: "
0164                 << " " << winner() << std::endl;
0165     }
0166   }
0167 
0168   unsigned L1Track::modeExtended(void) const {
0169     unsigned modeExt = mode();
0170     unsigned fr = (m_ptAddress >> 21) & 0x1;
0171 
0172     if (modeExt == 11 && fr == 1)
0173       modeExt = 17;
0174     else if (modeExt == 12 && fr == 1)
0175       modeExt = 18;
0176     else if (modeExt == 14 && fr == 1)
0177       modeExt = 16;
0178     return modeExt;
0179   }
0180 }  // namespace csc