CMS 3D CMS Logo

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