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