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