]>
Commit | Line | Data |
---|---|---|
4bd37bd4 | 1 | |
916f1e76 | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* | |
18 | ||
19 | ||
20 | ||
21 | This class provides access to STU DDL raw data. | |
22 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 | |
23 | */ | |
24 | ||
25 | #include "AliEMCALTriggerSTURawStream.h" | |
26 | #include "AliRawReader.h" | |
27 | #include "AliLog.h" | |
28 | ||
29 | #include "Riostream.h" | |
30 | #include "TBits.h" | |
31 | ||
c58cfdff | 32 | #include <cstdlib> |
33 | ||
916f1e76 | 34 | namespace |
35 | { | |
de39a0ff | 36 | const Int_t kPayLoadSize = 944; |
37 | const Int_t kPayLoadSizeWithRawData = 1772; | |
916f1e76 | 38 | } |
39 | ||
40 | ClassImp(AliEMCALTriggerSTURawStream) | |
41 | ||
42 | //_____________________________________________________________________________ | |
43 | AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(), | |
44 | fRawReader(0x0), | |
45 | fL1JetThreshold(0), | |
46 | fL1GammaThreshold(0), | |
de39a0ff | 47 | fL0GammaPatchIndex(), |
48 | fL1GammaPatchIndex(), | |
49 | fL1JetPatchIndex(), | |
916f1e76 | 50 | fNL0GammaPatch(0), |
51 | fNL1JetPatch(0), | |
52 | fNL1GammaPatch(0), | |
de39a0ff | 53 | fGetRawData(0) |
916f1e76 | 54 | { |
55 | // | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(), | |
60 | fRawReader(rawReader), | |
61 | fL1JetThreshold(0), | |
62 | fL1GammaThreshold(0), | |
de39a0ff | 63 | fL0GammaPatchIndex(), |
64 | fL1GammaPatchIndex(), | |
65 | fL1JetPatchIndex(), | |
916f1e76 | 66 | fNL0GammaPatch(0), |
67 | fNL1JetPatch(0), | |
de39a0ff | 68 | fNL1GammaPatch(0), |
69 | fGetRawData(0) | |
916f1e76 | 70 | { |
71 | // | |
72 | fRawReader->Reset(); | |
73 | fRawReader->Select("EMCAL",44); | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream() | |
78 | { | |
79 | // destructor | |
80 | } | |
81 | ||
82 | //_____________________________________________________________________________ | |
83 | void AliEMCALTriggerSTURawStream::Reset() | |
84 | { | |
85 | // | |
86 | if (fRawReader) fRawReader->Reset(); | |
de39a0ff | 87 | |
fff39dd1 | 88 | fNL0GammaPatch = 0; |
89 | fNL1GammaPatch = 0; | |
90 | fNL1JetPatch = 0; | |
916f1e76 | 91 | } |
92 | ||
93 | //_____________________________________________________________________________ | |
94 | Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad() | |
95 | { | |
96 | // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3 | |
4bd37bd4 | 97 | // bourrion_at_lpsc_dot_in2p3_dot_fr |
916f1e76 | 98 | |
99 | UInt_t word32[1772]; // 32b words | |
de39a0ff | 100 | for (Int_t i=0;i<1772;i++) word32[i] = 0; |
101 | ||
916f1e76 | 102 | Int_t iword = 0; |
fff39dd1 | 103 | |
104 | fNL0GammaPatch = 0; | |
105 | fNL1GammaPatch = 0; | |
106 | fNL1JetPatch = 0; | |
107 | ||
de39a0ff | 108 | Int_t eqId = -1, eqSize = 0; |
916f1e76 | 109 | |
110 | UInt_t w32; | |
de39a0ff | 111 | while (fRawReader->ReadNextInt(w32)) |
112 | { | |
113 | if (!iword) | |
114 | { | |
115 | eqId = fRawReader->GetEquipmentId(); | |
116 | eqSize = fRawReader->GetEquipmentSize(); | |
117 | } | |
118 | ||
119 | word32[iword++] = w32; | |
120 | } | |
916f1e76 | 121 | |
de39a0ff | 122 | if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData) |
916f1e76 | 123 | { |
de39a0ff | 124 | AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32", |
125 | eqId, eqSize, iword)); | |
916f1e76 | 126 | return kFALSE; |
de39a0ff | 127 | } |
128 | else if (AliDebugLevel()) | |
916f1e76 | 129 | { |
de39a0ff | 130 | AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32", |
131 | eqId, eqSize, iword)); | |
916f1e76 | 132 | } |
916f1e76 | 133 | |
134 | fL1JetThreshold = ((word32[0]>>16) & 0xFFF); | |
135 | fL1GammaThreshold = (word32[0] & 0xFFF); | |
136 | ||
137 | for (Int_t jet_row=0; jet_row<11; jet_row++) | |
138 | { | |
139 | UInt_t currentrow = word32[1+jet_row]; | |
140 | ||
141 | for (Int_t jet_col=0; jet_col<15; jet_col++) | |
142 | { | |
143 | if (currentrow & (1 << jet_col)) | |
144 | { | |
145 | fNL1JetPatch++; | |
916f1e76 | 146 | |
147 | fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF); | |
148 | } | |
149 | } | |
150 | } | |
151 | ||
152 | ////////////////////////////////////////////////////////// | |
153 | // index des L0 // | |
154 | ////////////////////////////////////////////////////////// | |
155 | // FIXME: still not interpreted to be done with Jiri | |
156 | ||
157 | unsigned short TRU_L0_indexes[32][6]; | |
158 | ||
159 | // extraction from stream | |
160 | for (Int_t index=0;index<6;index++) | |
161 | { | |
162 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
163 | { | |
164 | TRU_L0_indexes[2*tru_num ][index] = ( word32[12+index*16+tru_num] & 0xFFFF); | |
165 | TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF); | |
166 | } | |
167 | } | |
168 | ||
169 | for (Int_t tru_num=0;tru_num<32;tru_num++) | |
170 | { | |
171 | for (Int_t index=0;index<6;index++) | |
172 | { | |
173 | for (Int_t bit_num=0;bit_num<12;bit_num++) | |
174 | { | |
175 | if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num))) | |
176 | { | |
916f1e76 | 177 | Int_t idx = 12 * index + bit_num; |
de39a0ff | 178 | |
916f1e76 | 179 | fNL0GammaPatch++; |
916f1e76 | 180 | |
de39a0ff | 181 | fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F)); |
916f1e76 | 182 | } |
183 | } | |
184 | } | |
185 | } | |
186 | ||
187 | ////////////////////////////////////////////////////////// | |
188 | // index des L1 gamma // | |
189 | ////////////////////////////////////////////////////////// | |
190 | ||
191 | unsigned short TRU_L1_indexes[32][8]; | |
192 | ||
193 | // extraction from stream | |
194 | for (Int_t index=0;index<8;index++) | |
195 | { | |
196 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
197 | { | |
198 | TRU_L1_indexes[2*tru_num ][index] = ( word32[108+index*16+tru_num] & 0xFFFF); | |
199 | TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF); | |
200 | } | |
201 | } | |
202 | ||
203 | // interpretation | |
204 | int gammacolnum; | |
205 | short indexcopy; | |
206 | ||
207 | for (Int_t tru_num=0;tru_num<32;tru_num++) | |
208 | { | |
209 | for (Int_t index=0;index<8;index++) | |
210 | { | |
211 | for (Int_t bit_num=0; bit_num<12; bit_num++) | |
212 | { | |
213 | if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0) | |
214 | { | |
215 | if (index<4) // Even | |
216 | { | |
217 | gammacolnum = (2*bit_num ); | |
218 | indexcopy = index; | |
219 | } | |
220 | else // Odd | |
221 | { | |
222 | gammacolnum = (2*bit_num+1); | |
223 | indexcopy = index-4; | |
224 | } | |
225 | ||
226 | fNL1GammaPatch++; | |
916f1e76 | 227 | |
228 | fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F)); | |
229 | } | |
230 | } | |
231 | } | |
232 | } | |
233 | ||
234 | ////////////////////////////////////////////////////////// | |
235 | // raw output // | |
236 | ////////////////////////////////////////////////////////// | |
237 | ||
39c05eac | 238 | if ( iword <= kPayLoadSize ) |
239 | { | |
240 | fGetRawData = 0; | |
de39a0ff | 241 | return kTRUE; |
39c05eac | 242 | } |
243 | ||
244 | fGetRawData = 1; | |
916f1e76 | 245 | |
246 | // extraction from stream | |
247 | for (Int_t index=0;index<96;index++) | |
248 | { | |
249 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
250 | { | |
251 | fADC[2*tru_num ][index] = ( word32[236+index*16+tru_num] & 0xFFFF); | |
252 | fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF); | |
253 | } | |
254 | } | |
255 | ||
256 | for (Int_t tru_num=16;tru_num<32;tru_num++) // A side | |
257 | { | |
de39a0ff | 258 | Int_t v[96]; |
259 | for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index]; | |
260 | ||
261 | for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index]; | |
916f1e76 | 262 | } |
263 | ||
de39a0ff | 264 | return kTRUE; |
916f1e76 | 265 | } |
266 | ||
267 | //_____________________________________________________________________________ | |
de39a0ff | 268 | Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const |
916f1e76 | 269 | { |
270 | // | |
271 | if (i > fNL0GammaPatch) return kFALSE; | |
272 | ||
273 | tru = fL0GammaPatchIndex[i] & 0x1F; | |
de39a0ff | 274 | idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5; |
916f1e76 | 275 | |
276 | return kTRUE; | |
277 | } | |
278 | ||
279 | //_____________________________________________________________________________ | |
280 | Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const | |
281 | { | |
282 | // | |
283 | if (i > fNL1GammaPatch) return kFALSE; | |
284 | ||
285 | tru = fL1GammaPatchIndex[i] & 0x1F; | |
286 | col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5; | |
287 | row = (fL1GammaPatchIndex[i] & 0xC00) >> 10; | |
288 | ||
289 | return kTRUE; | |
290 | } | |
291 | ||
292 | //_____________________________________________________________________________ | |
293 | Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const | |
294 | { | |
295 | // | |
296 | if (i > fNL1JetPatch) return kFALSE; | |
297 | ||
298 | col = fL1JetPatchIndex[i] & 0xFF; | |
299 | row = (fL1JetPatchIndex[i] & 0xFF00) >> 8; | |
300 | ||
301 | return kTRUE; | |
302 | } | |
303 | ||
304 | //_____________________________________________________________________________ | |
305 | void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[]) | |
306 | { | |
307 | // | |
308 | for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i]; | |
309 | } | |
310 | ||
311 | //_____________________________________________________________________________ | |
80e5a1ae | 312 | void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const |
916f1e76 | 313 | { |
314 | // | |
315 | TString op = option; | |
316 | ||
317 | cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl; | |
de39a0ff | 318 | cout << "Number of L0: " << fNL0GammaPatch << endl; |
319 | cout << "Number of L1-g: " << fNL1GammaPatch << endl; | |
320 | cout << "Number of L1-j: " << fNL1JetPatch << endl; | |
916f1e76 | 321 | |
322 | Int_t itru, col, row; | |
916f1e76 | 323 | |
324 | if (op.Contains("L0") || op.Contains("ALL")) | |
325 | { | |
326 | for (Int_t i=0;i<fNL0GammaPatch;i++) | |
327 | { | |
de39a0ff | 328 | |
329 | if (GetL0GammaPatch(i,itru,col)) | |
330 | cout << "> Found L0 gamma in TRU #" << setw(2) << itru << " at idx: " << setw(2) << col << endl; | |
916f1e76 | 331 | } |
332 | } | |
333 | ||
334 | if (op.Contains("L1") || op.Contains("ALL")) | |
335 | { | |
336 | for (Int_t i=0;i<fNL1GammaPatch;i++) | |
337 | { | |
de39a0ff | 338 | if (GetL1GammaPatch(i,itru,col,row)) |
339 | cout << "> Found L1 gamma in TRU #" << setw(2) << itru << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl; | |
916f1e76 | 340 | } |
341 | ||
342 | for (Int_t i=0;i<fNL1JetPatch;i++) | |
343 | { | |
de39a0ff | 344 | if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl; |
916f1e76 | 345 | } |
346 | } | |
347 | ||
39c05eac | 348 | cout << "> RawData: " << fGetRawData << endl; |
349 | ||
350 | if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData ) | |
916f1e76 | 351 | { |
352 | for (Int_t i=0;i<32;i++) | |
353 | { | |
354 | cout << "--------\n"; | |
355 | cout << "TRU #" << setw(2) << i << ":"; | |
356 | for (Int_t j=0;j<96;j++) | |
357 | { | |
358 | TBits xadc(12); xadc.Set(12,&fADC[i][j]); | |
359 | if ((j%4)==0) cout << endl; | |
360 | //cout << setw(2) << j << ": " << xadc << " "; | |
361 | printf("%2d: %3x / ",j,fADC[i][j]); | |
362 | } | |
363 | cout << "\n"; | |
364 | } | |
365 | } | |
366 | } |