]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONGlobalTriggerBoard.cxx
Additional protection in case of negative indexes. More investigation is needed
[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
18//*-- Author: Rachid Guernane (LPCCFd)
19
20#include "AliMUONGlobalTriggerBoard.h"
41922e78 21#include "AliLog.h"
d15ca731 22#include "TBits.h"
23
24#include <Riostream.h>
25
26ClassImp(AliMUONGlobalTriggerBoard)
27
28//___________________________________________
29AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard()
30{
31 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
32}
33
34//___________________________________________
35AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
36{
37 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
38}
39
41922e78 40//___________________________________________
41void AliMUONGlobalTriggerBoard::Mask(Int_t index, UShort_t mask)
42{
43 if ( index>=0 && index < 16 )
44 {
45 fMask[index]=mask;
46 }
47 else
48 {
49 AliError(Form("Index %d out of bounds (max %d)",index,16));
50 }
51}
52
d15ca731 53//___________________________________________
54void AliMUONGlobalTriggerBoard::Response()
55{
56 Int_t t[16];
57
41922e78 58 for (Int_t i=0;i<16;i++) t[i] = fRegionalResponse[i] & fMask[i];
d15ca731 59
60 Int_t rank = 8;
61
62 for (Int_t i=0;i<4;i++)
63 {
64 Int_t ip = 0;
65
66 for (Int_t j=0;j<rank;j++)
67 {
68 UShort_t athres = Algo(t[2*j],t[2*j+1],"APT");
69
70 UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT"); lthres <<= 4;
71
72 UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT"); hthres <<= 8;
73
74 t[ip] = athres | lthres | hthres;
75
76 ip++;
77 }
78
79 rank /= 2;
80 }
81
82 fResponse = t[0]; // 12-bit [H4:L4:A4]
83}
84
85//___________________________________________
86UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
87{
88 TBits a(12), b(12); a.Set(12,&i); b.Set(12,&j);
89
90 TBits trg1(2), trg2(2), trg(2);
91
92 if (!strcmp(thres,"APT"))
93 {
94 trg1[0] = a[2]; trg1[1] = a[3];
95 trg2[0] = b[2]; trg2[1] = b[3];
96 }
97 else if (!strcmp(thres,"LPT"))
98 {
99 trg1[0] = a[6]; trg1[1] = a[7];
100 trg2[0] = b[6]; trg2[1] = b[7];
101 }
102 else
103 {
104 trg1[0] = a[10]; trg1[1] = a[11];
105 trg2[0] = b[10]; trg2[1] = b[11];
106 }
107
108 TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
109
110 if (!strcmp(thres,"APT"))
111 {
112 trgLS1[0] = a[1]; trgUS1[0] = a[0];
113 trgLS2[0] = b[1]; trgUS2[0] = b[0];
114 }
115 else if (!strcmp(thres,"LPT"))
116 {
117 trgLS1[0] = a[5]; trgUS1[0] = a[4];
118 trgLS2[0] = b[5]; trgUS2[0] = b[4];
119 }
120 else
121 {
122 trgLS1[0] = a[9]; trgUS1[0] = a[8];
123 trgLS2[0] = b[9]; trgUS2[0] = b[8];
124 }
125
126 trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
127 trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
128
129 trg[0] = trg1[0] | trg2[0];
130 trg[1] = trg1[1] | trg2[1];
131
132 TBits v(4);
133
134 v[0] = trgUS[0];
135 v[1] = trgLS[0];
136 v[2] = trg[0];
137 v[3] = trg[1];
138
139 UShort_t rv = 0;
140 v.Get(&rv);
141
142 return rv;
143}
144
145//___________________________________________
146void AliMUONGlobalTriggerBoard::Scan(Option_t*)
147{
148 TBits w(12); w.Set(12,&fResponse);
149
150// TRG[1:0]
151// 00 noth
152// 01 negative track
153// 10 positive track
154// 11 undef
155
156 Int_t iSP[3] = {0,0,0}, iSM[3] = {0,0,0}, iSU[3] = {0,0,0};
157
158 TBits a(2), n(2), p(2), u(2);
159
160 UShort_t val;
161
162 val = 1; n.Set(2,&val);
163 val = 2; p.Set(2,&val);
164 val = 3; u.Set(2,&val);
165
166 a[0] = w[2];
167 a[1] = w[3];
168
169 if (a==p) iSP[0] = 1;
170 else if (a==n) iSM[0] = 1;
171 else if (a==u) iSU[0] = 1;
172
173 a[0] = w[6];
174 a[1] = w[7];
175
176 if (a==p) iSP[1] = 1;
177 else if (a==n) iSM[1] = 1;
178 else if (a==u) iSU[1] = 1;
179
180 a[0] = w[10];
181 a[1] = w[11];
182
183 if (a==p) iSP[2] = 1;
184 else if (a==n) iSM[2] = 1;
185 else if (a==u) iSU[2] = 1;
186
187 Int_t iPU[3] = {w[0],w[4],w[8]};
188 Int_t iPL[3] = {w[1],w[5],w[9]};
189
190 printf("===================================================\n");
191 printf(" Global Trigger output Low pt High pt All\n");
192 printf(" number of Single Plus :\t");
193 for (Int_t i=0; i<3; i++) printf("%i\t",iSP[i]);
194 printf("\n");
195 printf(" number of Single Minus :\t");
196 for (Int_t i=0; i<3; i++) printf("%i\t",iSM[i]);
197 printf("\n");
198 printf(" number of Single Undefined :\t");
199 for (Int_t i=0; i<3; i++) printf("%i\t",iSU[i]);
200 printf("\n");
201 printf(" number of UnlikeSign pair :\t");
202 for (Int_t i=0; i<3; i++) printf("%i\t",iPU[i]);
203 printf("\n");
204 printf(" number of LikeSign pair :\t");
205 for (Int_t i=0; i<3; i++) printf("%i\t",iPL[i]);
206 printf("\n");
207 printf("===================================================\n");
208 printf("\n");
209}
210
211ClassImp(AliMUONGlobalTriggerBoard)