]>
Commit | Line | Data |
---|---|---|
916f1e76 | 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 | /* | |
17 | ||
18 | ||
19 | ||
20 | This class provides access to STU DDL raw data. | |
21 | Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3 | |
22 | */ | |
23 | ||
24 | #include "AliEMCALTriggerSTURawStream.h" | |
25 | #include "AliRawReader.h" | |
26 | #include "AliLog.h" | |
27 | ||
28 | #include "Riostream.h" | |
29 | #include "TBits.h" | |
30 | ||
c58cfdff | 31 | #include <cstdlib> |
32 | ||
916f1e76 | 33 | namespace |
34 | { | |
35 | const Int_t kPayLoadSize = 944; | |
36 | } | |
37 | ||
38 | ClassImp(AliEMCALTriggerSTURawStream) | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(), | |
42 | fRawReader(0x0), | |
43 | fL1JetThreshold(0), | |
44 | fL1GammaThreshold(0), | |
45 | fL0GammaPatchIndex(0x0), | |
46 | fL1GammaPatchIndex(0x0), | |
47 | fL1JetPatchIndex(0x0), | |
48 | fNL0GammaPatch(0), | |
49 | fNL1JetPatch(0), | |
50 | fNL1GammaPatch(0), | |
51 | fL0(0) | |
52 | { | |
53 | // | |
54 | } | |
55 | ||
56 | //_____________________________________________________________________________ | |
57 | AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(), | |
58 | fRawReader(rawReader), | |
59 | fL1JetThreshold(0), | |
60 | fL1GammaThreshold(0), | |
61 | fL0GammaPatchIndex(0x0), | |
62 | fL1GammaPatchIndex(0x0), | |
63 | fL1JetPatchIndex(0x0), | |
64 | fNL0GammaPatch(0), | |
65 | fNL1JetPatch(0), | |
66 | fNL1GammaPatch(0), | |
67 | fL0(0) | |
68 | { | |
69 | // | |
70 | fRawReader->Reset(); | |
71 | fRawReader->Select("EMCAL",44); | |
72 | } | |
73 | ||
74 | //_____________________________________________________________________________ | |
75 | AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream() | |
76 | { | |
77 | // destructor | |
78 | } | |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | void AliEMCALTriggerSTURawStream::Reset() | |
82 | { | |
83 | // | |
84 | if (fRawReader) fRawReader->Reset(); | |
85 | } | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad() | |
89 | { | |
90 | // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3 | |
91 | // bourrion@lpsc.in2p3.fr | |
92 | ||
93 | UInt_t word32[1772]; // 32b words | |
94 | ||
95 | Int_t iword = 0; | |
96 | ||
97 | UInt_t w32; | |
98 | while (fRawReader->ReadNextInt(w32)) word32[iword++] = w32; | |
99 | ||
100 | if (iword < kPayLoadSize) | |
101 | { | |
102 | AliError(Form("STU raw data size is too small: %d word32 only!", iword)); | |
103 | return kFALSE; | |
104 | } | |
105 | else if (iword > kPayLoadSize ) | |
106 | { | |
107 | AliLog::Message(AliLog::kInfo, "TRU raw data in the STU payload enabled","EMCAL","AliEMCALTriggerSTURawStream","ReadPayLoad()","AliEMCALTriggerSTURawStream.cxx",104); | |
108 | } | |
109 | ||
110 | fL0 = 0; | |
111 | ||
112 | fL1JetThreshold = ((word32[0]>>16) & 0xFFF); | |
113 | fL1GammaThreshold = (word32[0] & 0xFFF); | |
114 | ||
115 | for (Int_t jet_row=0; jet_row<11; jet_row++) | |
116 | { | |
117 | UInt_t currentrow = word32[1+jet_row]; | |
118 | ||
119 | for (Int_t jet_col=0; jet_col<15; jet_col++) | |
120 | { | |
121 | if (currentrow & (1 << jet_col)) | |
122 | { | |
123 | fNL1JetPatch++; | |
124 | fL1JetPatchIndex = (UShort_t*)realloc(fL1JetPatchIndex, fNL1JetPatch * sizeof(UShort_t)); | |
125 | if (fL1JetPatchIndex == NULL) {AliError("Error (re)allocating L1 jet patch memory");} | |
126 | ||
127 | fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF); | |
128 | } | |
129 | } | |
130 | } | |
131 | ||
132 | ////////////////////////////////////////////////////////// | |
133 | // index des L0 // | |
134 | ////////////////////////////////////////////////////////// | |
135 | // FIXME: still not interpreted to be done with Jiri | |
136 | ||
137 | unsigned short TRU_L0_indexes[32][6]; | |
138 | ||
139 | // extraction from stream | |
140 | for (Int_t index=0;index<6;index++) | |
141 | { | |
142 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
143 | { | |
144 | TRU_L0_indexes[2*tru_num ][index] = ( word32[12+index*16+tru_num] & 0xFFFF); | |
145 | TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF); | |
146 | } | |
147 | } | |
148 | ||
149 | for (Int_t tru_num=0;tru_num<32;tru_num++) | |
150 | { | |
151 | for (Int_t index=0;index<6;index++) | |
152 | { | |
153 | for (Int_t bit_num=0;bit_num<12;bit_num++) | |
154 | { | |
155 | if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num))) | |
156 | { | |
157 | fL0 = 1; | |
158 | ||
159 | Int_t idx = 12 * index + bit_num; | |
160 | ||
161 | Int_t col = idx / 3; | |
162 | Int_t row = idx % 3; | |
163 | ||
164 | fNL0GammaPatch++; | |
165 | fL0GammaPatchIndex = (UShort_t*)realloc(fL0GammaPatchIndex, fNL0GammaPatch * sizeof(UShort_t)); | |
166 | ||
167 | if (fL0GammaPatchIndex == NULL) {AliError("Error (re)allocating L0 gamma patch memory");} | |
168 | ||
169 | fL0GammaPatchIndex[fNL0GammaPatch-1] = (((row << 10) & 0xC00) | ((col << 5) & 0x3E0) | (tru_num & 0x1F)); | |
170 | } | |
171 | } | |
172 | } | |
173 | } | |
174 | ||
175 | ////////////////////////////////////////////////////////// | |
176 | // index des L1 gamma // | |
177 | ////////////////////////////////////////////////////////// | |
178 | ||
179 | unsigned short TRU_L1_indexes[32][8]; | |
180 | ||
181 | // extraction from stream | |
182 | for (Int_t index=0;index<8;index++) | |
183 | { | |
184 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
185 | { | |
186 | TRU_L1_indexes[2*tru_num ][index] = ( word32[108+index*16+tru_num] & 0xFFFF); | |
187 | TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF); | |
188 | } | |
189 | } | |
190 | ||
191 | // interpretation | |
192 | int gammacolnum; | |
193 | short indexcopy; | |
194 | ||
195 | for (Int_t tru_num=0;tru_num<32;tru_num++) | |
196 | { | |
197 | for (Int_t index=0;index<8;index++) | |
198 | { | |
199 | for (Int_t bit_num=0; bit_num<12; bit_num++) | |
200 | { | |
201 | if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0) | |
202 | { | |
203 | if (index<4) // Even | |
204 | { | |
205 | gammacolnum = (2*bit_num ); | |
206 | indexcopy = index; | |
207 | } | |
208 | else // Odd | |
209 | { | |
210 | gammacolnum = (2*bit_num+1); | |
211 | indexcopy = index-4; | |
212 | } | |
213 | ||
214 | fNL1GammaPatch++; | |
215 | fL1GammaPatchIndex = (UShort_t*)realloc(fL1GammaPatchIndex, fNL1GammaPatch * sizeof(UShort_t)); | |
216 | ||
217 | if (fL1GammaPatchIndex == NULL) {AliError("Error (re)allocating L1 gamma patch memory");} | |
218 | ||
219 | fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F)); | |
220 | } | |
221 | } | |
222 | } | |
223 | } | |
224 | ||
225 | ////////////////////////////////////////////////////////// | |
226 | // raw output // | |
227 | ////////////////////////////////////////////////////////// | |
228 | ||
229 | if ( iword <= kPayLoadSize ) return kFALSE; | |
230 | ||
231 | // extraction from stream | |
232 | for (Int_t index=0;index<96;index++) | |
233 | { | |
234 | for (Int_t tru_num=0;tru_num<16;tru_num++) | |
235 | { | |
236 | fADC[2*tru_num ][index] = ( word32[236+index*16+tru_num] & 0xFFFF); | |
237 | fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF); | |
238 | } | |
239 | } | |
240 | ||
241 | for (Int_t tru_num=16;tru_num<32;tru_num++) // A side | |
242 | { | |
243 | for (Int_t index=0;index<96;index++) | |
244 | { | |
245 | fADC[tru_num][index] = fADC[tru_num][95-index]; | |
246 | } | |
247 | } | |
248 | ||
249 | return kFALSE; | |
250 | } | |
251 | ||
252 | //_____________________________________________________________________________ | |
253 | Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const | |
254 | { | |
255 | // | |
256 | if (i > fNL0GammaPatch) return kFALSE; | |
257 | ||
258 | tru = fL0GammaPatchIndex[i] & 0x1F; | |
259 | col = (fL0GammaPatchIndex[i] & 0x3E0) >> 5; | |
260 | row = (fL0GammaPatchIndex[i] & 0xC00) >> 10; | |
261 | ||
262 | return kTRUE; | |
263 | } | |
264 | ||
265 | //_____________________________________________________________________________ | |
266 | Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const | |
267 | { | |
268 | // | |
269 | if (i > fNL1GammaPatch) return kFALSE; | |
270 | ||
271 | tru = fL1GammaPatchIndex[i] & 0x1F; | |
272 | col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5; | |
273 | row = (fL1GammaPatchIndex[i] & 0xC00) >> 10; | |
274 | ||
275 | return kTRUE; | |
276 | } | |
277 | ||
278 | //_____________________________________________________________________________ | |
279 | Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const | |
280 | { | |
281 | // | |
282 | if (i > fNL1JetPatch) return kFALSE; | |
283 | ||
284 | col = fL1JetPatchIndex[i] & 0xFF; | |
285 | row = (fL1JetPatchIndex[i] & 0xFF00) >> 8; | |
286 | ||
287 | return kTRUE; | |
288 | } | |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[]) | |
292 | { | |
293 | // | |
294 | for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i]; | |
295 | } | |
296 | ||
297 | //_____________________________________________________________________________ | |
298 | void AliEMCALTriggerSTURawStream::Dump(const Option_t *option) const | |
299 | { | |
300 | // | |
301 | TString op = option; | |
302 | ||
303 | cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl; | |
304 | ||
305 | Int_t itru, col, row; | |
306 | ||
307 | Bool_t isOK; | |
308 | ||
309 | if (op.Contains("L0") || op.Contains("ALL")) | |
310 | { | |
311 | for (Int_t i=0;i<fNL0GammaPatch;i++) | |
312 | { | |
313 | isOK = GetL0GammaPatch(i,itru,col,row); | |
314 | if (isOK) cout << "> Found L0 gamma in TRU #" << setw(2) << itru | |
315 | << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl; | |
316 | } | |
317 | } | |
318 | ||
319 | if (op.Contains("L1") || op.Contains("ALL")) | |
320 | { | |
321 | for (Int_t i=0;i<fNL1GammaPatch;i++) | |
322 | { | |
323 | isOK = GetL1GammaPatch(i,itru,col,row); | |
324 | if (isOK) cout << "> Found L1 gamma in TRU #" << setw(2) << itru | |
325 | << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl; | |
326 | } | |
327 | ||
328 | for (Int_t i=0;i<fNL1JetPatch;i++) | |
329 | { | |
330 | isOK = GetL1JetPatch(i,col,row); | |
331 | if (isOK) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl; | |
332 | } | |
333 | } | |
334 | ||
335 | if (op.Contains("ADC") || op.Contains("ALL")) | |
336 | { | |
337 | for (Int_t i=0;i<32;i++) | |
338 | { | |
339 | cout << "--------\n"; | |
340 | cout << "TRU #" << setw(2) << i << ":"; | |
341 | for (Int_t j=0;j<96;j++) | |
342 | { | |
343 | TBits xadc(12); xadc.Set(12,&fADC[i][j]); | |
344 | if ((j%4)==0) cout << endl; | |
345 | //cout << setw(2) << j << ": " << xadc << " "; | |
346 | printf("%2d: %3x / ",j,fADC[i][j]); | |
347 | } | |
348 | cout << "\n"; | |
349 | } | |
350 | } | |
351 | } |