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