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