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