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 
46  for (int stat = 1; stat <= 4; stat++) {
47  m_station[stat - 1] = addarray.m_station[stat - 1];
48  }
49 }
50 
51 //--------------
52 // Destructor --
53 //--------------
54 
56 
57 //--------------
58 // Operations --
59 //--------------
60 
61 //
62 // assignment operator
63 //
65  if (this != &addarray) {
66  for (int stat = 1; stat <= 4; stat++) {
67  m_station[stat - 1] = addarray.m_station[stat - 1];
68  }
69  }
70  return *this;
71 }
72 
73 //
74 //
75 //
77  for (int stat = 1; stat <= 4; stat++) {
78  if (m_station[stat - 1] != addarray.m_station[stat - 1])
79  return false;
80  }
81 
82  return true;
83 }
84 
85 //
86 //
87 //
89  for (int stat = 1; stat <= 4; stat++) {
90  if (m_station[stat - 1] != addarray.m_station[stat - 1])
91  return true;
92  }
93 
94  return false;
95 }
96 
97 //
98 // reset AddressArray
99 //
101  for (int stat = 1; stat <= 4; stat++) {
102  m_station[stat - 1] = 15;
103  }
104 }
105 
106 //
107 // set Address of a given station
108 //
110  // assert( stat > 0 && stat <= 4 );
111  // assert( adr >= 0 && adr <= 15 );
112  m_station[stat - 1] = adr;
113 }
114 
115 //
116 // set Addresses of all four stations
117 //
118 void L1MuDTAddressArray::setStations(int adr1, int adr2, int adr3, int adr4) {
119  setStation(1, adr1);
120  setStation(2, adr2);
121  setStation(3, adr3);
122  setStation(4, adr4);
123 }
124 
125 //
126 // get track address code (for eta track finder)
127 //
129  int code = -1;
130 
131  int s1 = m_station[0];
132  s1 = (s1 == 15) ? 0 : ((s1 / 2) % 2) + 1;
133  int s2 = m_station[1];
134  s2 = (s2 == 15) ? 0 : ((s2 / 2) % 2) + 1;
135  int s3 = m_station[2];
136  s3 = (s3 == 15) ? 0 : ((s3 / 2) % 2) + 1;
137  int s4 = m_station[3];
138  s4 = (s4 == 15) ? 0 : ((s4 / 2) % 2) + 1;
139 
140  // 0 ... empty track segment
141  // 1 ... same wheel
142  // 2 ... next wheel
143 
144  if (s1 == 0 && s2 == 0 && s3 == 0 && s4 == 0)
145  code = 0;
146  if (s1 == 0 && s2 == 0 && s3 == 2 && s4 == 1)
147  code = 0;
148  if (s1 == 0 && s2 == 0 && s3 == 2 && s4 == 2)
149  code = 0;
150  if (s1 == 0 && s2 == 2 && s3 == 0 && s4 == 1)
151  code = 0;
152  if (s1 == 0 && s2 == 2 && s3 == 0 && s4 == 2)
153  code = 0;
154  if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 0)
155  code = 0;
156  if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 0)
157  code = 0;
158  if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 1)
159  code = 0;
160  if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 1)
161  code = 0;
162  if (s1 == 0 && s2 == 2 && s3 == 1 && s4 == 2)
163  code = 0;
164  if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 1)
165  code = 0;
166  if (s1 == 0 && s2 == 2 && s3 == 2 && s4 == 2)
167  code = 0;
168  if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 1)
169  code = 0;
170  if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 1)
171  code = 0;
172  if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 0)
173  code = 0;
174  if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 1)
175  code = 0;
176  if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 1)
177  code = 0;
178  if (s1 == 1 && s2 == 2 && s3 == 1 && s4 == 2)
179  code = 0;
180  if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 1)
181  code = 0;
182  if (s1 == 0 && s2 == 0 && s3 == 1 && s4 == 1)
183  code = 1;
184  if (s1 == 0 && s2 == 0 && s3 == 1 && s4 == 2)
185  code = 2;
186  if (s1 == 0 && s2 == 1 && s3 == 0 && s4 == 1)
187  code = 3;
188  if (s1 == 0 && s2 == 1 && s3 == 0 && s4 == 2)
189  code = 4;
190  if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 0)
191  code = 5;
192  if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 1)
193  code = 6;
194  if (s1 == 0 && s2 == 1 && s3 == 1 && s4 == 2)
195  code = 7;
196  if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 0)
197  code = 8;
198  if (s1 == 0 && s2 == 1 && s3 == 2 && s4 == 2)
199  code = 8;
200  if (s1 == 1 && s2 == 0 && s3 == 0 && s4 == 1)
201  code = 9;
202  if (s1 == 1 && s2 == 0 && s3 == 0 && s4 == 2)
203  code = 10;
204  if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 0)
205  code = 11;
206  if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 1)
207  code = 12;
208  if (s1 == 1 && s2 == 0 && s3 == 1 && s4 == 2)
209  code = 13;
210  if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 0)
211  code = 14;
212  if (s1 == 1 && s2 == 0 && s3 == 2 && s4 == 2)
213  code = 14;
214  if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 0)
215  code = 15;
216  if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 1)
217  code = 16;
218  if (s1 == 1 && s2 == 1 && s3 == 0 && s4 == 2)
219  code = 17;
220  if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 0)
221  code = 18;
222  if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 1)
223  code = 19;
224  if (s1 == 1 && s2 == 1 && s3 == 1 && s4 == 2)
225  code = 20;
226  if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 0)
227  code = 21;
228  if (s1 == 1 && s2 == 1 && s3 == 2 && s4 == 2)
229  code = 21;
230  if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 0)
231  code = 22;
232  if (s1 == 1 && s2 == 2 && s3 == 0 && s4 == 2)
233  code = 22;
234  if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 0)
235  code = 22;
236  if (s1 == 1 && s2 == 2 && s3 == 2 && s4 == 2)
237  code = 22;
238 
239  return code;
240 }
241 
242 //
243 // get converted Addresses
244 //
246  unsigned short int adr1 = L1MuDTAddressArray::convert(m_station[0]);
247  unsigned short int adr2 = L1MuDTAddressArray::convert(m_station[1]);
248  unsigned short int adr3 = L1MuDTAddressArray::convert(m_station[2]);
249  unsigned short int adr4 = L1MuDTAddressArray::convert(m_station[3]);
250 
251  L1MuDTAddressArray newaddressarray;
252  newaddressarray.setStations(adr1, adr2, adr3, adr4);
253 
254  return newaddressarray;
255 }
256 
257 //
258 //
259 //
260 ostream& operator<<(ostream& s, const L1MuDTAddressArray& adrarr) {
261  s.setf(ios::right, ios::adjustfield);
262  for (int stat = 1; stat <= 4; stat++) {
263  s << "stat " << stat << ": " << setw(2) << adrarr.station(stat) << " ";
264  }
265 
266  return s;
267 }
268 
269 //
270 // convert address to corresponding VHDL address
271 //
272 unsigned short int L1MuDTAddressArray::convert(unsigned short int adr) {
273  unsigned short int newaddress = 15;
274 
275  switch (adr) {
276  case 0: {
277  newaddress = 8;
278  break;
279  }
280  case 1: {
281  newaddress = 9;
282  break;
283  }
284  case 2: {
285  newaddress = 0;
286  break;
287  }
288  case 3: {
289  newaddress = 1;
290  break;
291  }
292  case 4: {
293  newaddress = 10;
294  break;
295  }
296  case 5: {
297  newaddress = 11;
298  break;
299  }
300  case 6: {
301  newaddress = 2;
302  break;
303  }
304  case 7: {
305  newaddress = 3;
306  break;
307  }
308  case 8: {
309  newaddress = 12;
310  break;
311  }
312  case 9: {
313  newaddress = 13;
314  break;
315  }
316  case 10: {
317  newaddress = 4;
318  break;
319  }
320  case 11: {
321  newaddress = 5;
322  break;
323  }
324  case 15: {
325  newaddress = 15;
326  break;
327  }
328  default: {
329  newaddress = 15;
330  break;
331  }
332  }
333 
334  return newaddress;
335 }
336 
337 //
338 // is it a same wheel address?
339 //
340 bool L1MuDTAddressArray::sameWheel(unsigned short int adr) {
341  // if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
342  return ((adr / 2) % 2 == 0);
343 }
344 
345 //
346 // is it a next wheel address?
347 //
348 bool L1MuDTAddressArray::nextWheel(unsigned short int adr) {
349  // if ( adr > 15 ) cerr << "L1MuDTAddressArray : Error wrong address " << adr << endl;
350  return ((adr / 2) % 2 == 1);
351 }
L1MuDTAddressArray::operator=
L1MuDTAddressArray & operator=(const L1MuDTAddressArray &)
assignment operator
Definition: L1MuDTAddressArray.cc:64
L1MuDTAddressArray
Definition: L1MuDTAddressArray.h:50
L1MuDTAddressArray::operator!=
bool operator!=(const L1MuDTAddressArray &) const
unequal operator
Definition: L1MuDTAddressArray.cc:88
L1MuDTAddressArray::station
unsigned short station(int stat) const
get address of a given station [1-4]
Definition: L1MuDTAddressArray.h:80
L1MuDTAddressArray.h
L1MuDTAddressArray::convert
static unsigned short int convert(unsigned short int adr)
convert address to corresponding VHDL addresse
Definition: L1MuDTAddressArray.cc:272
indexGen.s2
s2
Definition: indexGen.py:107
std::operator<<
std::ostream & operator<<(std::ostream &out, const std::tuple< Types... > &value)
Definition: Utilities.h:32
alignCSCRings.s
s
Definition: alignCSCRings.py:92
L1MuDTAddressArray::reset
void reset()
reset address array
Definition: L1MuDTAddressArray.cc:100
L1MuDTAddressArray::nextWheel
static bool nextWheel(unsigned short int adr)
is it a next wheel address?
Definition: L1MuDTAddressArray.cc:348
L1MuDTAddressArray::setStations
void setStations(int adr1, int adr2, int adr3, int adr4)
set addresses of all four stations
Definition: L1MuDTAddressArray.cc:118
L1MuDTAddressArray::trackAddressCode
int trackAddressCode() const
get track address code (for eta track finder)
Definition: L1MuDTAddressArray.cc:128
L1MuDTAddressArray::m_station
unsigned short int m_station[4]
Definition: L1MuDTAddressArray.h:101
L1MuDTAddressArray::setStation
void setStation(int stat, int adr)
set address of a given station [1-4]
Definition: L1MuDTAddressArray.cc:109
L1MuDTAddressArray::~L1MuDTAddressArray
virtual ~L1MuDTAddressArray()
destructor
Definition: L1MuDTAddressArray.cc:55
std
Definition: JetResolutionObject.h:76
L1MuDTAddressArray::converted
L1MuDTAddressArray converted() const
get converted Addresses
Definition: L1MuDTAddressArray.cc:245
L1MuDTAddressArray::operator==
bool operator==(const L1MuDTAddressArray &) const
equal operator
Definition: L1MuDTAddressArray.cc:76
reset
void reset(double vett[256])
Definition: TPedValues.cc:11
L1MuDTAddressArray::L1MuDTAddressArray
L1MuDTAddressArray()
default constructor
Definition: L1MuDTAddressArray.cc:43
edm_modernize_messagelogger.stat
stat
Definition: edm_modernize_messagelogger.py:27
L1MuDTAddressArray::sameWheel
static bool sameWheel(unsigned short int adr)
is it a same wheel address?
Definition: L1MuDTAddressArray.cc:340