Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:45:49

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTTrackSegPhi
0004 //
0005 //   Description: PHI Track Segment
0006 //
0007 //
0008 //
0009 //   Author :
0010 //   N. Neumeister            CERN EP
0011 //
0012 //--------------------------------------------------
0013 
0014 //-----------------------
0015 // This Class's Header --
0016 //-----------------------
0017 
0018 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegPhi.h"
0019 
0020 //---------------
0021 // C++ Headers --
0022 //---------------
0023 
0024 #include <iostream>
0025 #include <iomanip>
0026 #include <cmath>
0027 
0028 //-------------------------------
0029 // Collaborating Class Headers --
0030 //-------------------------------
0031 
0032 #include "L1Trigger/DTTrackFinder/interface/L1MuDTTrackSegLoc.h"
0033 
0034 using namespace std;
0035 
0036 // --------------------------------
0037 //       class L1MuDTTrackSegPhi
0038 //---------------------------------
0039 
0040 //----------------
0041 // Constructors --
0042 //----------------
0043 
0044 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi()
0045     : m_location(), m_phi(0), m_phib(0), m_quality(Null), m_tag(false), m_bx(0), m_etaFlag(false) {}
0046 
0047 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(
0048     int wheel_id, int sector_id, int station_id, int phi, int phib, TSQuality quality, bool tag, int bx, bool etaFlag)
0049     : m_location(wheel_id, sector_id, station_id),
0050       m_phi(phi),
0051       m_phib(phib),
0052       m_quality(quality),
0053       m_tag(false),
0054       m_bx(bx),
0055       m_etaFlag(etaFlag) {
0056   if (phi < -2048 || phi > 2047) {
0057     //    cerr << "TrackSegPhi : phi out of range: " << phi << endl;
0058   }
0059   if (phib < -512 || phib > 511) {
0060     //    cerr << "TrackSegPhi : phib out of range: " << phib << endl;
0061   }
0062   if (quality > 7) {
0063     //    cerr << "TrackSegPhi : quality out of range: " << quality << endl;
0064   }
0065 }
0066 
0067 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(
0068     const L1MuDTTrackSegLoc& id, int phi, int phib, TSQuality quality, bool tag, int bx, bool etaFlag)
0069     : m_location(id), m_phi(phi), m_phib(phib), m_quality(quality), m_tag(tag), m_bx(bx), m_etaFlag(etaFlag) {
0070   if (phi < -2048 || phi > 2047) {
0071     //    cerr << "TrackSegPhi : phi out of range: " << phi << endl;
0072   }
0073   if (phib < -512 || phib > 511) {
0074     //    cerr << "TrackSegPhi : phib out of range: " << phib << endl;
0075   }
0076   if (quality > 7) {
0077     //    cerr << "TrackSegPhi : quality out of range: " << quality << endl;
0078   }
0079 }
0080 
0081 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(const L1MuDTTrackSegPhi& id)
0082     : m_location(id.m_location),
0083       m_phi(id.m_phi),
0084       m_phib(id.m_phib),
0085       m_quality(id.m_quality),
0086       m_tag(id.m_tag),
0087       m_bx(id.m_bx),
0088       m_etaFlag(id.m_etaFlag) {}
0089 
0090 //--------------
0091 // Destructor --
0092 //--------------
0093 L1MuDTTrackSegPhi::~L1MuDTTrackSegPhi() {}
0094 
0095 //--------------
0096 // Operations --
0097 //--------------
0098 
0099 //
0100 // reset PHI Track Segment
0101 //
0102 void L1MuDTTrackSegPhi::reset() {
0103   m_phi = 0;
0104   m_phib = 0;
0105   m_quality = Null;
0106   m_tag = false;
0107   m_bx = 0;
0108   m_etaFlag = false;
0109 }
0110 
0111 //
0112 // return phi in global coordinates [0,2pi]
0113 //
0114 double L1MuDTTrackSegPhi::phiValue() const {
0115   double tmp = static_cast<double>(m_location.sector()) * M_PI / 6;
0116   tmp += static_cast<double>(m_phi) / 4096;
0117   return (tmp > 0) ? tmp : (2 * M_PI + tmp);
0118 }
0119 
0120 //
0121 // return phib in radians
0122 //
0123 double L1MuDTTrackSegPhi::phibValue() const { return static_cast<double>(m_phib) / 512; }
0124 
0125 //
0126 // Assignment operator
0127 //
0128 L1MuDTTrackSegPhi& L1MuDTTrackSegPhi::operator=(const L1MuDTTrackSegPhi& id) {
0129   if (this != &id) {
0130     m_location = id.m_location;
0131     m_phi = id.m_phi;
0132     m_phib = id.m_phib;
0133     m_quality = id.m_quality;
0134     m_tag = id.m_tag;
0135     m_bx = id.m_bx;
0136     m_etaFlag = id.m_etaFlag;
0137   }
0138   return *this;
0139 }
0140 
0141 //
0142 // Equal operator
0143 //
0144 bool L1MuDTTrackSegPhi::operator==(const L1MuDTTrackSegPhi& id) const {
0145   if (m_location != id.m_location)
0146     return false;
0147   if (m_phi != id.m_phi)
0148     return false;
0149   if (m_phib != id.m_phib)
0150     return false;
0151   if (m_quality != id.m_quality)
0152     return false;
0153   if (m_bx != id.m_bx)
0154     return false;
0155   return true;
0156 }
0157 
0158 //
0159 // Unequal operator
0160 //
0161 bool L1MuDTTrackSegPhi::operator!=(const L1MuDTTrackSegPhi& id) const {
0162   if (m_location != id.m_location)
0163     return true;
0164   if (m_phi != id.m_phi)
0165     return true;
0166   if (m_phib != id.m_phib)
0167     return true;
0168   if (m_quality != id.m_quality)
0169     return true;
0170   if (m_bx != id.m_bx)
0171     return true;
0172   return false;
0173 }
0174 
0175 //
0176 // output stream operator phi track segment quality
0177 //
0178 ostream& operator<<(ostream& s, const L1MuDTTrackSegPhi::TSQuality& quality) {
0179   switch (quality) {
0180     case L1MuDTTrackSegPhi::Li:
0181       return s << "Li ";
0182     case L1MuDTTrackSegPhi::Lo:
0183       return s << "Lo ";
0184     case L1MuDTTrackSegPhi::Hi:
0185       return s << "Hi ";
0186     case L1MuDTTrackSegPhi::Ho:
0187       return s << "Ho ";
0188     case L1MuDTTrackSegPhi::LL:
0189       return s << "LL ";
0190     case L1MuDTTrackSegPhi::HL:
0191       return s << "HL ";
0192     case L1MuDTTrackSegPhi::HH:
0193       return s << "HH ";
0194     case L1MuDTTrackSegPhi::Null:
0195       return s << "Null ";
0196     default:
0197       return s << "unknown TS phi Quality ";
0198   }
0199 }
0200 
0201 //
0202 // output stream operator for phi track segments
0203 //
0204 ostream& operator<<(ostream& s, const L1MuDTTrackSegPhi& id) {
0205   s.setf(ios::right, ios::adjustfield);
0206   s << (id.m_location) << "\t"
0207     << "phi : " << setw(5) << id.m_phi << "  "
0208     << "phib : " << setw(4) << id.m_phib << "  "
0209     << "quality : " << setw(4) << id.m_quality;
0210 
0211   return s;
0212 }