CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuDTTrackAssembler.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuDTTrackAssembler
4 //
5 // Description: Track Assembler
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 <string>
26 
27 //-------------------------------
28 // Collaborating Class Headers --
29 //-------------------------------
30 
34 
35 using namespace std;
36 
37 // --------------------------------
38 // class L1MuDTTrackAssembler
39 //---------------------------------
40 
41 //----------------
42 // Constructors --
43 //----------------
44 
46  m_sp(sp) {
47 
48 
49 }
50 
51 
52 //--------------
53 // Destructor --
54 //--------------
55 
57 
58 }
59 
60 
61 //--------------
62 // Operations --
63 //--------------
64 
65 //
66 // run Track Assembler
67 //
69 
70  // get the 18 bitmap tables from the Quality Sorter Unit
71 
72  bitset<12> b_adr12_8 = m_sp.EU()->getQSTable(EX12, 0);
73  bitset<12> b_adr12_9 = m_sp.EU()->getQSTable(EX12, 1);
74  bitset<12> b_adr13_8 = m_sp.EU()->getQSTable(EX13, 0);
75  bitset<12> b_adr13_9 = m_sp.EU()->getQSTable(EX13, 1);
76  bitset<12> b_adr14_8 = m_sp.EU()->getQSTable(EX14, 0);
77  bitset<12> b_adr14_9 = m_sp.EU()->getQSTable(EX14, 1);
78  bitset<12> b_adr23_8 = m_sp.EU()->getQSTable(EX23, 0);
79  bitset<12> b_adr23_9 = m_sp.EU()->getQSTable(EX23, 1);
80  bitset<12> b_adr23_0 = m_sp.EU()->getQSTable(EX23, 2);
81  bitset<12> b_adr23_1 = m_sp.EU()->getQSTable(EX23, 3);
82  bitset<12> b_adr24_8 = m_sp.EU()->getQSTable(EX24, 0);
83  bitset<12> b_adr24_9 = m_sp.EU()->getQSTable(EX24, 1);
84  bitset<12> b_adr24_0 = m_sp.EU()->getQSTable(EX24, 2);
85  bitset<12> b_adr24_1 = m_sp.EU()->getQSTable(EX24, 3);
86  bitset<12> b_adr34_8 = m_sp.EU()->getQSTable(EX34, 0);
87  bitset<12> b_adr34_9 = m_sp.EU()->getQSTable(EX34, 1);
88  bitset<12> b_adr34_0 = m_sp.EU()->getQSTable(EX34, 2);
89  bitset<12> b_adr34_1 = m_sp.EU()->getQSTable(EX34, 3);
90 
91 
92  // Last segment node building
93 
94  bitset<12> n_1234_888 = ( b_adr14_8 & b_adr24_8 & b_adr34_8 );
95  bitset<12> n_1234_889 = ( b_adr14_8 & b_adr24_8 & b_adr34_9 );
96  bitset<12> n_1234_880 = ( b_adr14_8 & b_adr24_8 & b_adr34_0 );
97  bitset<12> n_1234_881 = ( b_adr14_8 & b_adr24_8 & b_adr34_1 );
98  bitset<12> n_1234_898 = ( b_adr14_8 & b_adr24_9 & b_adr34_8 );
99  bitset<12> n_1234_899 = ( b_adr14_8 & b_adr24_9 & b_adr34_9 );
100  bitset<12> n_1234_890 = ( b_adr14_8 & b_adr24_9 & b_adr34_0 );
101  bitset<12> n_1234_891 = ( b_adr14_8 & b_adr24_9 & b_adr34_1 );
102  bitset<12> n_1234_800 = ( b_adr14_8 & b_adr24_0 & b_adr34_0 );
103  bitset<12> n_1234_801 = ( b_adr14_8 & b_adr24_0 & b_adr34_1 );
104  bitset<12> n_1234_810 = ( b_adr14_8 & b_adr24_1 & b_adr34_0 );
105  bitset<12> n_1234_811 = ( b_adr14_8 & b_adr24_1 & b_adr34_1 );
106 
107  bitset<12> n_1234_988 = ( b_adr14_9 & b_adr24_8 & b_adr34_8 );
108  bitset<12> n_1234_989 = ( b_adr14_9 & b_adr24_8 & b_adr34_9 );
109  bitset<12> n_1234_980 = ( b_adr14_9 & b_adr24_8 & b_adr34_0 );
110  bitset<12> n_1234_981 = ( b_adr14_9 & b_adr24_8 & b_adr34_1 );
111  bitset<12> n_1234_998 = ( b_adr14_9 & b_adr24_9 & b_adr34_8 );
112  bitset<12> n_1234_999 = ( b_adr14_9 & b_adr24_9 & b_adr34_9 );
113  bitset<12> n_1234_990 = ( b_adr14_9 & b_adr24_9 & b_adr34_0 );
114  bitset<12> n_1234_991 = ( b_adr14_9 & b_adr24_9 & b_adr34_1 );
115  bitset<12> n_1234_900 = ( b_adr14_9 & b_adr24_0 & b_adr34_0 );
116  bitset<12> n_1234_901 = ( b_adr14_9 & b_adr24_0 & b_adr34_1 );
117  bitset<12> n_1234_910 = ( b_adr14_9 & b_adr24_1 & b_adr34_0 );
118  bitset<12> n_1234_911 = ( b_adr14_9 & b_adr24_1 & b_adr34_1 );
119 
120  bitset<12> n_123_88 = ( b_adr13_8 & b_adr23_8 );
121  bitset<12> n_123_89 = ( b_adr13_8 & b_adr23_9 );
122  bitset<12> n_123_80 = ( b_adr13_8 & b_adr23_0 );
123  bitset<12> n_123_81 = ( b_adr13_8 & b_adr23_1 );
124 
125  bitset<12> n_123_98 = ( b_adr13_9 & b_adr23_8 );
126  bitset<12> n_123_99 = ( b_adr13_9 & b_adr23_9 );
127  bitset<12> n_123_90 = ( b_adr13_9 & b_adr23_0 );
128  bitset<12> n_123_91 = ( b_adr13_9 & b_adr23_1 );
129 
130  bitset<12> n_124_88 = ( b_adr14_8 & b_adr24_8 );
131  bitset<12> n_124_89 = ( b_adr14_8 & b_adr24_9 );
132  bitset<12> n_124_80 = ( b_adr14_8 & b_adr24_0 );
133  bitset<12> n_124_81 = ( b_adr14_8 & b_adr24_1 );
134 
135  bitset<12> n_124_98 = ( b_adr14_9 & b_adr24_8 );
136  bitset<12> n_124_99 = ( b_adr14_9 & b_adr24_9 );
137  bitset<12> n_124_90 = ( b_adr14_9 & b_adr24_0 );
138  bitset<12> n_124_91 = ( b_adr14_9 & b_adr24_1 );
139 
140  bitset<12> n_134_88 = ( b_adr14_8 & b_adr34_8 );
141  bitset<12> n_134_89 = ( b_adr14_8 & b_adr34_9 );
142  bitset<12> n_134_80 = ( b_adr14_8 & b_adr34_0 );
143  bitset<12> n_134_81 = ( b_adr14_8 & b_adr34_1 );
144 
145  bitset<12> n_134_98 = ( b_adr14_9 & b_adr34_8 );
146  bitset<12> n_134_99 = ( b_adr14_9 & b_adr34_9 );
147  bitset<12> n_134_90 = ( b_adr14_9 & b_adr34_0 );
148  bitset<12> n_134_91 = ( b_adr14_9 & b_adr34_1 );
149 
150  bitset<12> n_234_88 = ( b_adr24_8 & b_adr34_8 );
151  bitset<12> n_234_89 = ( b_adr24_8 & b_adr34_9 );
152  bitset<12> n_234_80 = ( b_adr24_8 & b_adr34_0 );
153  bitset<12> n_234_81 = ( b_adr24_8 & b_adr34_1 );
154 
155  bitset<12> n_234_98 = ( b_adr24_9 & b_adr34_8 );
156  bitset<12> n_234_99 = ( b_adr24_9 & b_adr34_9 );
157  bitset<12> n_234_90 = ( b_adr24_9 & b_adr34_0 );
158  bitset<12> n_234_91 = ( b_adr24_9 & b_adr34_1 );
159 
160  bitset<12> n_12_8 = b_adr12_8;
161  bitset<12> n_12_9 = b_adr12_9;
162 
163  bitset<12> n_13_8 = b_adr13_8;
164  bitset<12> n_13_9 = b_adr13_9;
165 
166  bitset<12> n_14_8 = b_adr14_8;
167  bitset<12> n_14_9 = b_adr14_9;
168 
169  bitset<12> n_23_8 = b_adr23_8;
170  bitset<12> n_23_9 = b_adr23_9;
171 
172  bitset<12> n_24_8 = b_adr24_8;
173  bitset<12> n_24_9 = b_adr24_9;
174 
175  bitset<12> n_34_8 = b_adr34_8;
176  bitset<12> n_34_9 = b_adr34_9;
177 
178  // Last address encoders
179 
180  m_theLastAddress[67] = addressEncoder12(n_1234_888);
181  m_theLastAddress[66] = addressEncoder12(n_1234_889);
182  m_theLastAddress[65] = addressEncoder12(n_1234_880);
183  m_theLastAddress[64] = addressEncoder12(n_1234_881);
184 
185  m_theLastAddress[63] = addressEncoder12(n_1234_898);
186  m_theLastAddress[62] = addressEncoder12(n_1234_899);
187  m_theLastAddress[61] = addressEncoder12(n_1234_890);
188  m_theLastAddress[60] = addressEncoder12(n_1234_891);
189 
190  m_theLastAddress[59] = addressEncoder12(n_1234_800);
191  m_theLastAddress[58] = addressEncoder12(n_1234_801);
192  m_theLastAddress[57] = addressEncoder12(n_1234_810);
193  m_theLastAddress[56] = addressEncoder12(n_1234_811);
194 
195  m_theLastAddress[55] = addressEncoder12(n_1234_988);
196  m_theLastAddress[54] = addressEncoder12(n_1234_989);
197  m_theLastAddress[53] = addressEncoder12(n_1234_980);
198  m_theLastAddress[52] = addressEncoder12(n_1234_981);
199 
200  m_theLastAddress[51] = addressEncoder12(n_1234_998);
201  m_theLastAddress[50] = addressEncoder12(n_1234_999);
202  m_theLastAddress[49] = addressEncoder12(n_1234_990);
203  m_theLastAddress[48] = addressEncoder12(n_1234_991);
204 
205  m_theLastAddress[47] = addressEncoder12(n_1234_900);
206  m_theLastAddress[46] = addressEncoder12(n_1234_901);
207  m_theLastAddress[45] = addressEncoder12(n_1234_910);
208  m_theLastAddress[44] = addressEncoder12(n_1234_911);
209 
210  m_theLastAddress[43] = addressEncoder12(n_123_88);
211  m_theLastAddress[42] = addressEncoder12(n_123_89);
212  m_theLastAddress[41] = addressEncoder12(n_123_80);
213  m_theLastAddress[40] = addressEncoder12(n_123_81);
214 
215  m_theLastAddress[39] = addressEncoder12(n_123_98);
216  m_theLastAddress[38] = addressEncoder12(n_123_99);
217  m_theLastAddress[37] = addressEncoder12(n_123_90);
218  m_theLastAddress[36] = addressEncoder12(n_123_91);
219 
220  m_theLastAddress[35] = addressEncoder12(n_124_88);
221  m_theLastAddress[34] = addressEncoder12(n_124_89);
222  m_theLastAddress[33] = addressEncoder12(n_124_80);
223  m_theLastAddress[32] = addressEncoder12(n_124_81);
224 
225  m_theLastAddress[31] = addressEncoder12(n_124_98);
226  m_theLastAddress[30] = addressEncoder12(n_124_99);
227  m_theLastAddress[29] = addressEncoder12(n_124_90);
228  m_theLastAddress[28] = addressEncoder12(n_124_91);
229 
230  m_theLastAddress[27] = addressEncoder12(n_134_88);
231  m_theLastAddress[26] = addressEncoder12(n_134_89);
232  m_theLastAddress[25] = addressEncoder12(n_134_80);
233  m_theLastAddress[24] = addressEncoder12(n_134_81);
234 
235  m_theLastAddress[23] = addressEncoder12(n_134_98);
236  m_theLastAddress[22] = addressEncoder12(n_134_99);
237  m_theLastAddress[21] = addressEncoder12(n_134_90);
238  m_theLastAddress[20] = addressEncoder12(n_134_91);
239 
240  m_theLastAddress[19] = addressEncoder12(n_234_88);
241  m_theLastAddress[18] = addressEncoder12(n_234_89);
242  m_theLastAddress[17] = addressEncoder12(n_234_80);
243  m_theLastAddress[16] = addressEncoder12(n_234_81);
244 
245  m_theLastAddress[15] = addressEncoder12(n_234_98);
246  m_theLastAddress[14] = addressEncoder12(n_234_99);
247  m_theLastAddress[13] = addressEncoder12(n_234_90);
248  m_theLastAddress[12] = addressEncoder12(n_234_91);
249 
250  m_theLastAddress[11] = addressEncoder12(n_12_8);
251  m_theLastAddress[10] = addressEncoder12(n_12_9);
252 
253  m_theLastAddress[9] = addressEncoder12(n_13_8);
254  m_theLastAddress[8] = addressEncoder12(n_13_9);
255 
256  m_theLastAddress[7] = addressEncoder12(n_14_8);
257  m_theLastAddress[6] = addressEncoder12(n_14_9);
258 
259  m_theLastAddress[5] = addressEncoder12(n_23_8);
260  m_theLastAddress[4] = addressEncoder12(n_23_9);
261 
262  m_theLastAddress[3] = addressEncoder12(n_24_8);
263  m_theLastAddress[2] = addressEncoder12(n_24_9);
264 
265  m_theLastAddress[1] = addressEncoder12(n_34_8);
266  m_theLastAddress[0] = addressEncoder12(n_34_9);
267 
268  m_theLastAddressI[11] = addressEncoder12s(n_12_8);
269  m_theLastAddressI[10] = addressEncoder12s(n_12_9);
280 
281  // Main equations (68)
282 
283  m_thePriorityTable1[67] = ( b_adr12_8[0] & b_adr13_8[0] & b_adr23_8[0] & n_1234_888.any() );
284  m_thePriorityTable1[66] = ( b_adr12_8[0] & b_adr13_8[1] & b_adr23_8[1] & n_1234_889.any() );
285  m_thePriorityTable1[65] = ( b_adr12_8[0] & b_adr13_8[2] & b_adr23_8[2] & n_1234_880.any() );
286  m_thePriorityTable1[64] = ( b_adr12_8[0] & b_adr13_8[3] & b_adr23_8[3] & n_1234_881.any() );
287  m_thePriorityTable1[63] = ( b_adr12_8[1] & b_adr13_8[0] & b_adr23_9[0] & n_1234_898.any() );
288  m_thePriorityTable1[62] = ( b_adr12_8[1] & b_adr13_8[1] & b_adr23_9[1] & n_1234_899.any() );
289  m_thePriorityTable1[61] = ( b_adr12_8[1] & b_adr13_8[2] & b_adr23_9[2] & n_1234_890.any() );
290  m_thePriorityTable1[60] = ( b_adr12_8[1] & b_adr13_8[3] & b_adr23_9[3] & n_1234_891.any() );
291  m_thePriorityTable1[59] = ( b_adr12_8[2] & b_adr13_8[2] & b_adr23_0[2] & n_1234_800.any() );
292  m_thePriorityTable1[58] = ( b_adr12_8[2] & b_adr13_8[3] & b_adr23_0[3] & n_1234_801.any() );
293  m_thePriorityTable1[57] = ( b_adr12_8[3] & b_adr13_8[2] & b_adr23_1[2] & n_1234_810.any() );
294  m_thePriorityTable1[56] = ( b_adr12_8[3] & b_adr13_8[3] & b_adr23_1[3] & n_1234_811.any() );
295 
296  m_thePriorityTable1[55] = ( b_adr12_9[0] & b_adr13_9[0] & b_adr23_8[0] & n_1234_988.any() );
297  m_thePriorityTable1[54] = ( b_adr12_9[0] & b_adr13_9[1] & b_adr23_8[1] & n_1234_989.any() );
298  m_thePriorityTable1[53] = ( b_adr12_9[0] & b_adr13_9[2] & b_adr23_8[2] & n_1234_980.any() );
299  m_thePriorityTable1[52] = ( b_adr12_9[0] & b_adr13_9[3] & b_adr23_8[3] & n_1234_981.any() );
300  m_thePriorityTable1[51] = ( b_adr12_9[1] & b_adr13_9[0] & b_adr23_9[0] & n_1234_998.any() );
301  m_thePriorityTable1[50] = ( b_adr12_9[1] & b_adr13_9[1] & b_adr23_9[1] & n_1234_999.any() );
302  m_thePriorityTable1[49] = ( b_adr12_9[1] & b_adr13_9[2] & b_adr23_9[2] & n_1234_990.any() );
303  m_thePriorityTable1[48] = ( b_adr12_9[1] & b_adr13_9[3] & b_adr23_9[3] & n_1234_991.any() );
304  m_thePriorityTable1[47] = ( b_adr12_9[2] & b_adr13_9[2] & b_adr23_0[2] & n_1234_900.any() );
305  m_thePriorityTable1[46] = ( b_adr12_9[2] & b_adr13_9[3] & b_adr23_0[3] & n_1234_901.any() );
306  m_thePriorityTable1[45] = ( b_adr12_9[3] & b_adr13_9[2] & b_adr23_1[2] & n_1234_910.any() );
307  m_thePriorityTable1[44] = ( b_adr12_9[3] & b_adr13_9[3] & b_adr23_1[3] & n_1234_911.any() );
308 
309  m_thePriorityTable1[43] = ( b_adr12_8[0] & n_123_88.any() );
310  m_thePriorityTable1[42] = ( b_adr12_8[1] & n_123_89.any() );
311  m_thePriorityTable1[41] = ( b_adr12_8[2] & n_123_80.any() );
312  m_thePriorityTable1[40] = ( b_adr12_8[3] & n_123_81.any() );
313 
314  m_thePriorityTable1[39] = ( b_adr12_9[0] & n_123_98.any() );
315  m_thePriorityTable1[38] = ( b_adr12_9[1] & n_123_99.any() );
316  m_thePriorityTable1[37] = ( b_adr12_9[2] & n_123_90.any() );
317  m_thePriorityTable1[36] = ( b_adr12_9[3] & n_123_91.any() );
318 
319  m_thePriorityTable1[35] = ( b_adr12_8[0] & n_124_88.any() );
320  m_thePriorityTable1[34] = ( b_adr12_8[1] & n_124_89.any() );
321  m_thePriorityTable1[33] = ( b_adr12_8[2] & n_124_80.any() );
322  m_thePriorityTable1[32] = ( b_adr12_8[3] & n_124_81.any() );
323 
324  m_thePriorityTable1[31] = ( b_adr12_9[0] & n_124_98.any() );
325  m_thePriorityTable1[30] = ( b_adr12_9[1] & n_124_99.any() );
326  m_thePriorityTable1[29] = ( b_adr12_9[2] & n_124_90.any() );
327  m_thePriorityTable1[28] = ( b_adr12_9[3] & n_124_91.any() );
328 
329  m_thePriorityTable1[27] = ( b_adr13_8[0] & n_134_88.any() );
330  m_thePriorityTable1[26] = ( b_adr13_8[1] & n_134_89.any() );
331  m_thePriorityTable1[25] = ( b_adr13_8[2] & n_134_80.any() );
332  m_thePriorityTable1[24] = ( b_adr13_8[3] & n_134_81.any() );
333 
334  m_thePriorityTable1[23] = ( b_adr13_9[0] & n_134_98.any() );
335  m_thePriorityTable1[22] = ( b_adr13_9[1] & n_134_99.any() );
336  m_thePriorityTable1[21] = ( b_adr13_9[2] & n_134_90.any() );
337  m_thePriorityTable1[20] = ( b_adr13_9[3] & n_134_91.any() );
338 
339  m_thePriorityTable1[19] = ( b_adr23_8[0] & n_234_88.any() );
340  m_thePriorityTable1[18] = ( b_adr23_8[1] & n_234_89.any() );
341  m_thePriorityTable1[17] = ( b_adr23_8[2] & n_234_80.any() );
342  m_thePriorityTable1[16] = ( b_adr23_8[3] & n_234_81.any() );
343 
344  m_thePriorityTable1[15] = ( b_adr23_9[0] & n_234_98.any() );
345  m_thePriorityTable1[14] = ( b_adr23_9[1] & n_234_99.any() );
346  m_thePriorityTable1[13] = ( b_adr23_9[2] & n_234_90.any() );
347  m_thePriorityTable1[12] = ( b_adr23_9[3] & n_234_91.any() );
348 
349  m_thePriorityTable1[11] = n_12_8.any();
350  m_thePriorityTable1[10] = n_12_9.any();
351 
352  m_thePriorityTable1[9] = n_13_8.any();
353  m_thePriorityTable1[8] = n_13_9.any();
354 
355  m_thePriorityTable1[7] = n_14_8.any();
356  m_thePriorityTable1[6] = n_14_9.any();
357 
358  m_thePriorityTable1[5] = n_23_8.any();
359  m_thePriorityTable1[4] = n_23_9.any();
360 
361  m_thePriorityTable1[3] = n_24_8.any();
362  m_thePriorityTable1[2] = n_24_9.any();
363 
364  m_thePriorityTable1[1] = n_34_8.any();
365  m_thePriorityTable1[0] = n_34_9.any();
366 
367 
368  if ( !m_thePriorityTable1.any() ) return;
369 
370 
371  // first Priority Encoder Sub-Unit
372  unsigned int global1 = 0;
373  unsigned int group1 = 0;
374  unsigned int p1 = 0;
375  runEncoderSubUnit1(global1, group1, p1);
376 
377  // Address Assignment for the highest priority track
378  runAddressAssignment1(global1, group1);
379 
380  // Cancellation and second Track Finder Unit
381  for ( int i = 0; i < 56; i++ ) {
383  }
385 
386  if ( !m_thePriorityTable2.any() ) return;
387 
388  // second Priority Encoder Sub-Unit
389  unsigned int global2 = 0;
390  unsigned int group2 = 0;
391  unsigned int p2 = 0;
392  runEncoderSubUnit2(global2, group2, p2);
393 
394  // Address Assignment for the second priority track
395  runAddressAssignment2(global2, group2);
396 
397  // Fake Pair Cancellation Unit
398 
399  unsigned int s1_2 = m_theAddresses[1].station(1);
400  unsigned int s2_2 = m_theAddresses[1].station(2);
401  unsigned int s3_2 = m_theAddresses[1].station(3);
402  unsigned int s4_2 = m_theAddresses[1].station(4);
403 
404  if ( s2_2 == m_theAddresses[0].station(2) ) {
405  s2_2 = 15; m_theBitMaps[1].reset(1); m_theAddresses[1].setStation(2,15);
406  if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T134;
407  if ( m_theTCs[1] == T123 ) m_theTCs[1] = T13;
408  if ( m_theTCs[1] == T124 ) m_theTCs[1] = T14;
409  if ( m_theTCs[1] == T234 ) m_theTCs[1] = T34;
410  }
411  if ( s3_2 == m_theAddresses[0].station(3) ) {
412  s3_2 = 15; m_theBitMaps[1].reset(2); m_theAddresses[1].setStation(3,15);
413  if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T124;
414  if ( m_theTCs[1] == T123 ) m_theTCs[1] = T12;
415  if ( m_theTCs[1] == T134 ) m_theTCs[1] = T14;
416  if ( m_theTCs[1] == T234 ) m_theTCs[1] = T24;
417  }
418  if ( s4_2 == m_theAddresses[0].station(4) ) {
419  s4_2 = 15; m_theBitMaps[1].reset(3); m_theAddresses[1].setStation(4,15);
420  if ( m_theTCs[1] == T1234 ) m_theTCs[1] = T123;
421  if ( m_theTCs[1] == T124 ) m_theTCs[1] = T12;
422  if ( m_theTCs[1] == T134 ) m_theTCs[1] = T13;
423  if ( m_theTCs[1] == T234 ) m_theTCs[1] = T23;
424  }
425 
426  if ( ( s2_2 == 15 && s3_2 == 15 && s4_2 == 15 ) ||
427  ( s1_2 == 15 && s3_2 == 15 && s4_2 == 15 ) ||
428  ( s1_2 == 15 && s2_2 == 15 && s4_2 == 15 ) ||
429  ( s1_2 == 15 && s2_2 == 15 && s3_2 == 15 ) ) {
430 
431  if ( L1MuDTTFConfig::Debug(5) ) cout << "L1MuDTTrackAssembler: second track has been cancelled" << endl;
432  if ( L1MuDTTFConfig::Debug(5) ) print();
433 
434  m_theTCs[1] = UNDEF;
435  m_theAddresses[1].reset();
436  m_theBitMaps[1].reset();
437 
438  }
439 
440 /*
441  if ( m_theBitMaps[1].to_ulong() != tc2bitmap(m_theTCs[1]) ) {
442  if ( L1MuDTTFConfig::Debug(5) ) cout << "L1MuDTTrackAssembler: second track has been cancelled" << endl;
443  if ( L1MuDTTFConfig::Debug(5) ) print();
444 
445  m_theTCs[1] = UNDEF;
446  m_theAddresses[1].reset();
447  m_theBitMaps[1].reset();
448  }
449 */
450 
451 }
452 
453 
454 //
455 // reset Track Assembler
456 //
458 
459  for ( int i = 0; i < 68; i++ ) m_theLastAddress[i] = 15;
460  for ( int j = 0; j < 12; j++ ) m_theLastAddressI[j] = 15;
461  m_thePriorityTable1.reset();
462  m_thePriorityTable2.reset();
463  m_theTCs[0] = UNDEF;
464  m_theTCs[1] = UNDEF;
465  m_theBitMaps[0].reset();
466  m_theBitMaps[1].reset();
467  m_theAddresses[0].reset();
468  m_theAddresses[1].reset();
469 
470 }
471 
472 
473 //
474 // print result of Track Assembler
475 //
477 
478  cout << "Track Assembler : " << endl;
479  cout << " Priority Table 1 : " << m_thePriorityTable1 << endl;
480  cout << " Priority Table 2 : " << " " << m_thePriorityTable2 << endl;
481 
482  // print result
483  cout << "Track 1: " << m_theTCs[0] << " " << m_theBitMaps[0] << '\t' << m_theAddresses[0] << endl;
484  cout << "Track 2: " << m_theTCs[1] << " " << m_theBitMaps[1] << '\t' << m_theAddresses[1] << endl;
485 
486 }
487 
488 
489 //
490 // run the first Priority Encoder Sub-Unit
491 //
492 void L1MuDTTrackAssembler::runEncoderSubUnit1(unsigned& global, unsigned& group, unsigned& priority) {
493 
494  // Global Grouping
495 
496  bitset<22> exi;
497 
498  exi[21] = m_thePriorityTable1[67] || m_thePriorityTable1[66] ||
504  exi[20] = m_thePriorityTable1[55] || m_thePriorityTable1[54] ||
510  exi[19] = m_thePriorityTable1[43] || m_thePriorityTable1[42] ||
512  exi[18] = m_thePriorityTable1[39] || m_thePriorityTable1[38] ||
514  exi[17] = m_thePriorityTable1[35] || m_thePriorityTable1[34] ||
516  exi[16] = m_thePriorityTable1[31] || m_thePriorityTable1[30] ||
518  exi[15] = m_thePriorityTable1[27] || m_thePriorityTable1[26] ||
520  exi[14] = m_thePriorityTable1[23] || m_thePriorityTable1[22] ||
522  exi[13] = m_thePriorityTable1[19] || m_thePriorityTable1[18] ||
524  exi[12] = m_thePriorityTable1[15] || m_thePriorityTable1[14] ||
526  exi[11] = m_thePriorityTable1[11];
527  exi[10] = m_thePriorityTable1[10];
528  exi[9] = m_thePriorityTable1[9];
529  exi[8] = m_thePriorityTable1[8];
530  exi[7] = m_thePriorityTable1[7];
531  exi[6] = m_thePriorityTable1[6];
532  exi[5] = m_thePriorityTable1[5];
533  exi[4] = m_thePriorityTable1[4];
534  exi[3] = m_thePriorityTable1[3];
535  exi[2] = m_thePriorityTable1[2];
536  exi[1] = m_thePriorityTable1[1];
537  exi[0] = m_thePriorityTable1[0];
538 
539  // Global Priority Encoder
540 
541  global = priorityEncoder22(exi);
542  if ( global == 31 ) {
543  group = 15;
544  priority = 0;
545  return;
546  }
547 
548  // Group priority encoders
549 
550  bitset<12> x;
551  x = subBitset68(m_thePriorityTable1,56,12);
552  unsigned int prio1234a = priorityEncoder12(x);
553  x = subBitset68(m_thePriorityTable1,44,12);
554  unsigned int prio1234b = priorityEncoder12(x);
555 
556  bitset<4> y;
558  unsigned int prio123a = priorityEncoder4(y);
560  unsigned int prio123b = priorityEncoder4(y);
562  unsigned int prio124a = priorityEncoder4(y);
564  unsigned int prio124b = priorityEncoder4(y);
566  unsigned int prio134a = priorityEncoder4(y);
568  unsigned int prio134b = priorityEncoder4(y);
570  unsigned int prio234a = priorityEncoder4(y);
572  unsigned int prio234b = priorityEncoder4(y);
573 
574  switch ( global ) {
575  case 21 : { group = prio1234a; priority = 56 + group; break; }
576  case 20 : { group = prio1234b; priority = 44 + group; break; }
577  case 19 : { group = prio123a; priority = 40 + group; break; }
578  case 18 : { group = prio123b; priority = 36 + group; break; }
579  case 17 : { group = prio124a; priority = 32 + group; break; }
580  case 16 : { group = prio124b; priority = 28 + group; break; }
581  case 15 : { group = prio134a; priority = 24 + group; break; }
582  case 14 : { group = prio134b; priority = 20 + group; break; }
583  case 13 : { group = prio234a; priority = 16 + group; break; }
584  case 12 : { group = prio234b; priority = 12 + group; break; }
585  default : { group = 15; priority = global; break; }
586  }
587 
588 }
589 
590 
591 //
592 // run the second Priority Encoder Sub-Unit
593 //
594 void L1MuDTTrackAssembler::runEncoderSubUnit2(unsigned& global, unsigned& group, unsigned& priority) {
595 
596  // Global Grouping
597 
598  bitset<21> exi;
599 
600  exi[20] = m_thePriorityTable2[55] || m_thePriorityTable2[54] ||
606  exi[19] = m_thePriorityTable2[43] || m_thePriorityTable2[42] ||
608  exi[18] = m_thePriorityTable2[39] || m_thePriorityTable2[38] ||
610  exi[17] = m_thePriorityTable2[35] || m_thePriorityTable2[34] ||
612  exi[16] = m_thePriorityTable2[31] || m_thePriorityTable2[30] ||
614  exi[15] = m_thePriorityTable2[27] || m_thePriorityTable2[26] ||
616  exi[14] = m_thePriorityTable2[23] || m_thePriorityTable2[22] ||
618  exi[13] = m_thePriorityTable2[19] || m_thePriorityTable2[18] ||
620  exi[12] = m_thePriorityTable2[15] || m_thePriorityTable2[14] ||
622  exi[11] = m_thePriorityTable2[11];
623  exi[10] = m_thePriorityTable2[10];
624  exi[9] = m_thePriorityTable2[9];
625  exi[8] = m_thePriorityTable2[8];
626  exi[7] = m_thePriorityTable2[7];
627  exi[6] = m_thePriorityTable2[6];
628  exi[5] = m_thePriorityTable2[5];
629  exi[4] = m_thePriorityTable2[4];
630  exi[3] = m_thePriorityTable2[3];
631  exi[2] = m_thePriorityTable2[2];
632  exi[1] = m_thePriorityTable2[1];
633  exi[0] = m_thePriorityTable2[0];
634 
635  // Global Priority Encoder
636 
637  global = priorityEncoder21(exi);
638  if ( global == 31 ) {
639  group = 15;
640  priority = 0;
641  return;
642  }
643 
644  // Group priority encoders
645 
646  bitset<12> x;
647  x = subBitset56(m_thePriorityTable2,44,12);
648  unsigned int prio1234b = priorityEncoder12(x);
649 
650  bitset<4> y;
652  unsigned int prio123a = priorityEncoder4(y);
654  unsigned int prio123b = priorityEncoder4(y);
656  unsigned int prio124a = priorityEncoder4(y);
658  unsigned int prio124b = priorityEncoder4(y);
660  unsigned int prio134a = priorityEncoder4(y);
662  unsigned int prio134b = priorityEncoder4(y);
664  unsigned int prio234a = priorityEncoder4(y);
666  unsigned int prio234b = priorityEncoder4(y);
667 
668  switch ( global ) {
669  case 20 : { group = prio1234b; priority = 44 + group; break; }
670  case 19 : { group = prio123a; priority = 40 + group; break; }
671  case 18 : { group = prio123b; priority = 36 + group; break; }
672  case 17 : { group = prio124a; priority = 32 + group; break; }
673  case 16 : { group = prio124b; priority = 28 + group; break; }
674  case 15 : { group = prio134a; priority = 24 + group; break; }
675  case 14 : { group = prio134b; priority = 20 + group; break; }
676  case 13 : { group = prio234a; priority = 16 + group; break; }
677  case 12 : { group = prio234b; priority = 12 + group; break; }
678  default : { group = 15; priority = global; break; }
679  }
680 
681 }
682 
683 
684 //
685 // run the first Address Assignment Sub-Unit
686 //
688 
689  TrackClass tc(UNDEF);
690 
691  switch ( global ) {
692  case 21 : { tc = T1234;
693  switch ( group ) {
694  case 11 : m_theAddresses[0].setStations( 0, 0, 0, m_theLastAddress[67]); break;
695  case 10 : m_theAddresses[0].setStations( 0, 0, 1, m_theLastAddress[66]); break;
696  case 9 : m_theAddresses[0].setStations( 0, 0, 2, m_theLastAddress[65]); break;
697  case 8 : m_theAddresses[0].setStations( 0, 0, 3, m_theLastAddress[64]); break;
698  case 7 : m_theAddresses[0].setStations( 0, 1, 0, m_theLastAddress[63]); break;
699  case 6 : m_theAddresses[0].setStations( 0, 1, 1, m_theLastAddress[62]); break;
700  case 5 : m_theAddresses[0].setStations( 0, 1, 2, m_theLastAddress[61]); break;
701  case 4 : m_theAddresses[0].setStations( 0, 1, 3, m_theLastAddress[60]); break;
702  case 3 : m_theAddresses[0].setStations( 0, 2, 2, m_theLastAddress[59]); break;
703  case 2 : m_theAddresses[0].setStations( 0, 2, 3, m_theLastAddress[58]); break;
704  case 1 : m_theAddresses[0].setStations( 0, 3, 2, m_theLastAddress[57]); break;
705  case 0 : m_theAddresses[0].setStations( 0, 3, 3, m_theLastAddress[56]); break;
706  }
707  break;
708  }
709  case 20 : { tc = T1234;
710  switch ( group ) {
711  case 11 : m_theAddresses[0].setStations( 1, 0, 0, m_theLastAddress[55]); break;
712  case 10 : m_theAddresses[0].setStations( 1, 0, 1, m_theLastAddress[54]); break;
713  case 9 : m_theAddresses[0].setStations( 1, 0, 2, m_theLastAddress[53]); break;
714  case 8 : m_theAddresses[0].setStations( 1, 0, 3, m_theLastAddress[52]); break;
715  case 7 : m_theAddresses[0].setStations( 1, 1, 0, m_theLastAddress[51]); break;
716  case 6 : m_theAddresses[0].setStations( 1, 1, 1, m_theLastAddress[50]); break;
717  case 5 : m_theAddresses[0].setStations( 1, 1, 2, m_theLastAddress[49]); break;
718  case 4 : m_theAddresses[0].setStations( 1, 1, 3, m_theLastAddress[48]); break;
719  case 3 : m_theAddresses[0].setStations( 1, 2, 2, m_theLastAddress[47]); break;
720  case 2 : m_theAddresses[0].setStations( 1, 2, 3, m_theLastAddress[46]); break;
721  case 1 : m_theAddresses[0].setStations( 1, 3, 2, m_theLastAddress[45]); break;
722  case 0 : m_theAddresses[0].setStations( 1, 3, 3, m_theLastAddress[44]); break;
723  }
724  break;
725  }
726  case 19 : { tc = T123;
727  switch ( group ) {
728  case 3 : m_theAddresses[0].setStations( 0, 0, m_theLastAddress[43],15); break;
729  case 2 : m_theAddresses[0].setStations( 0, 1, m_theLastAddress[42],15); break;
730  case 1 : m_theAddresses[0].setStations( 0, 2, m_theLastAddress[41],15); break;
731  case 0 : m_theAddresses[0].setStations( 0, 3, m_theLastAddress[40],15); break;
732  }
733  break;
734  }
735  case 18 : { tc = T123;
736  switch ( group ) {
737  case 3 : m_theAddresses[0].setStations( 1, 0, m_theLastAddress[39],15); break;
738  case 2 : m_theAddresses[0].setStations( 1, 1, m_theLastAddress[38],15); break;
739  case 1 : m_theAddresses[0].setStations( 1, 2, m_theLastAddress[37],15); break;
740  case 0 : m_theAddresses[0].setStations( 1, 3, m_theLastAddress[36],15); break;
741  }
742  break;
743  }
744  case 17 : { tc = T124;
745  switch ( group ) {
746  case 3 : m_theAddresses[0].setStations( 0, 0,15, m_theLastAddress[35]); break;
747  case 2 : m_theAddresses[0].setStations( 0, 1,15, m_theLastAddress[34]); break;
748  case 1 : m_theAddresses[0].setStations( 0, 2,15, m_theLastAddress[33]); break;
749  case 0 : m_theAddresses[0].setStations( 0, 3,15, m_theLastAddress[32]); break;
750  }
751  break;
752  }
753  case 16 : { tc = T124;
754  switch ( group ) {
755  case 3 : m_theAddresses[0].setStations( 1, 0,15, m_theLastAddress[31]); break;
756  case 2 : m_theAddresses[0].setStations( 1, 1,15, m_theLastAddress[30]); break;
757  case 1 : m_theAddresses[0].setStations( 1, 2,15, m_theLastAddress[29]); break;
758  case 0 : m_theAddresses[0].setStations( 1, 3,15, m_theLastAddress[28]); break;
759  }
760  break;
761  }
762  case 15 : { tc = T134;
763  switch ( group ) {
764  case 3 : m_theAddresses[0].setStations( 0,15, 0, m_theLastAddress[27]); break;
765  case 2 : m_theAddresses[0].setStations( 0,15, 1, m_theLastAddress[26]); break;
766  case 1 : m_theAddresses[0].setStations( 0,15, 2, m_theLastAddress[25]); break;
767  case 0 : m_theAddresses[0].setStations( 0,15, 3, m_theLastAddress[24]); break;
768  }
769  break;
770  }
771  case 14 : { tc = T134;
772  switch ( group ) {
773  case 3 : m_theAddresses[0].setStations( 1,15, 0, m_theLastAddress[23]); break;
774  case 2 : m_theAddresses[0].setStations( 1,15, 1, m_theLastAddress[22]); break;
775  case 1 : m_theAddresses[0].setStations( 1,15, 2, m_theLastAddress[21]); break;
776  case 0 : m_theAddresses[0].setStations( 1,15, 3, m_theLastAddress[20]); break;
777  }
778  break;
779  }
780  case 13 : { tc = T234;
781  switch ( group ) {
782  case 3 : m_theAddresses[0].setStations(15, 0, 0, m_theLastAddress[19]); break;
783  case 2 : m_theAddresses[0].setStations(15, 0, 1, m_theLastAddress[18]); break;
784  case 1 : m_theAddresses[0].setStations(15, 0, 2, m_theLastAddress[17]); break;
785  case 0 : m_theAddresses[0].setStations(15, 0, 3, m_theLastAddress[16]); break;
786  }
787  break;
788  }
789  case 12 : { tc = T234;
790  switch ( group ) {
791  case 3 : m_theAddresses[0].setStations(15, 1, 0, m_theLastAddress[15]); break;
792  case 2 : m_theAddresses[0].setStations(15, 1, 1, m_theLastAddress[14]); break;
793  case 1 : m_theAddresses[0].setStations(15, 1, 2, m_theLastAddress[13]); break;
794  case 0 : m_theAddresses[0].setStations(15, 1, 3, m_theLastAddress[12]); break;
795  }
796  break;
797  }
798  case 11 : { tc = T12; m_theAddresses[0].setStations( 0, m_theLastAddress[11],15,15); break; }
799  case 10 : { tc = T12; m_theAddresses[0].setStations( 1, m_theLastAddress[10],15,15); break; }
800  case 9 : { tc = T13; m_theAddresses[0].setStations( 0,15, m_theLastAddress[9],15); break; }
801  case 8 : { tc = T13; m_theAddresses[0].setStations( 1,15, m_theLastAddress[8],15); break; }
802  case 7 : { tc = T14; m_theAddresses[0].setStations( 0,15,15, m_theLastAddress[7]); break; }
803  case 6 : { tc = T14; m_theAddresses[0].setStations( 1,15,15, m_theLastAddress[6]); break; }
804  case 5 : { tc = T23; m_theAddresses[0].setStations(15, 0, m_theLastAddress[5],15); break; }
805  case 4 : { tc = T23; m_theAddresses[0].setStations(15, 1, m_theLastAddress[4],15); break; }
806  case 3 : { tc = T24; m_theAddresses[0].setStations(15, 0,15, m_theLastAddress[3]); break; }
807  case 2 : { tc = T24; m_theAddresses[0].setStations(15, 1,15, m_theLastAddress[2]); break; }
808  case 1 : { tc = T34; m_theAddresses[0].setStations(15,15, 0, m_theLastAddress[1]); break; }
809  case 0 : { tc = T34; m_theAddresses[0].setStations(15,15, 1, m_theLastAddress[0]); break; }
810  }
811 
812  // set Track Class and covert to bitmap
813  m_theTCs[0] = tc;
814  m_theBitMaps[0] = tc2bitmap(tc);
815 
816 }
817 
818 
819 //
820 // run the second Address Assignment Sub-Unit
821 //
823 
824  TrackClass tc(UNDEF);
825 
826  switch ( global ) {
827  case 20 : { tc = T1234;
828  switch ( group ) {
829  case 11 : m_theAddresses[1].setStations( 1, 0, 0, m_theLastAddress[55]); break;
830  case 10 : m_theAddresses[1].setStations( 1, 0, 1, m_theLastAddress[54]); break;
831  case 9 : m_theAddresses[1].setStations( 1, 0, 2, m_theLastAddress[53]); break;
832  case 8 : m_theAddresses[1].setStations( 1, 0, 3, m_theLastAddress[52]); break;
833  case 7 : m_theAddresses[1].setStations( 1, 1, 0, m_theLastAddress[51]); break;
834  case 6 : m_theAddresses[1].setStations( 1, 1, 1, m_theLastAddress[50]); break;
835  case 5 : m_theAddresses[1].setStations( 1, 1, 2, m_theLastAddress[49]); break;
836  case 4 : m_theAddresses[1].setStations( 1, 1, 3, m_theLastAddress[48]); break;
837  case 3 : m_theAddresses[1].setStations( 1, 2, 2, m_theLastAddress[47]); break;
838  case 2 : m_theAddresses[1].setStations( 1, 2, 3, m_theLastAddress[46]); break;
839  case 1 : m_theAddresses[1].setStations( 1, 3, 2, m_theLastAddress[45]); break;
840  case 0 : m_theAddresses[1].setStations( 1, 3, 3, m_theLastAddress[44]); break;
841  }
842  break;
843  }
844  case 19 : { tc = T123;
845  switch ( group ) {
846  case 3 : m_theAddresses[1].setStations( 0, 0, m_theLastAddress[43],15); break;
847  case 2 : m_theAddresses[1].setStations( 0, 1, m_theLastAddress[42],15); break;
848  case 1 : m_theAddresses[1].setStations( 0, 2, m_theLastAddress[41],15); break;
849  case 0 : m_theAddresses[1].setStations( 0, 3, m_theLastAddress[40],15); break;
850  }
851  break;
852  }
853  case 18 : { tc = T123;
854  switch ( group ) {
855  case 3 : m_theAddresses[1].setStations( 1, 0, m_theLastAddress[39],15); break;
856  case 2 : m_theAddresses[1].setStations( 1, 1, m_theLastAddress[38],15); break;
857  case 1 : m_theAddresses[1].setStations( 1, 2, m_theLastAddress[37],15); break;
858  case 0 : m_theAddresses[1].setStations( 1, 3, m_theLastAddress[36],15); break;
859  }
860  break;
861  }
862  case 17 : { tc = T124;
863  switch ( group ) {
864  case 3 : m_theAddresses[1].setStations( 0, 0,15, m_theLastAddress[35]); break;
865  case 2 : m_theAddresses[1].setStations( 0, 1,15, m_theLastAddress[34]); break;
866  case 1 : m_theAddresses[1].setStations( 0, 2,15, m_theLastAddress[33]); break;
867  case 0 : m_theAddresses[1].setStations( 0, 3,15, m_theLastAddress[32]); break;
868  }
869  break;
870  }
871  case 16 : { tc = T124;
872  switch ( group ) {
873  case 3 : m_theAddresses[1].setStations( 1, 0,15, m_theLastAddress[31]); break;
874  case 2 : m_theAddresses[1].setStations( 1, 1,15, m_theLastAddress[30]); break;
875  case 1 : m_theAddresses[1].setStations( 1, 2,15, m_theLastAddress[29]); break;
876  case 0 : m_theAddresses[1].setStations( 1, 3,15, m_theLastAddress[28]); break;
877  }
878  break;
879  }
880  case 15 : { tc = T134;
881  switch ( group ) {
882  case 3 : m_theAddresses[1].setStations( 0,15, 0, m_theLastAddress[27]); break;
883  case 2 : m_theAddresses[1].setStations( 0,15, 1, m_theLastAddress[26]); break;
884  case 1 : m_theAddresses[1].setStations( 0,15, 2, m_theLastAddress[25]); break;
885  case 0 : m_theAddresses[1].setStations( 0,15, 3, m_theLastAddress[24]); break;
886  }
887  break;
888  }
889  case 14 : { tc = T134;
890  switch ( group ) {
891  case 3 : m_theAddresses[1].setStations( 1,15, 0, m_theLastAddress[23]); break;
892  case 2 : m_theAddresses[1].setStations( 1,15, 1, m_theLastAddress[22]); break;
893  case 1 : m_theAddresses[1].setStations( 1,15, 2, m_theLastAddress[21]); break;
894  case 0 : m_theAddresses[1].setStations( 1,15, 3, m_theLastAddress[20]); break;
895  }
896  break;
897  }
898  case 13 : { tc = T234;
899  switch ( group ) {
900  case 3 : m_theAddresses[1].setStations(15, 0, 0, m_theLastAddress[19]); break;
901  case 2 : m_theAddresses[1].setStations(15, 0, 1, m_theLastAddress[18]); break;
902  case 1 : m_theAddresses[1].setStations(15, 0, 2, m_theLastAddress[17]); break;
903  case 0 : m_theAddresses[1].setStations(15, 0, 3, m_theLastAddress[16]); break;
904  }
905  break;
906  }
907  case 12 : { tc = T234;
908  switch ( group ) {
909  case 3 : m_theAddresses[1].setStations(15, 1, 0, m_theLastAddress[15]); break;
910  case 2 : m_theAddresses[1].setStations(15, 1, 1, m_theLastAddress[14]); break;
911  case 1 : m_theAddresses[1].setStations(15, 1, 2, m_theLastAddress[13]); break;
912  case 0 : m_theAddresses[1].setStations(15, 1, 3, m_theLastAddress[12]); break;
913  }
914  break;
915  }
916  case 11 : { tc = T12; m_theAddresses[1].setStations( 0, m_theLastAddressI[11],15,15); break; }
917  case 10 : { tc = T12; m_theAddresses[1].setStations( 1, m_theLastAddressI[10],15,15); break; }
918  case 9 : { tc = T13; m_theAddresses[1].setStations( 0,15, m_theLastAddressI[9],15); break; }
919  case 8 : { tc = T13; m_theAddresses[1].setStations( 1,15, m_theLastAddressI[8],15); break; }
920  case 7 : { tc = T14; m_theAddresses[1].setStations( 0,15,15, m_theLastAddressI[7]); break; }
921  case 6 : { tc = T14; m_theAddresses[1].setStations( 1,15,15, m_theLastAddressI[6]); break; }
922  case 5 : { tc = T23; m_theAddresses[1].setStations(15, 0, m_theLastAddressI[5],15); break; }
923  case 4 : { tc = T23; m_theAddresses[1].setStations(15, 1, m_theLastAddressI[4],15); break; }
924  case 3 : { tc = T24; m_theAddresses[1].setStations(15, 0,15, m_theLastAddressI[3]); break; }
925  case 2 : { tc = T24; m_theAddresses[1].setStations(15, 1,15, m_theLastAddressI[2]); break; }
926  case 1 : { tc = T34; m_theAddresses[1].setStations(15,15, 0, m_theLastAddressI[1]); break; }
927  case 0 : { tc = T34; m_theAddresses[1].setStations(15,15, 1, m_theLastAddressI[0]); break; }
928  }
929 
930  // set Track Class and covert to bitmap
931  m_theTCs[1] = tc;
932  m_theBitMaps[1] = tc2bitmap(tc);
933 
934 }
935 
936 
937 //
938 // 12 bit priority encoder
939 //
940 unsigned int L1MuDTTrackAssembler::priorityEncoder12(const bitset<12>& input) {
941 
942  unsigned int result = 15;
943 
944  for ( int i = 0; i < 12; i++ ) {
945  if ( input.test(i) ) result = i;
946  }
947 
948  return result;
949 
950 }
951 
952 
953 //
954 // 4 bit priority encoder
955 //
956 unsigned int L1MuDTTrackAssembler::priorityEncoder4(const bitset<4>& input) {
957 
958  unsigned int result = 3;
959 
960  for ( int i = 0; i < 4; i++ ) {
961  if ( input.test(i) ) result = i;
962  }
963 
964  return result;
965 
966 }
967 
968 
969 //
970 // 22 bit priority encoder
971 //
972 unsigned int L1MuDTTrackAssembler::priorityEncoder22(const bitset<22>& input) {
973 
974  unsigned int result = 31;
975 
976  for ( int i = 0; i < 22; i++ ) {
977  if ( input.test(i) ) result = i;
978  }
979 
980  return result;
981 
982 }
983 
984 
985 //
986 // 21 bit priority encoder
987 //
988 unsigned int L1MuDTTrackAssembler::priorityEncoder21(const bitset<21>& input) {
989 
990  unsigned int result = 31;
991 
992  for ( int i = 0; i < 21; i++ ) {
993  if ( input.test(i) ) result = i;
994  }
995 
996  return result;
997 
998 }
999 
1000 
1001 //
1002 // 12 bit address encoder
1003 //
1004 unsigned int L1MuDTTrackAssembler::addressEncoder12(const bitset<12>& input) {
1005 
1006  // inverse order priority encoder
1007 
1008  unsigned int result = 15;
1009 
1010  for ( int i = 0; i < 12; i++ ) {
1011  if ( input.test(i) ) {
1012  result = i;
1013  break;
1014  }
1015  }
1016 
1017  return result;
1018 
1019 }
1020 
1021 
1022 //
1023 // special 12 bit address encoder
1024 //
1025 unsigned int L1MuDTTrackAssembler::addressEncoder12s(const bitset<12>& input) {
1026 
1027  // inverse order priority encoder which prefers second addresses
1028 
1029  unsigned int result = 15;
1030 
1031  for ( int i = 0; i < 11; i += 2 ) {
1032  if ( input.test(i) || input.test(i+1) ) {
1033  if ( input.test(i) ) result = i;
1034  if ( input.test(i+1) ) result = i+1;
1035  break;
1036  }
1037  }
1038 
1039  return result;
1040 
1041 }
1042 
1043 //
1044 // get sub-bitmap of a 68-bit word
1045 //
1046 unsigned long L1MuDTTrackAssembler::subBitset68(const bitset<68>& input, int pos, int length) {
1047 
1048  bitset<68> s(input);
1049 
1050  for ( int i = pos+length; i < 68; i++ ) s.reset(i);
1051 
1052  s >>= pos;
1053 
1054  return s.to_ulong();
1055 
1056 }
1057 
1058 
1059 //
1060 // get sub-bitmap of a 56-bit word
1061 //
1062 unsigned long L1MuDTTrackAssembler::subBitset56(const bitset<56>& input, int pos, int length) {
1063 
1064  bitset<56> s(input);
1065 
1066  for ( int i = pos+length; i < 56; i++ ) s.reset(i);
1067 
1068  s >>= pos;
1069 
1070  return s.to_ulong();
1071 
1072 }
1073 
1074 
1075 //
1076 // Cancel Out Table
1077 //
1079 
1080  // Cancellation Table
1081  // Each 0 in this Table means a sub-track of the
1082  // previous found Track
1083 
1084  switch ( p ) {
1085  case 67 : { bitset<56> b(string("00000111111100000111000001110000011100000111010101010101")); return b; break; }
1086  case 66 : { bitset<56> b(string("00001011111100000111000001110000101100001011010101010110")); return b; break; }
1087  case 65 : { bitset<56> b(string("00001101010100000111000001110000110100001101010101010111")); return b; break; }
1088  case 64 : { bitset<56> b(string("00001110101000000111000001110000111000001110010101010111")); return b; break; }
1089  case 63 : { bitset<56> b(string("01110000111100001011000010110000011101110000010101101001")); return b; break; }
1090  case 62 : { bitset<56> b(string("10110000111100001011000010110000101110110000010101101010")); return b; break; }
1091  case 61 : { bitset<56> b(string("11010000111100001011000010110000110111010000010101101011")); return b; break; }
1092  case 60 : { bitset<56> b(string("11100000111100001011000010110000111011100000010101101011")); return b; break; }
1093  case 59 : { bitset<56> b(string("11011101000100001101000011010000110111011101010101111111")); return b; break; }
1094  case 58 : { bitset<56> b(string("11101110001000001101000011010000111011101110010101111111")); return b; break; }
1095  case 57 : { bitset<56> b(string("11011101010000001110000011100000110111011101010101111111")); return b; break; }
1096  case 56 : { bitset<56> b(string("11101110100000001110000011100000111011101110010101111111")); return b; break; }
1097 
1098  case 55 : { bitset<56> b(string("00000000000001110000011100000111000000000111101010010101")); return b; break; }
1099  case 54 : { bitset<56> b(string("00000000000001110000011100001011000000001011101010010110")); return b; break; }
1100  case 53 : { bitset<56> b(string("00000000000001110000011100001101000000001101101010010111")); return b; break; }
1101  case 52 : { bitset<56> b(string("00000000000001110000011100001110000000001110101010010111")); return b; break; }
1102  case 51 : { bitset<56> b(string("00000000000010110000101100000111000001110000101010101001")); return b; break; }
1103  case 50 : { bitset<56> b(string("00000000000010110000101100001011000010110000101010101010")); return b; break; }
1104  case 49 : { bitset<56> b(string("00000000000010110000101100001101000011010000101010101011")); return b; break; }
1105  case 48 : { bitset<56> b(string("00000000000010110000101100001110000011100000101010101011")); return b; break; }
1106  case 47 : { bitset<56> b(string("00000000000011010000110100001101000011011101101010111111")); return b; break; }
1107  case 46 : { bitset<56> b(string("00000000000011010000110100001110000011101110101010111111")); return b; break; }
1108  case 45 : { bitset<56> b(string("00000000000011100000111000001101000011011101101010111111")); return b; break; }
1109  case 44 : { bitset<56> b(string("00000000000011100000111000001110000011101110101010111111")); return b; break; }
1110 
1111  case 43 : { bitset<56> b(string("00000000000000000111000001110000111100001111010101010111")); return b; break; }
1112  case 42 : { bitset<56> b(string("00000000000000001011000010110000111111110000010101101011")); return b; break; }
1113  case 41 : { bitset<56> b(string("00000000000000001101000011010000111111111111010101111111")); return b; break; }
1114  case 40 : { bitset<56> b(string("00000000000000001110000011100000111111111111010101111111")); return b; break; }
1115 
1116  case 39 : { bitset<56> b(string("00000000000000000000011100001111000000001111101010010111")); return b; break; }
1117  case 38 : { bitset<56> b(string("00000000000000000000101100001111000011110000101010101011")); return b; break; }
1118  case 37 : { bitset<56> b(string("00000000000000000000110100001111000011111111101010111111")); return b; break; }
1119  case 36 : { bitset<56> b(string("00000000000000000000111000001111000011111111101010111111")); return b; break; }
1120 
1121  case 35 : { bitset<56> b(string("00000000000000000000000001110000111100001111010101010111")); return b; break; }
1122  case 34 : { bitset<56> b(string("00000000000000000000000010110000111111110000010101101011")); return b; break; }
1123  case 33 : { bitset<56> b(string("00000000000000000000000011010000111111111111010101111111")); return b; break; }
1124  case 32 : { bitset<56> b(string("00000000000000000000000011100000111111111111010101111111")); return b; break; }
1125 
1126  case 31 : { bitset<56> b(string("00000000000000000000011100001111000000001111101010010111")); return b; break; }
1127  case 30 : { bitset<56> b(string("00000000000000000000101100001111000011110000101010101011")); return b; break; }
1128  case 29 : { bitset<56> b(string("00000000000000000000110100001111000011111111101010111111")); return b; break; }
1129  case 28 : { bitset<56> b(string("00000000000000000000111000001111000011111111101010111111")); return b; break; }
1130 
1131  case 27 : { bitset<56> b(string("00000000000000000000000000000000011101110111010101111101")); return b; break; }
1132  case 26 : { bitset<56> b(string("00000000000000000000000000000000101110111011010101111110")); return b; break; }
1133  case 25 : { bitset<56> b(string("00000000000000000000000000000000110111011101010101111111")); return b; break; }
1134  case 24 : { bitset<56> b(string("00000000000000000000000000000000111011101110010101111111")); return b; break; }
1135 
1136  case 23 : { bitset<56> b(string("00000000000000000000000000000000000001110111101010111101")); return b; break; }
1137  case 22 : { bitset<56> b(string("00000000000000000000000000000000000010111011101010111110")); return b; break; }
1138  case 21 : { bitset<56> b(string("00000000000000000000000000000000000011011101101010111111")); return b; break; }
1139  case 20 : { bitset<56> b(string("00000000000000000000000000000000000011101110101010111111")); return b; break; }
1140 
1141  case 19 : { bitset<56> b(string("00000000000000000000000000000000000000000111111111010101")); return b; break; }
1142  case 18 : { bitset<56> b(string("00000000000000000000000000000000000000001011111111010110")); return b; break; }
1143  case 17 : { bitset<56> b(string("00000000000000000000000000000000000000001101111111010111")); return b; break; }
1144  case 16 : { bitset<56> b(string("00000000000000000000000000000000000000001110111111010111")); return b; break; }
1145 
1146  case 15 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101001")); return b; break; }
1147  case 14 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101010")); return b; break; }
1148  case 13 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101011")); return b; break; }
1149  case 12 : { bitset<56> b(string("00000000000000000000000000000000000000000000111111101011")); return b; break; }
1150 
1151  case 11 : { bitset<56> b(string("00000000000000000000000000000000000000000000010101111111")); return b; break; }
1152  case 10 : { bitset<56> b(string("00000000000000000000000000000000000000000000001010111111")); return b; break; }
1153 
1154  case 9 : { bitset<56> b(string("00000000000000000000000000000000000000000000000101111111")); return b; break; }
1155  case 8 : { bitset<56> b(string("00000000000000000000000000000000000000000000000010111111")); return b; break; }
1156 
1157  case 7 : { bitset<56> b(string("00000000000000000000000000000000000000000000000001111111")); return b; break; }
1158  case 6 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000111111")); return b; break; }
1159 
1160  case 5 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000010111")); return b; break; }
1161  case 4 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000001011")); return b; break; }
1162 
1163  case 3 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000111")); return b; break; }
1164  case 2 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000011")); return b; break; }
1165 
1166  case 1 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000001")); return b; break; }
1167  case 0 : { bitset<56> b(string("00000000000000000000000000000000000000000000000000000000")); return b; break; }
1168  default : { bitset<56> b; return b; break; }
1169 
1170  }
1171 
1172 }
int i
Definition: DBlmapReader.cc:9
static unsigned int addressEncoder12(const std::bitset< 12 > &input)
12 bit address encoder
void reset()
reset address array
static unsigned int addressEncoder12s(const std::bitset< 12 > &input)
special 12 bit address encoder
void runAddressAssignment1(int global, int group)
run the first Address Assignment Sub-Unit
void print() const
print result of Track Assembler
L1MuDTAddressArray m_theAddresses[2]
static unsigned int priorityEncoder12(const std::bitset< 12 > &input)
12 bit priority encoder
const unsigned int tc2bitmap(const TrackClass tc)
unsigned int m_theLastAddress[68]
static std::string const input
Definition: EdmProvDump.cc:44
static unsigned int priorityEncoder22(const std::bitset< 22 > &input)
22 bit priority encoder
tuple result
Definition: mps_fire.py:84
L1MuDTTrackAssembler(const L1MuDTSectorProcessor &)
constructor
const std::bitset< 12 > & getQSTable(Extrapolation ext, unsigned int startAdr) const
get Quality Sorter table for a given SEU
const L1MuDTSectorProcessor & m_sp
void runEncoderSubUnit2(unsigned &global, unsigned &group, unsigned &priority)
run the second Priority Encoder Sub-Unit
virtual void run()
run Track Assembler
int j
Definition: DBlmapReader.cc:9
static bool Debug()
virtual void reset()
reset Track Assembler
virtual ~L1MuDTTrackAssembler()
destructor
std::bitset< 4 > m_theBitMaps[2]
double p2[4]
Definition: TauolaWrapper.h:90
static std::bitset< 56 > getCancelationTable(unsigned int)
cancel Out Table
static unsigned int priorityEncoder21(const std::bitset< 21 > &input)
21 bit priority encoder
void setStations(int adr1, int adr2, int adr3, int adr4)
set addresses of all four stations
tuple group
Definition: watchdog.py:82
std::bitset< 68 > m_thePriorityTable1
double b
Definition: hdecay.h:120
unsigned int m_theLastAddressI[12]
static unsigned int priorityEncoder4(const std::bitset< 4 > &input)
4 bit priority encoder
void runAddressAssignment2(int global, int group)
run the second Address Assignment Sub-Unit
void setStation(int stat, int adr)
set address of a given station [1-4]
static unsigned long subBitset56(const std::bitset< 56 > &input, int pos, int length)
get sub-bitmap of a 56-bit word
void runEncoderSubUnit1(unsigned &global, unsigned &group, unsigned &priority)
run the first Priority Encoder Sub-Unit
double p1[4]
Definition: TauolaWrapper.h:89
std::bitset< 56 > m_thePriorityTable2
tuple cout
Definition: gather_cfg.py:145
Definition: sp.h:21
const L1MuDTExtrapolationUnit * EU() const
return pointer to Extrapolation Unit
static unsigned long subBitset68(const std::bitset< 68 > &input, int pos, int length)
get sub-bitmap of a 68-bit word
unsigned short station(int stat) const
get address of a given station [1-4]