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