1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
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
25 /// \author Rachid Guernane (LPCCFd),
26 /// Corrected by Christian Finck (Subatech)
27 //-----------------------------------------------------------------------------
29 #include "AliMUONGlobalTriggerBoard.h"
33 #include <Riostream.h>
36 ClassImp(AliMUONGlobalTriggerBoard)
39 //___________________________________________
40 AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(): AliMUONTriggerBoard()
42 /// Default constructor
44 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
45 for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
48 //___________________________________________
49 AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
51 /// Standard constructor
53 for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
54 for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
57 //___________________________________________
58 AliMUONGlobalTriggerBoard::~AliMUONGlobalTriggerBoard()
63 //___________________________________________
64 void AliMUONGlobalTriggerBoard::Mask(Int_t index, UInt_t mask)
66 /// mask global trigger board input index with value mask
67 if ( index >= 0 && index < 4 )
73 AliError(Form("Index %d out of bounds (max %d)",index,3));
77 //___________________________________________
78 void AliMUONGlobalTriggerBoard::Response()
80 /// compute the global trigger board
81 /// response according to the algo() method
82 // output from global trigger algorithm
83 // [+, -, US, LS] * [Hpt, Lpt]
84 // transformed to [usHpt, usLpt, lsHpt, lsLpt, sHpt, sLpt] according
85 // to Global Trigger Unit user manual
92 for (Int_t i = 0; i < 16; ++i)
94 t[i] = fRegionalResponse[i];
100 for (Int_t i=0;i<4;i++)
104 for (Int_t j=0;j<rank;j++)
106 UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT");
108 UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT"); hthres <<= 4;
110 t[ip] = lthres | hthres;
117 UChar_t sLpt, sHpt, lsLpt, lsHpt, usLpt, usHpt;
118 sLpt = ((t[0] & 0xC) != 0);
119 sHpt = ((t[0] & 0xC0) != 0);
120 lsLpt = ((t[0] & 0x1) != 0);
121 lsHpt = ((t[0] & 0x10) != 0);
122 usLpt = ((t[0] & 0x2 ) != 0);
123 usHpt = ((t[0] & 0x20) != 0);
131 fResponse = sLpt | sHpt | lsLpt | lsHpt | usLpt |usHpt;
136 //___________________________________________
137 UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres)
139 /// global trigger algorithm
140 /// a ,b = reg response = Hpt (+|-|us|ls) | Lpt (+|-|us|ls)
142 TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
144 TBits trg1(2), trg2(2), trg(2);
146 if (!strcmp(thres,"LPT"))
148 trg1[0] = a[2]; trg1[1] = a[3];
149 trg2[0] = b[2]; trg2[1] = b[3];
153 trg1[0] = a[6]; trg1[1] = a[7];
154 trg2[0] = b[6]; trg2[1] = b[7];
157 TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
159 if (!strcmp(thres,"LPT"))
161 //trgLS1[0] = a[1]; trgUS1[0] = a[0];
162 //trgLS2[0] = b[1]; trgUS2[0] = b[0];
163 trgLS1[0] = a[0]; trgUS1[0] = a[1];
164 trgLS2[0] = b[0]; trgUS2[0] = b[1];
168 //trgLS1[0] = a[5]; trgUS1[0] = a[4];
169 //trgLS2[0] = b[5]; trgUS2[0] = b[4];
170 trgLS1[0] = a[4]; trgUS1[0] = a[5];
171 trgLS2[0] = b[4]; trgUS2[0] = b[5];
174 trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
175 trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
177 trg[0] = trg1[0] | trg2[0];
178 trg[1] = trg1[1] | trg2[1];
195 //___________________________________________
196 void AliMUONGlobalTriggerBoard::BuildGlobalInput()
198 /// build the 4 words (32bits) global input from the regional responses
199 /// the order of regional responses is:
200 /// 1R, 2R, 2-3R, 3R, 4R, 5R, 6R, 7R, 1L, 2L, 2-3L, 3L, 4L, 5L, 6L, 7L
202 for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
204 for (Int_t iReg = 0; iReg < 16; iReg++) {
205 if (iReg < 8) { // right
207 fGlobalInput[0] |= (fRegionalResponse[iReg] & 0x0F) << (4*iReg);
209 fGlobalInput[2] |= ((fRegionalResponse[iReg] & 0xF0) >> 4) << (4*iReg);
212 fGlobalInput[1] |= (fRegionalResponse[iReg] & 0x0F) << (4*(iReg-8));
214 fGlobalInput[3] |= ((fRegionalResponse[iReg] & 0xF0) >> 4) << (4*(iReg-8));
221 //___________________________________________
222 void AliMUONGlobalTriggerBoard::MaskRegionalInput()
224 /// Apply masks to global input and recalculate regional inputs before
225 /// applying the global response
227 // temporary global inputs with masks applied
230 for (Int_t i = 0; i < 4; i++) {
231 gitmp[i] = fGlobalInput[i];
232 gitmp[i] &= fMask[i];
235 for (Int_t iReg = 0; iReg < 16; iReg++) {
236 fRegionalResponse[iReg] = 0;
237 if (iReg < 8) { // right
239 fRegionalResponse[iReg] |= (gitmp[0] >> (4*iReg)) & 0xF;
241 fRegionalResponse[iReg] |= ((gitmp[2] >> (4*iReg)) & 0xF) << 4;
244 fRegionalResponse[iReg] |= (gitmp[1] >> (4*(iReg-8))) & 0xF;
246 fRegionalResponse[iReg] |= ((gitmp[3] >> (4*(iReg-8))) & 0xF) << 4;
252 //___________________________________________
253 void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
255 /// print global trigger output
256 TBits w(6); w.Set(6,&fResponse);
266 iS[0] = (Int_t)w.TestBitNumber(0);
267 iS[1] = (Int_t)w.TestBitNumber(1);
269 Int_t iPU[2] = {w[4],w[5]};
270 Int_t iPL[2] = {w[2],w[3]};
272 printf("============================================\n");
273 printf(" Global Trigger output Low pt High pt\n");
274 printf(" number of Single :\t");
275 for (Int_t i=0; i<2; i++) printf("%i\t",iS[i]);
277 printf(" number of UnlikeSign pair :\t");
278 for (Int_t i=0; i<2; i++) printf("%i\t",iPU[i]);
280 printf(" number of LikeSign pair :\t");
281 for (Int_t i=0; i<2; i++) printf("%i\t",iPL[i]);
283 printf("===================================================\n");