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