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