be972727 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
16 | /* $Id$ */ |
17 | |
18 | //_________________________________________________________________________ |
19 | // Implementation of local trigger board objects |
20 | // A local trigger board has as input a bit pattern and returns |
21 | // the local trigger response after comparison w/ a LUT |
22 | // |
23 | //*-- Author: Rachid Guernane (LPCCFd) |
24 | |
25 | #include "AliMUONLocalTriggerBoard.h" |
26 | #include "AliMUONTriggerLut.h" |
27 | #include "AliMUONTriggerConstants.h" |
28 | #include "AliLog.h" |
29 | |
30 | #include <TBits.h> |
31 | |
32 | #include <Riostream.h> |
33 | |
34 | //___________________________________________ |
35 | AliMUONLocalTriggerBoard::AliMUONLocalTriggerBoard() |
41922e78 |
36 | : AliMUONTriggerBoard() |
be972727 |
37 | { |
38 | fNumber = 0; |
39 | |
40 | for (Int_t i=0; i<2; i++) |
41 | for (Int_t j=0; j<4; j++) |
42 | { |
43 | fXY[i][j] = fXYU[i][j] = fXYD[i][j] = 0; |
44 | |
45 | fMask[i][j] = 0xFFFF; |
46 | } |
47 | |
48 | for (Int_t i=0; i<10; i++) fSwitch[i] = 0; |
49 | |
50 | fTC = kTRUE; |
51 | |
52 | fLUT = 0x0; |
53 | |
54 | for (Int_t i=0; i<5; i++) fMinDevStrip[i] = fMinDev[i] = fCoordY[i] = 0; |
55 | |
56 | fOutput = 0; |
57 | |
58 | fStripX11 = fStripY11 = fDev = 0; |
59 | |
60 | for (Int_t i=0; i<2; i++) fLutLpt[i] = fLutHpt[i] = fLutApt[i] = 0; |
61 | } |
62 | |
63 | //___________________________________________ |
41922e78 |
64 | AliMUONLocalTriggerBoard::AliMUONLocalTriggerBoard(const char *name, Int_t a, |
65 | AliMUONTriggerLut* lut) |
66 | : AliMUONTriggerBoard(name, a) |
be972727 |
67 | { |
68 | fNumber = 0; |
69 | |
70 | for (Int_t i=0; i<2; i++) |
71 | for (Int_t j=0; j<4; j++) |
72 | { |
73 | fXY[i][j] = fXYU[i][j] = fXYD[i][j] = 0; |
74 | |
75 | fMask[i][j] = 0xFFFF; |
76 | } |
77 | |
78 | for (Int_t i=0; i<10; i++) fSwitch[i] = 0; |
79 | |
80 | fTC = kTRUE; |
81 | |
41922e78 |
82 | fLUT = lut; |
be972727 |
83 | |
84 | for (Int_t i=0; i<5; i++) fMinDevStrip[i] = fMinDev[i] = fCoordY[i] = 0; |
85 | |
86 | fOutput = 0; |
87 | |
88 | fStripX11 = fStripY11 = fDev = 0; |
89 | |
90 | for (Int_t i=0; i<2; i++) fLutLpt[i] = fLutHpt[i] = fLutApt[i] = 0; |
91 | } |
92 | |
884a73f1 |
93 | //______________________________________________________________________________ |
94 | AliMUONLocalTriggerBoard::AliMUONLocalTriggerBoard(const AliMUONLocalTriggerBoard& right) |
95 | : AliMUONTriggerBoard(right) |
96 | { |
97 | /// Protected copy constructor (not implemented) |
98 | |
99 | AliFatal("Copy constructor not provided."); |
100 | } |
101 | |
102 | //______________________________________________________________________________ |
103 | AliMUONLocalTriggerBoard& |
104 | AliMUONLocalTriggerBoard::operator=(const AliMUONLocalTriggerBoard& right) |
105 | { |
106 | /// Protected assignement operator (not implemented) |
107 | |
108 | // check assignement to self |
109 | if (this == &right) return *this; |
110 | |
111 | AliFatal("Assignement operator not provided."); |
112 | |
113 | return *this; |
114 | } |
115 | |
be972727 |
116 | //___________________________________________ |
117 | void AliMUONLocalTriggerBoard::Reset() |
118 | { |
119 | for (Int_t i=0; i<2; i++) |
120 | for (Int_t j=0; j<4; j++) |
121 | fXY[i][j] = fXYU[i][j] = fXYD[i][j] = 0; |
122 | |
123 | fResponse = 0; |
124 | |
125 | for (Int_t i=0; i<5; i++) fMinDevStrip[i] = fMinDev[i] = fCoordY[i] = 0; |
126 | |
127 | fOutput = 0; |
128 | |
129 | fStripX11 = fStripY11 = fDev = 0; |
130 | |
131 | for (Int_t i=0; i<2; i++) fLutLpt[i] = fLutHpt[i] = fLutApt[i] = 0; |
132 | } |
133 | |
134 | //___________________________________________ |
135 | void AliMUONLocalTriggerBoard::Setbit(Int_t strip, Int_t cathode, Int_t chamber) |
136 | { |
137 | // 0 .. LBS : N-1 .. MSB |
138 | TBits w, m; |
139 | |
140 | UShort_t xy = fXY[cathode][chamber], mask = fMask[cathode][chamber]; |
141 | |
142 | w.Set(16,&xy); |
143 | m.Set(16,&mask); |
144 | |
145 | Int_t s = strip - int(strip / 16) * 16; |
146 | |
147 | w.SetBitNumber(s); |
148 | |
149 | w &= m; |
150 | |
151 | UShort_t value; |
152 | |
153 | w.Get(&value); |
154 | |
155 | fXY[cathode][chamber] = value; |
156 | } |
157 | |
8af755f4 |
158 | //___________________________________________ |
159 | void AliMUONLocalTriggerBoard::SetbitM(Int_t strip, Int_t cathode, Int_t chamber) |
160 | { |
161 | // 0 .. LBS : N-1 .. MSB |
162 | TBits w, m; |
163 | |
164 | UShort_t xy = fXY[cathode][chamber], mask = fMask[cathode][chamber]; |
165 | |
166 | w.Set(16,&xy); |
167 | m.Set(16,&mask); |
168 | |
169 | // Int_t s = strip - int(strip / 16) * 16; |
170 | |
171 | w.SetBitNumber(strip); |
172 | |
173 | w &= m; |
174 | |
175 | UShort_t value; |
176 | |
177 | w.Get(&value); |
178 | |
179 | fXY[cathode][chamber] = value; |
180 | } |
181 | |
be972727 |
182 | //___________________________________________ |
183 | void AliMUONLocalTriggerBoard::Pattern(Option_t *option) |
184 | { |
185 | TString op = option; |
186 | |
187 | if (op.Contains("X")) BP("X"); |
188 | |
189 | if (op.Contains("Y")) BP("Y"); |
190 | } |
191 | |
192 | |
193 | //___________________________________________ |
194 | void AliMUONLocalTriggerBoard::BP(Option_t *option) |
195 | { |
196 | // RESPECT THE OLD PRINTOUT FORMAT |
197 | |
198 | TString op = option; |
199 | |
8af755f4 |
200 | TString nn = GetName(); |
201 | |
be972727 |
202 | if (op.Contains("X")) |
203 | { |
204 | printf("-------- TRIGGER INPUT ---------\n"); |
205 | printf("===============================================================\n"); |
206 | printf(" 5432109876543210"); |
207 | |
208 | char *x[4] = {"XMC11","XMC12","XMC21","XMC22"}; |
209 | char *s[4] = {" ", |
210 | " ", |
211 | " ", |
212 | " "}; |
213 | |
214 | for (Int_t ch=0; ch<4; ch++) |
215 | { |
216 | printf("\n %s%s", x[ch], s[ch]); |
217 | |
218 | UShort_t xy = fXY[0][ch]; |
219 | |
220 | TBits w(16); w.Set(16,&xy); |
221 | |
222 | if (ch<2) cout << w; |
223 | else |
224 | { |
225 | UShort_t xyd = fXYD[0][ch], xyu = fXYU[0][ch]; |
226 | TBits dw(16), uw(16); dw.Set(16,&xyd); uw.Set(16,&xyu); |
227 | |
228 | TBits ew(32); |
229 | |
230 | for (Int_t i=0;i<16;i++) ew[i+8] = w[i]; |
231 | |
232 | for (Int_t i=0;i<8;i++) |
233 | { |
234 | ew[i] = dw[i+8]; // 8 MSB |
235 | ew[i+24] = uw[i]; // |
236 | } |
237 | |
238 | cout << ew; |
239 | } |
240 | } |
241 | |
242 | printf("\n "); |
243 | printf("10987654321098765432109876543210\n"); |
244 | } |
245 | |
246 | if (op.Contains("Y")) |
247 | { |
248 | printf("---------------------------------------------------------------\n"); |
249 | printf(" "); |
250 | |
251 | /* OLD NUMBERING STYLE */ |
252 | /**/ |
8af755f4 |
253 | Int_t idCircuit = 0, absidModule = 0; |
254 | |
255 | if (!(nn.Contains("Int"))) |
256 | { |
257 | idCircuit = AliMUONTriggerConstants::CircuitId(GetI()); |
258 | absidModule = TMath::Abs(Int_t(idCircuit/10)); |
259 | } |
260 | |
be972727 |
261 | Int_t iModule=0; |
8af755f4 |
262 | |
be972727 |
263 | for (Int_t i=0; i<63; i++) |
264 | { |
265 | if (AliMUONTriggerConstants::ModuleId(i)==absidModule) |
266 | { |
267 | iModule=i; |
268 | break; |
269 | } |
270 | } |
271 | |
272 | Int_t nStrip = AliMUONTriggerConstants::NstripY(iModule); |
273 | for (Int_t istrip=nStrip-1; istrip>=0; istrip--) { |
274 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); |
275 | if (istrip<10) printf("%i",istrip); |
276 | } |
277 | /**/ |
278 | /* */ |
279 | |
280 | UShort_t xyval = 0; |
281 | |
282 | if (fSwitch[1]) |
283 | { |
284 | xyval = fXY[1][0]; |
285 | TBits v11(8); v11.Set(8,&xyval); |
286 | printf("\n YMC11 "); |
287 | cout << v11; |
288 | |
289 | xyval = fXY[1][1]; |
290 | TBits v12(8); v12.Set(8,&xyval); |
291 | printf("\n YMC12 "); |
292 | cout << v12; |
293 | |
294 | xyval = fXY[1][2]; |
295 | TBits v21(8); v21.Set(8,&xyval); |
296 | printf("\n YMC21 "); |
297 | cout << v21; |
298 | |
299 | xyval = fXY[1][3]; |
300 | TBits v22(8); v22.Set(8,&xyval); |
301 | printf("\n YMC22 "); |
302 | cout << v22 << endl; |
303 | } |
304 | else |
305 | { |
306 | xyval = fXY[1][0]; |
307 | TBits v11(16); v11.Set(16,&xyval); |
308 | printf("\n YMC11 "); |
309 | cout << v11; |
310 | |
311 | xyval = fXY[1][1]; |
312 | TBits v12(16); v12.Set(16,&xyval); |
313 | printf("\n YMC12 "); |
314 | cout << v12; |
315 | |
316 | xyval = fXY[1][2]; |
317 | TBits v21(16); v21.Set(16,&xyval); |
318 | printf("\n YMC21 "); |
319 | cout << v21; |
320 | |
321 | xyval = fXY[1][3]; |
322 | TBits v22(16); v22.Set(16,&xyval); |
323 | printf("\n YMC22 "); |
324 | cout << v22 << endl; |
325 | } |
326 | |
be972727 |
327 | // tmp |
328 | printf("---------------------------------------------------------------"); |
329 | printf("\n upper part of circuit %i",idCircuit); |
330 | printf("\n UMC21 "); |
331 | xyval = fXYU[1][2]; |
332 | TBits wu21(16); wu21.Set(16,&xyval); |
333 | cout << wu21; |
334 | printf("\n UMC22 "); |
335 | xyval = fXYU[1][3]; |
336 | TBits wu22(16); wu22.Set(16,&xyval); |
337 | cout << wu22; |
338 | printf("\n lower part of circuit %i",idCircuit); |
339 | printf("\n LMC21 "); |
340 | xyval = fXYD[1][2]; |
341 | TBits wl21(16); wl21.Set(16,&xyval); |
342 | cout << wl21; |
343 | printf("\n LMC22 "); |
344 | xyval = fXYD[1][3]; |
345 | TBits wl22(16); wl22.Set(16,&xyval); |
346 | cout << wl22; |
347 | printf("\n"); |
348 | printf("===============================================================\n"); |
349 | } |
350 | } |
351 | |
352 | //___________________________________________ |
353 | void AliMUONLocalTriggerBoard::Conf() |
354 | { |
355 | cout << "Switch(" << GetName() << ")" |
356 | << " x2d = " << fSwitch[0] |
357 | << " x2m = " << fSwitch[1] |
358 | << " x2u = " << fSwitch[2] |
359 | << " OR[0] = " << fSwitch[3] |
360 | << " OR[1] = " << fSwitch[4] |
361 | << " EN-Y = " << fSwitch[5] |
362 | << " ZERO-ALLY-LSB = " << fSwitch[6] |
363 | << " ZERO-down = " << fSwitch[7] |
364 | << " ZERO-middle = " << fSwitch[8] |
365 | << " ZERO-up = " << fSwitch[9] |
366 | << " trans. conn. " << fTC |
367 | << " Slot = " << fSlot |
368 | << endl; |
369 | } |
370 | |
371 | //___________________________________________ |
372 | void AliMUONLocalTriggerBoard::Module(char *mod) |
373 | { |
374 | const Int_t maxfields = 2; char **fields = new char*[maxfields]; |
375 | |
376 | char s[100]; strcpy(s, GetName()); |
377 | |
378 | Int_t numlines = 0; |
379 | |
380 | for (char *token = strtok(s, "B"); |
381 | token != NULL; |
382 | token = strtok(NULL, " ")) |
383 | { |
384 | fields[numlines] = new char[strlen(token)+1]; |
385 | strcpy(fields[numlines++],token); |
386 | } |
387 | |
388 | strcpy(mod,fields[0]); |
389 | } |
390 | |
391 | //___________________________________________ |
392 | void AliMUONLocalTriggerBoard::TrigX(Int_t ch1q[16], Int_t ch2q[16], Int_t ch3q[32], Int_t ch4q[32], |
393 | Int_t coinc44) |
394 | { |
395 | // note : coinc44 = flag 0 or 1 (0 coincidence -> 3/4, 1 coincidence -> 4/4) |
396 | //--------------------------------------------------------- |
397 | // step # 1 : declustering, reduction DS, calculate sgle & dble |
398 | //--------------------------------------------------------- |
399 | Int_t ch1e[19], ch2e[20], ch3e[35], ch4e[36]; |
400 | Int_t sgleHit1[31], sgleHit2[63]; |
401 | Int_t dbleHit1[31], dbleHit2[63]; |
402 | |
403 | Int_t i; |
404 | Int_t j; |
405 | Int_t istrip; |
406 | |
407 | for (i=0; i<31; i++) { |
408 | sgleHit1[i]=0; |
409 | dbleHit1[i]=0; |
410 | } |
411 | for (i=0; i<63; i++) { |
412 | sgleHit2[i]=0; |
413 | dbleHit2[i]=0; |
414 | } |
415 | |
416 | //--- inititialize che using chq |
417 | for (i=0; i<19; i++) { |
418 | if (i<1||i>16) ch1e[i]=0; |
419 | else ch1e[i]=ch1q[i-1]; |
420 | } |
421 | for (i=0; i<20; i++) { |
422 | if (i<2||i>17) ch2e[i]=0; |
423 | else ch2e[i]=ch2q[i-2]; |
424 | } |
425 | for (i=0; i<35; i++) { |
426 | if (i<1||i>32) ch3e[i]=0; |
427 | else ch3e[i]=ch3q[i-1]; |
428 | } |
429 | for (i=0; i<36; i++) { |
430 | if (i<2||i>33) ch4e[i]=0; |
431 | else ch4e[i]=ch4q[i-2]; |
432 | } |
433 | |
434 | |
435 | //--- calculate dble & sgle first station |
436 | for (i=0; i<=15; i++) { |
437 | sgleHit1[2*i] = (!ch1e[i+1]|(ch1e[i]^ch1e[i+2])) & |
438 | (!ch2e[i+2] | (ch2e[i+1]^ch2e[i+3])); |
439 | |
440 | dbleHit1[2*i] = ch1e[i+1]&!(ch1e[i+2]^ch1e[i]) & |
441 | (ch2e[i+2] | (!ch2e[i]&ch2e[i+1]) | (ch2e[i+3]&!ch2e[i+4])); |
442 | } |
443 | |
444 | for (i=0; i<=14; i++) { |
445 | sgleHit1[2*i+1] = (!ch1e[i+1]|!ch1e[i+2]|(ch1e[i]^ch1e[i+3])) & |
446 | (!ch2e[i+2] | !ch2e[i+3] | (ch2e[i+1]^ch2e[i+4])); |
447 | dbleHit1[2*i+1] = ch1e[i+1]&ch1e[i+2]&!(ch1e[i]^ch1e[i+3]) & |
448 | (ch2e[i+2]&(!ch2e[i+1]|!ch2e[i]) | |
449 | ch2e[i+3]&(ch2e[i+2]|!ch2e[i+4]|!ch2e[i+5])); |
450 | } |
451 | |
452 | //--- calculate dble & sgle second station |
453 | for (i=0; i<=31; i++) { |
454 | sgleHit2[2*i] = (!ch3e[i+1]|(ch3e[i]^ch3e[i+2])) & |
455 | (!ch4e[i+2] | (ch4e[i+1]^ch4e[i+3])); |
456 | dbleHit2[2*i] = ch3e[i+1]&!(ch3e[i+2]^ch3e[i]) & |
457 | (ch4e[i+2] | (!ch4e[i]&ch4e[i+1]) | (ch4e[i+3]&!ch4e[i+4])); |
458 | } |
459 | |
460 | for (i=0; i<=30; i++) { |
461 | sgleHit2[2*i+1] = (!ch3e[i+1]|!ch3e[i+2]|(ch3e[i]^ch3e[i+3])) & |
462 | (!ch4e[i+2] | !ch4e[i+3] | (ch4e[i+1]^ch4e[i+4])); |
463 | dbleHit2[2*i+1] = ch3e[i+1]&ch3e[i+2]&!(ch3e[i]^ch3e[i+3]) & |
464 | (ch4e[i+2]&(!ch4e[i+1]|!ch4e[i]) | |
465 | ch4e[i+3]&(ch4e[i+2]|!ch4e[i+4]|!ch4e[i+5])); |
466 | } |
467 | |
468 | //--- |
469 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
470 | printf("===============================================================\n"); |
471 | printf(" X plane after sgle and dble \n"); |
472 | printf(" 0987654321098765432109876543210"); |
473 | printf("\n SGLE1 "); |
474 | for (istrip=30; istrip>=0; istrip--) printf("%i",(!sgleHit1[istrip])); |
475 | printf("\n DBLE1 "); |
476 | for (istrip=30; istrip>=0; istrip--) printf("%i",dbleHit1[istrip]); |
477 | printf("\n SGLE2 "); |
478 | for (istrip=62; istrip>=0; istrip--) printf("%i",(!sgleHit2[istrip])); |
479 | printf("\n DBLE2 "); |
480 | for (istrip=62; istrip>=0; istrip--) printf("%i",dbleHit2[istrip]); |
481 | printf("\n 210987654321098765432109876543210987654321098765432109876543210\n"); |
482 | } |
483 | |
484 | //--------------------------------------------------------- |
485 | // step # 2 : coincidence 3/4 |
486 | //--------------------------------------------------------- |
487 | Int_t rearImage[31][31]; |
488 | for (i=0; i<31; i++) { |
489 | for (j=0; j<31; j++) { |
490 | rearImage[i][j]=0; |
491 | } |
492 | } |
493 | |
494 | Int_t notOr1=!dbleHit1[30] & !dbleHit1[29] & !dbleHit1[28] & !dbleHit1[27] & |
495 | !dbleHit1[26] & !dbleHit1[25] & !dbleHit1[24] & !dbleHit1[23] & |
496 | !dbleHit1[22] & !dbleHit1[21] & !dbleHit1[20] & !dbleHit1[19] & |
497 | !dbleHit1[18] & !dbleHit1[17] & !dbleHit1[16] & !dbleHit1[15] & |
498 | !dbleHit1[14] & !dbleHit1[13] & !dbleHit1[12] & !dbleHit1[11] & |
499 | !dbleHit1[10] & !dbleHit1[9] & !dbleHit1[8] & !dbleHit1[7] & |
500 | !dbleHit1[6] & !dbleHit1[5] & !dbleHit1[4] & !dbleHit1[3] & |
501 | !dbleHit1[2] & !dbleHit1[1] & !dbleHit1[0] & !coinc44; |
502 | |
503 | Int_t notOr2= !dbleHit2[62] & !dbleHit2[61] & !dbleHit2[60] & !dbleHit2[59] & |
504 | !dbleHit2[58] & !dbleHit2[57] & !dbleHit2[56] & !dbleHit2[55] & |
505 | !dbleHit2[54] & !dbleHit2[53] & !dbleHit2[52] & !dbleHit2[51] & |
506 | !dbleHit2[50] & !dbleHit2[49] & !dbleHit2[48] & !dbleHit2[47] & |
507 | !dbleHit2[46] & !dbleHit2[45] & !dbleHit2[44] & !dbleHit2[43] & |
508 | !dbleHit2[42] & !dbleHit2[41] & !dbleHit2[40] & !dbleHit2[39] & |
509 | !dbleHit2[38] & !dbleHit2[37] & !dbleHit2[36] & !dbleHit2[35] & |
510 | !dbleHit2[34] & !dbleHit2[33] & !dbleHit2[32] & !dbleHit2[31] & |
511 | !dbleHit2[30] & !dbleHit2[29] & !dbleHit2[28] & !dbleHit2[27] & |
512 | !dbleHit2[26] & !dbleHit2[25] & !dbleHit2[24] & !dbleHit2[23] & |
513 | !dbleHit2[22] & !dbleHit2[21] & !dbleHit2[20] & !dbleHit2[19] & |
514 | !dbleHit2[18] & !dbleHit2[17] & !dbleHit2[16] & !dbleHit2[15] & |
515 | !dbleHit2[14] & !dbleHit2[13] & !dbleHit2[12] & !dbleHit2[11] & |
516 | !dbleHit2[10] & !dbleHit2[9] & !dbleHit2[8] & !dbleHit2[7] & |
517 | !dbleHit2[6] & !dbleHit2[5] & !dbleHit2[4] & !dbleHit2[3] & |
518 | !dbleHit2[2] & !dbleHit2[1] & !dbleHit2[0] & !coinc44; |
519 | |
520 | // DS reduction |
521 | for (i=0; i<31; i++) { |
522 | sgleHit1[i] = !sgleHit1[i]¬Or1; |
523 | } |
524 | for (i=0; i<63; i++) { |
525 | sgleHit2[i] = !sgleHit2[i]¬Or2; |
526 | } |
527 | |
528 | // extract rearImage |
529 | for (i=0; i<31; i++){ |
530 | Int_t tmpSgleHit2[31]; |
531 | Int_t tmpDbleHit2[31]; |
532 | for (j=0; j<31; j++){ |
533 | tmpSgleHit2[j] = sgleHit2[i+j+1]; |
534 | tmpDbleHit2[j] = dbleHit2[i+j+1]; |
535 | } |
536 | |
537 | for (Int_t k=0; k<31; k++) { |
538 | rearImage[i][k]=(sgleHit1[i]&tmpDbleHit2[k])| |
539 | (dbleHit1[i]&(tmpSgleHit2[k]|tmpDbleHit2[k])); |
540 | } |
541 | } |
542 | |
543 | //----------- |
544 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
545 | printf("===============================================================\n"); |
546 | for (i=30; i>=0; i--) { |
547 | printf("%i \t",i); |
548 | for (istrip=31; istrip>=0; istrip--) printf("%i",rearImage[i][istrip]); |
549 | printf("\n"); |
550 | } |
551 | } |
552 | |
553 | //--------------------------------------------------------- |
554 | // step # 3 : calculate deviation |
555 | //--------------------------------------------------------- |
556 | Int_t dev[31][6]; |
557 | for (i=0; i<31; i++) { |
558 | for (j=0; j<6; j++) { |
559 | dev[i][j]=0; |
560 | } |
561 | } |
562 | |
563 | for (i=0; i<31; i++){ |
564 | Int_t leftDev[5], rightDev[5]; |
565 | Int_t orL1, andL1, andL2, orR1, orR2, andR1, andR2, andR3; |
566 | |
567 | // calculate Left deviation |
568 | orL1=rearImage[i][16]|rearImage[i][18]|rearImage[i][20]|rearImage[i][22]; |
569 | andL1=!rearImage[i][17]&!rearImage[i][19]&!rearImage[i][21] & !orL1; |
570 | andL2=!rearImage[i][23]&!rearImage[i][24]&!rearImage[i][25]&!rearImage[i][26]; |
571 | |
572 | leftDev[0] = (rearImage[i][16]|!rearImage[i][17]) & |
573 | (rearImage[i][16]|rearImage[i][18]|!rearImage[i][19]& |
574 | (rearImage[i][20]|!rearImage[i][21])) & |
575 | (orL1|!rearImage[i][23]&(rearImage[i][24]|!rearImage[i][25])) & |
576 | (orL1|rearImage[i][24]|rearImage[i][26]|!rearImage[i][27]& |
577 | (rearImage[i][28]|!rearImage[i][29])); |
578 | |
579 | leftDev[1] = !rearImage[i][16] & |
580 | !(!rearImage[i][17]&!rearImage[i][18]&!rearImage[i][21]&!rearImage[i][22] & |
581 | (!rearImage[i][25]&!rearImage[i][26]&(rearImage[i][27]|rearImage[i][28]))) & |
582 | (rearImage[i][17]|rearImage[i][18] | !rearImage[i][19]&!rearImage[i][20]) & |
583 | (rearImage[i][17]|rearImage[i][18]|rearImage[i][21]|rearImage[i][22] | |
584 | !rearImage[i][23]&!rearImage[i][24]); |
585 | |
586 | leftDev[2] = (!rearImage[i][16]&!rearImage[i][17]&!rearImage[i][18]) & |
587 | (rearImage[i][19]|rearImage[i][20]|rearImage[i][21]|rearImage[i][22] | andL2); |
588 | |
589 | leftDev[3] = andL1; |
590 | |
591 | leftDev[4] = |
592 | !rearImage[i][27]&!rearImage[i][28]&!rearImage[i][29]&!rearImage[i][30] & |
593 | andL1 & andL2; |
594 | |
595 | // calculate Right deviation |
596 | orR1=rearImage[i][8]|rearImage[i][10]|rearImage[i][12]|rearImage[i][14]; |
597 | orR2=rearImage[i][8]|rearImage[i][9]|rearImage[i][10]|rearImage[i][11]; |
598 | andR1=!rearImage[i][12]&!rearImage[i][13]&!rearImage[i][14]&!rearImage[i][15]; |
599 | andR2= |
600 | !rearImage[i][8]&!rearImage[i][9]&!rearImage[i][10]&!rearImage[i][11] & andR1; |
601 | andR3=!rearImage[i][4]&!rearImage[i][5]&!rearImage[i][6]&!rearImage[i][7]; |
602 | |
603 | rightDev[0] = !rearImage[i][15]&(rearImage[i][14]|!rearImage[i][13]) & |
604 | ((rearImage[i][12]|rearImage[i][14]|!rearImage[i][11]& |
605 | (rearImage[i][10]|!rearImage[i][9])) & |
606 | ((orR1|!rearImage[i][7]&(rearImage[i][6]|!rearImage[i][5])) & |
607 | (orR1|rearImage[i][4]|rearImage[i][6]|!rearImage[i][3]&(rearImage[i][2]| |
608 | !rearImage[i][1])))); |
609 | |
610 | rightDev[1] = !rearImage[i][15]&!rearImage[i][14] & |
611 | !(!rearImage[i][4]&!rearImage[i][5]&!rearImage[i][8]&!rearImage[i][9] & |
612 | (!rearImage[i][12]&!rearImage[i][13]&(rearImage[i][2]|rearImage[i][3]))) & |
613 | (rearImage[i][12]|rearImage[i][13] | !rearImage[i][10]&!rearImage[i][11]) & |
614 | (rearImage[i][8]|rearImage[i][9]|rearImage[i][12]|rearImage[i][13] | |
615 | !rearImage[i][6]&!rearImage[i][7]); |
616 | |
617 | rightDev[2] = andR1 & (orR2 | andR3); |
618 | rightDev[3] = andR2; |
619 | rightDev[4] = |
620 | !rearImage[i][0]&!rearImage[i][1]&!rearImage[i][2]&!rearImage[i][3] & |
621 | andR2 & andR3 ; |
622 | |
623 | // compare Left & Right deviations |
624 | Int_t tmpLeftDev=0, tmpRightDev=0; |
625 | for (j=0; j<5; j++){ |
626 | tmpLeftDev = tmpLeftDev + Int_t(leftDev[j]<<j); |
627 | tmpRightDev = tmpRightDev + Int_t(rightDev[j]<<j); |
628 | } |
629 | |
630 | // assign mimimum deviation do dev[][] |
631 | if (tmpLeftDev < tmpRightDev ){ |
632 | for (j=0; j<5; j++){ dev[i][j]=leftDev[j];} |
633 | dev[i][5]=1; |
634 | } else { |
635 | for (j=0; j<5; j++){ dev[i][j]=rightDev[j];} |
636 | dev[i][5]=0; |
637 | } |
638 | } |
639 | |
640 | //--- |
641 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
642 | printf("===============================================================\n"); |
643 | for (i=30; i>=0; i--) { |
644 | printf("%i \t",i); |
645 | for (istrip=5; istrip>=0; istrip--) printf("%i",dev[i][istrip]); |
646 | printf(" \n"); |
647 | } |
648 | } |
649 | |
650 | //--------------------------------------------------------- |
651 | // step # 4 : sort deviation |
652 | //--------------------------------------------------------- |
653 | Int_t bga1[16], bga2[8], bga3[4], bga4[2], bga5; |
654 | Int_t tmpbga1[16][6], tmpbga2[8][6], tmpbga3[4][6], tmpbga4[2][6], tmpbga5[6]; |
655 | Int_t tmpMax[6]={1,1,1,1,1,0}; |
656 | |
657 | for (i=0; i<15; i++) { |
658 | Sort2x5(dev[2*i],dev[2*i+1],tmpbga1[i],bga1[i]); |
659 | } |
660 | Sort2x5(dev[30],tmpMax,tmpbga1[15],bga1[15]); |
661 | |
662 | //-- |
663 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
664 | printf("===============================================================\n"); |
665 | printf(" sorting : 1st level \n"); |
666 | for (i=15; i>=0; i--) { |
667 | printf("\t %i \t",bga1[i]); |
668 | for (j=5; j>=0; j--) printf("%i",tmpbga1[i][j]); |
669 | printf(" \n"); |
670 | } |
671 | } |
672 | |
673 | for (i=0; i<8; i++) { |
674 | Sort2x5(tmpbga1[2*i],tmpbga1[2*i+1],tmpbga2[i],bga2[i]); |
675 | } |
676 | |
677 | //-- |
678 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
679 | printf("===============================================================\n"); |
680 | printf(" sorting : 2nd level \n"); |
681 | for (i=7; i>=0; i--) { |
682 | printf("\t %i \t",bga2[i]); |
683 | for (j=5; j>=0; j--) printf("%i",tmpbga1[i][j]); |
684 | printf(" \n"); |
685 | } |
686 | } |
687 | |
688 | for (i=0; i<4; i++) { |
689 | Sort2x5(tmpbga2[2*i],tmpbga2[2*i+1],tmpbga3[i],bga3[i]); |
690 | } |
691 | |
692 | //-- |
693 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
694 | printf("===============================================================\n"); |
695 | printf(" sorting : 3rd level \n"); |
696 | for (i=3; i>=0; i--) { |
697 | printf("\t %i \t",bga3[i]); |
698 | for (j=5; j>=0; j--) printf("%i",tmpbga3[i][j]); |
699 | printf(" \n"); |
700 | } |
701 | } |
702 | |
703 | for (i=0; i<2; i++) { |
704 | Sort2x5(tmpbga3[2*i],tmpbga3[2*i+1],tmpbga4[i],bga4[i]); |
705 | } |
706 | |
707 | //-- |
708 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
709 | printf("===============================================================\n"); |
710 | printf(" sorting : 4th level \n"); |
711 | for (i=1; i>=0; i--) { |
712 | printf("\t %i \t",bga4[i]); |
713 | for (j=5; j>=0; j--) printf("%i",tmpbga4[i][j]); |
714 | printf(" \n"); |
715 | } |
716 | } |
717 | |
718 | Sort2x5(tmpbga4[0],tmpbga4[1],tmpbga5,bga5); |
719 | |
720 | // coding from 6 to 5 bits |
721 | fMinDev[4] = tmpbga5[5] | tmpbga5[4]; |
722 | for (i=0; i<4; i++) { |
723 | fMinDev[i]=tmpbga5[i] & !tmpbga5[4]; |
724 | } |
725 | |
726 | // find address of strip with minimum deviation |
727 | fMinDevStrip[4]=bga5; |
728 | if (bga5<=1) fMinDevStrip[3]=bga4[bga5]; |
729 | |
730 | Int_t tmpAd=fMinDevStrip[3]+fMinDevStrip[4]*2; |
731 | if (tmpAd<=3) fMinDevStrip[2]=bga3[tmpAd]; |
732 | |
733 | tmpAd=fMinDevStrip[2]+fMinDevStrip[3]*2+fMinDevStrip[4]*4; |
734 | if (tmpAd<=7) fMinDevStrip[1]=bga2[tmpAd]; |
735 | |
736 | tmpAd=fMinDevStrip[1]+fMinDevStrip[2]*2+fMinDevStrip[3]*4+fMinDevStrip[4]*8; |
737 | if (tmpAd<=15) fMinDevStrip[0]=bga1[tmpAd]; |
738 | |
739 | if(AliDebugLevel()==3||AliDebugLevel()==5) { |
740 | printf("===============================================================\n"); |
741 | printf("minDevStrip = "); |
742 | for (i=4; i>=0; i--) printf("%i",fMinDevStrip[i]); |
743 | printf(" minDev = "); |
744 | for (i=4; i>=0; i--) printf("%i",fMinDev[i]); |
745 | printf(" \n"); |
746 | printf("===============================================================\n"); |
747 | } |
748 | |
749 | } |
750 | |
751 | //___________________________________________ |
752 | void AliMUONLocalTriggerBoard::Sort2x5(Int_t dev1[6], Int_t dev2[6], |
753 | Int_t minDev[6], Int_t &dev1GTdev2) |
754 | { |
755 | // returns minimun between dev1 and dev2 |
756 | Int_t tmpDev1=0, tmpDev2=0; |
757 | |
758 | for (Int_t j=0; j<5; j++) |
759 | { |
760 | tmpDev1 += Int_t(dev1[j]<<j); |
761 | tmpDev2 += Int_t(dev2[j]<<j); |
762 | } |
763 | |
764 | if (tmpDev1<=tmpDev2) |
765 | { |
766 | for (Int_t j=0; j<=5; j++) minDev[j]=dev1[j]; |
767 | dev1GTdev2=0; |
768 | } |
769 | else |
770 | { |
771 | for (Int_t j=0; j<=5; j++) minDev[j]=dev2[j]; |
772 | dev1GTdev2=1; |
773 | } |
774 | } |
775 | |
776 | //___________________________________________ |
777 | void AliMUONLocalTriggerBoard::TrigY(Int_t y1[16], Int_t y2[16], Int_t y3[16], Int_t y4[16], |
778 | Int_t y3u[16], Int_t y3d[16], Int_t y4u[16], Int_t y4d[16], |
779 | Int_t coinc44) |
780 | { |
781 | // note : resMid = 1 -> cancel |
782 | //--------------------------------------------------------- |
783 | // step # 1 : prehandling Y |
784 | //--------------------------------------------------------- |
785 | Int_t i; |
786 | Int_t istrip; |
787 | |
788 | for (i=0; i<16; i++) |
789 | { |
790 | y3[i]=y3[i]&!fSwitch[8]; |
791 | y4[i]=y4[i]&!fSwitch[8]; |
792 | } |
793 | |
794 | // 10/29/04 fZeroAllYLSB added |
795 | // for (i=0; i<8; i++) |
796 | // { |
797 | // y1[i] = y1[i]&!fSwitch[6]; |
798 | // y2[i] = y2[i]&!fSwitch[6]; |
799 | // y3[i] = y3[i]&!fSwitch[6]; |
800 | // y4[i] = y4[i]&!fSwitch[6]; |
801 | // } |
802 | |
803 | Int_t ch1[16], ch2[16], ch3[16], ch4[16]; |
804 | |
805 | Int_t tmpy3to16[16], tmpy4to16[16]; |
806 | Int_t tmpy3uto16[16], tmpy3dto16[16], tmpy4uto16[16], tmpy4dto16[16]; |
807 | for (i=0; i<8; i++){ |
808 | ch1[2*i] = y1[i]&fSwitch[1] | y1[2*i]&!fSwitch[1]; |
809 | ch1[2*i+1] = y1[i]&fSwitch[1] | y1[2*i+1]&!fSwitch[1]; |
810 | |
811 | ch2[2*i] = y2[i]&fSwitch[1] | y2[2*i]&!fSwitch[1]; |
812 | ch2[2*i+1] = y2[i]&fSwitch[1] | y2[2*i+1]&!fSwitch[1]; |
813 | |
814 | tmpy3to16[2*i ] = y3[i]&fSwitch[1] | y3[2*i ]&!fSwitch[1]; |
815 | tmpy3to16[2*i+1] = y3[i]&fSwitch[1] | y3[2*i+1]&!fSwitch[1]; |
816 | |
817 | tmpy4to16[2*i ] = y4[i]&fSwitch[1] | y4[2*i ]&!fSwitch[1]; |
818 | tmpy4to16[2*i+1] = y4[i]&fSwitch[1] | y4[2*i+1]&!fSwitch[1]; |
819 | |
820 | tmpy3uto16[2*i ] = y3u[i]&fSwitch[2] | y3u[2*i ]&!fSwitch[2]; |
821 | tmpy3uto16[2*i+1] = y3u[i]&fSwitch[2] | y3u[2*i+1]&!fSwitch[2]; |
822 | |
823 | tmpy4uto16[2*i ] = y4u[i]&fSwitch[2] | y4u[2*i ]&!fSwitch[2]; |
824 | tmpy4uto16[2*i+1] = y4u[i]&fSwitch[2] | y4u[2*i+1]&!fSwitch[2]; |
825 | |
826 | tmpy3dto16[2*i ] = y3d[i]&fSwitch[0] | y3d[2*i ]&!fSwitch[0]; |
827 | tmpy3dto16[2*i+1] = y3d[i]&fSwitch[0] | y3d[2*i+1]&!fSwitch[0]; |
828 | |
829 | tmpy4dto16[2*i ] = y4d[i]&fSwitch[0] | y4d[2*i ]&!fSwitch[0]; |
830 | tmpy4dto16[2*i+1] = y4d[i]&fSwitch[0] | y4d[2*i+1]&!fSwitch[0]; |
831 | } |
832 | |
833 | if (fSwitch[3]==0&&fSwitch[4]==0){ |
834 | for (i=0; i<16; i++){ |
835 | ch3[i] = tmpy3to16[i]; |
836 | ch4[i] = tmpy4to16[i]; |
837 | } |
838 | } |
839 | if (fSwitch[3]==0&&fSwitch[4]==1){ |
840 | for (i=0; i<16; i++){ |
8af755f4 |
841 | ch3[i] = tmpy3dto16[i]|tmpy3to16[i]; |
842 | ch4[i] = tmpy4dto16[i]|tmpy4to16[i]; |
be972727 |
843 | } |
844 | } |
845 | if (fSwitch[3]==1&&fSwitch[4]==0){ |
846 | for (i=0; i<16; i++){ |
8af755f4 |
847 | ch3[i] = tmpy3uto16[i]|tmpy3to16[i]; |
848 | ch4[i] = tmpy4uto16[i]|tmpy4to16[i]; |
be972727 |
849 | } |
850 | } |
851 | if (fSwitch[3]==1&&fSwitch[4]==1){ |
852 | for (i=0; i<16; i++){ |
853 | ch3[i] = tmpy3dto16[i]|tmpy3to16[i]|tmpy3uto16[i]; |
854 | ch4[i] = tmpy4dto16[i]|tmpy4to16[i]|tmpy4uto16[i]; |
855 | } |
856 | } |
857 | |
858 | // debug |
859 | if(AliDebugLevel()==4||AliDebugLevel()==5) { |
860 | printf("===============================================================\n"); |
861 | printf(" Y plane after PreHandling x2m x2u x2d orMud %i %i %i %i %i \n", |
862 | fSwitch[1],fSwitch[2], fSwitch[0],fSwitch[3],fSwitch[4]); |
863 | printf(" "); |
864 | for (istrip=15; istrip>=0; istrip--) { |
865 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); |
866 | if (istrip<10) printf("%i",istrip); |
867 | } |
868 | printf("\n YMC11 "); |
869 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch1[istrip]); |
870 | printf("\n YMC12 "); |
871 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch2[istrip]); |
872 | printf("\n YMC21 "); |
873 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch3[istrip]); |
874 | printf("\n YMC22 "); |
875 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch4[istrip]); |
876 | printf(" \n"); |
877 | } |
878 | //debug |
879 | |
880 | //--------------------------------------------------------- |
881 | // step # 2 : calculate sgle and dble, apply DS reduction |
882 | //--------------------------------------------------------- |
883 | Int_t sgle1[16], dble1[16]; |
884 | Int_t sgle2[16], dble2[16]; |
885 | |
886 | // Calculate simple and double hits |
887 | for (i=0; i<16; i++) { |
888 | dble1[i] = ch1[i] & ch2[i]; |
889 | dble2[i] = ch3[i] & ch4[i]; |
890 | |
891 | sgle1[i] = (ch1[i]|ch2[i]); |
892 | sgle2[i] = (ch3[i]|ch4[i]); |
893 | } |
894 | |
895 | //debug |
896 | if(AliDebugLevel()==4||AliDebugLevel()==5) { |
897 | printf("===============================================================\n"); |
898 | printf(" Y plane after sgle dble \n"); |
899 | printf(" "); |
900 | for (istrip=15; istrip>=0; istrip--) { |
901 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); |
902 | if (istrip<10) printf("%i",istrip); |
903 | } |
904 | printf("\n SGLE1 "); |
905 | for (istrip=15; istrip>=0; istrip--) printf("%i",sgle1[istrip]); |
906 | printf("\n DBLE1 "); |
907 | for (istrip=15; istrip>=0; istrip--) printf("%i",dble1[istrip]); |
908 | printf("\n SGLE2 "); |
909 | for (istrip=15; istrip>=0; istrip--) printf("%i",sgle2[istrip]); |
910 | printf("\n DBLE2 "); |
911 | for (istrip=15; istrip>=0; istrip--) printf("%i",dble2[istrip]); |
912 | printf(" \n"); |
913 | } |
914 | //debug |
915 | |
916 | // DS Reduction |
917 | Int_t notOr1, notOr2; |
918 | |
919 | notOr1=!dble1[15] & !dble1[14] & !dble1[13] & !dble1[12] & |
920 | !dble1[11] & !dble1[10] & !dble1[9] & !dble1[8] & |
921 | !dble1[7] & !dble1[6] & !dble1[5] & !dble1[4] & |
922 | !dble1[3] & !dble1[2] & !dble1[1] & !dble1[0]; |
923 | |
924 | notOr2=!dble2[15] & !dble2[14] & !dble2[13] & !dble2[12] & |
925 | !dble2[11] & !dble2[10] & !dble2[9] & !dble2[8] & |
926 | !dble2[7] & !dble2[6] & !dble2[5] & !dble2[4] & |
927 | !dble2[3] & !dble2[2] & !dble2[1] & !dble2[0]; |
928 | |
929 | for (i=0; i<16; i++) { |
930 | sgle1[i] = sgle1[i] & notOr1 & !coinc44; |
931 | sgle2[i] = sgle2[i] & notOr2 & !coinc44; |
932 | } |
933 | |
934 | //--------------------------------------------------------- |
935 | // step # 3 : 3/4 coincidence |
936 | //--------------------------------------------------------- |
937 | Int_t frontImage[16]; |
938 | |
939 | for (i=1; i<15; i++) { |
940 | frontImage[i] = (dble1[i] | sgle1[i]) & |
941 | (dble2[i+1] | dble2[i] | dble2[i-1]) | |
942 | dble1[i] & (sgle2[i+1] | sgle2[i] | sgle2[i-1]); |
943 | } |
944 | frontImage[0] = (dble1[0] | sgle1[0]) & |
945 | (dble2[1] | dble2[0]) | dble1[0] & (sgle2[1] | sgle2[0]); |
946 | |
947 | frontImage[15] = (dble1[15] | sgle1[15]) & |
948 | (dble2[15] | dble2[14]) | dble1[15] & (sgle2[15] | sgle2[14]); |
949 | |
950 | |
951 | //debug |
952 | if(AliDebugLevel()==4||AliDebugLevel()==5) { |
953 | printf("===============================================================\n"); |
954 | printf(" Y plane frontImage\n"); |
955 | printf(" "); |
956 | for (istrip=15; istrip>=0; istrip--) { |
957 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); |
958 | if (istrip<10) printf("%i",istrip); |
959 | } |
960 | printf("\n "); |
961 | for (istrip=15; istrip>=0; istrip--) printf("%i",frontImage[istrip]); |
962 | printf("\n"); |
963 | } |
964 | //debug |
965 | |
966 | //--------------------------------------------------------- |
967 | // step # 4 : Y position |
968 | //--------------------------------------------------------- |
969 | Int_t or1, or2, and1, and2, and3; |
970 | |
971 | or1 = frontImage[7]|frontImage[5]|frontImage[3]|frontImage[1]; |
972 | or2 = frontImage[7]|frontImage[6]|frontImage[5]|frontImage[4]; |
973 | and1 = !frontImage[3]&!frontImage[2]&!frontImage[1]&!frontImage[0]; |
974 | and2 = !frontImage[7]&!frontImage[6]&!frontImage[5]&!frontImage[4] & and1; |
975 | and3 = !frontImage[11]&!frontImage[10]&!frontImage[9]&!frontImage[8]; |
976 | |
977 | fCoordY[0] = !frontImage[0]&(frontImage[1]|!frontImage[2]) & |
978 | (frontImage[3]|frontImage[1]|!frontImage[4]&(frontImage[5]|!frontImage[6])) & |
979 | (or1|!frontImage[8]&(frontImage[9]|!frontImage[10])) & |
980 | (or1|frontImage[11]|frontImage[9]|!frontImage[12]&(frontImage[13]|!frontImage[14])); |
981 | |
982 | fCoordY[1] = !frontImage[0]&!frontImage[1] & |
983 | !(!frontImage[11]&!frontImage[10]&!frontImage[7]&!frontImage[6] & |
984 | !frontImage[3]&!frontImage[2]&(frontImage[13]|frontImage[12])) & |
985 | (frontImage[3]|frontImage[2] | !frontImage[5]&!frontImage[4]) & |
986 | (frontImage[7]|frontImage[6]|frontImage[3]|frontImage[2] | |
987 | !frontImage[9]&!frontImage[8]); |
988 | |
989 | fCoordY[2] = and1 & (or2 | and3); |
990 | |
991 | fCoordY[3] = and2; |
992 | |
993 | fCoordY[4] = !frontImage[15]&!frontImage[14]&!frontImage[13]&!frontImage[12] & |
994 | and2 & and3 ; |
995 | } |
996 | |
997 | //___________________________________________ |
998 | void AliMUONLocalTriggerBoard::LocalTrigger() |
999 | { |
1000 | Int_t deviation=0, iStripY=0; |
1001 | |
1002 | for (Int_t i=0; i<4; i++) deviation += static_cast<int>( fMinDev[i] << i ); |
1003 | for (Int_t i=0; i<4; i++) iStripY += static_cast<int>( fCoordY[i] << i ); |
1004 | |
1005 | if (fMinDev[4]==1 && !deviation) fOutput=0; // No trigger |
1006 | else |
1007 | { |
1008 | if (fCoordY[4]==1 && iStripY==15) fOutput=0; // No trigger |
1009 | else |
1010 | fOutput=1; |
1011 | } |
1012 | |
1013 | if (fOutput) |
1014 | { |
1015 | for (Int_t i=0; i<5; i++) fStripX11 += static_cast<int>( fMinDevStrip[i] << i ); |
1016 | |
1017 | fDev = deviation; |
8af755f4 |
1018 | |
1019 | fStripY11 = iStripY; |
1020 | |
1021 | if ( fSwitch[1] && |
1022 | (fSwitch[0] || fSwitch[2]) && |
1023 | !(!fSwitch[0] && fSwitch[4]) && |
1024 | !(!fSwitch[2] && fSwitch[3]) ) fStripY11 /= 2; |
be972727 |
1025 | |
1026 | Int_t sign = 0; |
1027 | |
1028 | if ( !fMinDev[4] && deviation ) sign=-1; |
1029 | if ( !fMinDev[4] && !deviation ) sign= 0; |
1030 | if ( fMinDev[4]==1) sign=+1; |
1031 | |
1032 | fDev *= sign; |
1033 | |
1034 | // calculate deviation in [0;+30] |
1035 | fDev += 15; |
1036 | |
1037 | Int_t icirc = GetI(); |
1038 | |
8af755f4 |
1039 | // LEFT SHIFT OF ZERO-ALLY-LSB BOARDS TO ACCESS TO LUT |
1040 | if (GetSwitch(6)) fStripY11 -= 8; |
1041 | |
1042 | // GET LUT OUTPUT FOR icirc/istripX1/deviation/istripY |
be972727 |
1043 | fLUT->GetLutOutput(icirc, fStripX11, fDev, fStripY11, fLutLpt, fLutHpt, fLutApt); |
1044 | } |
1045 | } |
1046 | |
1047 | //___________________________________________ |
1048 | Int_t AliMUONLocalTriggerBoard::GetI() |
1049 | { |
1050 | const Int_t maxfields = 2; char **fields = new char*[maxfields]; |
1051 | |
1052 | char s[100]; strcpy(s, GetName()); |
1053 | |
1054 | Int_t numlines = 0; |
1055 | |
1056 | for (char *token = strtok(s, "B"); |
1057 | token != NULL; |
1058 | token = strtok(NULL, " ")) |
1059 | { |
1060 | fields[numlines] = new char[strlen(token)+1]; |
1061 | strcpy(fields[numlines++], token); |
1062 | } |
1063 | |
1064 | TString l(fields[0]); |
1065 | |
1066 | char copy = l[0]; |
1067 | |
1068 | Int_t L = atoi(&l[4]), C = atoi(&l[2]), S = (copy=='R') ? +1 : -1; |
1069 | |
1070 | char *b[4] = {"12", "34", "56", "78"}; |
1071 | |
1072 | Int_t ib = 0; |
1073 | |
1074 | for (Int_t i=0; i<4; i++) if (!strcmp(fields[1],b[i])) {ib = i; break;} ib++; |
1075 | |
1076 | // L=1 ON TOP |
1077 | L -= 9; L = abs(L); L++; |
1078 | |
1079 | Int_t code = 100 * L + 10 * C + ib; |
1080 | |
1081 | code *= S; |
1082 | |
1083 | Int_t ic = 0; |
1084 | |
1085 | for (Int_t i=0; i<234; i++) if (AliMUONTriggerConstants::CircuitId(i) == code) {ic = i; break;} |
1086 | |
1087 | return ic; |
1088 | } |
1089 | |
1090 | //___________________________________________ |
41922e78 |
1091 | void AliMUONLocalTriggerBoard::Mask(Int_t index, UShort_t mask) |
be972727 |
1092 | { |
41922e78 |
1093 | if ( index >= 0 && index < 2*4 ) |
1094 | { |
1095 | Int_t i = index/4; |
1096 | Int_t j = index - i*4; |
1097 | fMask[i][j]=mask; |
1098 | } |
1099 | else |
1100 | { |
1101 | AliError(Form("Index %d out of bounds (max %d)",index,8)); |
1102 | } |
be972727 |
1103 | } |
1104 | |
1105 | //___________________________________________ |
1106 | void AliMUONLocalTriggerBoard::Scan(Option_t *option) |
1107 | { |
1108 | TString op = option; |
1109 | |
1110 | if (op.Contains("CONF")) Conf(); |
1111 | |
8af755f4 |
1112 | if (op.Contains("BITP")) Pattern(); |
be972727 |
1113 | |
1114 | if (op.Contains("RESPI")) Resp("I"); |
1115 | |
1116 | if (op.Contains("RESPF")) Resp("F"); |
1117 | |
1118 | if (op.Contains("ALL")) |
1119 | { |
1120 | Conf(); |
1121 | Pattern(); |
1122 | Resp("I"); |
1123 | Resp("F"); |
1124 | } |
1125 | } |
1126 | |
1127 | //___________________________________________ |
1128 | void AliMUONLocalTriggerBoard::Resp(Option_t *option) |
1129 | { |
1130 | TString op = option; |
1131 | |
1132 | if (op.Contains("I")) |
1133 | { |
1134 | // print Local trigger output before the LuT step |
1135 | printf("===============================================================\n"); |
1136 | printf("-------- TRIGGER OUTPUT --------\n"); |
1137 | printf("minDevStrip = "); |
1138 | for (Int_t i=4; i>=0; i--) printf("%i",fMinDevStrip[i]); |
1139 | printf(" minDev = "); |
1140 | for (Int_t i=4; i>=0; i--) printf("%i",fMinDev[i]); |
1141 | printf(" coordY = "); |
1142 | for (Int_t i=4; i>=0; i--) printf("%i",fCoordY[i]); |
1143 | printf(" \n"); |
1144 | } |
1145 | |
1146 | if (op.Contains("F")) |
1147 | { |
1148 | Int_t icirc = GetI(); |
1149 | Int_t idCircuit = AliMUONTriggerConstants::CircuitId(icirc); |
1150 | |
1151 | Int_t deviation = 0, iStripY = 0; |
1152 | |
1153 | for (Int_t i=0; i<4; i++) iStripY += static_cast<int>( fCoordY[i] << i ); |
1154 | |
1155 | for (Int_t i=0; i<4; i++) deviation += Int_t(fMinDev[i]<<i); |
1156 | |
1157 | Float_t pt = 0.; //triggerCircuit->PtCal(fStripX11, fDev, fStripY11); |
1158 | printf("-------------------------------------------\n"); |
1159 | printf(" Local Trigger info for circuit Id %i (number %i ) \n", idCircuit, icirc); |
1160 | printf(" istripX1 signDev deviation istripY = %i %i %i %i \n", fStripX11, fMinDev[4], deviation, iStripY); |
1161 | printf(" pt = %f (GeV/c) \n", pt); |
1162 | printf("-------------------------------------------\n"); |
1163 | printf(" Local Trigger Lut Output = Lpt : "); |
1164 | for (Int_t i=1; i>=0; i--) printf("%i", fLutLpt[i]); |
1165 | printf(" Hpt : "); |
1166 | for (Int_t i=1; i>=0; i--) printf("%i", fLutHpt[i]); |
1167 | printf(" Apt : "); |
1168 | for (Int_t i=1; i>=0; i--) printf("%i", fLutApt[i]); |
1169 | printf("\n"); |
1170 | printf("-------------------------------------------\n"); |
1171 | } |
1172 | // else |
1173 | // { |
1174 | |
1175 | // } |
1176 | } |
1177 | |
1178 | //___________________________________________ |
be972727 |
1179 | void AliMUONLocalTriggerBoard::Response() |
1180 | { |
1181 | Int_t X1[16], X2[16], XX3[32], XX4[32]; |
1182 | |
1183 | TBits x1(16), x2(16), x3(16), x4(16); |
1184 | |
1185 | UShort_t xyv = 0; |
1186 | |
1187 | xyv = fXY[0][0]; x1.Set(16,&xyv); |
1188 | xyv = fXY[0][1]; x2.Set(16,&xyv); |
1189 | xyv = fXY[0][2]; x3.Set(16,&xyv); |
1190 | xyv = fXY[0][3]; x4.Set(16,&xyv); |
1191 | |
1192 | TBits x3u(16), x4u(16), x3d(16), x4d(16); |
1193 | |
1194 | xyv = fXYU[0][2]; x3u.Set(16,&xyv); |
1195 | xyv = fXYU[0][3]; x4u.Set(16,&xyv); |
1196 | |
1197 | xyv = fXYD[0][2]; x3d.Set(16,&xyv); |
1198 | xyv = fXYD[0][3]; x4d.Set(16,&xyv); |
1199 | |
1200 | for (Int_t i=0;i<16;i++) |
1201 | { |
1202 | X1[i] = x1[i]; |
1203 | X2[i] = x2[i]; |
1204 | |
1205 | XX3[i+8] = x3[i]; |
1206 | XX4[i+8] = x4[i]; |
1207 | } |
1208 | |
1209 | for (Int_t i=0;i<8;i++) |
1210 | { |
1211 | XX3[i] = x3d[i+8]; |
1212 | XX4[i] = x4d[i+8]; |
1213 | |
1214 | XX3[i+24] = x3u[i]; |
1215 | XX4[i+24] = x4u[i]; |
1216 | } |
1217 | |
1218 | Int_t coinc44 = 0; |
1219 | |
1220 | TrigX(X1, X2, XX3, XX4, coinc44); |
1221 | |
1222 | Int_t Y1[16], Y2[16], Y3[16], Y4[16]; |
1223 | |
1224 | Int_t Y3U[16], Y3D[16], Y4U[16], Y4D[16]; |
1225 | |
1226 | TBits y1(16), y2(16), y3(16), y4(16); |
1227 | |
1228 | TBits y3u(16), y3d(16), y4u(16), y4d(16); |
1229 | |
1230 | xyv = fXY[1][0]; y1.Set(16,&xyv); |
1231 | xyv = fXY[1][1]; y2.Set(16,&xyv); |
1232 | xyv = fXY[1][2]; y3.Set(16,&xyv); |
1233 | xyv = fXY[1][3]; y4.Set(16,&xyv); |
1234 | |
1235 | xyv = fXYU[1][2]; y3u.Set(16,&xyv); |
1236 | xyv = fXYD[1][2]; y3d.Set(16,&xyv); |
1237 | xyv = fXYU[1][3]; y4u.Set(16,&xyv); |
1238 | xyv = fXYD[1][3]; y4d.Set(16,&xyv); |
1239 | |
1240 | for (Int_t i=0;i<16;i++) |
1241 | { |
1242 | Y1[i] = y1[i]; |
1243 | Y2[i] = y2[i]; |
1244 | Y3[i] = y3[i]; |
1245 | Y4[i] = y4[i]; |
1246 | |
1247 | Y3U[i] = y3u[i]; |
1248 | Y3D[i] = y3d[i]; |
1249 | |
1250 | Y4U[i] = y4u[i]; |
1251 | Y4D[i] = y4d[i]; |
1252 | } |
1253 | |
1254 | TrigY(Y1, Y2, Y3, Y4, Y3U, Y3D, Y4U, Y4D, coinc44); |
1255 | |
1256 | // ASIGN fLutLpt, fLutHpt, fLutApt |
1257 | LocalTrigger(); |
1258 | |
1259 | fResponse = fLutApt[0] + |
1260 | static_cast<int>(fLutApt[1]<<1) + |
1261 | static_cast<int>(fLutLpt[0]<<2) + |
1262 | static_cast<int>(fLutLpt[1]<<3) + |
1263 | static_cast<int>(fLutHpt[0]<<4) + |
1264 | static_cast<int>(fLutHpt[1]<<5); |
1265 | } |
1266 | |
1267 | ClassImp(AliMUONLocalTriggerBoard) |
1268 | |