Removing leftover return
[u/mrichter/AliRoot.git] / MUON / AliMUONRegionalTriggerBoard.cxx
CommitLineData
809874e0 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 AliMUONRegionalTriggerBoard
20/// Dimuon regional trigger implementation:
21/// - entry are local board responses
22/// - output is 12-bit word
23/// - algorithm is similar to the global one
24///
25/// \author Rachid Guernane (LPCCFd)
c05673c9 26/// Corrected by Christian Finck (Subatech)
3d1463c8 27//-----------------------------------------------------------------------------
809874e0 28
29#include "AliMUONRegionalTriggerBoard.h"
30
41922e78 31#include "AliLog.h"
32
809874e0 33#include "TBits.h"
34
35#include <Riostream.h>
36
cdd730d0 37using std::endl;
38using std::cout;
71a2d3aa 39/// \cond CLASSIMP
809874e0 40ClassImp(AliMUONRegionalTriggerBoard)
71a2d3aa 41/// \endcond
809874e0 42
43//___________________________________________
44AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard()
c05673c9 45 : AliMUONTriggerBoard(),
46 fMask(0x0)
809874e0 47{
71a2d3aa 48/// Default constructor
809874e0 49 for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
50}
51
52//___________________________________________
c05673c9 53AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a)
54 : AliMUONTriggerBoard(name, a),
55 fMask(0x0)
809874e0 56{
71a2d3aa 57/// Standard constructor
809874e0 58 for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
59}
60
61//___________________________________________
71a2d3aa 62AliMUONRegionalTriggerBoard::~AliMUONRegionalTriggerBoard()
63{
64/// Destructor
65}
66
67//___________________________________________
809874e0 68void AliMUONRegionalTriggerBoard::Response()
69{
c05673c9 70/// response is given following the regional algorithm
254985cb 71// output from local trigger algorithm
72// [+, -] * [Hpt, Lpt]
73// transformed to [+, -, US, LS] * [Hpt, Lpt]
71a2d3aa 74
00d46f24 75 if ( IsNull() ) return; // Do nothing if all local responses are null
76
edd00c2d 77 Int_t t[16];
809874e0 78
c05673c9 79 for (Int_t i = 0; i < 16; ++i)
80 {
81 if ((fMask >> i) & 0x1)
82 t[i] = fLocalResponse[i];
83 else
84 t[i] = 0;
85 }
86
809874e0 87 Int_t rank = 8;
88
c05673c9 89 for (Int_t i = 0; i < 4; ++i)
809874e0 90 {
91 Int_t ip = 0;
92
c05673c9 93 for (Int_t j = 0; j < rank; ++j)
809874e0 94 {
ad705f30 95 UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i);
254985cb 96
ad705f30 97 UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 4;
809874e0 98
ad705f30 99 t[ip] = lthres | hthres;
809874e0 100
101 ip++;
102 }
103
104 rank /= 2;
105 }
00d46f24 106
ad705f30 107 fResponse = t[0]; // 8-bit [H4:L4]
809874e0 108}
109
110//___________________________________________
a6e0ebfe 111UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres, Int_t level)
809874e0 112{
c05673c9 113/// implementation of the regional algorithm
114/// similar to the global algorithm except for the
115/// input layer
71a2d3aa 116
254985cb 117/// level = 0 a ,b = local response = Hpt (+|-) | Lpt (+|-)
118/// level > 0 a ,b = reg response = Hpt (+|-|us|ls) | Lpt (+|-|us|ls)
119
ad705f30 120 TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
809874e0 121
122 TBits trg1(2), trg2(2), trg(2);
123
ad705f30 124 if (!strcmp(thres,"LPT"))
809874e0 125 {
254985cb 126
127 if (!level)
809874e0 128 {
129 trg1[0] = a[0]; trg1[1] = a[1];
130 trg2[0] = b[0]; trg2[1] = b[1];
131 }
132 else
133 {
134 trg1[0] = a[2]; trg1[1] = a[3];
135 trg2[0] = b[2]; trg2[1] = b[3];
136 }
137 }
ad705f30 138 else
809874e0 139 {
140 if (!level)
141 {
142 trg1[0] = a[2]; trg1[1] = a[3];
143 trg2[0] = b[2]; trg2[1] = b[3];
144 }
145 else
146 {
147 trg1[0] = a[6]; trg1[1] = a[7];
ad705f30 148 trg2[0] = b[6]; trg2[1] = b[7];
809874e0 149 }
150 }
151
152 TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
153
154 if (!level)
155 {
156 trgLS1[0] = trgUS1[0] = trgLS2[0] = trgUS2[0] = 0;
157 }
158 else
159 {
ad705f30 160 if (!strcmp(thres,"LPT"))
809874e0 161 {
254985cb 162 //trgLS1[0] = a[1]; trgUS1[0] = a[0];
163 //trgLS2[0] = b[1]; trgUS2[0] = b[0];
164 trgLS1[0] = a[0]; trgUS1[0] = a[1];
165 trgLS2[0] = b[0]; trgUS2[0] = b[1];
809874e0 166 }
809874e0 167 else
168 {
254985cb 169 //trgLS1[0] = a[5]; trgUS1[0] = a[4];
170 //trgLS2[0] = b[5]; trgUS2[0] = b[4];
171 trgLS1[0] = a[4]; trgUS1[0] = a[5];
172 trgLS2[0] = b[4]; trgUS2[0] = b[5];
809874e0 173 }
174 }
175
176 trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
177 trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
178
179 trg[0] = trg1[0] | trg2[0];
180 trg[1] = trg1[1] | trg2[1];
181
182 TBits v(4);
183
254985cb 184 //v[0] = trgUS[0];
185 //v[1] = trgLS[0];
186 v[0] = trgLS[0];
187 v[1] = trgUS[0];
809874e0 188 v[2] = trg[0];
189 v[3] = trg[1];
809874e0 190 UShort_t rv = 0;
191 v.Get(&rv);
809874e0 192 return rv;
193}
edd00c2d 194
809874e0 195//___________________________________________
edd00c2d 196void AliMUONRegionalTriggerBoard::Scan(Option_t*) const
809874e0 197{
c05673c9 198/// scan local board entries
71a2d3aa 199
edd00c2d 200 for (Int_t i=0; i<16; i++)
a4435944 201 {
202 TBits b;
203 b.Set(6,&fLocalResponse[i]);
204
205 cout << "Entry " << i << " is " << b << endl;
206
207 }
208
809874e0 209}
41922e78 210//___________________________________________
c05673c9 211void AliMUONRegionalTriggerBoard::Mask(UShort_t mask)
41922e78 212{
c05673c9 213/// mask entry index
214
215 fMask = mask;
41922e78 216}
c05673c9 217
00d46f24 218//___________________________________________
219Bool_t AliMUONRegionalTriggerBoard::IsNull()
220{
221 /// Check if all local response are null
222 for (Int_t i=0; i<16; i++) {
223 if ( fLocalResponse[i] ) return kFALSE;
224 }
225 return kTRUE;
226}
c05673c9 227
228
00d46f24 229//___________________________________________
230void AliMUONRegionalTriggerBoard::Reset()
231{
232 /// Reset board
233
234 for (Int_t i=0; i<16; ++i) fLocalResponse[i] = 0;
235
236 fResponse = 0;
237
238}