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