]>
Commit | Line | Data |
---|---|---|
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 | #include <TError.h> | |
19 | ||
20 | #include "AliMUONTriggerCircuit.h" | |
21 | #include "AliMUONTriggerDecision.h" | |
22 | #include "AliMUONTriggerLut.h" | |
23 | #include "AliMUON.h" | |
24 | #include "AliMUONDigit.h" | |
25 | #include "AliMUONConstants.h" | |
26 | #include "AliMUONGlobalTrigger.h" | |
27 | #include "AliMUONLocalTrigger.h" | |
28 | #include "AliRun.h" | |
29 | #include "AliRunLoader.h" | |
30 | #include "AliLoader.h" | |
31 | #include "AliRawReader.h" // for raw data | |
32 | #include "AliLog.h" | |
33 | ||
34 | ||
35 | //---------------------------------------------------------------------- | |
36 | ClassImp(AliMUONTriggerDecision) | |
37 | ||
38 | //---------------------------------------------------------------------- | |
39 | AliMUONTriggerDecision::AliMUONTriggerDecision(AliLoader* loader, Int_t iprint, AliMUONData* data) | |
40 | : TObject() | |
41 | { | |
42 | // Constructor | |
43 | fDebug = iprint; // print option | |
44 | // iprint = 0 : don't print anything | |
45 | // iprint = 1 : print Global Trigger Output | |
46 | // iprint = 2 : print Local and Global Trigger Outputs | |
47 | // iprint = 3 : iprint = 2 + detailed info on X strips | |
48 | // iprint = 4 : iprint = 2 + detailed info on Y strip | |
49 | // iprint = 5 : iprint = 2 + detailed info on X and Y strips | |
50 | // Note : with iprint>2, the strips detailed info is given for all circuits | |
51 | ||
52 | // Global Trigger information | |
53 | Int_t i; | |
54 | Int_t icirc; | |
55 | Int_t istrip; | |
56 | ||
57 | for (i=0; i<3; i++) { // [0] : Low pt, [1] : High pt, [2] : All pt | |
58 | fGlobalSinglePlus[i]=0; // tot num of single plus | |
59 | fGlobalSingleMinus[i]=0; // tot num of single minus | |
60 | fGlobalSingleUndef[i]=0; // tot num of single undefined | |
61 | fGlobalPairUnlike[i]=0; // tot num of unlike-sign pairs | |
62 | fGlobalPairLike[i]=0; // tot num of like-sign pairs | |
63 | } | |
64 | // Local Trigger information | |
65 | for (icirc=0; icirc<234; icirc++){ | |
66 | fTrigger[icirc]=0; // trigger or not | |
67 | fStripX11[icirc]=0; // X strip in MC11 which triggers | |
68 | fDev[icirc]=0; // deviation which triggers | |
69 | fStripY11[icirc]=0; // Y strip in MC11 which triggers | |
70 | for (i=0; i<2; i++) { // pt information via LuT | |
71 | fLutLpt[icirc][i]=fLutHpt[icirc][i]=fLutApt[icirc][i]=0; | |
72 | } | |
73 | } | |
74 | // bit pattern | |
75 | for (icirc=0; icirc<234; icirc++) { | |
76 | for (istrip=0; istrip<16; istrip++) { | |
77 | fXbit11[icirc][istrip]=fXbit12[icirc][istrip]=0; | |
78 | fYbit11[icirc][istrip]=fYbit12[icirc][istrip]=0; | |
79 | fYbit21[icirc][istrip]=fYbit22[icirc][istrip]=0; | |
80 | fYbit21U[icirc][istrip]=fYbit22U[icirc][istrip]=0; | |
81 | fYbit21D[icirc][istrip]=fYbit22D[icirc][istrip]=0; | |
82 | } | |
83 | for (istrip=0; istrip<32; istrip++) { | |
84 | fXbit21[icirc][istrip]=fXbit22[icirc][istrip]=0; | |
85 | } | |
86 | } | |
87 | ||
88 | fTriggerCircuit = new TObjArray(AliMUONConstants::NTriggerCircuit()); | |
89 | ||
90 | // initialize loader's | |
91 | fLoader = loader; | |
92 | ||
93 | // initialize container | |
94 | if (data == 0){ | |
95 | AliError("No MUONdata for trigger"); | |
96 | }else{ | |
97 | fMUONData = data; | |
98 | } | |
99 | ||
100 | // getting MUON | |
101 | fMUON = (AliMUON*) gAlice->GetDetector("MUON"); | |
102 | ||
103 | // setting circuit | |
104 | for (icirc = 0; icirc < AliMUONConstants::NTriggerCircuit(); icirc++) { | |
105 | AliMUONTriggerCircuit* pCir = 0; | |
106 | pCir = &(fMUON->TriggerCircuit(icirc)); | |
107 | fTriggerCircuit->AddAt(pCir, icirc); | |
108 | } | |
109 | ||
110 | // setting digits | |
111 | fDigits = new TObjArray(AliMUONConstants::NCh()); //NTriggerCh | |
112 | for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) | |
113 | fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i); | |
114 | fDigitIndices = new TArrayI[AliMUONConstants::NCh()]; | |
115 | } | |
116 | ||
117 | //---------------------------------------------------------------------- | |
118 | AliMUONTriggerDecision::AliMUONTriggerDecision() | |
119 | : TObject(), | |
120 | fLoader(0), | |
121 | fTriggerCircuit(0), | |
122 | fMUONData(0), | |
123 | fMUON(0) | |
124 | { | |
125 | // Default constructor | |
126 | fDigitIndices = NULL; | |
127 | } | |
128 | ||
129 | //---------------------------------------------------------------------- | |
130 | AliMUONTriggerDecision::AliMUONTriggerDecision(const AliMUONTriggerDecision& rhs) | |
131 | : TObject(rhs) | |
132 | { | |
133 | // Protected copy constructor | |
134 | ||
135 | AliFatal("Not implemented."); | |
136 | } | |
137 | ||
138 | //---------------------------------------------------------------------- | |
139 | void AliMUONTriggerDecision::ClearDigits() | |
140 | { | |
141 | for ( int i=0;i<AliMUONConstants::NCh();i++ ) | |
142 | { | |
143 | if ((*fDigits)[i]) ((TClonesArray*)fDigits->At(i))->Clear(); | |
144 | fDigitIndices[i].Set(0); | |
145 | }; | |
146 | } | |
147 | ||
148 | //---------------------------------------------------------------------- | |
149 | TClonesArray* AliMUONTriggerDecision::Digits(Int_t DetectionPlane) | |
150 | { | |
151 | //Getting List of Digits | |
152 | if (fDigits) | |
153 | return ((TClonesArray*) fDigits->At(DetectionPlane)); | |
154 | else | |
155 | return NULL; | |
156 | } | |
157 | ||
158 | //_____________________________________________________________________________ | |
159 | void AliMUONTriggerDecision::AddDigit( | |
160 | Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits, | |
161 | Int_t digitindex | |
162 | ) | |
163 | { | |
164 | // | |
165 | // Add a MUON digit to the list of Digits of the detection plane id | |
166 | // Also adds the digit index to the corresponding fDigitIndices arrays. | |
167 | // | |
168 | TClonesArray &ldigits = *Digits(id); | |
169 | new(ldigits[ldigits.GetEntriesFast()]) AliMUONDigit(tracks,charges,digits); | |
170 | ||
171 | TArrayI& indices = fDigitIndices[id]; | |
172 | indices.Set(indices.GetSize() + 1); | |
173 | indices[indices.GetSize() - 1] = digitindex; | |
174 | } | |
175 | ||
176 | //---------------------------------------------------------------------- | |
177 | AliMUONTriggerDecision::~AliMUONTriggerDecision() | |
178 | { | |
179 | // Destructor | |
180 | if (fTriggerCircuit){ | |
181 | fTriggerCircuit->Clear();// Sets pointers to 0 since it is not the owner | |
182 | delete fTriggerCircuit; | |
183 | } | |
184 | // if (fMUONData) | |
185 | // delete fMUONData; | |
186 | ||
187 | if (fDigits) { | |
188 | fDigits->Delete(); | |
189 | delete fDigits; | |
190 | } | |
191 | ||
192 | if (fDigitIndices) | |
193 | delete [] fDigitIndices; | |
194 | } | |
195 | ||
196 | //---------------------------------------------------------------------- | |
197 | AliMUONTriggerDecision& | |
198 | AliMUONTriggerDecision::operator=(const AliMUONTriggerDecision& rhs) | |
199 | { | |
200 | // Protected assignement operator | |
201 | ||
202 | if (this == &rhs) return *this; | |
203 | ||
204 | AliFatal("Not implemented."); | |
205 | ||
206 | return *this; | |
207 | } | |
208 | ||
209 | ||
210 | //---------------------------------------------------------------------- | |
211 | void AliMUONTriggerDecision::Trigger(){ | |
212 | // main method of the class which calls the overall Trigger procedure | |
213 | ||
214 | ResetBit(); | |
215 | SetBit(); | |
216 | SetBitUpDownY(); | |
217 | ||
218 | Int_t coinc44=0, resetMid=0; // initialize coincidence | |
219 | ||
220 | AliMUONTriggerCircuit* triggerCircuit; | |
221 | ||
222 | for (Int_t icirc=0; icirc<234; icirc++) { // loop on circuits | |
223 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
224 | // Int_t idCircuit=triggerCircuit->GetIdCircuit(); | |
225 | ||
226 | Int_t minDevStrip[5], minDev[5], coordY[5]; | |
227 | for (Int_t i=0; i<5; i++) { | |
228 | minDevStrip[i]=minDev[i]=coordY[i]=0; | |
229 | } | |
230 | Int_t x2m=triggerCircuit->GetX2m(); | |
231 | Int_t x2ud=triggerCircuit->GetX2ud(); | |
232 | Int_t orMud[2]={0,0}; | |
233 | triggerCircuit->GetOrMud(orMud); | |
234 | ||
235 | // call triggerX | |
236 | TrigX(fXbit11[icirc],fXbit12[icirc],fXbit21[icirc],fXbit22[icirc], | |
237 | coinc44, minDevStrip, minDev); | |
238 | // call triggerY | |
239 | TrigY(fYbit11[icirc],fYbit12[icirc],fYbit21[icirc],fYbit22[icirc], | |
240 | fYbit21U[icirc],fYbit21D[icirc],fYbit22U[icirc],fYbit22D[icirc], | |
241 | x2m,x2ud,orMud,resetMid,coinc44,coordY); | |
242 | // call LocalTrigger | |
243 | Int_t iTrigger=0; | |
244 | LocalTrigger(icirc, minDevStrip, minDev, coordY, iTrigger); | |
245 | ||
246 | if (iTrigger==1&&fDebug>1) { | |
247 | PrintBitPatXInput(icirc); | |
248 | PrintBitPatYInput(icirc); | |
249 | PrintLocalOutput(minDevStrip, minDev, coordY); | |
250 | } | |
251 | } // end loop on circuits | |
252 | ||
253 | // call Global Trigger | |
254 | GlobalTrigger(); | |
255 | } | |
256 | ||
257 | //---------------------------------------------------------------------- | |
258 | void AliMUONTriggerDecision::ResetBit(){ | |
259 | // reset bit pattern, global and local trigger output tables to 0 | |
260 | ||
261 | Int_t i; | |
262 | Int_t icirc; | |
263 | Int_t istrip; | |
264 | ||
265 | for (icirc=0; icirc<234; icirc++) { | |
266 | for (istrip=0; istrip<16; istrip++) { | |
267 | fXbit11[icirc][istrip]=fXbit12[icirc][istrip]=0; | |
268 | fYbit11[icirc][istrip]=fYbit12[icirc][istrip]=0; | |
269 | fYbit21[icirc][istrip]=fYbit22[icirc][istrip]=0; | |
270 | fYbit21U[icirc][istrip]=fYbit22U[icirc][istrip]=0; | |
271 | fYbit21D[icirc][istrip]=fYbit22D[icirc][istrip]=0; | |
272 | } | |
273 | for (istrip=0; istrip<32; istrip++) { | |
274 | fXbit21[icirc][istrip]=fXbit22[icirc][istrip]=0; | |
275 | } | |
276 | } | |
277 | for (i=0; i<3; i++) { | |
278 | fGlobalSinglePlus[i]=0; | |
279 | fGlobalSingleMinus[i]=0; | |
280 | fGlobalSingleUndef[i]=0; | |
281 | fGlobalPairLike[i]=0; | |
282 | fGlobalPairLike[i]=0; | |
283 | } | |
284 | for (icirc=0; icirc<234; icirc++){ | |
285 | fTrigger[icirc]=0; | |
286 | fStripX11[icirc]=0; | |
287 | fDev[icirc]=0; | |
288 | fStripY11[icirc]=0; | |
289 | for (i=0; i<2; i++) { | |
290 | fLutLpt[icirc][i]=fLutHpt[icirc][i]=fLutApt[icirc][i]=0; | |
291 | } | |
292 | } | |
293 | } | |
294 | ||
295 | //---------------------------------------------------------------------- | |
296 | void AliMUONTriggerDecision::SetBit(){ | |
297 | // 1) loop over chambers and cathodes | |
298 | // 2) load digits | |
299 | // 3) remove soft background | |
300 | // 4) set the bit patterns | |
301 | ||
302 | Int_t cathode; | |
303 | AliMUONTriggerCircuit* triggerCircuit; | |
304 | ||
305 | for (Int_t chamber = 11; chamber < 15; chamber++){ | |
306 | ||
307 | TClonesArray *muonDigits = Digits(chamber-1); | |
308 | Int_t ndigits = muonDigits->GetEntriesFast(); | |
309 | AliDebug(3,Form("Found %d digits in %p %d", ndigits, (void*)muonDigits,chamber-1)); | |
310 | ||
311 | AliMUONDigit *mdig; | |
312 | ||
313 | for (Int_t digit = 0; digit < ndigits; digit++) { | |
314 | mdig = (AliMUONDigit*)muonDigits->UncheckedAt(digit); | |
315 | // get the center of the pad Id | |
316 | Int_t ix=mdig->PadX(); | |
317 | Int_t iy=mdig->PadY(); | |
318 | cathode = mdig->Cathode() + 1; | |
319 | AliDebug(3,Form("cathode %d ix %d iy %d ",cathode,ix,iy)); | |
320 | ||
321 | // get the sum of the coded charge | |
322 | // see coding convention in AliMUONChamberTrigger::DisIntegration | |
323 | Int_t sumCharge=0; | |
324 | for (Int_t icharge=0; icharge<10; icharge++) { | |
325 | sumCharge=sumCharge+mdig->TrackCharge(icharge); | |
326 | } | |
327 | // apply condition on soft background | |
328 | Int_t testCharge=sumCharge-(Int_t(sumCharge/10))*10; | |
329 | if(sumCharge<=10||testCharge>0) { | |
330 | // code pad | |
331 | Int_t code=TMath::Abs(ix)*100+iy; | |
332 | if (ix<0) { code=-code; } | |
333 | ||
334 | Int_t icirc; | |
335 | Int_t istrip; | |
336 | Int_t nStrip; | |
337 | ||
338 | // If I want to fetch the digits as in MUONCheck.C then I need to | |
339 | // know the correct digit index. These were stored in fDigitIndices | |
340 | // by the digitizer so we just need to fetch the correct value. | |
341 | Int_t digitindex = fDigitIndices[chamber-1][digit]; | |
342 | ||
343 | if (cathode==1) { | |
344 | switch (chamber) | |
345 | { | |
346 | case 11: | |
347 | for (icirc=0; icirc<234; icirc++) { | |
348 | triggerCircuit = (AliMUONTriggerCircuit*) fTriggerCircuit->At(icirc); | |
349 | for (istrip=0; istrip<16; istrip++) { | |
350 | if (triggerCircuit->GetXcode(0,istrip)==code) | |
351 | { | |
352 | fXbit11[icirc][istrip]=1; | |
353 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
354 | }; | |
355 | } | |
356 | } | |
357 | break; | |
358 | case 12: | |
359 | for (icirc=0; icirc<234; icirc++) { | |
360 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
361 | for (istrip=0; istrip<16; istrip++) { | |
362 | if (triggerCircuit->GetXcode(1,istrip)==code) | |
363 | { | |
364 | fXbit12[icirc][istrip]=1; | |
365 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
366 | }; | |
367 | } | |
368 | } | |
369 | break; | |
370 | case 13: | |
371 | for (icirc=0; icirc<234; icirc++) { | |
372 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
373 | for (istrip=0; istrip<32; istrip++) { | |
374 | if (triggerCircuit->GetXcode(2,istrip)==code) | |
375 | { | |
376 | fXbit21[icirc][istrip]=1; | |
377 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
378 | }; | |
379 | } | |
380 | } | |
381 | break; | |
382 | case 14: | |
383 | for (icirc=0; icirc<234; icirc++) { | |
384 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
385 | for (istrip=0; istrip<32; istrip++) { | |
386 | if (triggerCircuit->GetXcode(3,istrip)==code) | |
387 | { | |
388 | fXbit22[icirc][istrip]=1; | |
389 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
390 | }; | |
391 | } | |
392 | } | |
393 | break; | |
394 | } | |
395 | ||
396 | } else { // Y plane | |
397 | switch (chamber) | |
398 | { | |
399 | case 11: | |
400 | for (icirc=0; icirc<234; icirc++) { | |
401 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
402 | nStrip=triggerCircuit->GetNstripY(); | |
403 | for (istrip=0; istrip<nStrip; istrip++) { | |
404 | if (triggerCircuit->GetYcode(0,istrip)==code) | |
405 | { | |
406 | fYbit11[icirc][istrip]=1; | |
407 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
408 | }; | |
409 | } | |
410 | } | |
411 | break; | |
412 | case 12: | |
413 | for (icirc=0; icirc<234; icirc++) { | |
414 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
415 | nStrip=triggerCircuit->GetNstripY(); | |
416 | for (istrip=0; istrip<nStrip; istrip++) { | |
417 | if (triggerCircuit->GetYcode(1,istrip)==code) | |
418 | { | |
419 | fYbit12[icirc][istrip]=1; | |
420 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
421 | }; | |
422 | } | |
423 | } | |
424 | break; | |
425 | case 13: | |
426 | for (icirc=0; icirc<234; icirc++) { | |
427 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
428 | nStrip=triggerCircuit->GetNstripY(); | |
429 | for (istrip=0; istrip<nStrip; istrip++) { | |
430 | if (triggerCircuit->GetYcode(2,istrip)==code) | |
431 | { | |
432 | fYbit21[icirc][istrip]=1; | |
433 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
434 | }; | |
435 | } | |
436 | } | |
437 | break; | |
438 | case 14: | |
439 | for (icirc=0; icirc<234; icirc++) { | |
440 | triggerCircuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
441 | nStrip=triggerCircuit->GetNstripY(); | |
442 | for (istrip=0; istrip<nStrip; istrip++) { | |
443 | if (triggerCircuit->GetYcode(3,istrip)==code) | |
444 | { | |
445 | fYbit22[icirc][istrip]=1; | |
446 | DigitFiredCircuit(icirc, cathode-1, chamber-1, digitindex); | |
447 | }; | |
448 | } | |
449 | } | |
450 | break; | |
451 | } | |
452 | } // if cathode | |
453 | } // remove soft background | |
454 | } // end loop on digit | |
455 | fMUONData->ResetDigits(); | |
456 | // } // end loop on cathode | |
457 | } // end loop on chamber | |
458 | } | |
459 | ||
460 | //---------------------------------------------------------------------- | |
461 | void AliMUONTriggerDecision::SetBitUpDownY(){ | |
462 | // Set Y bit for up and down parts of circuits | |
463 | Int_t idModule, nStripX, nStripY, iPosCircuit; | |
464 | ||
465 | ||
466 | for (Int_t icirc=0; icirc<234; icirc++) { | |
467 | ||
468 | AliMUONTriggerCircuit* circuit; // current circuit | |
469 | AliMUONTriggerCircuit* circuitD; // circuit Down | |
470 | AliMUONTriggerCircuit* circuitU; // circuit Up | |
471 | ||
472 | circuit = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icirc); | |
473 | idModule=circuit->GetIdModule(); // corresponding module Id. | |
474 | nStripX=circuit->GetNstripX(); // number of X strips | |
475 | nStripY=circuit->GetNstripY(); // number of Y strips | |
476 | iPosCircuit=circuit->GetPosCircuit(); // position of circuit in module | |
477 | ||
478 | // fill lower part | |
479 | if (iPosCircuit==1) { // need to scan lower module | |
480 | if(idModule<91&&TMath::Abs(idModule)!=41&&idModule>-91) { | |
481 | Int_t icircD=circuit->GetICircuitD(); | |
482 | circuitD = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icircD); | |
483 | Int_t nStripD=circuitD->GetNstripY(); | |
484 | ||
485 | if (TMath::Abs(idModule)==42) { // shift of +8 bits | |
486 | for (Int_t istrip=0; istrip<nStripD; istrip++) { | |
487 | fYbit21D[icirc][istrip+8]=fYbit21[icircD][istrip]; | |
488 | fYbit22D[icirc][istrip+8]=fYbit22[icircD][istrip]; | |
489 | } | |
490 | } else if (TMath::Abs(idModule)==52) { // shift of -8 bits | |
491 | for (Int_t istrip=0; istrip<nStripD; istrip++) { | |
492 | fYbit21D[icirc][istrip]=fYbit21[icircD][istrip+8]; | |
493 | fYbit22D[icirc][istrip]=fYbit22[icircD][istrip+8]; | |
494 | } | |
495 | } else { | |
496 | for (Int_t istrip=0; istrip<nStripD; istrip++) { | |
497 | fYbit21D[icirc][istrip]=fYbit21[icircD][istrip]; | |
498 | fYbit22D[icirc][istrip]=fYbit22[icircD][istrip]; | |
499 | } | |
500 | } | |
501 | } | |
502 | } else { // lower strips within same module | |
503 | for (Int_t istrip=0; istrip<nStripY; istrip++) { | |
504 | fYbit21D[icirc][istrip]=fYbit21[icirc][istrip]; | |
505 | fYbit22D[icirc][istrip]=fYbit22[icirc][istrip]; | |
506 | } | |
507 | } | |
508 | ||
509 | // fill upper part | |
510 | if ((iPosCircuit==1&&nStripX==16)||(iPosCircuit==2&&nStripX==32)|| | |
511 | (iPosCircuit==3&&nStripX==48)||(iPosCircuit==4&&nStripX==64)) { | |
512 | if ((idModule>17||idModule<-17)&&TMath::Abs(idModule)!=61) { | |
513 | Int_t icircU=circuit->GetICircuitU(); | |
514 | circuitU = (AliMUONTriggerCircuit*)fTriggerCircuit->At(icircU); | |
515 | Int_t nStripU=circuitU->GetNstripY(); | |
516 | ||
517 | if (TMath::Abs(idModule)==62) { // shift of +8 bits | |
518 | for (Int_t istrip=0; istrip<nStripU; istrip++) { | |
519 | fYbit21U[icirc][istrip+8]=fYbit21[icircU][istrip]; | |
520 | fYbit22U[icirc][istrip+8]=fYbit22[icircU][istrip]; | |
521 | } | |
522 | } else if (TMath::Abs(idModule)==52) { // shift of -8 bits | |
523 | for (Int_t istrip=0; istrip<nStripU; istrip++) { | |
524 | fYbit21U[icirc][istrip]=fYbit21[icircU][istrip+8]; | |
525 | fYbit22U[icirc][istrip]=fYbit22[icircU][istrip+8]; | |
526 | } | |
527 | } else { | |
528 | for (Int_t istrip=0; istrip<nStripU; istrip++) { | |
529 | fYbit21U[icirc][istrip]=fYbit21[icircU][istrip]; | |
530 | fYbit22U[icirc][istrip]=fYbit22[icircU][istrip]; | |
531 | } | |
532 | } | |
533 | } | |
534 | } else { // upper strips within same module | |
535 | for (Int_t istrip=0; istrip<nStripY; istrip++) { | |
536 | fYbit21U[icirc][istrip]=fYbit21[icirc][istrip]; | |
537 | fYbit22U[icirc][istrip]=fYbit22[icirc][istrip]; | |
538 | } | |
539 | } | |
540 | } // loop on circuit | |
541 | } | |
542 | ||
543 | //---------------------------------------------------------------------- | |
544 | // x part of trigger Algo | |
545 | //---------------------------------------------------------------------- | |
546 | //---------------------------------------------------------------------- | |
547 | void AliMUONTriggerDecision::TrigX(Int_t ch1q[16], Int_t ch2q[16], | |
548 | Int_t ch3q[32], Int_t ch4q[32], | |
549 | Int_t coinc44, Int_t minDevStrip[5], | |
550 | Int_t minDev[5]){ | |
551 | // note : coinc44 = flag 0 or 1 (0 coincidence -> 3/4, 1 coincidence -> 4/4) | |
552 | //--------------------------------------------------------- | |
553 | // step # 1 : declustering, reduction DS, calculate sgle & dble | |
554 | //--------------------------------------------------------- | |
555 | Int_t ch1e[19], ch2e[20], ch3e[35], ch4e[36]; | |
556 | Int_t sgleHit1[31], sgleHit2[63]; | |
557 | Int_t dbleHit1[31], dbleHit2[63]; | |
558 | ||
559 | Int_t i; | |
560 | Int_t j; | |
561 | Int_t istrip; | |
562 | ||
563 | for (i=0; i<31; i++) { | |
564 | sgleHit1[i]=0; | |
565 | dbleHit1[i]=0; | |
566 | } | |
567 | for (i=0; i<63; i++) { | |
568 | sgleHit2[i]=0; | |
569 | dbleHit2[i]=0; | |
570 | } | |
571 | ||
572 | //--- inititialize che using chq | |
573 | for (i=0; i<19; i++) { | |
574 | if (i<1||i>16) ch1e[i]=0; | |
575 | else ch1e[i]=ch1q[i-1]; | |
576 | } | |
577 | for (i=0; i<20; i++) { | |
578 | if (i<2||i>17) ch2e[i]=0; | |
579 | else ch2e[i]=ch2q[i-2]; | |
580 | } | |
581 | for (i=0; i<35; i++) { | |
582 | if (i<1||i>32) ch3e[i]=0; | |
583 | else ch3e[i]=ch3q[i-1]; | |
584 | } | |
585 | for (i=0; i<36; i++) { | |
586 | if (i<2||i>33) ch4e[i]=0; | |
587 | else ch4e[i]=ch4q[i-2]; | |
588 | } | |
589 | ||
590 | ||
591 | //--- calculate dble & sgle first station | |
592 | for (i=0; i<=15; i++) { | |
593 | sgleHit1[2*i] = (!ch1e[i+1]|(ch1e[i]^ch1e[i+2])) & | |
594 | (!ch2e[i+2] | (ch2e[i+1]^ch2e[i+3])); | |
595 | ||
596 | dbleHit1[2*i] = ch1e[i+1]&!(ch1e[i+2]^ch1e[i]) & | |
597 | (ch2e[i+2] | (!ch2e[i]&ch2e[i+1]) | (ch2e[i+3]&!ch2e[i+4])); | |
598 | } | |
599 | ||
600 | for (i=0; i<=14; i++) { | |
601 | sgleHit1[2*i+1] = (!ch1e[i+1]|!ch1e[i+2]|(ch1e[i]^ch1e[i+3])) & | |
602 | (!ch2e[i+2] | !ch2e[i+3] | (ch2e[i+1]^ch2e[i+4])); | |
603 | dbleHit1[2*i+1] = ch1e[i+1]&ch1e[i+2]&!(ch1e[i]^ch1e[i+3]) & | |
604 | (ch2e[i+2]&(!ch2e[i+1]|!ch2e[i]) | | |
605 | ch2e[i+3]&(ch2e[i+2]|!ch2e[i+4]|!ch2e[i+5])); | |
606 | } | |
607 | ||
608 | //--- calculate dble & sgle second station | |
609 | for (i=0; i<=31; i++) { | |
610 | sgleHit2[2*i] = (!ch3e[i+1]|(ch3e[i]^ch3e[i+2])) & | |
611 | (!ch4e[i+2] | (ch4e[i+1]^ch4e[i+3])); | |
612 | dbleHit2[2*i] = ch3e[i+1]&!(ch3e[i+2]^ch3e[i]) & | |
613 | (ch4e[i+2] | (!ch4e[i]&ch4e[i+1]) | (ch4e[i+3]&!ch4e[i+4])); | |
614 | } | |
615 | ||
616 | for (i=0; i<=30; i++) { | |
617 | sgleHit2[2*i+1] = (!ch3e[i+1]|!ch3e[i+2]|(ch3e[i]^ch3e[i+3])) & | |
618 | (!ch4e[i+2] | !ch4e[i+3] | (ch4e[i+1]^ch4e[i+4])); | |
619 | dbleHit2[2*i+1] = ch3e[i+1]&ch3e[i+2]&!(ch3e[i]^ch3e[i+3]) & | |
620 | (ch4e[i+2]&(!ch4e[i+1]|!ch4e[i]) | | |
621 | ch4e[i+3]&(ch4e[i+2]|!ch4e[i+4]|!ch4e[i+5])); | |
622 | } | |
623 | ||
624 | //--- | |
625 | if(fDebug==3||fDebug==5) { | |
626 | printf("===============================================================\n"); | |
627 | printf(" X plane after sgle and dble \n"); | |
628 | printf(" 0987654321098765432109876543210"); | |
629 | printf("\n SGLE1 "); | |
630 | for (istrip=30; istrip>=0; istrip--) printf("%i",(!sgleHit1[istrip])); | |
631 | printf("\n DBLE1 "); | |
632 | for (istrip=30; istrip>=0; istrip--) printf("%i",dbleHit1[istrip]); | |
633 | printf("\n SGLE2 "); | |
634 | for (istrip=62; istrip>=0; istrip--) printf("%i",(!sgleHit2[istrip])); | |
635 | printf("\n DBLE2 "); | |
636 | for (istrip=62; istrip>=0; istrip--) printf("%i",dbleHit2[istrip]); | |
637 | printf("\n 210987654321098765432109876543210987654321098765432109876543210\n"); | |
638 | } | |
639 | ||
640 | //--------------------------------------------------------- | |
641 | // step # 2 : coincidence 3/4 | |
642 | //--------------------------------------------------------- | |
643 | Int_t rearImage[31][31]; | |
644 | for (i=0; i<31; i++) { | |
645 | for (j=0; j<31; j++) { | |
646 | rearImage[i][j]=0; | |
647 | } | |
648 | } | |
649 | ||
650 | Int_t notOr1=!dbleHit1[30] & !dbleHit1[29] & !dbleHit1[28] & !dbleHit1[27] & | |
651 | !dbleHit1[26] & !dbleHit1[25] & !dbleHit1[24] & !dbleHit1[23] & | |
652 | !dbleHit1[22] & !dbleHit1[21] & !dbleHit1[20] & !dbleHit1[19] & | |
653 | !dbleHit1[18] & !dbleHit1[17] & !dbleHit1[16] & !dbleHit1[15] & | |
654 | !dbleHit1[14] & !dbleHit1[13] & !dbleHit1[12] & !dbleHit1[11] & | |
655 | !dbleHit1[10] & !dbleHit1[9] & !dbleHit1[8] & !dbleHit1[7] & | |
656 | !dbleHit1[6] & !dbleHit1[5] & !dbleHit1[4] & !dbleHit1[3] & | |
657 | !dbleHit1[2] & !dbleHit1[1] & !dbleHit1[0] & !coinc44; | |
658 | ||
659 | Int_t notOr2= !dbleHit2[62] & !dbleHit2[61] & !dbleHit2[60] & !dbleHit2[59] & | |
660 | !dbleHit2[58] & !dbleHit2[57] & !dbleHit2[56] & !dbleHit2[55] & | |
661 | !dbleHit2[54] & !dbleHit2[53] & !dbleHit2[52] & !dbleHit2[51] & | |
662 | !dbleHit2[50] & !dbleHit2[49] & !dbleHit2[48] & !dbleHit2[47] & | |
663 | !dbleHit2[46] & !dbleHit2[45] & !dbleHit2[44] & !dbleHit2[43] & | |
664 | !dbleHit2[42] & !dbleHit2[41] & !dbleHit2[40] & !dbleHit2[39] & | |
665 | !dbleHit2[38] & !dbleHit2[37] & !dbleHit2[36] & !dbleHit2[35] & | |
666 | !dbleHit2[34] & !dbleHit2[33] & !dbleHit2[32] & !dbleHit2[31] & | |
667 | !dbleHit2[30] & !dbleHit2[29] & !dbleHit2[28] & !dbleHit2[27] & | |
668 | !dbleHit2[26] & !dbleHit2[25] & !dbleHit2[24] & !dbleHit2[23] & | |
669 | !dbleHit2[22] & !dbleHit2[21] & !dbleHit2[20] & !dbleHit2[19] & | |
670 | !dbleHit2[18] & !dbleHit2[17] & !dbleHit2[16] & !dbleHit2[15] & | |
671 | !dbleHit2[14] & !dbleHit2[13] & !dbleHit2[12] & !dbleHit2[11] & | |
672 | !dbleHit2[10] & !dbleHit2[9] & !dbleHit2[8] & !dbleHit2[7] & | |
673 | !dbleHit2[6] & !dbleHit2[5] & !dbleHit2[4] & !dbleHit2[3] & | |
674 | !dbleHit2[2] & !dbleHit2[1] & !dbleHit2[0] & !coinc44; | |
675 | ||
676 | // DS reduction | |
677 | for (i=0; i<31; i++) { | |
678 | sgleHit1[i] = !sgleHit1[i]¬Or1; | |
679 | } | |
680 | for (i=0; i<63; i++) { | |
681 | sgleHit2[i] = !sgleHit2[i]¬Or2; | |
682 | } | |
683 | ||
684 | // extract rearImage | |
685 | for (i=0; i<31; i++){ | |
686 | Int_t tmpSgleHit2[31]; | |
687 | Int_t tmpDbleHit2[31]; | |
688 | for (j=0; j<31; j++){ | |
689 | tmpSgleHit2[j] = sgleHit2[i+j+1]; | |
690 | tmpDbleHit2[j] = dbleHit2[i+j+1]; | |
691 | } | |
692 | ||
693 | for (Int_t k=0; k<31; k++) { | |
694 | rearImage[i][k]=(sgleHit1[i]&tmpDbleHit2[k])| | |
695 | (dbleHit1[i]&(tmpSgleHit2[k]|tmpDbleHit2[k])); | |
696 | } | |
697 | } | |
698 | ||
699 | //----------- | |
700 | if(fDebug==3||fDebug==5) { | |
701 | printf("===============================================================\n"); | |
702 | for (i=30; i>=0; i--) { | |
703 | printf("%i \t",i); | |
704 | for (istrip=31; istrip>=0; istrip--) printf("%i",rearImage[i][istrip]); | |
705 | printf("\n"); | |
706 | } | |
707 | } | |
708 | ||
709 | //--------------------------------------------------------- | |
710 | // step # 3 : calculate deviation | |
711 | //--------------------------------------------------------- | |
712 | Int_t dev[31][6]; | |
713 | for (i=0; i<31; i++) { | |
714 | for (j=0; j<6; j++) { | |
715 | dev[i][j]=0; | |
716 | } | |
717 | } | |
718 | ||
719 | for (i=0; i<31; i++){ | |
720 | Int_t leftDev[5], rightDev[5]; | |
721 | Int_t orL1, andL1, andL2, orR1, orR2, andR1, andR2, andR3; | |
722 | ||
723 | // calculate Left deviation | |
724 | orL1=rearImage[i][16]|rearImage[i][18]|rearImage[i][20]|rearImage[i][22]; | |
725 | andL1=!rearImage[i][17]&!rearImage[i][19]&!rearImage[i][21] & !orL1; | |
726 | andL2=!rearImage[i][23]&!rearImage[i][24]&!rearImage[i][25]&!rearImage[i][26]; | |
727 | ||
728 | leftDev[0] = (rearImage[i][16]|!rearImage[i][17]) & | |
729 | (rearImage[i][16]|rearImage[i][18]|!rearImage[i][19]& | |
730 | (rearImage[i][20]|!rearImage[i][21])) & | |
731 | (orL1|!rearImage[i][23]&(rearImage[i][24]|!rearImage[i][25])) & | |
732 | (orL1|rearImage[i][24]|rearImage[i][26]|!rearImage[i][27]& | |
733 | (rearImage[i][28]|!rearImage[i][29])); | |
734 | ||
735 | leftDev[1] = !rearImage[i][16] & | |
736 | !(!rearImage[i][17]&!rearImage[i][18]&!rearImage[i][21]&!rearImage[i][22] & | |
737 | (!rearImage[i][25]&!rearImage[i][26]&(rearImage[i][27]|rearImage[i][28]))) & | |
738 | (rearImage[i][17]|rearImage[i][18] | !rearImage[i][19]&!rearImage[i][20]) & | |
739 | (rearImage[i][17]|rearImage[i][18]|rearImage[i][21]|rearImage[i][22] | | |
740 | !rearImage[i][23]&!rearImage[i][24]); | |
741 | ||
742 | leftDev[2] = (!rearImage[i][16]&!rearImage[i][17]&!rearImage[i][18]) & | |
743 | (rearImage[i][19]|rearImage[i][20]|rearImage[i][21]|rearImage[i][22] | andL2); | |
744 | ||
745 | leftDev[3] = andL1; | |
746 | ||
747 | leftDev[4] = | |
748 | !rearImage[i][27]&!rearImage[i][28]&!rearImage[i][29]&!rearImage[i][30] & | |
749 | andL1 & andL2; | |
750 | ||
751 | // calculate Right deviation | |
752 | orR1=rearImage[i][8]|rearImage[i][10]|rearImage[i][12]|rearImage[i][14]; | |
753 | orR2=rearImage[i][8]|rearImage[i][9]|rearImage[i][10]|rearImage[i][11]; | |
754 | andR1=!rearImage[i][12]&!rearImage[i][13]&!rearImage[i][14]&!rearImage[i][15]; | |
755 | andR2= | |
756 | !rearImage[i][8]&!rearImage[i][9]&!rearImage[i][10]&!rearImage[i][11] & andR1; | |
757 | andR3=!rearImage[i][4]&!rearImage[i][5]&!rearImage[i][6]&!rearImage[i][7]; | |
758 | ||
759 | rightDev[0] = !rearImage[i][15]&(rearImage[i][14]|!rearImage[i][13]) & | |
760 | ((rearImage[i][12]|rearImage[i][14]|!rearImage[i][11]& | |
761 | (rearImage[i][10]|!rearImage[i][9])) & | |
762 | ((orR1|!rearImage[i][7]&(rearImage[i][6]|!rearImage[i][5])) & | |
763 | (orR1|rearImage[i][4]|rearImage[i][6]|!rearImage[i][3]&(rearImage[i][2]| | |
764 | !rearImage[i][1])))); | |
765 | ||
766 | rightDev[1] = !rearImage[i][15]&!rearImage[i][14] & | |
767 | !(!rearImage[i][4]&!rearImage[i][5]&!rearImage[i][8]&!rearImage[i][9] & | |
768 | (!rearImage[i][12]&!rearImage[i][13]&(rearImage[i][2]|rearImage[i][3]))) & | |
769 | (rearImage[i][12]|rearImage[i][13] | !rearImage[i][10]&!rearImage[i][11]) & | |
770 | (rearImage[i][8]|rearImage[i][9]|rearImage[i][12]|rearImage[i][13] | | |
771 | !rearImage[i][6]&!rearImage[i][7]); | |
772 | ||
773 | rightDev[2] = andR1 & (orR2 | andR3); | |
774 | rightDev[3] = andR2; | |
775 | rightDev[4] = | |
776 | !rearImage[i][0]&!rearImage[i][1]&!rearImage[i][2]&!rearImage[i][3] & | |
777 | andR2 & andR3 ; | |
778 | ||
779 | // compare Left & Right deviations | |
780 | Int_t tmpLeftDev=0, tmpRightDev=0; | |
781 | for (j=0; j<5; j++){ | |
782 | tmpLeftDev = tmpLeftDev + Int_t(leftDev[j]*TMath::Power(2,j)); | |
783 | tmpRightDev = tmpRightDev + Int_t(rightDev[j]*TMath::Power(2,j)); | |
784 | } | |
785 | ||
786 | // assign mimimum deviation do dev[][] | |
787 | if (tmpLeftDev < tmpRightDev ){ | |
788 | for (j=0; j<5; j++){ dev[i][j]=leftDev[j];} | |
789 | dev[i][5]=1; | |
790 | } else { | |
791 | for (j=0; j<5; j++){ dev[i][j]=rightDev[j];} | |
792 | dev[i][5]=0; | |
793 | } | |
794 | } | |
795 | ||
796 | //--- | |
797 | if(fDebug==3||fDebug==5) { | |
798 | printf("===============================================================\n"); | |
799 | for (i=30; i>=0; i--) { | |
800 | printf("%i \t",i); | |
801 | for (istrip=5; istrip>=0; istrip--) printf("%i",dev[i][istrip]); | |
802 | printf(" \n"); | |
803 | } | |
804 | } | |
805 | ||
806 | //--------------------------------------------------------- | |
807 | // step # 4 : sort deviation | |
808 | //--------------------------------------------------------- | |
809 | Int_t bga1[16], bga2[8], bga3[4], bga4[2], bga5; | |
810 | Int_t tmpbga1[16][6], tmpbga2[8][6], tmpbga3[4][6], tmpbga4[2][6], tmpbga5[6]; | |
811 | Int_t tmpMax[6]={1,1,1,1,1,0}; | |
812 | ||
813 | for (i=0; i<15; i++) { | |
814 | Sort2x5(dev[2*i],dev[2*i+1],tmpbga1[i],bga1[i]); | |
815 | } | |
816 | Sort2x5(dev[30],tmpMax,tmpbga1[15],bga1[15]); | |
817 | ||
818 | //-- | |
819 | if(fDebug==3||fDebug==5) { | |
820 | printf("===============================================================\n"); | |
821 | printf(" sorting : 1st level \n"); | |
822 | for (i=15; i>=0; i--) { | |
823 | printf("\t %i \t",bga1[i]); | |
824 | for (j=5; j>=0; j--) printf("%i",tmpbga1[i][j]); | |
825 | printf(" \n"); | |
826 | } | |
827 | } | |
828 | ||
829 | for (i=0; i<8; i++) { | |
830 | Sort2x5(tmpbga1[2*i],tmpbga1[2*i+1],tmpbga2[i],bga2[i]); | |
831 | } | |
832 | ||
833 | //-- | |
834 | if(fDebug==3||fDebug==5) { | |
835 | printf("===============================================================\n"); | |
836 | printf(" sorting : 2nd level \n"); | |
837 | for (i=7; i>=0; i--) { | |
838 | printf("\t %i \t",bga2[i]); | |
839 | for (j=5; j>=0; j--) printf("%i",tmpbga1[i][j]); | |
840 | printf(" \n"); | |
841 | } | |
842 | } | |
843 | ||
844 | for (i=0; i<4; i++) { | |
845 | Sort2x5(tmpbga2[2*i],tmpbga2[2*i+1],tmpbga3[i],bga3[i]); | |
846 | } | |
847 | ||
848 | //-- | |
849 | if(fDebug==3||fDebug==5) { | |
850 | printf("===============================================================\n"); | |
851 | printf(" sorting : 3rd level \n"); | |
852 | for (i=3; i>=0; i--) { | |
853 | printf("\t %i \t",bga3[i]); | |
854 | for (j=5; j>=0; j--) printf("%i",tmpbga3[i][j]); | |
855 | printf(" \n"); | |
856 | } | |
857 | } | |
858 | ||
859 | for (i=0; i<2; i++) { | |
860 | Sort2x5(tmpbga3[2*i],tmpbga3[2*i+1],tmpbga4[i],bga4[i]); | |
861 | } | |
862 | ||
863 | //-- | |
864 | if(fDebug==3||fDebug==5) { | |
865 | printf("===============================================================\n"); | |
866 | printf(" sorting : 4th level \n"); | |
867 | for (i=1; i>=0; i--) { | |
868 | printf("\t %i \t",bga4[i]); | |
869 | for (j=5; j>=0; j--) printf("%i",tmpbga4[i][j]); | |
870 | printf(" \n"); | |
871 | } | |
872 | } | |
873 | ||
874 | Sort2x5(tmpbga4[0],tmpbga4[1],tmpbga5,bga5); | |
875 | ||
876 | // coding from 6 to 5 bits | |
877 | minDev[4] = tmpbga5[5] | tmpbga5[4]; | |
878 | for (i=0; i<4; i++) { | |
879 | minDev[i]=tmpbga5[i] & !tmpbga5[4]; | |
880 | } | |
881 | ||
882 | // find address of strip with minimum deviation | |
883 | minDevStrip[4]=bga5; | |
884 | if (bga5<=1) minDevStrip[3]=bga4[bga5]; | |
885 | ||
886 | Int_t tmpAd=minDevStrip[3]+minDevStrip[4]*2; | |
887 | if (tmpAd<=3) minDevStrip[2]=bga3[tmpAd]; | |
888 | ||
889 | tmpAd=minDevStrip[2]+minDevStrip[3]*2+minDevStrip[4]*4; | |
890 | if (tmpAd<=7) minDevStrip[1]=bga2[tmpAd]; | |
891 | ||
892 | tmpAd=minDevStrip[1]+minDevStrip[2]*2+minDevStrip[3]*4+minDevStrip[4]*8; | |
893 | if (tmpAd<=15) minDevStrip[0]=bga1[tmpAd]; | |
894 | ||
895 | if(fDebug==3||fDebug==5) { | |
896 | printf("===============================================================\n"); | |
897 | printf("minDevStrip = "); | |
898 | for (i=4; i>=0; i--) printf("%i",minDevStrip[i]); | |
899 | printf(" minDev = "); | |
900 | for (i=4; i>=0; i--) printf("%i",minDev[i]); | |
901 | printf(" \n"); | |
902 | printf("===============================================================\n"); | |
903 | } | |
904 | ||
905 | } | |
906 | ||
907 | //--------------------------------------------- | |
908 | void AliMUONTriggerDecision::Sort2x5(Int_t dev1[6], Int_t dev2[6], | |
909 | Int_t minDev[6], Int_t &dev1GTdev2){ | |
910 | // returns minimun between dev1 and dev2 | |
911 | Int_t tmpDev1=0, tmpDev2=0; | |
912 | for (Int_t j=0; j<5; j++){ | |
913 | tmpDev1 = tmpDev1 + Int_t(dev1[j]*TMath::Power(2,j)); | |
914 | tmpDev2 = tmpDev2 + Int_t(dev2[j]*TMath::Power(2,j)); | |
915 | } | |
916 | if (tmpDev1 <= tmpDev2 ){ | |
917 | for (Int_t j=0; j<=5; j++) { minDev[j]=dev1[j];} | |
918 | dev1GTdev2=0; | |
919 | } else { | |
920 | for (Int_t j=0; j<=5; j++) { minDev[j]=dev2[j];} | |
921 | dev1GTdev2=1; | |
922 | } | |
923 | } | |
924 | ||
925 | //---------------------------------------------------------------------- | |
926 | // y part of trigger Algo | |
927 | //---------------------------------------------------------------------- | |
928 | //---------------------------------------------------------------------- | |
929 | void AliMUONTriggerDecision::TrigY(Int_t y1[16], Int_t y2[16], | |
930 | Int_t y3[16], Int_t y4[16], | |
931 | Int_t y3u[16], Int_t y3d[16], | |
932 | Int_t y4u[16], Int_t y4d[16], | |
933 | Int_t x2m, Int_t x2ud, Int_t orMud[2], | |
934 | Int_t resetMid, Int_t coinc44, | |
935 | Int_t coordY[5]){ | |
936 | // note : resMid = 1 -> cancel | |
937 | //--------------------------------------------------------- | |
938 | // step # 1 : prehandling Y | |
939 | //--------------------------------------------------------- | |
940 | Int_t i; | |
941 | Int_t istrip; | |
942 | ||
943 | for (i=0; i<16; i++){ | |
944 | y3[i]=y3[i]&!resetMid; | |
945 | y4[i]=y4[i]&!resetMid; | |
946 | } | |
947 | ||
948 | Int_t ch1[16], ch2[16], ch3[16], ch4[16]; | |
949 | ||
950 | Int_t tmpy3to16[16], tmpy4to16[16]; | |
951 | Int_t tmpy3uto16[16], tmpy3dto16[16], tmpy4uto16[16], tmpy4dto16[16]; | |
952 | for (i=0; i<8; i++){ | |
953 | ch1[2*i] = y1[i]&x2m | y1[2*i]&!x2m; | |
954 | ch1[2*i+1] = y1[i]&x2m | y1[2*i+1]&!x2m; | |
955 | ||
956 | ch2[2*i] = y2[i]&x2m | y2[2*i]&!x2m; | |
957 | ch2[2*i+1] = y2[i]&x2m | y2[2*i+1]&!x2m; | |
958 | ||
959 | tmpy3to16[2*i] = y3[i]&x2m | y3[2*i]&!x2m; | |
960 | tmpy3to16[2*i+1] = y3[i]&x2m | y3[2*i+1]&!x2m; | |
961 | ||
962 | tmpy4to16[2*i] = y4[i]&x2m | y4[2*i]&!x2m; | |
963 | tmpy4to16[2*i+1] = y4[i]&x2m | y4[2*i+1]&!x2m; | |
964 | ||
965 | tmpy3uto16[2*i] = y3u[i]&x2ud | y3u[2*i]&!x2ud; | |
966 | tmpy3uto16[2*i+1] = y3u[i]&x2ud | y3u[2*i+1]&!x2ud; | |
967 | ||
968 | tmpy4uto16[2*i] = y4u[i]&x2ud | y4u[2*i]&!x2ud; | |
969 | tmpy4uto16[2*i+1] = y4u[i]&x2ud | y4u[2*i+1]&!x2ud; | |
970 | ||
971 | tmpy3dto16[2*i] = y3d[i]&x2ud | y3d[2*i]&!x2ud; | |
972 | tmpy3dto16[2*i+1] = y3d[i]&x2ud | y3d[2*i+1]&!x2ud; | |
973 | ||
974 | tmpy4dto16[2*i] = y4d[i]&x2ud | y4d[2*i]&!x2ud; | |
975 | tmpy4dto16[2*i+1] = y4d[i]&x2ud | y4d[2*i+1]&!x2ud; | |
976 | } | |
977 | ||
978 | if (orMud[0]==0&&orMud[1]==0){ | |
979 | for (i=0; i<16; i++){ | |
980 | ch3[i] = tmpy3to16[i]; | |
981 | ch4[i] = tmpy4to16[i]; | |
982 | } | |
983 | } | |
984 | if (orMud[0]==0&&orMud[1]==1){ | |
985 | for (i=0; i<16; i++){ | |
986 | ch3[i] = tmpy3uto16[i]|tmpy3to16[i]; | |
987 | ch4[i] = tmpy4uto16[i]|tmpy4to16[i]; | |
988 | } | |
989 | } | |
990 | if (orMud[0]==1&&orMud[1]==0){ | |
991 | for (i=0; i<16; i++){ | |
992 | ch3[i] = tmpy3dto16[i]|tmpy3to16[i]; | |
993 | ch4[i] = tmpy4dto16[i]|tmpy4to16[i]; | |
994 | } | |
995 | } | |
996 | if (orMud[0]==1&&orMud[1]==1){ | |
997 | for (i=0; i<16; i++){ | |
998 | ch3[i] = tmpy3dto16[i]|tmpy3to16[i]|tmpy3uto16[i]; | |
999 | ch4[i] = tmpy4dto16[i]|tmpy4to16[i]|tmpy4uto16[i]; | |
1000 | } | |
1001 | } | |
1002 | ||
1003 | // debug | |
1004 | if(fDebug==4||fDebug==5) { | |
1005 | printf("===============================================================\n"); | |
1006 | printf(" Y plane after PreHandling x2m x2ud orMud %i %i %i %i \n", | |
1007 | x2m,x2ud,orMud[0],orMud[1]); | |
1008 | printf(" "); | |
1009 | for (istrip=15; istrip>=0; istrip--) { | |
1010 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); | |
1011 | if (istrip<10) printf("%i",istrip); | |
1012 | } | |
1013 | printf("\n YMC11 "); | |
1014 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch1[istrip]); | |
1015 | printf("\n YMC12 "); | |
1016 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch2[istrip]); | |
1017 | printf("\n YMC21 "); | |
1018 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch3[istrip]); | |
1019 | printf("\n YMC22 "); | |
1020 | for (istrip=15; istrip>=0; istrip--) printf("%i",ch4[istrip]); | |
1021 | printf(" \n"); | |
1022 | } | |
1023 | //debug | |
1024 | ||
1025 | //--------------------------------------------------------- | |
1026 | // step # 2 : calculate sgle and dble, apply DS reduction | |
1027 | //--------------------------------------------------------- | |
1028 | Int_t sgle1[16], dble1[16]; | |
1029 | Int_t sgle2[16], dble2[16]; | |
1030 | ||
1031 | // Calculate simple and double hits | |
1032 | for (i=0; i<16; i++) { | |
1033 | dble1[i] = ch1[i] & ch2[i]; | |
1034 | dble2[i] = ch3[i] & ch4[i]; | |
1035 | ||
1036 | sgle1[i] = (ch1[i]|ch2[i]); | |
1037 | sgle2[i] = (ch3[i]|ch4[i]); | |
1038 | } | |
1039 | ||
1040 | //debug | |
1041 | if(fDebug==4||fDebug==5) { | |
1042 | printf("===============================================================\n"); | |
1043 | printf(" Y plane after sgle dble \n"); | |
1044 | printf(" "); | |
1045 | for (istrip=15; istrip>=0; istrip--) { | |
1046 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); | |
1047 | if (istrip<10) printf("%i",istrip); | |
1048 | } | |
1049 | printf("\n SGLE1 "); | |
1050 | for (istrip=15; istrip>=0; istrip--) printf("%i",sgle1[istrip]); | |
1051 | printf("\n DBLE1 "); | |
1052 | for (istrip=15; istrip>=0; istrip--) printf("%i",dble1[istrip]); | |
1053 | printf("\n SGLE2 "); | |
1054 | for (istrip=15; istrip>=0; istrip--) printf("%i",sgle2[istrip]); | |
1055 | printf("\n DBLE2 "); | |
1056 | for (istrip=15; istrip>=0; istrip--) printf("%i",dble2[istrip]); | |
1057 | printf(" \n"); | |
1058 | } | |
1059 | //debug | |
1060 | ||
1061 | // DS Reduction | |
1062 | Int_t notOr1, notOr2; | |
1063 | ||
1064 | notOr1=!dble1[15] & !dble1[14] & !dble1[13] & !dble1[12] & | |
1065 | !dble1[11] & !dble1[10] & !dble1[9] & !dble1[8] & | |
1066 | !dble1[7] & !dble1[6] & !dble1[5] & !dble1[4] & | |
1067 | !dble1[3] & !dble1[2] & !dble1[1] & !dble1[0]; | |
1068 | ||
1069 | notOr2=!dble2[15] & !dble2[14] & !dble2[13] & !dble2[12] & | |
1070 | !dble2[11] & !dble2[10] & !dble2[9] & !dble2[8] & | |
1071 | !dble2[7] & !dble2[6] & !dble2[5] & !dble2[4] & | |
1072 | !dble2[3] & !dble2[2] & !dble2[1] & !dble2[0]; | |
1073 | ||
1074 | for (i=0; i<16; i++) { | |
1075 | sgle1[i] = sgle1[i] & notOr1 & !coinc44; | |
1076 | sgle2[i] = sgle2[i] & notOr2 & !coinc44; | |
1077 | } | |
1078 | ||
1079 | //--------------------------------------------------------- | |
1080 | // step # 3 : 3/4 coincidence | |
1081 | //--------------------------------------------------------- | |
1082 | Int_t frontImage[16]; | |
1083 | ||
1084 | for (i=1; i<15; i++) { | |
1085 | frontImage[i] = (dble1[i] | sgle1[i]) & | |
1086 | (dble2[i+1] | dble2[i] | dble2[i-1]) | | |
1087 | dble1[i] & (sgle2[i+1] | sgle2[i] | sgle2[i-1]); | |
1088 | } | |
1089 | frontImage[0] = (dble1[0] | sgle1[0]) & | |
1090 | (dble2[1] | dble2[0]) | dble1[0] & (sgle2[1] | sgle2[0]); | |
1091 | ||
1092 | frontImage[15] = (dble1[15] | sgle1[15]) & | |
1093 | (dble2[15] | dble2[14]) | dble1[15] & (sgle2[15] | sgle2[14]); | |
1094 | ||
1095 | ||
1096 | //debug | |
1097 | if(fDebug==4||fDebug==5) { | |
1098 | printf("===============================================================\n"); | |
1099 | printf(" Y plane frontImage\n"); | |
1100 | printf(" "); | |
1101 | for (istrip=15; istrip>=0; istrip--) { | |
1102 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); | |
1103 | if (istrip<10) printf("%i",istrip); | |
1104 | } | |
1105 | printf("\n "); | |
1106 | for (istrip=15; istrip>=0; istrip--) printf("%i",frontImage[istrip]); | |
1107 | printf("\n"); | |
1108 | } | |
1109 | //debug | |
1110 | ||
1111 | //--------------------------------------------------------- | |
1112 | // step # 4 : Y position | |
1113 | //--------------------------------------------------------- | |
1114 | Int_t or1, or2, and1, and2, and3; | |
1115 | ||
1116 | or1 = frontImage[7]|frontImage[5]|frontImage[3]|frontImage[1]; | |
1117 | or2 = frontImage[7]|frontImage[6]|frontImage[5]|frontImage[4]; | |
1118 | and1 = !frontImage[3]&!frontImage[2]&!frontImage[1]&!frontImage[0]; | |
1119 | and2 = !frontImage[7]&!frontImage[6]&!frontImage[5]&!frontImage[4] & and1; | |
1120 | and3 = !frontImage[11]&!frontImage[10]&!frontImage[9]&!frontImage[8]; | |
1121 | ||
1122 | coordY[0] = !frontImage[0]&(frontImage[1]|!frontImage[2]) & | |
1123 | (frontImage[3]|frontImage[1]|!frontImage[4]&(frontImage[5]|!frontImage[6])) & | |
1124 | (or1|!frontImage[8]&(frontImage[9]|!frontImage[10])) & | |
1125 | (or1|frontImage[11]|frontImage[9]|!frontImage[12]&(frontImage[13]|!frontImage[14])); | |
1126 | ||
1127 | coordY[1] = !frontImage[0]&!frontImage[1] & | |
1128 | !(!frontImage[11]&!frontImage[10]&!frontImage[7]&!frontImage[6] & | |
1129 | !frontImage[3]&!frontImage[2]&(frontImage[13]|frontImage[12])) & | |
1130 | (frontImage[3]|frontImage[2] | !frontImage[5]&!frontImage[4]) & | |
1131 | (frontImage[7]|frontImage[6]|frontImage[3]|frontImage[2] | | |
1132 | !frontImage[9]&!frontImage[8]); | |
1133 | ||
1134 | coordY[2] = and1 & (or2 | and3); | |
1135 | ||
1136 | coordY[3] = and2; | |
1137 | ||
1138 | coordY[4] = !frontImage[15]&!frontImage[14]&!frontImage[13]&!frontImage[12] & | |
1139 | and2 & and3 ; | |
1140 | ||
1141 | } | |
1142 | //---------------------------------------------------------------------- | |
1143 | // end of trigger Algo | |
1144 | //---------------------------------------------------------------------- | |
1145 | ||
1146 | //---------------------------------------------------------------------- | |
1147 | void AliMUONTriggerDecision::LocalTrigger(Int_t icirc, | |
1148 | Int_t minDevStrip[5], | |
1149 | Int_t minDev[5], Int_t coordY[5], | |
1150 | Int_t &iTrigger){ | |
1151 | // returns local trigger answer for circuit icirc | |
1152 | Int_t i; | |
1153 | ||
1154 | AliMUONTriggerCircuit* triggerCircuit; | |
1155 | triggerCircuit = (AliMUONTriggerCircuit*) fTriggerCircuit->At(icirc); | |
1156 | Int_t idCircuit=triggerCircuit->GetIdCircuit(); | |
1157 | ||
1158 | Int_t signDev=minDev[4]; | |
1159 | Int_t deviation=0; | |
1160 | for (i=0; i<4; i++) { // extract deviation | |
1161 | deviation = deviation+Int_t(minDev[i]*TMath::Power(2,i)); | |
1162 | } | |
1163 | ||
1164 | Int_t istripX1Circ=0; | |
1165 | for (i=0; i<5; i++) { // extract X1 strip fired | |
1166 | istripX1Circ = istripX1Circ+Int_t(minDevStrip[i]*TMath::Power(2,i)); | |
1167 | } | |
1168 | ||
1169 | Int_t iStripY=0; | |
1170 | for (i=0; i<4; i++) { // extract Y strip fired | |
1171 | iStripY = iStripY+Int_t(coordY[i]*TMath::Power(2,i)); | |
1172 | } | |
1173 | ||
1174 | // trigger or not | |
1175 | if (signDev==1&&deviation==0) { // something in X ? | |
1176 | iTrigger=0; | |
1177 | } else { | |
1178 | if (coordY[4]==1&&iStripY==15) { // something in Y ? | |
1179 | iTrigger=0; | |
1180 | } else { | |
1181 | iTrigger=1; | |
1182 | } | |
1183 | } | |
1184 | ||
1185 | if (iTrigger==1) { | |
1186 | // fill fTrigger fStripX11 fStripY11 | |
1187 | fTrigger[icirc] = 1; | |
1188 | fStripX11[icirc] = istripX1Circ; | |
1189 | fStripY11[icirc] = iStripY; | |
1190 | ||
1191 | // calculate deviation in [0+30] | |
1192 | Int_t sign=0; | |
1193 | if (signDev==0&&deviation!=0) sign=-1; | |
1194 | if (signDev==0&&deviation==0) sign=0; | |
1195 | if (signDev==1) sign=1; | |
1196 | fDev[icirc] = sign * deviation + 15; // fill fDev | |
1197 | ||
1198 | // get Lut output for circuit/istripX/idev/istripY | |
1199 | AliMUONTriggerLut* lut = new AliMUONTriggerLut; | |
1200 | // lut->StartEvent(); | |
1201 | lut->GetLutOutput(icirc,fStripX11[icirc],fDev[icirc],fStripY11[icirc], | |
1202 | fLutLpt[icirc],fLutHpt[icirc],fLutApt[icirc]); | |
1203 | // lut->FinishEvent(); | |
1204 | delete lut; | |
1205 | ||
1206 | if (fDebug>1) { | |
1207 | Float_t pt= // get ptCal corresponding to istripX1Circ/idev/iStripY | |
1208 | triggerCircuit->PtCal(fStripX11[icirc],fDev[icirc],fStripY11[icirc]); | |
1209 | printf("-------------------------------------------\n"); | |
1210 | printf(" Local Trigger info for circuit Id %i (number %i ) \n", | |
1211 | idCircuit,icirc); | |
1212 | printf(" istripX1 signDev deviation istripY = %i %i %i %i \n", | |
1213 | istripX1Circ,signDev,deviation,iStripY); | |
1214 | printf(" pt = %f (GeV/c) \n",pt); | |
1215 | printf("-------------------------------------------\n"); | |
1216 | printf(" Local Trigger Lut Output = Lpt : "); | |
1217 | for (i=1; i>=0; i--) printf("%i",fLutLpt[icirc][i]); | |
1218 | printf(" Hpt : "); | |
1219 | for (i=1; i>=0; i--) printf("%i",fLutHpt[icirc][i]); | |
1220 | printf(" Apt : "); | |
1221 | for (i=1; i>=0; i--) printf("%i",fLutApt[icirc][i]); | |
1222 | printf("\n"); | |
1223 | printf("-------------------------------------------\n"); | |
1224 | } // fDebug > 1 | |
1225 | } // local trigger = 1 | |
1226 | } | |
1227 | ||
1228 | //---------------------------------------------------------------------- | |
1229 | void AliMUONTriggerDecision::GlobalTrigger(){ | |
1230 | // loop on Lut[icirc] and give Global Trigger output | |
1231 | Int_t i; | |
1232 | ||
1233 | for (Int_t icirc=0; icirc<234; icirc++){ | |
1234 | if (fLutLpt[icirc][0]==1&&fLutLpt[icirc][1]==1) | |
1235 | fGlobalSingleUndef[0] = fGlobalSingleUndef[0] + 1; | |
1236 | if (fLutHpt[icirc][0]==1&&fLutHpt[icirc][1]==1) | |
1237 | fGlobalSingleUndef[1] = fGlobalSingleUndef[1] + 1; | |
1238 | if (fLutApt[icirc][0]==1&&fLutApt[icirc][1]==1) | |
1239 | fGlobalSingleUndef[2] = fGlobalSingleUndef[2] + 1; | |
1240 | ||
1241 | if (fLutLpt[icirc][0]==0&&fLutLpt[icirc][1]==1) | |
1242 | fGlobalSinglePlus[0] = fGlobalSinglePlus[0] + 1; | |
1243 | if (fLutHpt[icirc][0]==0&&fLutHpt[icirc][1]==1) | |
1244 | fGlobalSinglePlus[1] = fGlobalSinglePlus[1] + 1; | |
1245 | if (fLutApt[icirc][0]==0&&fLutApt[icirc][1]==1) | |
1246 | fGlobalSinglePlus[2] = fGlobalSinglePlus[2] + 1; | |
1247 | ||
1248 | if (fLutLpt[icirc][0]==1&&fLutLpt[icirc][1]==0) | |
1249 | fGlobalSingleMinus[0] = fGlobalSingleMinus[0] + 1; | |
1250 | if (fLutHpt[icirc][0]==1&&fLutHpt[icirc][1]==0) | |
1251 | fGlobalSingleMinus[1] = fGlobalSingleMinus[1] + 1; | |
1252 | if (fLutApt[icirc][0]==1&&fLutApt[icirc][1]==0) | |
1253 | fGlobalSingleMinus[2] = fGlobalSingleMinus[2] + 1; | |
1254 | } | |
1255 | ||
1256 | // like sign low, high and all pt | |
1257 | for (i=0; i<3; i++) { | |
1258 | fGlobalPairLike[i]=fGlobalSingleMinus[i]*(fGlobalSingleMinus[i]-1)/2 + | |
1259 | fGlobalSinglePlus[i]*(fGlobalSinglePlus[i]-1)/2 + | |
1260 | fGlobalSingleUndef[i]*(fGlobalSingleUndef[i]-1)/2 + | |
1261 | fGlobalSingleUndef[i]*fGlobalSinglePlus[i] + | |
1262 | fGlobalSingleUndef[i]*fGlobalSingleMinus[i]; | |
1263 | } | |
1264 | ||
1265 | // unlike sign low, high and all pt | |
1266 | for (i=0; i<3; i++) { | |
1267 | fGlobalPairUnlike[i]=fGlobalSingleMinus[i]*fGlobalSinglePlus[i] + | |
1268 | fGlobalSingleUndef[i]*(fGlobalSingleUndef[i]-1)/2 + | |
1269 | fGlobalSingleUndef[i]*fGlobalSinglePlus[i] + | |
1270 | fGlobalSingleUndef[i]*fGlobalSingleMinus[i]; | |
1271 | } | |
1272 | ||
1273 | if (fDebug>=1) { | |
1274 | printf("===================================================\n"); | |
1275 | printf(" Global Trigger output Low pt High pt All\n"); | |
1276 | printf(" number of Single Plus :\t"); | |
1277 | for (i=0; i<3; i++) printf("%i\t",fGlobalSinglePlus[i]); | |
1278 | printf("\n"); | |
1279 | printf(" number of Single Minus :\t"); | |
1280 | for (i=0; i<3; i++) printf("%i\t",fGlobalSingleMinus[i]); | |
1281 | printf("\n"); | |
1282 | printf(" number of Single Undefined :\t"); | |
1283 | for (i=0; i<3; i++) printf("%i\t",fGlobalSingleUndef[i]); | |
1284 | printf("\n"); | |
1285 | printf(" number of UnlikeSign pair :\t"); | |
1286 | for (i=0; i<3; i++) printf("%i\t",fGlobalPairUnlike[i]); | |
1287 | printf("\n"); | |
1288 | printf(" number of LikeSign pair :\t"); | |
1289 | for (i=0; i<3; i++) printf("%i\t",fGlobalPairLike[i]); | |
1290 | printf("\n"); | |
1291 | printf("===================================================\n"); | |
1292 | printf("\n"); | |
1293 | } | |
1294 | } | |
1295 | ||
1296 | //---------------------------------------------------------------------- | |
1297 | void AliMUONTriggerDecision::PrintBitPatXInput(Int_t icirc){ | |
1298 | // print bit pattern for X strips | |
1299 | ||
1300 | Int_t istrip; | |
1301 | ||
1302 | printf("-------- TRIGGER INPUT ---------\n"); | |
1303 | printf("===============================================================\n"); | |
1304 | printf(" 5432109876543210"); | |
1305 | printf("\n XMC11 "); | |
1306 | for (istrip=15; istrip>=0; istrip--) printf("%i",fXbit11[icirc][istrip]); | |
1307 | printf("\n XMC12 "); | |
1308 | for (istrip=15; istrip>=0; istrip--) printf("%i",fXbit12[icirc][istrip]); | |
1309 | printf("\n XMC21 "); | |
1310 | for (istrip=31; istrip>=0; istrip--) printf("%i",fXbit21[icirc][istrip]); | |
1311 | printf("\n XMC22 "); | |
1312 | for (istrip=31; istrip>=0; istrip--) printf("%i",fXbit22[icirc][istrip]); | |
1313 | printf("\n "); | |
1314 | printf("10987654321098765432109876543210\n"); | |
1315 | } | |
1316 | ||
1317 | //---------------------------------------------------------------------- | |
1318 | void AliMUONTriggerDecision::PrintBitPatYInput(Int_t icirc){ | |
1319 | // print bit pattern for Y strips | |
1320 | ||
1321 | Int_t istrip; | |
1322 | ||
1323 | AliMUONTriggerCircuit* triggerCircuit; | |
1324 | triggerCircuit = (AliMUONTriggerCircuit*) fTriggerCircuit->At(icirc); | |
1325 | Int_t idCircuit=triggerCircuit->GetIdCircuit(); | |
1326 | Int_t nStrip=triggerCircuit->GetNstripY(); | |
1327 | ||
1328 | printf("---------------------------------------------------------------\n"); | |
1329 | printf(" "); | |
1330 | for (istrip=nStrip-1; istrip>=0; istrip--) { | |
1331 | if (istrip>9) printf("%i",istrip-10*Int_t(istrip/10)); | |
1332 | if (istrip<10) printf("%i",istrip); | |
1333 | } | |
1334 | printf("\n YMC11 "); | |
1335 | for (istrip=nStrip-1; istrip>=0; istrip--) | |
1336 | printf("%i",fYbit11[icirc][istrip]); | |
1337 | printf("\n YMC12 "); | |
1338 | for (istrip=nStrip-1; istrip>=0; istrip--) | |
1339 | printf("%i",fYbit12[icirc][istrip]); | |
1340 | printf("\n YMC21 "); | |
1341 | for (istrip=nStrip-1; istrip>=0; istrip--) | |
1342 | printf("%i",fYbit21[icirc][istrip]); | |
1343 | printf("\n YMC22 "); | |
1344 | for (istrip=nStrip-1; istrip>=0; istrip--) | |
1345 | printf("%i",fYbit22[icirc][istrip]); | |
1346 | printf("\n"); | |
1347 | // tmp | |
1348 | printf("---------------------------------------------------------------"); | |
1349 | printf("\n upper part of circuit %i",idCircuit); | |
1350 | printf("\n UMC21 "); | |
1351 | for (istrip=15; istrip>=0; istrip--) printf("%i",fYbit21U[icirc][istrip]); | |
1352 | printf("\n UMC22 "); | |
1353 | for (istrip=15; istrip>=0; istrip--) printf("%i", fYbit22U[icirc][istrip]); | |
1354 | ||
1355 | printf("\n lower part of circuit %i",idCircuit); | |
1356 | printf("\n LMC21 "); | |
1357 | for (istrip=15; istrip>=0; istrip--) printf("%i",fYbit21D[icirc][istrip]); | |
1358 | printf("\n LMC22 "); | |
1359 | for (istrip=15; istrip>=0; istrip--) printf("%i",fYbit22D[icirc][istrip]); | |
1360 | printf("\n"); | |
1361 | printf("===============================================================\n"); | |
1362 | } | |
1363 | ||
1364 | //---------------------------------------------------------------------- | |
1365 | void AliMUONTriggerDecision::PrintLocalOutput(Int_t minDevStrip[5], | |
1366 | Int_t minDev[5], | |
1367 | Int_t coordY[5]){ | |
1368 | // print Local trigger output before the LuT step | |
1369 | ||
1370 | Int_t i; | |
1371 | ||
1372 | printf("===============================================================\n"); | |
1373 | printf("-------- TRIGGER OUTPUT --------\n"); | |
1374 | printf("minDevStrip = "); | |
1375 | for (i=4; i>=0; i--) printf("%i",minDevStrip[i]); | |
1376 | printf(" minDev = "); | |
1377 | for (i=4; i>=0; i--) printf("%i",minDev[i]); | |
1378 | printf(" coordY = "); | |
1379 | for (i=4; i>=0; i--) printf("%i",coordY[i]); | |
1380 | printf(" \n"); | |
1381 | } | |
1382 | ||
1383 | //---------------------------------------------------------------------- | |
1384 | //--- methods which return member data related info | |
1385 | //---------------------------------------------------------------------- | |
1386 | Int_t AliMUONTriggerDecision::GetITrigger(Int_t icirc) const{ | |
1387 | // returns Local Trigger Status | |
1388 | return fTrigger[icirc]; | |
1389 | } | |
1390 | //---------------------------------------------------------------------- | |
1391 | Int_t AliMUONTriggerDecision::GetStripX11(Int_t icirc) const{ | |
1392 | // returns fStripX11 | |
1393 | return fStripX11[icirc]; | |
1394 | } | |
1395 | //---------------------------------------------------------------------- | |
1396 | Int_t AliMUONTriggerDecision::GetDev(Int_t icirc) const{ | |
1397 | // returns idev | |
1398 | return fDev[icirc]; | |
1399 | } | |
1400 | //---------------------------------------------------------------------- | |
1401 | Int_t AliMUONTriggerDecision::GetStripY11(Int_t icirc) const{ | |
1402 | // returns fStripY11; | |
1403 | return fStripY11[icirc]; | |
1404 | } | |
1405 | //---------------------------------------------------------------------- | |
1406 | void AliMUONTriggerDecision::GetLutOutput(Int_t icirc, Int_t lpt[2], | |
1407 | Int_t hpt[2], Int_t apt[2]) const { | |
1408 | // returns Look up Table output | |
1409 | for (Int_t i=0; i<2; i++) { | |
1410 | lpt[i]=fLutLpt[icirc][i]; | |
1411 | hpt[i]=fLutHpt[icirc][i]; | |
1412 | apt[i]=fLutApt[icirc][i]; | |
1413 | } | |
1414 | } | |
1415 | //---------------------------------------------------------------------- | |
1416 | void AliMUONTriggerDecision::GetGlobalTrigger(Int_t singlePlus[3], | |
1417 | Int_t singleMinus[3], | |
1418 | Int_t singleUndef[3], | |
1419 | Int_t pairUnlike[3], | |
1420 | Int_t pairLike[3]) const { | |
1421 | // returns Global Trigger information (0,1,2 : Lpt,Hpt,Apt) | |
1422 | // should not be used anymore. | |
1423 | for (Int_t i=0; i<3; i++) { | |
1424 | singlePlus[i] = fGlobalSinglePlus[i]; | |
1425 | singleMinus[i] = fGlobalSingleMinus[i]; | |
1426 | singleUndef[i] = fGlobalSingleUndef[i]; | |
1427 | pairUnlike[i] = fGlobalPairUnlike[i]; | |
1428 | pairLike[i] = fGlobalPairLike[i]; | |
1429 | } | |
1430 | } | |
1431 | ||
1432 | //_______________________________________________________________________ | |
1433 | void AliMUONTriggerDecision::Digits2Trigger(){ | |
1434 | // call the Trigger Algorithm and fill TreeD | |
1435 | ||
1436 | ClearDigitNumbers(); | |
1437 | ||
1438 | fMUONData->ResetTrigger(); | |
1439 | Trigger(); | |
1440 | AliMUONGlobalTrigger* pGloTrig = new AliMUONGlobalTrigger(fGlobalSinglePlus, fGlobalSingleMinus, | |
1441 | fGlobalSingleUndef, fGlobalPairUnlike, | |
1442 | fGlobalPairLike); | |
1443 | // add a local trigger in the list | |
1444 | fMUONData->AddGlobalTrigger(*pGloTrig); | |
1445 | ||
1446 | for (Int_t icirc=0; icirc<AliMUONConstants::NTriggerCircuit(); icirc++) { | |
1447 | if(GetITrigger(icirc)==1) { | |
1448 | Int_t localtr[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; | |
1449 | Int_t loLpt[2]={0,0}; Int_t loHpt[2]={0,0}; Int_t loApt[2]={0,0}; | |
1450 | GetLutOutput(icirc, loLpt, loHpt, loApt); | |
1451 | localtr[0] = icirc; | |
1452 | localtr[1] = GetStripX11(icirc); | |
1453 | localtr[2] = GetDev(icirc); | |
1454 | localtr[3] = GetStripY11(icirc); | |
1455 | for (Int_t i = 0; i < 2; i++) { // convert the Lut output in 1 digit | |
1456 | localtr[4] += Int_t(loLpt[i]*TMath::Power(2,i)); | |
1457 | localtr[5] += Int_t(loHpt[i]*TMath::Power(2,i)); | |
1458 | localtr[6] += Int_t(loApt[i]*TMath::Power(2,i)); | |
1459 | } | |
1460 | ||
1461 | for (Int_t i = 0; i < 16; i++) { // convert X/Y bit in bit pattern | |
1462 | localtr[7] |= (fXbit11[icirc][i] << i); | |
1463 | localtr[8] |= (fXbit12[icirc][i] << i); | |
1464 | ||
1465 | // 8 first and last elts correspond to neighbouring cards | |
1466 | localtr[9] |= (fXbit21[icirc][i+8] << i); | |
1467 | localtr[10] |= (fXbit22[icirc][i+8] << i); | |
1468 | ||
1469 | localtr[11] |= (fYbit11[icirc][i] << i); | |
1470 | localtr[12] |= (fYbit12[icirc][i] << i); | |
1471 | localtr[13] |= (fYbit21[icirc][i] << i); | |
1472 | localtr[14] |= (fYbit22[icirc][i] << i); | |
1473 | } | |
1474 | ||
1475 | AliMUONLocalTrigger* pLocTrig = new AliMUONLocalTrigger(localtr, fDigitNumbers[icirc]); | |
1476 | fMUONData->AddLocalTrigger(*pLocTrig); // add a local trigger in the list | |
1477 | } | |
1478 | } | |
1479 | } | |
1480 | ||
1481 | //_______________________________________________________________________ | |
1482 | void AliMUONTriggerDecision::ClearDigitNumbers() | |
1483 | { | |
1484 | // Clears the fDigitNumbers arrays so that they are all empty. | |
1485 | ||
1486 | for (Int_t i = 0; i < AliMUONConstants::NTriggerCircuit(); i++) | |
1487 | fDigitNumbers[i].Set(0); | |
1488 | } | |
1489 | ||
1490 | //_______________________________________________________________________ | |
1491 | void AliMUONTriggerDecision::DigitFiredCircuit( | |
1492 | Int_t circuit, Int_t cathode, | |
1493 | Int_t chamber, Int_t digit | |
1494 | ) | |
1495 | { | |
1496 | // Registers that the specified digit fired the specified circuit. | |
1497 | // This digit gets added to an array which will be copied to | |
1498 | // AliMUONLocalTrigger when such an object is created for each circuit. | |
1499 | ||
1500 | Int_t digitnumber = AliMUONLocalTrigger::EncodeDigitNumber(chamber, cathode, digit); | |
1501 | Int_t last = fDigitNumbers[circuit].GetSize(); | |
1502 | fDigitNumbers[circuit].Set(last + 1); | |
1503 | fDigitNumbers[circuit][last] = digitnumber; | |
1504 | } | |
1505 |