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