CMS 3D CMS Logo

SourceCardRouting.cc
Go to the documentation of this file.
1 /*
2  SourceCardRouting library
3  Andrew Rose 2007
4 */
5 
6 // Prototype class definition
7 #include "SourceCardRouting.h" //hh"
8 
9 // File streams
10 #include <iomanip>
11 #include <iostream>
12 #include <sstream>
13 using namespace std;
14 
18  // std::cout<<"Constructor"<<std::endl;
19 }
20 
22  // std::cout<<"Destructor"<<std::endl;
23 }
26 // SFP arrays are SFP[cycle<2][sfp number<4]
27 // electron arrays are eIsoRank[candidate number<4]
28 // muon arrays are MIPbits[rec card number<7][region<2]
29 
31  unsigned short (&eIsoRank)[4], unsigned short (&eIsoCardId)[4],
32  unsigned short (&eIsoRegionId)[4], unsigned short (&eNonIsoRank)[4],
33  unsigned short (&eNonIsoCardId)[4], unsigned short (&eNonIsoRegionId)[4],
34  unsigned short (&MIPbits)[7][2], unsigned short (&Qbits)[7][2],
35  unsigned short (&SFP)[2][4]) const {
36 
37  SFP[0][0] = 0;
38  SFP[1][0] = 0x8000;
39 
40  for (int i = 0; i < 7; i++) {
41  for (int j = 0; j < 2; j++) {
42  SFP[0][0] = SFP[0][0] | ((MIPbits[i][j] & 0x01) << ((2 * i) + j));
43  SFP[1][0] = SFP[1][0] | ((Qbits[i][j] & 0x01) << ((2 * i) + j));
44  }
45  }
46 
47  SFP[0][1] = (eIsoRank[0] & 0x3f) | ((eIsoRegionId[0] & 0x01) << 6) |
48  ((eIsoCardId[0] & 0x07) << 7) | ((eIsoRank[1] & 0x7) << 10);
49  SFP[1][1] = 0x8000 | (eIsoRank[2] & 0x3f) | ((eIsoRegionId[2] & 0x01) << 6) |
50  ((eIsoCardId[2] & 0x07) << 7) | ((eIsoRank[3] & 0x7) << 10);
51  SFP[0][2] = (eNonIsoRank[0] & 0x3f) | ((eNonIsoRegionId[0] & 0x01) << 6) |
52  ((eNonIsoCardId[0] & 0x07) << 7) | ((eIsoRank[1] & 0x38) << 7) |
53  ((eIsoRegionId[1] & 0x01) << 13);
54  SFP[1][2] = 0x8000 | (eNonIsoRank[2] & 0x3f) |
55  ((eNonIsoRegionId[2] & 0x01) << 6) |
56  ((eNonIsoCardId[2] & 0x07) << 7) | ((eIsoRank[3] & 0x38) << 7) |
57  ((eIsoRegionId[3] & 0x01) << 13);
58  SFP[0][3] = (eNonIsoRank[1] & 0x3f) | ((eNonIsoRegionId[1] & 0x01) << 6) |
59  ((eNonIsoCardId[1] & 0x07) << 7) | ((eIsoCardId[1] & 0x07) << 10);
60  SFP[1][3] = 0x8000 | (eNonIsoRank[3] & 0x3f) |
61  ((eNonIsoRegionId[3] & 0x01) << 6) |
62  ((eNonIsoCardId[3] & 0x07) << 7) | ((eIsoCardId[3] & 0x07) << 10);
63 }
64 
66 // SFP arrays are SFP[cycle<2][sfp number<4]
67 // electron arrays are eIsoRank[candidate number<4]
68 // muon arrays are MIPbits[rec card number<7][region<2]
69 
71  unsigned short (&eIsoRank)[4], unsigned short (&eIsoCardId)[4],
72  unsigned short (&eIsoRegionId)[4], unsigned short (&eNonIsoRank)[4],
73  unsigned short (&eNonIsoCardId)[4], unsigned short (&eNonIsoRegionId)[4],
74  unsigned short (&MIPbits)[7][2], unsigned short (&Qbits)[7][2],
75  unsigned short (&SFP)[2][4]) const {
76 
77  for (int i = 0; i < 7; i++) {
78  for (int j = 0; j < 2; j++) {
79  MIPbits[i][j] = (SFP[0][0] >> ((2 * i) + j)) & 0x1;
80  Qbits[i][j] = (SFP[1][0] >> ((2 * i) + j)) & 0x1;
81  }
82  }
83 
84  eIsoRank[0] = SFP[0][1] & 0x3f;
85  eIsoRank[1] = ((SFP[0][1] >> 10) & 0x7) | ((SFP[0][2] >> 7) & 0x38);
86  eIsoRank[2] = SFP[1][1] & 0x3f;
87  eIsoRank[3] = ((SFP[1][1] >> 10) & 0x7) | ((SFP[1][2] >> 7) & 0x38);
88 
89  eNonIsoRank[0] = SFP[0][2] & 0x3f;
90  eNonIsoRank[1] = SFP[0][3] & 0x3f;
91  eNonIsoRank[2] = SFP[1][2] & 0x3f;
92  eNonIsoRank[3] = SFP[1][3] & 0x3f;
93 
94  eIsoRegionId[0] = (SFP[0][1] >> 6) & 0x1;
95  eIsoRegionId[1] = (SFP[0][2] >> 13) & 0x1;
96  eIsoRegionId[2] = (SFP[1][1] >> 6) & 0x1;
97  eIsoRegionId[3] = (SFP[1][2] >> 13) & 0x1;
98 
99  eNonIsoRegionId[0] = (SFP[0][2] >> 6) & 0x1;
100  eNonIsoRegionId[1] = (SFP[0][3] >> 6) & 0x1;
101  eNonIsoRegionId[2] = (SFP[1][2] >> 6) & 0x1;
102  eNonIsoRegionId[3] = (SFP[1][3] >> 6) & 0x1;
103 
104  eIsoCardId[0] = (SFP[0][1] >> 7) & 0x7;
105  eIsoCardId[1] = (SFP[0][3] >> 10) & 0x7;
106  eIsoCardId[2] = (SFP[1][1] >> 7) & 0x7;
107  eIsoCardId[3] = (SFP[1][3] >> 10) & 0x7;
108 
109  eNonIsoCardId[0] = (SFP[0][2] >> 7) & 0x7;
110  eNonIsoCardId[1] = (SFP[0][3] >> 7) & 0x7;
111  eNonIsoCardId[2] = (SFP[1][2] >> 7) & 0x7;
112  eNonIsoCardId[3] = (SFP[1][3] >> 7) & 0x7;
113 }
114 
116 // RC arrays are RC[receiver card number<7][region<2]
117 // HF arrays are HF[eta<4][HF region<2]
118 // SFP arrays are SFP[cycle<2][sfp number<4]
119 
120 void SourceCardRouting::RC56HFtoSFP(unsigned short (&RC)[7][2],
121  unsigned short (&RCof)[7][2],
122  unsigned short (&RCtau)[7][2],
123  unsigned short (&HF)[4][2],
124  unsigned short (&HFQ)[4][2],
125  unsigned short (&SFP)[2][4]) const {
126 
127  SFP[0][0] = (RC[5][0] & 0x3ff) | ((RCof[5][0] & 0x1) << 10) |
128  ((RCtau[5][0] & 0x1) << 11) | ((HFQ[0][0] & 0x1) << 12) |
129  ((HFQ[1][0] & 0x01) << 13) | ((HF[0][0] & 0x01) << 14);
130  SFP[1][0] = 0x8000 | (RC[5][1] & 0x3ff) | ((RCof[5][1] & 0x1) << 10) |
131  ((RCtau[5][1] & 0x1) << 11) | ((HFQ[2][0] & 0x1) << 12) |
132  ((HFQ[3][0] & 0x01) << 13) | ((HF[2][0] & 0x01) << 14);
133  SFP[0][1] = (RC[6][0] & 0x3ff) | ((RCof[6][0] & 0x1) << 10) |
134  ((RCtau[6][0] & 0x1) << 11) | ((HFQ[0][1] & 0x1) << 12) |
135  ((HFQ[1][1] & 0x01) << 13) | ((HF[0][1] & 0x01) << 14);
136  SFP[1][1] = 0x8000 | (RC[6][1] & 0x3ff) | ((RCof[6][1] & 0x1) << 10) |
137  ((RCtau[6][1] & 0x1) << 11) | ((HFQ[2][1] & 0x1) << 12) |
138  ((HFQ[3][1] & 0x01) << 13) | ((HF[2][1] & 0x01) << 14);
139  SFP[0][2] = ((HF[0][0] >> 1) & 0x7f) | ((HF[1][0] & 0xff) << 7);
140  SFP[1][2] = 0x8000 | ((HF[2][0] >> 1) & 0x7f) | ((HF[3][0] & 0xff) << 7);
141  SFP[0][3] = ((HF[0][1] >> 1) & 0x7f) | ((HF[1][1] & 0xff) << 7);
142  SFP[1][3] = 0x8000 | ((HF[2][1] >> 1) & 0x7f) | ((HF[3][1] & 0xff) << 7);
143 }
144 
146 // RC arrays are RC[receiver card number<7][region<2]
147 // HF arrays are HF[eta<4][HF region<2]
148 // SFP arrays are SFP[cycle<2][sfp number<4]
149 
150 void SourceCardRouting::SFPtoRC56HF(unsigned short (&RC)[7][2],
151  unsigned short (&RCof)[7][2],
152  unsigned short (&RCtau)[7][2],
153  unsigned short (&HF)[4][2],
154  unsigned short (&HFQ)[4][2],
155  unsigned short (&SFP)[2][4]) const {
156 
157  RC[5][0] = SFP[0][0] & 0x3ff;
158  RC[5][1] = SFP[1][0] & 0x3ff;
159  RC[6][0] = SFP[0][1] & 0x3ff;
160  RC[6][1] = SFP[1][1] & 0x3ff;
161 
162  RCof[5][0] = (SFP[0][0] >> 10) & 0x1;
163  RCof[5][1] = (SFP[1][0] >> 10) & 0x1;
164  RCof[6][0] = (SFP[0][1] >> 10) & 0x1;
165  RCof[6][1] = (SFP[1][1] >> 10) & 0x1;
166 
167  RCtau[5][0] = (SFP[0][0] >> 11) & 0x1;
168  RCtau[5][1] = (SFP[1][0] >> 11) & 0x1;
169  RCtau[6][0] = (SFP[0][1] >> 11) & 0x1;
170  RCtau[6][1] = (SFP[1][1] >> 11) & 0x1;
171 
172  HFQ[0][0] = (SFP[0][0] >> 12) & 0x1;
173  HFQ[1][0] = (SFP[0][0] >> 13) & 0x1;
174  HFQ[2][0] = (SFP[1][0] >> 12) & 0x1;
175  HFQ[3][0] = (SFP[1][0] >> 13) & 0x1;
176 
177  HFQ[0][1] = (SFP[0][1] >> 12) & 0x1;
178  HFQ[1][1] = (SFP[0][1] >> 13) & 0x1;
179  HFQ[2][1] = (SFP[1][1] >> 12) & 0x1;
180  HFQ[3][1] = (SFP[1][1] >> 13) & 0x1;
181 
182  HF[0][0] = ((SFP[0][2] & 0x7f) << 1) | ((SFP[0][0] >> 14) & 0x01);
183  HF[1][0] = (SFP[0][2] >> 7) & 0xff;
184  HF[2][0] = ((SFP[1][2] & 0x7f) << 1) | ((SFP[1][0] >> 14) & 0x01);
185  HF[3][0] = (SFP[1][2] >> 7) & 0xff;
186 
187  HF[0][1] = ((SFP[0][3] & 0x7f) << 1) | ((SFP[0][1] >> 14) & 0x01);
188  HF[1][1] = (SFP[0][3] >> 7) & 0xff;
189  HF[2][1] = ((SFP[1][3] & 0x7f) << 1) | ((SFP[1][1] >> 14) & 0x01);
190  HF[3][1] = (SFP[1][3] >> 7) & 0xff;
191 }
192 
194 // RC arrays are RC[receiver card number<7][region<2]
195 // SFP arrays are SFP[cycle<2][sfp number<4]
196 
197 void SourceCardRouting::RC012toSFP(unsigned short (&RC)[7][2],
198  unsigned short (&RCof)[7][2],
199  unsigned short (&RCtau)[7][2],
200  unsigned short (&SFP)[2][4]) const {
201 
202  SFP[0][0] = (RC[0][0] & 0x3ff) | ((RCof[0][0] & 0x1) << 10) |
203  ((RCtau[0][0] & 0x1) << 11) | ((RC[2][0] & 0x7) << 12);
204  SFP[1][0] = 0x8000 | (RC[0][1] & 0x3ff) | ((RCof[0][1] & 0x1) << 10) |
205  ((RCtau[0][1] & 0x1) << 11) | ((RC[2][1] & 0x7) << 12);
206 
207  SFP[0][1] = (RC[1][0] & 0x3ff) | ((RCof[1][0] & 0x1) << 10) |
208  ((RCtau[1][0] & 0x1) << 11) | ((RC[2][0] & 0x38) << 9);
209  SFP[1][1] = 0x8000 | (RC[1][1] & 0x3ff) | ((RCof[1][1] & 0x1) << 10) |
210  ((RCtau[1][1] & 0x1) << 11) | ((RC[2][1] & 0x38) << 9);
211 
212  SFP[0][2] = (RC[0][0] & 0x3ff) | ((RCof[0][0] & 0x1) << 10) |
213  ((RCtau[0][0] & 0x1) << 11);
214  SFP[1][2] = 0x8000 | (RC[0][1] & 0x3ff) | ((RCof[0][1] & 0x1) << 10) |
215  ((RCtau[0][1] & 0x1) << 11);
216 
217  SFP[0][3] = (RC[1][0] & 0x3ff) | ((RCof[1][0] & 0x1) << 10) |
218  ((RCtau[1][0] & 0x1) << 11);
219  SFP[1][3] = 0x8000 | (RC[1][1] & 0x3ff) | ((RCof[1][1] & 0x1) << 10) |
220  ((RCtau[1][1] & 0x1) << 11);
221 }
222 
224 // RC arrays are RC[receiver card number<7][region<2]
225 // SFP arrays are SFP[cycle<2][sfp number<4]
226 
227 void SourceCardRouting::SFPtoRC012(unsigned short (&RC)[7][2],
228  unsigned short (&RCof)[7][2],
229  unsigned short (&RCtau)[7][2],
230  unsigned short (&SFP)[2][4]) const {
231 
232  RC[0][0] = SFP[0][0] & 0x3ff;
233  RC[0][1] = SFP[1][0] & 0x3ff;
234  RC[1][0] = SFP[0][1] & 0x3ff;
235  RC[1][1] = SFP[1][1] & 0x3ff;
236  RC[2][0] = (RC[2][0] & 0x3c0) | ((SFP[0][0] & 0x7000) >> 12) |
237  ((SFP[0][1] & 0x7000) >> 9);
238  RC[2][1] = (RC[2][1] & 0x3c0) | ((SFP[1][0] & 0x7000) >> 12) |
239  ((SFP[1][1] & 0x7000) >> 9);
240 
241  RCof[0][0] = (SFP[0][0] >> 10) & 0x1;
242  RCof[0][1] = (SFP[1][0] >> 10) & 0x1;
243  RCof[1][0] = (SFP[0][1] >> 10) & 0x1;
244  RCof[1][1] = (SFP[1][1] >> 10) & 0x1;
245 
246  RCtau[0][0] = (SFP[0][0] >> 11) & 0x1;
247  RCtau[0][1] = (SFP[1][0] >> 11) & 0x1;
248  RCtau[1][0] = (SFP[0][1] >> 11) & 0x1;
249  RCtau[1][1] = (SFP[1][1] >> 11) & 0x1;
250 }
251 
253 // RC arrays are RC[receiver card number<7][region<2]
254 // SFP arrays are SFP[cycle<2][sfp number<4]
255 
256 void SourceCardRouting::RC234toSFP(unsigned short (&RC)[7][2],
257  unsigned short (&RCof)[7][2],
258  unsigned short (&RCtau)[7][2],
259  unsigned short (&sisterRC)[7][2],
260  unsigned short (&sisterRCof)[7][2],
261  unsigned short (&sisterRCtau)[7][2],
262  unsigned short (&SFP)[2][4]) const {
263 
264  SFP[0][0] = (RC[3][0] & 0x3ff) | ((RCof[3][0] & 0x1) << 10) |
265  ((RCtau[3][0] & 0x1) << 11) | ((RC[2][0] & 0x1c0) << 6);
266  SFP[1][0] = 0x8000 | (RC[3][1] & 0x3ff) | ((RCof[3][1] & 0x1) << 10) |
267  ((RCtau[3][1] & 0x1) << 11) | ((RC[2][1] & 0x1c0) << 6);
268 
269  SFP[0][1] = (RC[4][0] & 0x3ff) | ((RCof[4][0] & 0x1) << 10) |
270  ((RCtau[4][0] & 0x1) << 11) | ((RC[2][0] & 0x200) << 3) |
271  ((RCof[2][0] & 0x1) << 13) | ((RCtau[2][0] & 0x1) << 14);
272  SFP[1][1] = 0x8000 | (RC[4][1] & 0x3ff) | ((RCof[4][1] & 0x1) << 10) |
273  ((RCtau[4][1] & 0x1) << 11) | ((RC[2][1] & 0x200) << 3) |
274  ((RCof[2][1] & 0x1) << 13) | ((RCtau[2][1] & 0x1) << 14);
275 
276  SFP[0][2] = (sisterRC[3][0] & 0x3ff) | ((sisterRCof[3][0] & 0x1) << 10) |
277  ((sisterRCtau[3][0] & 0x1) << 11) |
278  ((sisterRC[2][0] & 0x1c0) << 6);
279  SFP[1][2] =
280  0x8000 | (sisterRC[3][1] & 0x3ff) | ((sisterRCof[3][1] & 0x1) << 10) |
281  ((sisterRCtau[3][1] & 0x1) << 11) | ((sisterRC[2][1] & 0x1c0) << 6);
282 
283  SFP[0][3] =
284  (sisterRC[4][0] & 0x3ff) | ((sisterRCof[4][0] & 0x1) << 10) |
285  ((sisterRCtau[4][0] & 0x1) << 11) | ((sisterRC[2][0] & 0x200) << 3) |
286  ((sisterRCof[2][0] & 0x1) << 13) | ((sisterRCtau[2][0] & 0x1) << 14);
287  SFP[1][3] =
288  0x8000 | (sisterRC[4][1] & 0x3ff) | ((sisterRCof[4][1] & 0x1) << 10) |
289  ((sisterRCtau[4][1] & 0x1) << 11) | ((sisterRC[2][1] & 0x200) << 3) |
290  ((sisterRCof[2][1] & 0x1) << 13) | ((sisterRCtau[2][1] & 0x1) << 14);
291 }
292 
294 // RC arrays are RC[receiver card number<7][region<2]
295 // SFP arrays are SFP[cycle<2][sfp number<4]
296 
297 void SourceCardRouting::SFPtoRC234(unsigned short (&RC)[7][2],
298  unsigned short (&RCof)[7][2],
299  unsigned short (&RCtau)[7][2],
300  unsigned short (&sisterRC)[7][2],
301  unsigned short (&sisterRCof)[7][2],
302  unsigned short (&sisterRCtau)[7][2],
303  unsigned short (&SFP)[2][4]) const {
304 
305  RC[2][0] = (RC[2][0] & 0x3f) | ((SFP[0][0] & 0x7000) >> 6) |
306  ((SFP[0][1] & 0x1000) >> 3);
307  RC[3][0] = SFP[0][0] & 0x3ff;
308  RC[4][0] = SFP[0][1] & 0x3ff;
309  RC[2][1] = (RC[2][1] & 0x3f) | ((SFP[1][0] & 0x7000) >> 6) |
310  ((SFP[1][1] & 0x1000) >> 3);
311  RC[3][1] = SFP[1][0] & 0x3ff;
312  RC[4][1] = SFP[1][1] & 0x3ff;
313 
314  RCof[2][0] = (SFP[0][1] >> 13) & 0x1;
315  RCof[3][0] = (SFP[0][0] >> 10) & 0x1;
316  RCof[4][0] = (SFP[0][1] >> 10) & 0x1;
317  RCof[2][1] = (SFP[1][1] >> 13) & 0x1;
318  RCof[3][1] = (SFP[1][0] >> 10) & 0x1;
319  RCof[4][1] = (SFP[1][1] >> 10) & 0x1;
320 
321  RCtau[2][0] = (SFP[0][1] >> 14) & 0x1;
322  RCtau[3][0] = (SFP[0][0] >> 11) & 0x1;
323  RCtau[4][0] = (SFP[0][1] >> 11) & 0x1;
324  RCtau[2][1] = (SFP[1][1] >> 14) & 0x1;
325  RCtau[3][1] = (SFP[1][0] >> 11) & 0x1;
326  RCtau[4][1] = (SFP[1][1] >> 11) & 0x1;
327 
328  sisterRC[2][0] = (sisterRC[2][0] & ~0x3C0) | ((SFP[0][2] & 0x7000) >> 6) |
329  ((SFP[0][3] & 0x1000) >> 3);
330  sisterRC[3][0] = SFP[0][2] & 0x3ff;
331  sisterRC[4][0] = SFP[0][3] & 0x3ff;
332  sisterRC[2][1] = (sisterRC[2][1] & ~0x3C0) | ((SFP[1][2] & 0x7000) >> 6) |
333  ((SFP[1][3] & 0x1000) >> 3);
334  sisterRC[3][1] = SFP[1][2] & 0x3ff;
335  sisterRC[4][1] = SFP[1][3] & 0x3ff;
336 
337  sisterRCof[2][0] = (SFP[0][3] >> 13) & 0x1;
338  sisterRCof[3][0] = (SFP[0][2] >> 10) & 0x1;
339  sisterRCof[4][0] = (SFP[0][3] >> 10) & 0x1;
340  sisterRCof[2][1] = (SFP[1][3] >> 13) & 0x1;
341  sisterRCof[3][1] = (SFP[1][2] >> 10) & 0x1;
342  sisterRCof[4][1] = (SFP[1][3] >> 10) & 0x1;
343 
344  sisterRCtau[2][0] = (SFP[0][3] >> 14) & 0x1;
345  sisterRCtau[3][0] = (SFP[0][2] >> 11) & 0x1;
346  sisterRCtau[4][0] = (SFP[0][3] >> 11) & 0x1;
347  sisterRCtau[2][1] = (SFP[1][3] >> 14) & 0x1;
348  sisterRCtau[3][1] = (SFP[1][2] >> 11) & 0x1;
349  sisterRCtau[4][1] = (SFP[1][3] >> 11) & 0x1;
350 }
351 
354 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
355 // SFP arrays are SFP[cycle<2][sfp number<4]
356 
357 void SourceCardRouting::SFPtoVHDCI(int RoutingMode, unsigned short (&SFP)[2][4],
358  unsigned long (&VHDCI)[2][2]) const {
359 
360  unsigned short sfp_reverse[2][4] = {{0}};
361 
362  for (int i = 0; i < 2; i++) {
363  for (int j = 0; j < 4; j++) {
364  for (int k = 0; k < 16; k++) {
365  sfp_reverse[i][j] =
366  sfp_reverse[i][j] | (((SFP[i][j] >> k) & 0x01) << (15 - k));
367  }
368  // std::cout <<hex<< SFP[i][j]<<'\t'<<sfp_reverse[i][j]<<std::endl;
369  }
370  }
371 
372  switch (RoutingMode) {
373  case 0:
374  VHDCI[0][0] = (SFP[0][1] & 0x3ff) | ((SFP[0][1] & 0x1c00) << 1) |
375  ((SFP[0][2] & 0x3c00) << 4) | ((SFP[0][3] & 0x1c00) << 8) |
376  ((SFP[0][0] & 0xff) << 22);
377  VHDCI[0][1] = (SFP[1][1] & 0x3ff) | ((SFP[1][1] & 0x1c00) << 1) |
378  ((SFP[1][2] & 0x3c00) << 4) | ((SFP[1][3] & 0x1c00) << 8) |
379  ((SFP[1][0] & 0xff) << 22);
380  VHDCI[1][0] = (SFP[0][2] & 0x3ff) | ((SFP[0][3] & 0x3ff) << 11) |
381  ((SFP[0][0] & 0x3f00) << 14);
382  VHDCI[1][1] = (SFP[1][2] & 0x3ff) | ((SFP[1][3] & 0x3ff) << 11) |
383  ((SFP[1][0] & 0x3f00) << 14);
384  break;
385  case 1:
386  VHDCI[0][0] = (SFP[0][0] & 0xfff) | ((SFP[0][1] & 0x7) << 12) |
387  ((SFP[0][2] & 0x80) << 10) | ((SFP[0][0] & 0x4000) << 4) |
388  ((sfp_reverse[0][1] & 0xc) << 17) |
389  ((sfp_reverse[0][0] & 0xc) << 19) |
390  ((sfp_reverse[0][1] & 0x1ff0) << 19);
391  VHDCI[0][1] = (SFP[1][0] & 0xfff) | ((SFP[1][1] & 0x7) << 12) |
392  ((SFP[1][2] & 0x80) << 10) | ((SFP[1][0] & 0x4000) << 4) |
393  ((sfp_reverse[1][1] & 0xc) << 17) |
394  ((sfp_reverse[1][0] & 0xc) << 19) |
395  ((sfp_reverse[1][1] & 0x1ff0) << 19);
396 
397  VHDCI[1][0] = (SFP[0][1] & 0x4000) | ((SFP[0][3] & 0x80) << 24);
398  VHDCI[1][1] = (SFP[1][1] & 0x4000) | ((SFP[1][3] & 0x80) << 24);
399 
400  for (int i = 0; i < 7; i++) {
401  VHDCI[1][0] = VHDCI[1][0] | (((SFP[0][2] >> i) & 0x1) << (2 * i)) |
402  (((SFP[0][2] >> (i + 8)) & 0x1) << ((2 * i) + 1)) |
403  (((sfp_reverse[0][3] >> (i + 1)) & 0x1) << ((2 * i) + 17)) |
404  (((sfp_reverse[0][3] >> (i + 9)) & 0x1) << ((2 * i) + 18));
405  VHDCI[1][1] = VHDCI[1][1] | (((SFP[1][2] >> i) & 0x1) << (2 * i)) |
406  (((SFP[1][2] >> (i + 8)) & 0x1) << ((2 * i) + 1)) |
407  (((sfp_reverse[1][3] >> (i + 1)) & 0x1) << ((2 * i) + 17)) |
408  (((sfp_reverse[1][3] >> (i + 9)) & 0x1) << ((2 * i) + 18));
409  }
410  break;
411  case 2:
412  VHDCI[0][0] = (SFP[0][0] & 0xfff) | ((SFP[0][1] & 0x7) << 12) |
413  ((sfp_reverse[0][1] & 0xe) << 16) |
414  ((sfp_reverse[0][0] & 0xe) << 19) |
415  ((sfp_reverse[0][1] & 0x1ff0) << 19);
416  VHDCI[0][1] = (SFP[1][0] & 0xfff) | ((SFP[1][1] & 0x7) << 12) |
417  ((sfp_reverse[1][1] & 0xe) << 16) |
418  ((sfp_reverse[1][0] & 0xe) << 19) |
419  ((sfp_reverse[1][1] & 0x1ff0) << 19);
420  VHDCI[1][0] = 0;
421  VHDCI[1][1] = 0;
422  break;
423  case 3:
424  VHDCI[0][0] = ((SFP[0][0] >> 12) & 0x7) | ((SFP[0][1] >> 9) & 0x38) |
425  ((SFP[0][0] & 0x1ff) << 6) |
426  ((sfp_reverse[0][1] & 0xfff0) << 13) |
427  ((sfp_reverse[0][0] & 0x70) << 25);
428  VHDCI[0][1] = ((SFP[1][0] >> 12) & 0x7) | ((SFP[1][1] >> 9) & 0x38) |
429  ((SFP[1][0] & 0x1ff) << 6) |
430  ((sfp_reverse[1][1] & 0xfff0) << 13) |
431  ((sfp_reverse[1][0] & 0x70) << 25);
432 
433  VHDCI[1][0] = ((SFP[0][2] >> 12) & 0x7) | ((SFP[0][3] >> 9) & 0x38) |
434  ((SFP[0][2] & 0x1ff) << 6) |
435  ((sfp_reverse[0][3] & 0xfff0) << 13) |
436  ((sfp_reverse[0][2] & 0x70) << 25);
437  VHDCI[1][1] = ((SFP[1][2] >> 12) & 0x7) | ((SFP[1][3] >> 9) & 0x38) |
438  ((SFP[1][2] & 0x1ff) << 6) |
439  ((sfp_reverse[1][3] & 0xfff0) << 13) |
440  ((sfp_reverse[1][2] & 0x70) << 25);
441  break;
442  default:
443  VHDCI[0][0] = 0;
444  VHDCI[0][1] = 0;
445  VHDCI[1][0] = 0;
446  VHDCI[1][1] = 0;
447  }
448 }
449 
451 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
452 // SFP arrays are SFP[cycle<2][sfp number<4]
453 void SourceCardRouting::VHDCItoSFP(int RoutingMode, unsigned short (&SFP)[2][4],
454  unsigned long (&VHDCI)[2][2]) const {
455 
456  unsigned short VHDCI_reverse[2][4] = {{0}};
457 
458  for (int i = 0; i < 2; i++) {
459  for (int j = 0; j < 2; j++) {
460  for (int k = 0; k < 32; k++) {
461  VHDCI_reverse[i][j] =
462  VHDCI_reverse[i][j] | (((VHDCI[i][j] >> k) & 0x01) << (31 - k));
463  }
464  }
465  }
466 
467  switch (RoutingMode) {
468  case 0:
469  SFP[0][0] = ((VHDCI[0][0] >> 22) & 0xff) | ((VHDCI[1][0] >> 14) & 0x3f00);
470  SFP[1][0] =
471  0x8000 | ((VHDCI[0][1] >> 22) & 0xff) | ((VHDCI[1][1] >> 14) & 0x3f00);
472  SFP[0][1] = (VHDCI[0][0] & 0x3ff) | ((VHDCI[0][0] >> 1) & 0x1c00);
473  SFP[1][1] = 0x8000 | (VHDCI[0][1] & 0x3ff) | ((VHDCI[0][1] >> 1) & 0x1c00);
474  SFP[0][2] = (VHDCI[1][0] & 0x3ff) | ((VHDCI[0][0] >> 4) & 0x3c00);
475  SFP[1][2] = 0x8000 | (VHDCI[1][1] & 0x3ff) | ((VHDCI[0][1] >> 4) & 0x3c00);
476  SFP[0][3] = ((VHDCI[1][0] >> 11) & 0x3ff) | ((VHDCI[0][0] >> 8) & 0x1c00);
477  SFP[1][3] =
478  0x8000 | ((VHDCI[1][1] >> 11) & 0x3ff) | ((VHDCI[0][1] >> 8) & 0x1c00);
479  break;
480  case 1:
481  SFP[0][0] = (VHDCI[0][0] & 0xfff) | ((VHDCI_reverse[0][0] & 0x600) << 3) |
482  ((VHDCI_reverse[0][0] & 0x2000) << 1);
483  SFP[1][0] = 0x8000 | (VHDCI[0][1] & 0xfff) |
484  ((VHDCI_reverse[0][1] & 0x600) << 3) |
485  ((VHDCI_reverse[0][1] & 0x2000) << 1);
486  SFP[0][1] = ((VHDCI[0][0] & 0x7000) >> 12) |
487  ((VHDCI_reverse[0][0] & 0x1ff) << 3) |
488  ((VHDCI_reverse[0][0] & 0x1800) << 1) | (VHDCI[1][0] & 0x4000);
489  SFP[1][1] = 0x8000 | ((VHDCI[0][1] & 0x7000) >> 12) |
490  ((VHDCI_reverse[0][1] & 0x1ff) << 3) |
491  ((VHDCI_reverse[0][1] & 0x1800) << 1) | (VHDCI[1][1] & 0x4000);
492 
493  SFP[0][2] = ((VHDCI[0][0] & 0x20000) >> 10);
494  SFP[1][2] = 0x8000 | ((VHDCI[0][1] & 0x20000) >> 10);
495  SFP[0][3] = ((VHDCI[1][0] & 0x20000) >> 3);
496  SFP[1][3] = 0x8000 | ((VHDCI[1][1] & 0x20000) >> 3);
497  for (int i = 0; i < 7; i++) {
498  SFP[0][2] = SFP[0][2] | (((VHDCI[1][0] >> (2 * i)) & 0x1) << i) |
499  (((VHDCI[1][0] >> ((2 * i) + 1)) & 0x1) << (i + 8));
500  SFP[1][2] = SFP[1][2] | (((VHDCI[1][1] >> (2 * i)) & 0x1) << i) |
501  (((VHDCI[1][1] >> ((2 * i) + 1)) & 0x1) << (i + 8));
502  SFP[0][3] = SFP[0][3] |
503  (((VHDCI_reverse[1][0] >> ((2 * i) + 1)) & 0x1) << i) |
504  (((VHDCI_reverse[1][0] >> (2 * i)) & 0x1) << (i + 7));
505  SFP[1][3] = SFP[1][3] |
506  (((VHDCI_reverse[1][1] >> ((2 * i) + 1)) & 0x1) << i) |
507  (((VHDCI_reverse[1][1] >> (2 * i)) & 0x1) << (i + 7));
508  }
509  break;
510  case 2:
511  SFP[0][0] = (VHDCI[0][0] & 0xfff) | ((VHDCI_reverse[0][0] & 0xe00) << 3);
512  SFP[1][0] =
513  0x8000 | (VHDCI[0][1] & 0xfff) | ((VHDCI_reverse[0][1] & 0xe00) << 3);
514  SFP[0][1] = ((VHDCI[0][0] & 0x7000) >> 12) |
515  ((VHDCI_reverse[0][0] & 0x1ff) << 3) |
516  (VHDCI_reverse[0][0] & 0x7000);
517  SFP[1][1] = 0x8000 | ((VHDCI[0][1] & 0x7000) >> 12) |
518  ((VHDCI_reverse[0][1] & 0x1ff) << 3) |
519  (VHDCI_reverse[0][1] & 0x7000);
520  SFP[0][2] = (VHDCI[0][0] & 0xfff);
521  SFP[1][2] = 0x8000 | (VHDCI[0][1] & 0xfff);
522  SFP[0][3] =
523  ((VHDCI[0][0] & 0x7000) >> 12) | ((VHDCI_reverse[0][0] & 0x1ff) << 3);
524  SFP[1][3] = 0x8000 | ((VHDCI[0][1] & 0x7000) >> 12) |
525  ((VHDCI_reverse[0][1] & 0x1ff) << 3);
526  break;
527  case 3:
528  SFP[0][0] = ((VHDCI[0][0] & 0x7fc0) >> 6) |
529  ((VHDCI_reverse[0][0] & 0x7) << 9) |
530  ((VHDCI[0][0] & 0x7) << 12);
531  SFP[1][0] = 0x8000 | ((VHDCI[0][1] & 0x7fc0) >> 6) |
532  ((VHDCI_reverse[0][1] & 0x7) << 9) |
533  ((VHDCI[0][1] & 0x7) << 12);
534  SFP[0][1] =
535  ((VHDCI_reverse[0][0] & 0x7ff8) >> 3) | ((VHDCI[0][0] & 0x38) << 9);
536  SFP[1][1] = 0x8000 | ((VHDCI_reverse[0][1] & 0x7ff8) >> 3) |
537  ((VHDCI[0][1] & 0x38) << 9);
538  SFP[0][2] = ((VHDCI[1][0] & 0x7fc0) >> 6) |
539  ((VHDCI_reverse[1][0] & 0x7) << 9) |
540  ((VHDCI[1][0] & 0x7) << 12);
541  SFP[1][2] = 0x8000 | ((VHDCI[1][1] & 0x7fc0) >> 6) |
542  ((VHDCI_reverse[1][1] & 0x7) << 9) |
543  ((VHDCI[1][1] & 0x7) << 12);
544  SFP[0][3] =
545  ((VHDCI_reverse[1][0] & 0x7ff8) >> 3) | ((VHDCI[1][0] & 0x38) << 9);
546  SFP[1][3] = 0x8000 | ((VHDCI_reverse[1][1] & 0x7ff8) >> 3) |
547  ((VHDCI[1][1] & 0x38) << 9);
548  break;
549  default:
550  SFP[0][0] = 0;
551  SFP[1][0] = 0x8000;
552  SFP[0][1] = 0;
553  SFP[1][1] = 0x8000;
554  SFP[0][2] = 0;
555  SFP[1][2] = 0x8000;
556  SFP[0][3] = 0;
557  SFP[1][3] = 0x8000;
558  }
559 }
560 
563 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
564 // electron arrays are eIsoRank[candidate number<4]
565 // muon arrays are MIPbits[rec card number<7][region<2]
566 
568  unsigned short (&eIsoRank)[4], unsigned short (&eIsoCardId)[4],
569  unsigned short (&eIsoRegionId)[4], unsigned short (&eNonIsoRank)[4],
570  unsigned short (&eNonIsoCardId)[4], unsigned short (&eNonIsoRegionId)[4],
571  unsigned short (&MIPbits)[7][2], unsigned short (&Qbits)[7][2],
572  unsigned long (&VHDCI)[2][2]) const {
573 
574  unsigned short SFP[2][4] = {{0}};
575  EMUtoSFP(eIsoRank, eIsoCardId, eIsoRegionId, eNonIsoRank, eNonIsoCardId,
576  eNonIsoRegionId, MIPbits, Qbits, SFP);
577  SFPtoVHDCI(0, SFP, VHDCI);
578 }
579 
581 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
582 // electron arrays are eIsoRank[candidate number<4]
583 // muon arrays are MIPbits[rec card number<7][region<2]
584 
586  unsigned short (&eIsoRank)[4], unsigned short (&eIsoCardId)[4],
587  unsigned short (&eIsoRegionId)[4], unsigned short (&eNonIsoRank)[4],
588  unsigned short (&eNonIsoCardId)[4], unsigned short (&eNonIsoRegionId)[4],
589  unsigned short (&MIPbits)[7][2], unsigned short (&Qbits)[7][2],
590  unsigned long (&VHDCI)[2][2]) const {
591 
592  unsigned short SFP[2][4] = {{0}};
593  VHDCItoSFP(0, SFP, VHDCI);
594  SFPtoEMU(eIsoRank, eIsoCardId, eIsoRegionId, eNonIsoRank, eNonIsoCardId,
595  eNonIsoRegionId, MIPbits, Qbits, SFP);
596 }
597 
599 // RC arrays are RC[receiver card number<7][region<2]
600 // HF arrays are HF[eta<4][HF region<2]
601 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
602 
603 void SourceCardRouting::RC56HFtoVHDCI(unsigned short (&RC)[7][2],
604  unsigned short (&RCof)[7][2],
605  unsigned short (&RCtau)[7][2],
606  unsigned short (&HF)[4][2],
607  unsigned short (&HFQ)[4][2],
608  unsigned long (&VHDCI)[2][2]) const {
609 
610  unsigned short SFP[2][4] = {{0}};
611  RC56HFtoSFP(RC, RCof, RCtau, HF, HFQ, SFP);
612  SFPtoVHDCI(1, SFP, VHDCI);
613 }
614 
616 // RC arrays are RC[receiver card number<7][region<2]
617 // HF arrays are HF[eta<4][HF region<2]
618 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
619 
620 void SourceCardRouting::VHDCItoRC56HF(unsigned short (&RC)[7][2],
621  unsigned short (&RCof)[7][2],
622  unsigned short (&RCtau)[7][2],
623  unsigned short (&HF)[4][2],
624  unsigned short (&HFQ)[4][2],
625  unsigned long (&VHDCI)[2][2]) const {
626 
627  unsigned short SFP[2][4] = {{0}};
628  VHDCItoSFP(1, SFP, VHDCI);
629  SFPtoRC56HF(RC, RCof, RCtau, HF, HFQ, SFP);
630 }
631 
633 // RC arrays are RC[receiver card number<7][region<2]
634 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
635 
636 void SourceCardRouting::RC012toVHDCI(unsigned short (&RC)[7][2],
637  unsigned short (&RCof)[7][2],
638  unsigned short (&RCtau)[7][2],
639  unsigned long (&VHDCI)[2][2]) const {
640 
641  unsigned short SFP[2][4] = {{0}};
642  RC012toSFP(RC, RCof, RCtau, SFP);
643  SFPtoVHDCI(2, SFP, VHDCI);
644 }
645 
647 // RC arrays are RC[receiver card number<7][region<2]
648 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
649 
650 void SourceCardRouting::VHDCItoRC012(unsigned short (&RC)[7][2],
651  unsigned short (&RCof)[7][2],
652  unsigned short (&RCtau)[7][2],
653  unsigned long (&VHDCI)[2][2]) const {
654 
655  unsigned short SFP[2][4] = {{0}};
656  VHDCItoSFP(2, SFP, VHDCI);
657  SFPtoRC012(RC, RCof, RCtau, SFP);
658 }
659 
661 // RC arrays are RC[receiver card number<7][region<2]
662 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
663 
664 void SourceCardRouting::RC234toVHDCI(unsigned short (&RC)[7][2],
665  unsigned short (&RCof)[7][2],
666  unsigned short (&RCtau)[7][2],
667  unsigned short (&sisterRC)[7][2],
668  unsigned short (&sisterRCof)[7][2],
669  unsigned short (&sisterRCtau)[7][2],
670  unsigned long (&VHDCI)[2][2]) const {
671 
672  unsigned short SFP[2][4] = {{0}};
673  RC234toSFP(RC, RCof, RCtau, sisterRC, sisterRCof, sisterRCtau, SFP);
674  SFPtoVHDCI(3, SFP, VHDCI);
675 }
676 
678 // RC arrays are RC[receiver card number<7][region<2]
679 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
680 
681 void SourceCardRouting::VHDCItoRC234(unsigned short (&RC)[7][2],
682  unsigned short (&RCof)[7][2],
683  unsigned short (&RCtau)[7][2],
684  unsigned short (&sisterRC)[7][2],
685  unsigned short (&sisterRCof)[7][2],
686  unsigned short (&sisterRCtau)[7][2],
687  unsigned long (&VHDCI)[2][2]) const {
688 
689  unsigned short SFP[2][4] = {{0}};
690  VHDCItoSFP(3, SFP, VHDCI);
691  SFPtoRC234(RC, RCof, RCtau, sisterRC, sisterRCof, sisterRCtau, SFP);
692 }
693 
696 // electron arrays are eIsoRank[candidate number<4]
697 // muon arrays are MIPbits[rec card number<7][region<2]
698 
700  unsigned short &logicalCardID, unsigned short &eventNumber,
701  unsigned short (&eIsoRank)[4], unsigned short (&eIsoCardId)[4],
702  unsigned short (&eIsoRegionId)[4], unsigned short (&eNonIsoRank)[4],
703  unsigned short (&eNonIsoCardId)[4], unsigned short (&eNonIsoRegionId)[4],
704  unsigned short (&MIPbits)[7][2], unsigned short (&Qbits)[7][2],
705  std::string &dataString) const {
706 
707  unsigned long VHDCI[2][2] = {{0}};
708  EMUtoVHDCI(eIsoRank, eIsoCardId, eIsoRegionId, eNonIsoRank, eNonIsoCardId,
709  eNonIsoRegionId, MIPbits, Qbits, VHDCI);
710  VHDCItoSTRING(logicalCardID, eventNumber, dataString, VHDCI);
711 }
712 
714 // RC arrays are RC[receiver card number<7][region<2]
715 // HF arrays are HF[eta<4][HF region<2]
716 
718  unsigned short &logicalCardID, unsigned short &eventNumber,
719  unsigned short (&RC)[7][2], unsigned short (&RCof)[7][2],
720  unsigned short (&RCtau)[7][2], unsigned short (&HF)[4][2],
721  unsigned short (&HFQ)[4][2], std::string &dataString) const {
722 
723  unsigned long VHDCI[2][2] = {{0}};
724  RC56HFtoVHDCI(RC, RCof, RCtau, HF, HFQ, VHDCI);
725  VHDCItoSTRING(logicalCardID, eventNumber, dataString, VHDCI);
726 }
727 
729 // RC arrays are RC[receiver card number<7][region<2]
730 
731 void SourceCardRouting::RC012toSTRING(unsigned short &logicalCardID,
732  unsigned short &eventNumber,
733  unsigned short (&RC)[7][2],
734  unsigned short (&RCof)[7][2],
735  unsigned short (&RCtau)[7][2],
736  std::string &dataString) const {
737 
738  unsigned long VHDCI[2][2] = {{0}};
739  RC012toVHDCI(RC, RCof, RCtau, VHDCI);
740  VHDCItoSTRING(logicalCardID, eventNumber, dataString, VHDCI);
741 }
742 
744 // RC arrays are RC[receiver card number<7][region<2]
745 
747  unsigned short &logicalCardID, unsigned short &eventNumber,
748  unsigned short (&RC)[7][2], unsigned short (&RCof)[7][2],
749  unsigned short (&RCtau)[7][2], unsigned short (&sisterRC)[7][2],
750  unsigned short (&sisterRCof)[7][2], unsigned short (&sisterRCtau)[7][2],
751  std::string &dataString) const {
752 
753  unsigned long VHDCI[2][2] = {{0}};
754  RC234toVHDCI(RC, RCof, RCtau, sisterRC, sisterRCof, sisterRCtau, VHDCI);
755  VHDCItoSTRING(logicalCardID, eventNumber, dataString, VHDCI);
756 }
757 
760 // SFP arrays are SFP[cycle<2][sfp number<4]
761 void SourceCardRouting::SFPtoSTRING(unsigned short &logicalCardID,
762  unsigned short &eventNumber,
763  int RoutingMode,
764  unsigned short (&SFP)[2][4],
765  std::string &dataString) const {
766 
767  unsigned long VHDCI[2][2] = {{0}};
768  SFPtoVHDCI(RoutingMode, SFP, VHDCI);
769  VHDCItoSTRING(logicalCardID, eventNumber, dataString, VHDCI);
770 }
771 
774 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
775 void SourceCardRouting::STRINGtoVHDCI(unsigned short &logicalCardID,
776  unsigned short &eventNumber,
777  std::string &dataString,
778  unsigned long (&VHDCI)[2][2]) const {
779 
780  stringstream temp;
781 
782  if (!dataString.empty()) {
783  temp << dataString << std::endl;
784  temp >> dec >> eventNumber;
785  temp >> dec >> logicalCardID;
786  temp >> hex >> VHDCI[0][0];
787  temp >> hex >> VHDCI[0][1];
788  temp >> hex >> VHDCI[1][0];
789  temp >> hex >> VHDCI[1][1];
790  } else {
791  eventNumber = 65535;
792  logicalCardID = 65535;
793  VHDCI[0][0] = 0;
794  VHDCI[0][1] = 0;
795  VHDCI[1][0] = 0;
796  VHDCI[1][1] = 0;
797  }
798 }
799 
801 // VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
802 void SourceCardRouting::VHDCItoSTRING(unsigned short &logicalCardID,
803  unsigned short &eventNumber,
804  std::string &dataString,
805  unsigned long (&VHDCI)[2][2]) const {
806 
807  stringstream temp;
808 
809  temp << dec << eventNumber << '\t';
810  temp << dec << logicalCardID << '\t';
811  temp << hex << setw(8) << setfill('0') << VHDCI[0][0] << '\t';
812  temp << hex << setw(8) << setfill('0') << VHDCI[0][1] << '\t';
813  temp << hex << setw(8) << setfill('0') << VHDCI[1][0] << '\t';
814  temp << hex << setw(8) << setfill('0') << VHDCI[1][1] << std::endl;
815  dataString = temp.str();
816 }
817 
820 
822  unsigned short &logicalCardID, int &RoutingMode,
823  int &RCTCrateNumber) const {
824 
825  RCTCrateNumber = (logicalCardID >> 3);
826  if ((logicalCardID & 0x4) != 0)
827  RCTCrateNumber += 9;
828  RoutingMode = (logicalCardID & 0x3);
829 }
830 
832 
834  unsigned short &logicalCardID, int &RoutingMode,
835  int &RCTCrateNumber) const {
836 
837  logicalCardID = ((RCTCrateNumber % 9) << 3) |
838  (RCTCrateNumber > 8 ? 0x4 : 0x0) | (RoutingMode & 0x3);
839 }
840 
842 // These were going to be implimented but made things a lot more complicated
843 // than necessary
844 
845 /*
847 //RC arrays are RC[receiver card number<7][region<2]
848 //HF arrays are HF[eta<4][HF region<2]
849 //SFP arrays are SFP[cycle<2][sfp number<4]
850  void SourceCardRouting::RCtoSFP( int &RoutingMode,
851  unsigned short (&RC)[7][2],
852  unsigned short (&RCof)[7][2],
853  unsigned short (&RCtau)[7][2],
854  unsigned short (&sisterRC)[7][2],
855  unsigned short (&sisterRCof)[7][2],
856  unsigned short (&sisterRCtau)[7][2],
857  unsigned short (&HF)[4][2],
858  unsigned short (&HFQ)[4][2],
859  unsigned short (&SFP)[2][4] ){
860 
861  switch(RoutingMode){
862  case 1:
863  RC56HFtoSFP(RC,RCof,RCtau,HF,HFQ,SFP);
864  break;
865  case 2:
866  RC012toSFP(RC,RCof,RCtau,SFP);
867  break;
868  case 3:
869  RC234toSFP(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
870  break;
871  default:
872  break;
873  }
874 }
875 
876 
878 //RC arrays are RC[receiver card number<7][region<2]
879 //HF arrays are HF[eta<4][HF region<2]
880 //SFP arrays are SFP[cycle<2][sfp number<4]
881  void SourceCardRouting::SFPtoRC( int &RoutingMode,
882  unsigned short (&RC)[7][2],
883  unsigned short (&RCof)[7][2],
884  unsigned short (&RCtau)[7][2],
885  unsigned short (&sisterRC)[7][2],
886  unsigned short (&sisterRCof)[7][2],
887  unsigned short (&sisterRCtau)[7][2],
888  unsigned short (&HF)[4][2],
889  unsigned short (&HFQ)[4][2],
890  unsigned short (&SFP)[2][4] ){
891 
892  switch(RoutingMode){
893  case 1:
894  SFPtoRC56HF(RC,RCof,RCtau,HF,HFQ,SFP);
895  break;
896  case 2:
897  SFPtoRC012(RC,RCof,RCtau,SFP);
898  break;
899  case 3:
900  SFPtoRC234(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,SFP);
901  break;
902  default:
903  break;
904  }
905 }
906 */
907 
908 /*
910 //RC arrays are RC[receiver card number<7][region<2]
911 //HF arrays are HF[eta<4][HF region<2]
912 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
913  void SourceCardRouting::RCtoVHDCI( int &RoutingMode,
914  unsigned short (&RC)[7][2],
915  unsigned short (&RCof)[7][2],
916  unsigned short (&RCtau)[7][2],
917  unsigned short (&sisterRC)[7][2],
918  unsigned short (&sisterRCof)[7][2],
919  unsigned short (&sisterRCtau)[7][2],
920  unsigned short (&HF)[4][2],
921  unsigned short (&HFQ)[4][2],
922  unsigned long (&VHDCI)[2][2] ){
923 
924  switch(RoutingMode){
925  case 1:
926  RC56HFtoVHDCI(RC,RCof,RCtau,HF,HFQ,VHDCI);
927  break;
928  case 2:
929  RC012toVHDCI(RC,RCof,RCtau,VHDCI);
930  break;
931  case 3:
932  RC234toVHDCI(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,VHDCI);
933  break;
934  default:
935  break;
936  }
937 }
938 
940 //RC arrays are RC[receiver card number<7][region<2]
941 //HF arrays are HF[eta<4][HF region<2]
942 //VHDCI arrays are VHDCI[VHDCI<2][cycle<2]
943  void SourceCardRouting::VHDCItoRC( int &RoutingMode,
944  unsigned short (&RC)[7][2],
945  unsigned short (&RCof)[7][2],
946  unsigned short (&RCtau)[7][2],
947  unsigned short (&sisterRC)[7][2],
948  unsigned short (&sisterRCof)[7][2],
949  unsigned short (&sisterRCtau)[7][2],
950  unsigned short (&HF)[4][2],
951  unsigned short (&HFQ)[4][2],
952  unsigned long (&VHDCI)[2][2] ){
953 
954  switch(RoutingMode){
955  case 1:
956  VHDCItoRC56HF(RC,RCof,RCtau,HF,HFQ,VHDCI);
957  break;
958  case 2:
959  VHDCItoRC012(RC,RCof,RCtau,VHDCI);
960  break;
961  case 3:
962  VHDCItoRC234(RC,RCof,RCtau,sisterRC,sisterRCof,sisterRCtau,VHDCI);
963  break;
964  default:
965  break;
966  }
967 }
968 */
void SFPtoRC56HF(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], unsigned short(&SFP)[2][4]) const
void RC012toSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], std::string &dataString) const
void SFPtoRC012(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&SFP)[2][4]) const
void VHDCItoEMU(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned long(&VHDCI)[2][2]) const
void SFPtoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, int RoutingMode, unsigned short(&SFP)[2][4], std::string &dataString) const
void SFPtoEMU(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
void VHDCItoRC012(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void SFPtoRC234(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], unsigned short(&SFP)[2][4]) const
void RC234toSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], std::string &dataString) const
void RoutingModetoLogicalCardID(unsigned short &logicalCardID, int &RoutingMode, int &RCTCrateNumber) const
void RC234toSFP(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], unsigned short(&SFP)[2][4]) const
void EMUtoSFP(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned short(&SFP)[2][4]) const
void EMUtoVHDCI(unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], unsigned long(&VHDCI)[2][2]) const
void VHDCItoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, std::string &dataString, unsigned long(&VHDCI)[2][2]) const
void EMUtoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&eIsoRank)[4], unsigned short(&eIsoCardId)[4], unsigned short(&eIsoRegionId)[4], unsigned short(&eNonIsoRank)[4], unsigned short(&eNonIsoCardId)[4], unsigned short(&eNonIsoRegionId)[4], unsigned short(&MIPbits)[7][2], unsigned short(&Qbits)[7][2], std::string &dataString) const
void VHDCItoRC56HF(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], unsigned long(&VHDCI)[2][2]) const
void RC56HFtoVHDCI(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], unsigned long(&VHDCI)[2][2]) const
int k[5][pyjets_maxn]
void SFPtoVHDCI(int RoutingMode, unsigned short(&SFP)[2][4], unsigned long(&VHDCI)[2][2]) const
void RC56HFtoSTRING(unsigned short &logicalCardID, unsigned short &eventNumber, unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], std::string &dataString) const
void VHDCItoRC234(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void VHDCItoSFP(int RoutingMode, unsigned short(&SFP)[2][4], unsigned long(&VHDCI)[2][2]) const
void STRINGtoVHDCI(unsigned short &logicalCardID, unsigned short &eventNumber, std::string &dataString, unsigned long(&VHDCI)[2][2]) const
void RC012toSFP(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&SFP)[2][4]) const
void RC012toVHDCI(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void RC234toVHDCI(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&sisterRC)[7][2], unsigned short(&sisterRCof)[7][2], unsigned short(&sisterRCtau)[7][2], unsigned long(&VHDCI)[2][2]) const
void LogicalCardIDtoRoutingMode(unsigned short &logicalCardID, int &RoutingMode, int &RCTCrateNumber) const
void RC56HFtoSFP(unsigned short(&RC)[7][2], unsigned short(&RCof)[7][2], unsigned short(&RCtau)[7][2], unsigned short(&HF)[4][2], unsigned short(&HFQ)[4][2], unsigned short(&SFP)[2][4]) const