CMS 3D CMS Logo

L1MuDTEtaPattern.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTEtaPattern
4 //
5 // Description: Pattern for Eta for Eta Track Finder
6 //
7 //
8 // $Date: 2009/02/03 23:33:45 $
9 // $Revision: 1.3 $
10 //
11 // Author :
12 // N. Neumeister CERN EP
13 // J. Troconiz UAM Madrid
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <iomanip>
29 #include <bitset>
30 #include <cstdlib>
31 
32 //-------------------------------
33 // Collaborating Class Headers --
34 //-------------------------------
35 
36 using namespace std;
37 
38 // --------------------------------
39 // class L1MuDTEtaPattern
40 //---------------------------------
41 
42 //----------------
43 // Constructors --
44 //----------------
45 
46 L1MuDTEtaPattern::L1MuDTEtaPattern() : m_id(0), m_eta(0), m_qual(0) {
47  for (int i = 0; i < 3; i++) {
48  m_wheel[i] = 0;
49  m_position[i] = 0;
50  }
51 }
52 
53 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, int w1, int w2, int w3, int p1, int p2, int p3, int eta, int qual)
54  :
55 
56  m_id(id),
57  m_eta(eta),
58  m_qual(qual) {
59  m_wheel[0] = w1;
60  m_wheel[1] = w2;
61  m_wheel[2] = w3;
62  m_position[0] = p1;
63  m_position[1] = p2;
64  m_position[2] = p3;
65 }
66 
67 L1MuDTEtaPattern::L1MuDTEtaPattern(int id, const string& pat, int eta, int qual) : m_id(id), m_eta(eta), m_qual(qual) {
68  for (int i = 0; i < 3; i++) {
69  string sub = pat.substr(3 * i, 3);
70  if (sub == "___") {
71  m_wheel[i] = 0;
72  m_position[i] = 0;
73  } else {
74  m_wheel[i] = atoi(sub.substr(0, 2).c_str());
75  m_position[i] = atoi(sub.substr(2, 1).c_str());
76  }
77  }
78 }
79 
80 L1MuDTEtaPattern::L1MuDTEtaPattern(const L1MuDTEtaPattern& p) : m_id(p.m_id), m_eta(p.m_eta), m_qual(p.m_qual) {
81  for (int i = 0; i < 3; i++) {
82  m_wheel[i] = p.m_wheel[i];
83  m_position[i] = p.m_position[i];
84  }
85 }
86 
87 //--------------
88 // Destructor --
89 //--------------
90 
92 
93 //--------------
94 // Operations --
95 //--------------
96 
97 //
98 // Assignment operator
99 //
101  if (this != &p) {
102  m_id = p.m_id;
103  m_eta = p.m_eta;
104  m_qual = p.m_qual;
105  for (int i = 0; i < 3; i++) {
106  m_wheel[i] = p.m_wheel[i];
107  m_position[i] = p.m_position[i];
108  }
109  }
110  return *this;
111 }
112 
113 //
114 // Equal operator
115 //
117  if (m_id != p.id())
118  return false;
119  if (m_eta != p.eta())
120  return false;
121  if (m_qual != p.quality())
122  return false;
123  for (int i = 0; i < 3; i++) {
124  if (m_wheel[i] != p.m_wheel[i])
125  return false;
126  if (m_position[i] != p.m_position[i])
127  return false;
128  }
129  return true;
130 }
131 
132 //
133 // Unequal operator
134 //
136  if (m_id != p.id())
137  return true;
138  if (m_eta != p.eta())
139  return true;
140  if (m_qual != p.quality())
141  return true;
142  for (int i = 0; i < 3; i++) {
143  if (m_wheel[i] != p.m_wheel[i])
144  return true;
145  if (m_position[i] != p.m_position[i])
146  return true;
147  }
148  return false;
149 }
150 
151 //
152 // output stream operator
153 //
154 ostream& operator<<(ostream& s, const L1MuDTEtaPattern& p) {
155  s.setf(ios::right, ios::adjustfield);
156  s << "ID = " << setw(8) << p.id() << " "
157  << "quality = " << setw(2) << p.quality() << " "
158  << "eta = " << setw(1) << p.eta() << endl;
159  for (int i = 0; i < 3; i++) {
160  s << "station = " << i + 1 << " : ";
161  for (int j = 0; j < 5; j++) {
162  bitset<7> pos;
163  if (p.m_position[i] && (p.m_wheel[i] == j - 2))
164  pos.set(p.m_position[i] - 1);
165  s << pos << " ";
166  }
167  s << endl;
168  }
169 
170  return s;
171 }
172 
173 //
174 // input stream operator
175 //
176 istream& operator>>(istream& s, L1MuDTEtaPattern& p) {
177  string pat;
178 
179  s >> p.m_id >> pat >> p.m_qual >> p.m_eta;
180 
181  for (int i = 0; i < 3; i++) {
182  string sub = pat.substr(3 * i, 3);
183  if (sub == "___") {
184  p.m_wheel[i] = 0;
185  p.m_position[i] = 0;
186  } else {
187  p.m_wheel[i] = atoi(sub.substr(0, 2).c_str());
188  p.m_position[i] = atoi(sub.substr(2, 1).c_str());
189  }
190  }
191 
192  return s;
193 }
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
bool operator==(const L1MuDTEtaPattern &) const
equal operator
L1MuDTEtaPattern & operator=(const L1MuDTEtaPattern &)
assignment operator
ostream & operator<<(ostream &s, const L1MuDTEtaPattern &p)
bool operator!=(const L1MuDTEtaPattern &) const
unequal operator
Definition: HeavyIon.h:7
L1MuDTEtaPattern()
default constructor
istream & operator>>(istream &s, L1MuDTEtaPattern &p)
common ppss p3p6s2 common epss epspn46 common const1 w3
Definition: inclppp.h:1
virtual ~L1MuDTEtaPattern()
destructor