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