CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/L1Trigger/DTTrackFinder/src/L1MuDTTrackSegPhi.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTTrackSegPhi
00004 //
00005 //   Description: PHI Track Segment 
00006 //
00007 //
00008 //   $Date: 2012/07/31 12:06:20 $
00009 //   $Revision: 1.4 $
00010 //
00011 //   Author :
00012 //   N. Neumeister            CERN EP 
00013 //
00014 //--------------------------------------------------
00015 
00016 //-----------------------
00017 // This Class's Header --
00018 //-----------------------
00019 
00020 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackSegPhi.h"
00021 
00022 //---------------
00023 // C++ Headers --
00024 //---------------
00025 
00026 #include <iostream>
00027 #include <iomanip>
00028 #include <cmath>
00029 
00030 //-------------------------------
00031 // Collaborating Class Headers --
00032 //-------------------------------
00033 
00034 #include "L1Trigger/DTTrackFinder/src/L1MuDTTrackSegLoc.h"
00035 
00036 using namespace std;
00037 
00038 // --------------------------------
00039 //       class L1MuDTTrackSegPhi
00040 //---------------------------------
00041 
00042 //----------------
00043 // Constructors --
00044 //----------------
00045 
00046 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi() : 
00047       m_location(), m_phi(0), m_phib(0), m_quality(Null), m_bx(0) {}
00048 
00049 
00050 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(int wheel_id, int sector_id, int station_id, 
00051                                      int phi, int phib, 
00052                                      TSQuality quality, bool tag, int  bx, 
00053                                      bool etaFlag) :
00054   m_location(wheel_id, sector_id, station_id),
00055   m_phi(phi), m_phib(phib), m_quality(quality), m_bx(bx), m_etaFlag(etaFlag) {
00056 
00057   if ( phi  < -2048 || phi  > 2047 ) { 
00058     //    cerr << "TrackSegPhi : phi out of range: " << phi << endl;
00059   }
00060   if ( phib <  -512 || phib >  511 ) {
00061     //    cerr << "TrackSegPhi : phib out of range: " << phib << endl;
00062   }
00063   if ( quality > 7 ) {
00064     //    cerr << "TrackSegPhi : quality out of range: " << quality << endl;
00065   }
00066 
00067 }
00068 
00069 
00070 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(const L1MuDTTrackSegLoc& id, 
00071                                      int phi, int phib, 
00072                                      TSQuality quality, bool tag, int bx,
00073                                      bool etaFlag) : 
00074   m_location(id), m_phi(phi), m_phib(phib), 
00075   m_quality(quality), m_tag(tag), m_bx(bx), m_etaFlag(etaFlag) {
00076 
00077   if ( phi  < -2048 || phi  > 2047 ) {
00078     //    cerr << "TrackSegPhi : phi out of range: " << phi << endl;
00079   }
00080   if ( phib <  -512 || phib >  511 ) {
00081     //    cerr << "TrackSegPhi : phib out of range: " << phib << endl;
00082   }
00083   if ( quality > 7 ) {
00084     //    cerr << "TrackSegPhi : quality out of range: " << quality << endl;
00085   }
00086 
00087 }
00088 
00089  
00090 L1MuDTTrackSegPhi::L1MuDTTrackSegPhi(const L1MuDTTrackSegPhi& id) :
00091   m_location(id.m_location),
00092   m_phi(id.m_phi), m_phib(id.m_phib), m_quality(id.m_quality), 
00093   m_tag(id.m_tag), m_bx(id.m_bx), m_etaFlag(id.m_etaFlag) {}
00094 
00095 
00096 
00097 //--------------
00098 // Destructor --
00099 //--------------
00100 L1MuDTTrackSegPhi::~L1MuDTTrackSegPhi() {}
00101 
00102 
00103 //--------------
00104 // Operations --
00105 //--------------
00106 
00107 //
00108 // reset PHI Track Segment
00109 //
00110 void L1MuDTTrackSegPhi::reset() {
00111 
00112   m_phi     = 0;
00113   m_phib    = 0;
00114   m_quality = Null;
00115   m_tag     = false;
00116   m_bx      = 0;
00117   m_etaFlag = false;
00118 
00119 }
00120 
00121 
00122 //
00123 // return phi in global coordinates [0,2pi]
00124 //
00125 double L1MuDTTrackSegPhi::phiValue() const {
00126 
00127   double tmp = static_cast<double>(m_location.sector())*M_PI/6;
00128   tmp += static_cast<double>(m_phi)/4096;
00129   return (tmp > 0 ) ? tmp : (2*M_PI + tmp);
00130 
00131 }
00132 
00133 
00134 //
00135 // return phib in radians
00136 //
00137 double L1MuDTTrackSegPhi::phibValue() const {
00138 
00139   return static_cast<double>(m_phib)/512;
00140 
00141 }
00142 
00143 
00144 //
00145 // Assignment operator
00146 //
00147 L1MuDTTrackSegPhi& L1MuDTTrackSegPhi::operator=(const L1MuDTTrackSegPhi& id) {
00148 
00149   if ( this != &id ) {
00150     m_location  = id.m_location;
00151     m_phi       = id.m_phi;
00152     m_phib      = id.m_phib;
00153     m_quality   = id.m_quality;
00154     m_tag       = id.m_tag;
00155     m_bx        = id.m_bx;
00156     m_etaFlag   = id.m_etaFlag;
00157   }
00158   return *this;
00159 
00160 }
00161 
00162 
00163 //
00164 // Equal operator
00165 //
00166 bool L1MuDTTrackSegPhi::operator==(const L1MuDTTrackSegPhi& id) const {
00167 
00168   if ( m_location != id.m_location ) return false;
00169   if ( m_phi      != id.m_phi )      return false;
00170   if ( m_phib     != id.m_phib )     return false;
00171   if ( m_quality  != id.m_quality )  return false;
00172   if ( m_bx       != id.m_bx )       return false;
00173   return true;
00174 
00175 }
00176 
00177 
00178 //
00179 // Unequal operator
00180 //
00181 bool L1MuDTTrackSegPhi::operator!=(const L1MuDTTrackSegPhi& id) const {
00182 
00183   if ( m_location != id.m_location ) return true;
00184   if ( m_phi      != id.m_phi )      return true;
00185   if ( m_phib     != id.m_phib )     return true;
00186   if ( m_quality  != id.m_quality )  return true;
00187   if ( m_bx       != id.m_bx )       return true;
00188   return false;
00189 
00190 }
00191 
00192 
00193 //
00194 // output stream operator phi track segment quality
00195 //
00196 ostream& operator<<(ostream& s, const L1MuDTTrackSegPhi::TSQuality& quality) {
00197 
00198   switch (quality) {
00199     case L1MuDTTrackSegPhi::Li   : return s << "Li ";
00200     case L1MuDTTrackSegPhi::Lo   : return s << "Lo ";
00201     case L1MuDTTrackSegPhi::Hi   : return s << "Hi ";
00202     case L1MuDTTrackSegPhi::Ho   : return s << "Ho ";
00203     case L1MuDTTrackSegPhi::LL   : return s << "LL ";
00204     case L1MuDTTrackSegPhi::HL   : return s << "HL ";
00205     case L1MuDTTrackSegPhi::HH   : return s << "HH ";
00206     case L1MuDTTrackSegPhi::Null : return s << "Null ";
00207     default :
00208       return s << "unknown TS phi Quality ";
00209   }
00210 
00211 }
00212 
00213 
00214 //
00215 // output stream operator for phi track segments
00216 //
00217 ostream& operator<<(ostream& s, const L1MuDTTrackSegPhi& id) {
00218 
00219   s.setf(ios::right,ios::adjustfield);
00220   s << (id.m_location) << "\t" 
00221     << "phi : "     << setw(5) << id.m_phi  << "  "
00222     << "phib : "    << setw(4) << id.m_phib << "  "
00223     << "quality : " << setw(4) << id.m_quality; 
00224 
00225   return s;
00226 
00227 }