CMS 3D CMS Logo

L1MuDTAddressArray.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTAddressArray
4 //
5 // Description: Array of relative Addresses
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 //
12 //--------------------------------------------------
13 
14 //-----------------------
15 // This Class's Header --
16 //-----------------------
17 
19 
20 //---------------
21 // C++ Headers --
22 //---------------
23 
24 #include <iostream>
25 #include <iomanip>
26 #include <vector>
27 #include <cassert>
28 
29 //-------------------------------
30 // Collaborating Class Headers --
31 //-------------------------------
32 
33 using namespace std;
34 
35 // --------------------------------
36 // class L1MuDTAddressArray
37 //---------------------------------
38 
39 //----------------
40 // Constructors --
41 //----------------
42 
44 
45  reset();
46 
47 }
48 
49 
51 
52  for ( int stat = 1; stat <= 4; stat++ ) {
53  m_station[stat-1] = addarray.m_station[stat-1];
54  }
55 
56 }
57 
58 
59 //--------------
60 // Destructor --
61 //--------------
62 
64 
65 
66 //--------------
67 // Operations --
68 //--------------
69 
70 //
71 // assignment operator
72 //
74 
75  if ( this != &addarray ) {
76  for ( int stat = 1; stat <= 4; stat++ ) {
77  m_station[stat-1] = addarray.m_station[stat-1];
78  }
79  }
80  return *this;
81 
82 }
83 
84 
85 //
86 //
87 //
89 
90  for ( int stat = 1; stat <= 4; stat++ ) {
91  if ( m_station[stat-1] != addarray.m_station[stat-1] ) return false;
92  }
93 
94  return true;
95 
96 }
97 
98 
99 //
100 //
101 //
103 
104  for ( int stat = 1; stat <= 4; stat++ ) {
105  if ( m_station[stat-1] != addarray.m_station[stat-1] ) return true;
106  }
107 
108  return false;
109 
110 }
111 
112 
113 //
114 // reset AddressArray
115 //
117 
118  for ( int stat = 1; stat <= 4; stat++ ) {
119  m_station[stat-1] = 15;
120  }
121 
122 }
123 
124 
125 //
126 // set Address of a given station
127 //
129 
130  // assert( stat > 0 && stat <= 4 );
131  // assert( adr >= 0 && adr <= 15 );
132  m_station[stat-1] = adr;
133 
134 }
135 
136 
137 //
138 // set Addresses of all four stations
139 //
140 void L1MuDTAddressArray::setStations(int adr1, int adr2, int adr3, int adr4) {
141 
142  setStation(1,adr1);
143  setStation(2,adr2);
144  setStation(3,adr3);
145  setStation(4,adr4);
146 
147 }
148 
149 
150 //
151 // get track address code (for eta track finder)
152 //
154 
155  int code = -1;
156 
157  int s1 = m_station[0];
158  s1 = ( s1 == 15 ) ? 0 : ((s1/2)%2)+1;
159  int s2 = m_station[1];
160  s2 = ( s2 == 15 ) ? 0 : ((s2/2)%2)+1;
161  int s3 = m_station[2];
162  s3 = ( s3 == 15 ) ? 0 : ((s3/2)%2)+1;
163  int s4 = m_station[3];
164  s4 = ( s4 == 15 ) ? 0 : ((s4/2)%2)+1;
165 
166  // 0 ... empty track segment
167  // 1 ... same wheel
168  // 2 ... next wheel
169 
170  if ( s1 == 0 && s2 == 0 && s3 == 0 && s4 == 0 ) code = 0;
171  if ( s1 == 0 && s2 == 0 && s3 == 2 && s4 == 1 ) code = 0;
172  if ( s1 == 0 && s2 == 0 && s3 == 2 && s4 == 2 ) code = 0;
173  if ( s1 == 0 && s2 == 2 && s3 == 0 && s4 == 1 ) code = 0;
174  if ( s1 == 0 && s2 == 2 && s3 == 0 && s4 == 2 ) code = 0;
175  if ( s1 == 0 && s2 == 2 && s3 == 1 && s4 == 0 ) code = 0;
176  if ( s1 == 0 && s2 == 2 && s3 == 2 && s4 == 0 ) code = 0;
177  if ( s1 == 0 && s2 == 1 && s3 == 2 && s4 == 1 ) code = 0;
178  if ( s1 == 0 && s2 == 2 && s3 == 1 && s4 == 1 ) code = 0;
179  if ( s1 == 0 && s2 == 2 && s3 == 1 && s4 == 2 ) code = 0;
180  if ( s1 == 0 && s2 == 2 && s3 == 2 && s4 == 1 ) code = 0;
181  if ( s1 == 0 && s2 == 2 && s3 == 2 && s4 == 2 ) code = 0;
182  if ( s1 == 1 && s2 == 0 && s3 == 2 && s4 == 1 ) code = 0;
183  if ( s1 == 1 && s2 == 2 && s3 == 0 && s4 == 1 ) code = 0;
184  if ( s1 == 1 && s2 == 2 && s3 == 1 && s4 == 0 ) code = 0;
185  if ( s1 == 1 && s2 == 1 && s3 == 2 && s4 == 1 ) code = 0;
186  if ( s1 == 1 && s2 == 2 && s3 == 1 && s4 == 1 ) code = 0;
187  if ( s1 == 1 && s2 == 2 && s3 == 1 && s4 == 2 ) code = 0;
188  if ( s1 == 1 && s2 == 2 && s3 == 2 && s4 == 1 ) code = 0;
189  if ( s1 == 0 && s2 == 0 && s3 == 1 && s4 == 1 ) code = 1;
190  if ( s1 == 0 && s2 == 0 && s3 == 1 && s4 == 2 ) code = 2;
191  if ( s1 == 0 && s2 == 1 && s3 == 0 && s4 == 1 ) code = 3;
192  if ( s1 == 0 && s2 == 1 && s3 == 0 && s4 == 2 ) code = 4;
193  if ( s1 == 0 && s2 == 1 && s3 == 1 && s4 == 0 ) code = 5;
194  if ( s1 == 0 && s2 == 1 && s3 == 1 && s4 == 1 ) code = 6;
195  if ( s1 == 0 && s2 == 1 && s3 == 1 && s4 == 2 ) code = 7;
196  if ( s1 == 0 && s2 == 1 && s3 == 2 && s4 == 0 ) code = 8;
197  if ( s1 == 0 && s2 == 1 && s3 == 2 && s4 == 2 ) code = 8;
198  if ( s1 == 1 && s2 == 0 && s3 == 0 && s4 == 1 ) code = 9;
199  if ( s1 == 1 && s2 == 0 && s3 == 0 && s4 == 2 ) code = 10;
200  if ( s1 == 1 && s2 == 0 && s3 == 1 && s4 == 0 ) code = 11;
201  if ( s1 == 1 && s2 == 0 && s3 == 1 && s4 == 1 ) code = 12;
202  if ( s1 == 1 && s2 == 0 && s3 == 1 && s4 == 2 ) code = 13;
203  if ( s1 == 1 && s2 == 0 && s3 == 2 && s4 == 0 ) code = 14;
204  if ( s1 == 1 && s2 == 0 && s3 == 2 && s4 == 2 ) code = 14;
205  if ( s1 == 1 && s2 == 1 && s3 == 0 && s4 == 0 ) code = 15;
206  if ( s1 == 1 && s2 == 1 && s3 == 0 && s4 == 1 ) code = 16;
207  if ( s1 == 1 && s2 == 1 && s3 == 0 && s4 == 2 ) code = 17;
208  if ( s1 == 1 && s2 == 1 && s3 == 1 && s4 == 0 ) code = 18;
209  if ( s1 == 1 && s2 == 1 && s3 == 1 && s4 == 1 ) code = 19;
210  if ( s1 == 1 && s2 == 1 && s3 == 1 && s4 == 2 ) code = 20;
211  if ( s1 == 1 && s2 == 1 && s3 == 2 && s4 == 0 ) code = 21;
212  if ( s1 == 1 && s2 == 1 && s3 == 2 && s4 == 2 ) code = 21;
213  if ( s1 == 1 && s2 == 2 && s3 == 0 && s4 == 0 ) code = 22;
214  if ( s1 == 1 && s2 == 2 && s3 == 0 && s4 == 2 ) code = 22;
215  if ( s1 == 1 && s2 == 2 && s3 == 2 && s4 == 0 ) code = 22;
216  if ( s1 == 1 && s2 == 2 && s3 == 2 && s4 == 2 ) code = 22;
217 
218  return code;
219 
220 }
221 
222 
223 //
224 // get converted Addresses
225 //
227 
228  unsigned short int adr1 = L1MuDTAddressArray::convert(m_station[0]);
229  unsigned short int adr2 = L1MuDTAddressArray::convert(m_station[1]);
230  unsigned short int adr3 = L1MuDTAddressArray::convert(m_station[2]);
231  unsigned short int adr4 = L1MuDTAddressArray::convert(m_station[3]);
232 
233  L1MuDTAddressArray newaddressarray;
234  newaddressarray.setStations(adr1,adr2,adr3,adr4);
235 
236  return newaddressarray;
237 
238 }
239 
240 
241 //
242 //
243 //
244 ostream& operator<<(ostream& s, const L1MuDTAddressArray& adrarr ) {
245 
246  s.setf(ios::right,ios::adjustfield);
247  for ( int stat = 1; stat <= 4; stat++ ) {
248  s << "stat " << stat << ": " << setw(2) << adrarr.station(stat) << " ";
249  }
250 
251  return s;
252 
253 }
254 
255 
256 //
257 // convert address to corresponding VHDL address
258 //
259 unsigned short int L1MuDTAddressArray::convert(unsigned short int adr) {
260 
261  unsigned short int newaddress = 15;
262 
263  switch ( adr ) {
264  case 0 : { newaddress = 8; break; }
265  case 1 : { newaddress = 9; break; }
266  case 2 : { newaddress = 0; break; }
267  case 3 : { newaddress = 1; break; }
268  case 4 : { newaddress = 10; break; }
269  case 5 : { newaddress = 11; break; }
270  case 6 : { newaddress = 2; break; }
271  case 7 : { newaddress = 3; break; }
272  case 8 : { newaddress = 12; break; }
273  case 9 : { newaddress = 13; break; }
274  case 10 : { newaddress = 4; break; }
275  case 11 : { newaddress = 5; break; }
276  case 15 : { newaddress = 15; break; }
277  default: { newaddress = 15; break; }
278 
279  }
280 
281  return newaddress;
282 
283 }
284 
285 
286 //
287 // is it a same wheel address?
288 //
289 bool L1MuDTAddressArray::sameWheel(unsigned short int adr) {
290 
291  // if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
292  return ( (adr/2)%2 == 0 );
293 
294 }
295 
296 
297 //
298 // is it a next wheel address?
299 //
300 bool L1MuDTAddressArray::nextWheel(unsigned short int adr) {
301 
302  // if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
303  return ( (adr/2)%2 == 1 );
304 
305 }
static bool sameWheel(unsigned short int adr)
is it a same wheel address?
int trackAddressCode() const
get track address code (for eta track finder)
void reset()
reset address array
L1MuDTAddressArray converted() const
get converted Addresses
static unsigned short int convert(unsigned short int adr)
convert address to corresponding VHDL addresse
unsigned short int m_station[4]
static bool nextWheel(unsigned short int adr)
is it a next wheel address?
bool operator==(const L1MuDTAddressArray &) const
equal operator
std::ostream & operator<<(std::ostream &out, const std::tuple< Types... > &value)
Definition: Utilities.h:38
L1MuDTAddressArray()
default constructor
void setStations(int adr1, int adr2, int adr3, int adr4)
set addresses of all four stations
void setStation(int stat, int adr)
set address of a given station [1-4]
bool operator!=(const L1MuDTAddressArray &) const
unequal operator
void reset(double vett[256])
Definition: TPedValues.cc:11
unsigned short station(int stat) const
get address of a given station [1-4]
virtual ~L1MuDTAddressArray()
destructor
L1MuDTAddressArray & operator=(const L1MuDTAddressArray &)
assignment operator