Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:20

0001 //-------------------------------------------------
0002 //
0003 //   Class: L1MuDTEtaPattern
0004 //
0005 //   Description: Pattern for Eta for Eta Track Finder
0006 //
0007 //
0008 //   $Date: 2009/02/03 23:33:45 $
0009 //   $Revision: 1.3 $
0010 //
0011 //   Author :
0012 //   N. Neumeister             CERN EP
0013 //   J. Troconiz               UAM Madrid
0014 //
0015 //--------------------------------------------------
0016 
0017 //-----------------------
0018 // This Class's Header --
0019 //-----------------------
0020 
0021 #include "CondFormats/L1TObjects/interface/L1MuDTEtaPattern.h"
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <iostream>
0028 #include <iomanip>
0029 #include <bitset>
0030 #include <cstdlib>
0031 
0032 //-------------------------------
0033 // Collaborating Class Headers --
0034 //-------------------------------
0035 
0036 using namespace std;
0037 
0038 // --------------------------------
0039 //       class L1MuDTEtaPattern
0040 //---------------------------------
0041 
0042 //----------------
0043 // Constructors --
0044 //----------------
0045 
0046 L1MuDTEtaPattern::L1MuDTEtaPattern() : m_id(0), m_eta(0), m_qual(0) {
0047   for (int i = 0; i < 3; i++) {
0048     m_wheel[i] = 0;
0049     m_position[i] = 0;
0050   }
0051 }
0052 
0053 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, int w1, int w2, int w3, int p1, int p2, int p3, int eta, int qual)
0054     :
0055 
0056       m_id(id),
0057       m_eta(eta),
0058       m_qual(qual) {
0059   m_wheel[0] = w1;
0060   m_wheel[1] = w2;
0061   m_wheel[2] = w3;
0062   m_position[0] = p1;
0063   m_position[1] = p2;
0064   m_position[2] = p3;
0065 }
0066 
0067 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, const string& pat, int eta, int qual) : m_id(id), m_eta(eta), m_qual(qual) {
0068   for (int i = 0; i < 3; i++) {
0069     string sub = pat.substr(3 * i, 3);
0070     if (sub == "___") {
0071       m_wheel[i] = 0;
0072       m_position[i] = 0;
0073     } else {
0074       m_wheel[i] = atoi(sub.substr(0, 2).c_str());
0075       m_position[i] = atoi(sub.substr(2, 1).c_str());
0076     }
0077   }
0078 }
0079 
0080 L1MuDTEtaPattern::L1MuDTEtaPattern(const L1MuDTEtaPattern& p) : m_id(p.m_id), m_eta(p.m_eta), m_qual(p.m_qual) {
0081   for (int i = 0; i < 3; i++) {
0082     m_wheel[i] = p.m_wheel[i];
0083     m_position[i] = p.m_position[i];
0084   }
0085 }
0086 
0087 //--------------
0088 // Destructor --
0089 //--------------
0090 
0091 L1MuDTEtaPattern::~L1MuDTEtaPattern() {}
0092 
0093 //--------------
0094 // Operations --
0095 //--------------
0096 
0097 //
0098 // Assignment operator
0099 //
0100 L1MuDTEtaPattern& L1MuDTEtaPattern::operator=(const L1MuDTEtaPattern& p) {
0101   if (this != &p) {
0102     m_id = p.m_id;
0103     m_eta = p.m_eta;
0104     m_qual = p.m_qual;
0105     for (int i = 0; i < 3; i++) {
0106       m_wheel[i] = p.m_wheel[i];
0107       m_position[i] = p.m_position[i];
0108     }
0109   }
0110   return *this;
0111 }
0112 
0113 //
0114 // Equal operator
0115 //
0116 bool L1MuDTEtaPattern::operator==(const L1MuDTEtaPattern& p) const {
0117   if (m_id != p.id())
0118     return false;
0119   if (m_eta != p.eta())
0120     return false;
0121   if (m_qual != p.quality())
0122     return false;
0123   for (int i = 0; i < 3; i++) {
0124     if (m_wheel[i] != p.m_wheel[i])
0125       return false;
0126     if (m_position[i] != p.m_position[i])
0127       return false;
0128   }
0129   return true;
0130 }
0131 
0132 //
0133 // Unequal operator
0134 //
0135 bool L1MuDTEtaPattern::operator!=(const L1MuDTEtaPattern& p) const {
0136   if (m_id != p.id())
0137     return true;
0138   if (m_eta != p.eta())
0139     return true;
0140   if (m_qual != p.quality())
0141     return true;
0142   for (int i = 0; i < 3; i++) {
0143     if (m_wheel[i] != p.m_wheel[i])
0144       return true;
0145     if (m_position[i] != p.m_position[i])
0146       return true;
0147   }
0148   return false;
0149 }
0150 
0151 //
0152 // output stream operator
0153 //
0154 ostream& operator<<(ostream& s, const L1MuDTEtaPattern& p) {
0155   s.setf(ios::right, ios::adjustfield);
0156   s << "ID = " << setw(8) << p.id() << "  "
0157     << "quality = " << setw(2) << p.quality() << "  "
0158     << "eta = " << setw(1) << p.eta() << endl;
0159   for (int i = 0; i < 3; i++) {
0160     s << "station = " << i + 1 << " : ";
0161     for (int j = 0; j < 5; j++) {
0162       bitset<7> pos;
0163       if (p.m_position[i] && (p.m_wheel[i] == j - 2))
0164         pos.set(p.m_position[i] - 1);
0165       s << pos << " ";
0166     }
0167     s << endl;
0168   }
0169 
0170   return s;
0171 }
0172 
0173 //
0174 // input stream operator
0175 //
0176 istream& operator>>(istream& s, L1MuDTEtaPattern& p) {
0177   string pat;
0178 
0179   s >> p.m_id >> pat >> p.m_qual >> p.m_eta;
0180 
0181   for (int i = 0; i < 3; i++) {
0182     string sub = pat.substr(3 * i, 3);
0183     if (sub == "___") {
0184       p.m_wheel[i] = 0;
0185       p.m_position[i] = 0;
0186     } else {
0187       p.m_wheel[i] = atoi(sub.substr(0, 2).c_str());
0188       p.m_position[i] = atoi(sub.substr(2, 1).c_str());
0189     }
0190   }
0191 
0192   return s;
0193 }