- Removed not implemented methods AddData(), GetGlobalTriggerPattern
[u/mrichter/AliRoot.git] / MUON / AliMUONGlobalTriggerBoard.cxx
CommitLineData
d15ca731 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/* $Id$ */
17
c4ee792d 18/// \class AliMUONGlobalTriggerBoard
19/// Global trigger implementation:
20/// - inputs are regional responses
21/// - output is a 12-bit word
22/// - 4 bits per trigger level
23///
24/// \author Rachid Guernane (LPCCFd)
d15ca731 25
26#include "AliMUONGlobalTriggerBoard.h"
41922e78 27#include "AliLog.h"
d15ca731 28#include "TBits.h"
29
30#include <Riostream.h>
31
32ClassImp(AliMUONGlobalTriggerBoard)
33
34//___________________________________________
35AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard()
36{
37 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
38}
39
40//___________________________________________
41AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
42{
43 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
44}
45
46//___________________________________________
41922e78 47void AliMUONGlobalTriggerBoard::Mask(Int_t index, UShort_t mask)
48{
edd00c2d 49 // MASK GLOBAL TRIGGER BOARD INPUT index WITH VALUE mask
41922e78 50 if ( index>=0 && index < 16 )
51 {
52 fMask[index]=mask;
53 }
54 else
55 {
56 AliError(Form("Index %d out of bounds (max %d)",index,16));
57 }
58}
59
60//___________________________________________
d15ca731 61void AliMUONGlobalTriggerBoard::Response()
62{
edd00c2d 63 // COMPUTE THE GLOBAL TRIGGER BOARD
64 // RESPONSE ACCORDING TO THE Algo() METHOD
8d4fefab 65/// output from global trigger algorithm
66/// [+, -, LS, US] * [Hpt, Lpt]
67/// transformed to [usHpt, usLpt, lsHpt, lsLpt, sHpt, sLpt] according
68/// to Global Trigger Unit user manual
d15ca731 69
8d4fefab 70 Int_t t[16];
41922e78 71 for (Int_t i=0;i<16;i++) t[i] = fRegionalResponse[i] & fMask[i];
d15ca731 72
73 Int_t rank = 8;
74
75 for (Int_t i=0;i<4;i++)
76 {
77 Int_t ip = 0;
78
79 for (Int_t j=0;j<rank;j++)
80 {
ad705f30 81 UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT");
d15ca731 82
ad705f30 83 UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT"); hthres <<= 4;
d15ca731 84
ad705f30 85 t[ip] = lthres | hthres;
d15ca731 86
87 ip++;
88 }
89
90 rank /= 2;
91 }
8d4fefab 92 UChar_t sLpt, sHpt, lsLpt, lsHpt, usLpt, usHpt;
93 sLpt = ((t[0] & 0xC) != 0);
94 sHpt = ((t[0] & 0xC0) != 0);
95 lsLpt = ((t[0] & 0x2) != 0);
96 lsHpt = ((t[0] & 0x20) != 0);
97 usLpt = ((t[0] & 0x1 ) != 0);
98 usHpt = ((t[0] & 0x10) != 0);
99
100 sHpt <<= 1;
101 lsLpt <<= 2;
102 lsHpt <<= 3;
103 usLpt <<= 4;
104 usHpt <<= 5;
105
106 fResponse = sLpt | sHpt | lsLpt | lsHpt | usLpt |usHpt;
d15ca731 107}
108
109//___________________________________________
110UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
111{
edd00c2d 112 // GLOBAL TRIGGER ALGORITHM
ad705f30 113 TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
d15ca731 114
115 TBits trg1(2), trg2(2), trg(2);
116
ad705f30 117 if (!strcmp(thres,"LPT"))
d15ca731 118 {
119 trg1[0] = a[2]; trg1[1] = a[3];
120 trg2[0] = b[2]; trg2[1] = b[3];
121 }
d15ca731 122 else
123 {
ad705f30 124 trg1[0] = a[6]; trg1[1] = a[7];
125 trg2[0] = b[6]; trg2[1] = b[7];
d15ca731 126 }
127
128 TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
129
ad705f30 130 if (!strcmp(thres,"LPT"))
d15ca731 131 {
132 trgLS1[0] = a[1]; trgUS1[0] = a[0];
133 trgLS2[0] = b[1]; trgUS2[0] = b[0];
134 }
d15ca731 135 else
136 {
ad705f30 137 trgLS1[0] = a[5]; trgUS1[0] = a[4];
138 trgLS2[0] = b[5]; trgUS2[0] = b[4];
d15ca731 139 }
140
141 trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
142 trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
143
144 trg[0] = trg1[0] | trg2[0];
145 trg[1] = trg1[1] | trg2[1];
146
147 TBits v(4);
148
149 v[0] = trgUS[0];
150 v[1] = trgLS[0];
151 v[2] = trg[0];
152 v[3] = trg[1];
153
154 UShort_t rv = 0;
155 v.Get(&rv);
156
157 return rv;
158}
159
160//___________________________________________
edd00c2d 161void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
d15ca731 162{
edd00c2d 163 // PRINT GLOBAL TRIGGER OUTPUT
ad705f30 164 TBits w(8); w.Set(8,&fResponse);
d15ca731 165
166// TRG[1:0]
167// 00 noth
168// 01 negative track
169// 10 positive track
170// 11 undef
171
ad705f30 172 Int_t iSP[2] = {0,0}, iSM[2] = {0,0}, iSU[2] = {0,0};
d15ca731 173
174 TBits a(2), n(2), p(2), u(2);
175
176 UShort_t val;
177
178 val = 1; n.Set(2,&val);
179 val = 2; p.Set(2,&val);
180 val = 3; u.Set(2,&val);
181
182 a[0] = w[2];
183 a[1] = w[3];
184
185 if (a==p) iSP[0] = 1;
186 else if (a==n) iSM[0] = 1;
187 else if (a==u) iSU[0] = 1;
188
189 a[0] = w[6];
190 a[1] = w[7];
191
192 if (a==p) iSP[1] = 1;
193 else if (a==n) iSM[1] = 1;
194 else if (a==u) iSU[1] = 1;
195
ad705f30 196 Int_t iPU[2] = {w[0],w[4]};
197 Int_t iPL[2] = {w[1],w[5]};
d15ca731 198
ad705f30 199 printf("============================================\n");
200 printf(" Global Trigger output Low pt High pt\n");
d15ca731 201 printf(" number of Single Plus :\t");
ad705f30 202 for (Int_t i=0; i<2; i++) printf("%i\t",iSP[i]);
d15ca731 203 printf("\n");
204 printf(" number of Single Minus :\t");
ad705f30 205 for (Int_t i=0; i<2; i++) printf("%i\t",iSM[i]);
d15ca731 206 printf("\n");
207 printf(" number of Single Undefined :\t");
ad705f30 208 for (Int_t i=0; i<2; i++) printf("%i\t",iSU[i]);
d15ca731 209 printf("\n");
210 printf(" number of UnlikeSign pair :\t");
ad705f30 211 for (Int_t i=0; i<2; i++) printf("%i\t",iPU[i]);
d15ca731 212 printf("\n");
213 printf(" number of LikeSign pair :\t");
ad705f30 214 for (Int_t i=0; i<2; i++) printf("%i\t",iPL[i]);
d15ca731 215 printf("\n");
216 printf("===================================================\n");
217 printf("\n");
218}
219
220ClassImp(AliMUONGlobalTriggerBoard)