CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DataFormats/L1CSCTrackFinder/src/L1Track.cc

Go to the documentation of this file.
00001 #include "DataFormats/L1CSCTrackFinder/interface/L1Track.h"
00002 #include <iostream>
00003 
00004 namespace csc {
00005 
00006   L1Track::L1Track(const csc::L1TrackId& id): m_name("csc::L1Track")
00007   {
00008     m_endcap = id.endcap();
00009     m_sector = id.sector();
00010     m_lphi = 0;
00011     m_ptAddress = 0;
00012     m_empty = true;
00013     setType(2);
00014     setPtPacked(0);
00015     m_rank = 0;
00016     me1_id = 0;
00017     me2_id = 0;
00018     me3_id = 0;
00019     me4_id = 0;
00020     mb1_id = 0;
00021     m_me1Tbin = 0;
00022     m_me2Tbin = 0;
00023     m_me3Tbin = 0;
00024     m_me4Tbin = 0;
00025     m_mbTbin  = 0;
00026     m_output_link = 0;
00027     m_winner = false;
00028     m_fr=0;
00029     m_se=true; m_bx0=true; m_bc0=true;
00030   }
00031 
00032   L1Track::L1Track(const csc::L1Track& rhs) : L1MuRegionalCand(rhs.type_idx(),rhs.phi_packed(),rhs.eta_packed(),
00033                                                       rhs.pt_packed(),rhs.charge_packed(),
00034                                                       rhs.charge_valid_packed(),rhs.finehalo_packed(),
00035                                                       rhs.quality_packed(),rhs.bx()),
00036                                               m_name(rhs.m_name)
00037   {
00038         this->setBx(rhs.bx());
00039         this->setDataWord(rhs.getDataWord());
00040         m_name    = rhs.m_name;
00041         this->setType(rhs.type_idx());
00042         this->setPhiPacked(rhs.phi_packed());
00043         this->setEtaPacked(rhs.eta_packed());
00044         this->setPtPacked(rhs.pt_packed());
00045         this->setChargePacked(rhs.charge_packed());
00046         this->setChargeValidPacked(rhs.charge_valid_packed());
00047         this->setFineHaloPacked(rhs.finehalo_packed());
00048         this->setQualityPacked(rhs.quality_packed());
00049     m_empty = rhs.m_empty;
00050     m_lphi = rhs.m_lphi;
00051     m_endcap = rhs.m_endcap;
00052     m_sector = rhs.m_sector;
00053     m_ptAddress = rhs.m_ptAddress;
00054     m_rank = rhs.m_rank;
00055     me1_id = rhs.me1_id;
00056     me2_id = rhs.me2_id;
00057     me3_id = rhs.me3_id;
00058     me4_id = rhs.me4_id;
00059     mb1_id = rhs.mb1_id;
00060     m_me1Tbin = rhs.m_me1Tbin;
00061     m_me2Tbin = rhs.m_me2Tbin;
00062     m_me3Tbin = rhs.m_me3Tbin;
00063     m_me4Tbin = rhs.m_me4Tbin;
00064     m_mbTbin  = rhs.m_mbTbin;
00065     m_output_link = rhs.m_output_link;
00066     m_winner = rhs.m_winner;
00067     m_fr=rhs.m_fr;
00068     m_se=rhs.m_se;
00069     m_bx0=rhs.m_bx0;
00070     m_bc0=rhs.m_bc0;
00071   }
00072 
00073   L1Track::~L1Track()
00074   {
00075   }
00076 
00077   const csc::L1Track& L1Track::operator=(const csc::L1Track& rhs)
00078   {
00079     if(this != &rhs)
00080       {
00081         m_fr=rhs.m_fr;
00082         m_se=rhs.m_se;
00083         m_bx0=rhs.m_bx0;
00084         m_bc0=rhs.m_bc0;
00085         m_empty = rhs.m_empty;
00086         this->setBx(rhs.bx());
00087         this->setDataWord(rhs.getDataWord());
00088         m_name    = rhs.m_name;
00089         m_lphi    = rhs.m_lphi;
00090         this->setType(rhs.type_idx());
00091         this->setPhiPacked(rhs.phi_packed());
00092         this->setEtaPacked(rhs.eta_packed());
00093         this->setPtPacked(rhs.pt_packed());
00094         this->setChargePacked(rhs.charge_packed());
00095         this->setChargeValidPacked(rhs.charge_valid_packed());
00096         this->setFineHaloPacked(rhs.finehalo_packed());
00097         this->setQualityPacked(rhs.quality_packed());
00098         m_endcap = rhs.m_endcap;
00099         m_sector = rhs.m_sector;
00100         m_ptAddress = rhs.m_ptAddress;
00101         m_rank = rhs.m_rank;
00102         me1_id = rhs.me1_id;
00103         me2_id = rhs.me2_id;
00104         me3_id = rhs.me3_id;
00105         me4_id = rhs.me4_id;
00106         mb1_id = rhs.mb1_id;
00107         m_me1Tbin = rhs.m_me1Tbin;
00108         m_me2Tbin = rhs.m_me2Tbin;
00109         m_me3Tbin = rhs.m_me3Tbin;
00110         m_me4Tbin = rhs.m_me4Tbin;
00111         m_mbTbin  = rhs.m_mbTbin;
00112         m_output_link = rhs.m_output_link;
00113         m_winner = rhs.m_winner;
00114           }
00115     return *this;
00116   }
00117 
00118   unsigned L1Track::rank() const
00119   {
00120     return m_rank;
00121   }
00122 
00123   void L1Track::setStationIds(const unsigned& me1, const unsigned& me2,
00124                               const unsigned& me3, const unsigned& me4,
00125                               const unsigned& mb1)
00126   {
00127     me1_id = me1;
00128     me2_id = me2;
00129     me3_id = me3;
00130     me4_id = me4;
00131     mb1_id = mb1;
00132   }
00133 
00134   unsigned L1Track::encodeRank(const unsigned& pt, const unsigned& quality)
00135   {
00136     if(pt == 0) return 0;
00137     return pt | (quality << L1MuRegionalCand::PT_LENGTH);
00138   }
00139 
00140   void L1Track::decodeRank(const unsigned& rank, unsigned& pt, unsigned& quality)
00141   {
00142     if(rank == 0)
00143       {
00144         quality = 0;
00145         pt = 0;
00146       }
00147     else
00148       {
00149         quality = rank >> L1MuRegionalCand::PT_LENGTH;
00150         pt = rank & ( (1<<L1MuRegionalCand::PT_LENGTH) - 1);
00151       }
00152   }
00153 
00154   bool L1Track::operator>(const csc::L1Track &rhs) const
00155   {
00156     return (rank() > rhs.rank());
00157   }
00158 
00159   bool L1Track::operator<(const csc::L1Track& rhs) const
00160   {
00161     return (rank() < rhs.rank());
00162   }
00163 
00164   bool L1Track::operator>=(const csc::L1Track& rhs) const
00165   {
00166     return (rank() >= rhs.rank());
00167   }
00168 
00169   bool L1Track::operator<=(const csc::L1Track& rhs) const
00170   {
00171     return (rank() <= rhs.rank());
00172   }
00173 
00174   bool L1Track::operator==(const csc::L1Track& rhs) const
00175   {
00176     return (rank() == rhs.rank());
00177   }
00178 
00179   bool L1Track::operator!=(const csc::L1Track& rhs) const
00180   {
00181     return (rank() != rhs.rank());
00182   }
00183 
00184   void L1Track::Print() const
00185   {
00186     if (!empty())
00187       {
00188         std::cout << "\t  Pt(int): "  << " " << pt_packed()
00189                   << " Phi(int): " << " " << phi_packed()
00190                   << " Eta(int): " << " " << eta_packed()
00191                   << " Quality: "  << " " << quality_packed()
00192                   << " charge: "   << " " << charge_packed()
00193                   << " side: "   << " " << endcap()
00194                   << " bx: "       << " " << BX()
00195           << " Winner: "   << " " << winner()
00196                   << std::endl;
00197       }
00198     else
00199       {
00200         std::cout <<"\t  Empty track!\n";
00201         std::cout << "\t  Pt(int): "  << " " << "unassigned or zero"
00202                   << " Phi(int): " << " " << phi_packed()
00203                   << " Eta(int): " << " " << eta_packed()
00204                   << " Quality: "  << " " << "unassigned or zero"
00205                   << " charge: "   << " " << charge_packed()
00206                   << " side: "   << " " << endcap()
00207                   << " bx: "       << " " << BX()
00208           << " Winner: "   << " " << winner()
00209                   << std::endl;
00210       }
00211   }
00212 
00213   unsigned L1Track::modeExtended(void) const
00214   {
00215     unsigned modeExt = mode(); 
00216     unsigned fr = (m_ptAddress>>21)&0x1;
00217 
00218     if (modeExt ==11 && fr==1)
00219         modeExt = 17;
00220     else if (modeExt==12 && fr==1)
00221         modeExt = 18;
00222     else if (modeExt==14 && fr==1)
00223         modeExt = 16;
00224     return modeExt;
00225   }
00226 }