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