Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:34

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuBMTrackSegPhi
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 "DataFormats/L1TMuon/interface/L1MuBMTrackSegPhi.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 "DataFormats/L1TMuon/interface/BMTF/L1MuBMTrackSegLoc.h"
0033 
0034 using namespace std;
0035 
0036 // --------------------------------
0037 //       class L1MuBMTrackSegPhi
0038 //---------------------------------
0039 
0040 //----------------
0041 // Constructors --
0042 //----------------
0043 
0044 L1MuBMTrackSegPhi::L1MuBMTrackSegPhi()
0045     : m_location(), m_phi(0), m_phib(0), m_quality(Null), m_tag(false), m_bx(0), m_etaFlag(false) {}
0046 
0047 L1MuBMTrackSegPhi::L1MuBMTrackSegPhi(
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(tag),
0054       m_bx(bx),
0055       m_etaFlag(etaFlag) {
0056   /*
0057   if ( phi  < -2048 || phi  > 2047 ) {
0058         cerr << "TrackSegPhi : phi out of range: " << phi << endl;
0059   }
0060   if ( phib <  -512 || phib >  511 ) {
0061         cerr << "TrackSegPhi : phib out of range: " << phib << endl;
0062   }
0063   if ( quality > 7 ) {
0064         cerr << "TrackSegPhi : quality out of range: " << quality << endl;
0065   }*/
0066 }
0067 
0068 L1MuBMTrackSegPhi::L1MuBMTrackSegPhi(
0069     const L1MuBMTrackSegLoc& id, int phi, int phib, TSQuality quality, bool tag, int bx, bool etaFlag)
0070     : m_location(id), m_phi(phi), m_phib(phib), m_quality(quality), m_tag(tag), m_bx(bx), m_etaFlag(etaFlag) {
0071   /*
0072   if ( phi  < -2048 || phi  > 2047 ) {
0073         cerr << "TrackSegPhi : phi out of range: " << phi << endl;
0074   }
0075   if ( phib <  -512 || phib >  511 ) {
0076         cerr << "TrackSegPhi : phib out of range: " << phib << endl;
0077   }
0078   if ( quality > 7 ) {
0079         cerr << "TrackSegPhi : quality out of range: " << quality << endl;
0080   }
0081 */
0082 }
0083 
0084 //--------------
0085 // Destructor --
0086 //--------------
0087 L1MuBMTrackSegPhi::~L1MuBMTrackSegPhi() {}
0088 
0089 //--------------
0090 // Operations --
0091 //--------------
0092 
0093 //
0094 // reset PHI Track Segment
0095 //
0096 void L1MuBMTrackSegPhi::reset() {
0097   m_phi = 0;
0098   m_phib = 0;
0099   m_quality = Null;
0100   m_tag = false;
0101   m_bx = 0;
0102   m_etaFlag = false;
0103 }
0104 
0105 //
0106 // return phi in global coordinates [0,2pi]
0107 //
0108 double L1MuBMTrackSegPhi::phiValue() const {
0109   double tmp = static_cast<double>(m_location.sector()) * M_PI / 6;
0110   tmp += static_cast<double>(m_phi) / 4096;
0111   return (tmp > 0) ? tmp : (2 * M_PI + tmp);
0112 }
0113 
0114 //
0115 // return phib in radians
0116 //
0117 double L1MuBMTrackSegPhi::phibValue() const { return static_cast<double>(m_phib) / 512; }
0118 
0119 //
0120 // Equal operator
0121 //
0122 bool L1MuBMTrackSegPhi::operator==(const L1MuBMTrackSegPhi& id) const {
0123   if (m_location != id.m_location)
0124     return false;
0125   if (m_phi != id.m_phi)
0126     return false;
0127   if (m_phib != id.m_phib)
0128     return false;
0129   if (m_quality != id.m_quality)
0130     return false;
0131   if (m_bx != id.m_bx)
0132     return false;
0133   return true;
0134 }
0135 
0136 //
0137 // Unequal operator
0138 //
0139 bool L1MuBMTrackSegPhi::operator!=(const L1MuBMTrackSegPhi& id) const {
0140   if (m_location != id.m_location)
0141     return true;
0142   if (m_phi != id.m_phi)
0143     return true;
0144   if (m_phib != id.m_phib)
0145     return true;
0146   if (m_quality != id.m_quality)
0147     return true;
0148   if (m_bx != id.m_bx)
0149     return true;
0150   return false;
0151 }
0152 
0153 //
0154 // output stream operator phi track segment quality
0155 //
0156 ostream& operator<<(ostream& s, const L1MuBMTrackSegPhi::TSQuality& quality) {
0157   switch (quality) {
0158     case L1MuBMTrackSegPhi::Li:
0159       return s << "Li ";
0160     case L1MuBMTrackSegPhi::Lo:
0161       return s << "Lo ";
0162     case L1MuBMTrackSegPhi::Hi:
0163       return s << "Hi ";
0164     case L1MuBMTrackSegPhi::Ho:
0165       return s << "Ho ";
0166     case L1MuBMTrackSegPhi::LL:
0167       return s << "LL ";
0168     case L1MuBMTrackSegPhi::HL:
0169       return s << "HL ";
0170     case L1MuBMTrackSegPhi::HH:
0171       return s << "HH ";
0172     case L1MuBMTrackSegPhi::Null:
0173       return s << "Null ";
0174     default:
0175       return s << "unknown TS phi Quality ";
0176   }
0177 }
0178 
0179 //
0180 // output stream operator for phi track segments
0181 //
0182 ostream& operator<<(ostream& s, const L1MuBMTrackSegPhi& id) {
0183   s.setf(ios::right, ios::adjustfield);
0184   s << (id.m_location) << "\t"
0185     << "phi : " << setw(5) << id.m_phi << "  "
0186     << "phib : " << setw(4) << id.m_phib << "  "
0187     << "quality : " << setw(4) << id.m_quality;
0188 
0189   return s;
0190 }