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