CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CondFormats/L1TObjects/src/L1MuDTEtaPattern.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuDTEtaPattern
00004 //
00005 //   Description: Pattern for Eta for Eta Track Finder
00006 //
00007 //
00008 //   $Date: 2010/01/19 18:39:54 $
00009 //   $Revision: 1.4 $
00010 //
00011 //   Author :
00012 //   N. Neumeister             CERN EP
00013 //   J. Troconiz               UAM Madrid
00014 //
00015 //--------------------------------------------------
00016 
00017 //-----------------------
00018 // This Class's Header --
00019 //-----------------------
00020 
00021 #include "CondFormats/L1TObjects/interface/L1MuDTEtaPattern.h"
00022 
00023 //---------------
00024 // C++ Headers --
00025 //---------------
00026 
00027 #include <iostream>
00028 #include <iomanip>
00029 #include <bitset>
00030 #include <cstdlib>
00031 
00032 //-------------------------------
00033 // Collaborating Class Headers --
00034 //-------------------------------
00035 
00036 using namespace std;
00037 
00038 // --------------------------------
00039 //       class L1MuDTEtaPattern  
00040 //---------------------------------
00041 
00042 //----------------
00043 // Constructors --
00044 //----------------
00045 
00046 L1MuDTEtaPattern::L1MuDTEtaPattern() :
00047   m_id(0), m_eta(0), m_qual(0) {
00048   
00049   for (int i = 0; i < 3; i++) {
00050     m_wheel[i] = 0; 
00051     m_position[i] = 0;
00052   }
00053      
00054 }
00055 
00056 
00057 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, int w1, int w2, int w3, 
00058                                    int p1, int p2, int p3, 
00059                                    int eta, int qual) : 
00060                                 
00061   m_id(id), m_eta(eta), m_qual(qual) { 
00062   
00063   m_wheel[0] = w1;
00064   m_wheel[1] = w2;
00065   m_wheel[2] = w3; 
00066   m_position[0] = p1;
00067   m_position[1] = p2;
00068   m_position[2] = p3;
00069   
00070 }                                                
00071 
00072 
00073 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, const string& pat, int eta, int qual) :
00074   m_id(id), m_eta(eta), m_qual(qual) {
00075   
00076   for ( int i = 0; i < 3; i++ ) {
00077     string sub = pat.substr(3*i,3);
00078     if ( sub == "___" ) {
00079       m_wheel[i] = 0;
00080       m_position[i] = 0;
00081     }
00082     else {
00083       m_wheel[i] = atoi(sub.substr(0,2).c_str());
00084       m_position[i] = atoi(sub.substr(2,1).c_str());
00085     }
00086   }
00087 }
00088 
00089 
00090 L1MuDTEtaPattern::L1MuDTEtaPattern(const L1MuDTEtaPattern& p) :
00091   m_id(p.m_id), m_eta(p.m_eta), m_qual(p.m_qual) {
00092   
00093   for (int i = 0; i < 3; i++) {
00094     m_wheel[i] = p.m_wheel[i]; 
00095     m_position[i] = p.m_position[i];
00096   }   
00097 
00098 }
00099 
00100 
00101 //--------------
00102 // Destructor --
00103 //--------------
00104 
00105 L1MuDTEtaPattern::~L1MuDTEtaPattern() {}
00106 
00107 
00108 //--------------
00109 // Operations --
00110 //--------------
00111 
00112 //
00113 // Assignment operator
00114 //
00115 L1MuDTEtaPattern& L1MuDTEtaPattern::operator=(const L1MuDTEtaPattern& p) {
00116 
00117   if ( this != &p ) {
00118     m_id   = p.m_id;
00119     m_eta  = p.m_eta;
00120     m_qual = p.m_qual;
00121     for (int i = 0; i < 3; i++) {
00122       m_wheel[i] = p.m_wheel[i];
00123       m_position[i] = p.m_position[i];
00124     }
00125   }
00126   return *this; 
00127   
00128 }
00129 
00130 
00131 //
00132 // Equal operator
00133 //
00134 bool L1MuDTEtaPattern::operator==(const L1MuDTEtaPattern& p) const { 
00135 
00136   if ( m_id   != p.id() )      return false;
00137   if ( m_eta  != p.eta() )     return false;
00138   if ( m_qual != p.quality() ) return false;
00139   for (int i = 0; i < 3; i++) {
00140     if ( m_wheel[i]    != p.m_wheel[i] )    return false;
00141     if ( m_position[i] != p.m_position[i] ) return false;
00142   }
00143   return true;
00144   
00145 }
00146 
00147 
00148 //
00149 // Unequal operator
00150 //
00151 bool L1MuDTEtaPattern::operator!=(const L1MuDTEtaPattern& p) const {
00152 
00153   if ( m_id   != p.id() )      return true;
00154   if ( m_eta  != p.eta() )     return true;
00155   if ( m_qual != p.quality() ) return true;
00156   for (int i = 0; i < 3; i++) {
00157     if ( m_wheel[i]    != p.m_wheel[i] )    return true;
00158     if ( m_position[i] != p.m_position[i] ) return true;
00159   }
00160   return false;
00161   
00162 }
00163 
00164 
00165 
00166 //
00167 // output stream operator
00168 //
00169 ostream& operator<<(ostream& s, const L1MuDTEtaPattern& p) {
00170 
00171   s.setf(ios::right,ios::adjustfield);
00172   s << "ID = " << setw(8) << p.id() << "  " 
00173     << "quality = "  << setw(2) << p.quality()  << "  " 
00174     << "eta = " << setw(1) << p.eta() << endl;
00175     for (int i = 0; i < 3; i++) {
00176       s << "station = " << i+1 << " : ";
00177       for (int j = 0; j < 5; j++) {
00178         bitset<7> pos;
00179         if ( p.m_position[i] && (p.m_wheel[i] == j-2) ) pos.set(p.m_position[i]-1);
00180         s <<  pos << " ";
00181       }
00182       s << endl;
00183     }    
00184 
00185   return s;
00186 
00187 }
00188 
00189 
00190 //
00191 // input stream operator
00192 //
00193 istream& operator>>(istream& s, L1MuDTEtaPattern& p) {
00194 
00195   string pat;
00196 
00197   s >> p.m_id >> pat >> p.m_qual >> p.m_eta;
00198 
00199   for ( int i = 0; i < 3; i++ ) {
00200     string sub = pat.substr(3*i,3);
00201     if ( sub == "___" ) {
00202       p.m_wheel[i] = 0;
00203       p.m_position[i] = 0;
00204     }
00205     else {
00206       p.m_wheel[i] = atoi(sub.substr(0,2).c_str());
00207       p.m_position[i] = atoi(sub.substr(2,1).c_str());
00208     }
00209   }
00210 
00211   return s;
00212 
00213 }