]>
Commit | Line | Data |
---|---|---|
f8e5b5a0 | 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 | /// This is a base class for reading raw data digits in Altro format. | |
19 | /// The class is able to read the RCU v3 and above formats. | |
20 | /// The main difference between the format V3 and older ones is in | |
21 | /// the coding of the 10-bit Altro payload words. In V3 3 10-bit words | |
22 | /// are coded in one 32-bit word. The bits 30 and 31 are used to identify | |
23 | /// the payload, altro header and RCU trailer contents. | |
24 | /// | |
25 | /// | |
26 | /// cvetan.cheshkov@cern.ch 1/04/2009 | |
27 | /////////////////////////////////////////////////////////////////////////////// | |
28 | ||
29 | #include "AliAltroRawStreamV3.h" | |
30 | #include "AliRawReader.h" | |
31 | #include "AliLog.h" | |
0148e633 | 32 | #include "AliAltroRawStream.h" |
f8e5b5a0 | 33 | |
34 | ClassImp(AliAltroRawStreamV3) | |
35 | ||
36 | ||
37 | //_____________________________________________________________________________ | |
38 | AliAltroRawStreamV3::AliAltroRawStreamV3(AliRawReader* rawReader) : | |
39 | fIsShortDataHeader(kFALSE), | |
40 | fDDLNumber(-1), | |
41 | fRCUId(-1), | |
42 | fHWAddress(-1), | |
43 | fRawReader(rawReader), | |
44 | fData(NULL), | |
45 | fPosition(-1), | |
46 | fCount(-1), | |
47 | fStartTimeBin(-1), | |
48 | fBunchLength(-1), | |
49 | fBadChannel(kFALSE), | |
50 | fPayloadSize(-1), | |
6d4dd848 | 51 | fBunchDataPointer(NULL), |
52 | fBunchDataIndex(-1), | |
f8e5b5a0 | 53 | fRCUTrailerData(NULL), |
54 | fRCUTrailerSize(0), | |
55 | fFECERRA(0), | |
56 | fFECERRB(0), | |
57 | fERRREG2(0), | |
58 | fERRREG3(0), | |
f8e5b5a0 | 59 | fActiveFECsA(0), |
60 | fActiveFECsB(0), | |
61 | fAltroCFG1(0), | |
0148e633 | 62 | fAltroCFG2(0), |
63 | fOldStream(NULL) | |
f8e5b5a0 | 64 | { |
65 | // Constructor | |
66 | // Create an object to read Altro raw digits in | |
67 | // RCU version 3 and beyond format | |
68 | for(Int_t i = 0; i < kMaxNTimeBins; i++) fBunchData[i] = 0; | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliAltroRawStreamV3::~AliAltroRawStreamV3() | |
73 | { | |
74 | // destructor | |
0148e633 | 75 | // delete old stream object if one exists |
76 | if (fOldStream) delete fOldStream; | |
f8e5b5a0 | 77 | } |
78 | ||
79 | //_____________________________________________________________________________ | |
80 | AliAltroRawStreamV3::AliAltroRawStreamV3(const AliAltroRawStreamV3& stream) : | |
81 | TObject(stream), | |
82 | fIsShortDataHeader(stream.fIsShortDataHeader), | |
83 | fDDLNumber(stream.fDDLNumber), | |
84 | fRCUId(stream.fRCUId), | |
85 | fHWAddress(stream.fHWAddress), | |
86 | fRawReader(stream.fRawReader), | |
87 | fData(stream.fData), | |
88 | fPosition(stream.fPosition), | |
89 | fCount(stream.fCount), | |
90 | fStartTimeBin(stream.fStartTimeBin), | |
91 | fBunchLength(stream.fBunchLength), | |
92 | fBadChannel(stream.fBadChannel), | |
93 | fPayloadSize(stream.fPayloadSize), | |
6d4dd848 | 94 | fBunchDataPointer(stream.fBunchDataPointer), |
95 | fBunchDataIndex(stream.fBunchDataIndex), | |
f8e5b5a0 | 96 | fRCUTrailerData(stream.fRCUTrailerData), |
97 | fRCUTrailerSize(stream.fRCUTrailerSize), | |
98 | fFECERRA(stream.fFECERRA), | |
99 | fFECERRB(stream.fFECERRB), | |
100 | fERRREG2(stream.fERRREG2), | |
101 | fERRREG3(stream.fERRREG3), | |
f8e5b5a0 | 102 | fActiveFECsA(stream.fActiveFECsA), |
103 | fActiveFECsB(stream.fActiveFECsB), | |
104 | fAltroCFG1(stream.fAltroCFG1), | |
0148e633 | 105 | fAltroCFG2(stream.fAltroCFG2), |
106 | fOldStream(NULL) | |
f8e5b5a0 | 107 | { |
108 | // Copy constructor | |
109 | // Copy the bunch data array | |
110 | for(Int_t i = 0; i < kMaxNTimeBins; i++) fBunchData[i] = stream.fBunchData[i]; | |
0148e633 | 111 | |
112 | if (stream.fOldStream) | |
113 | fOldStream = new AliAltroRawStream(*stream.fOldStream); | |
f8e5b5a0 | 114 | } |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | AliAltroRawStreamV3& AliAltroRawStreamV3::operator = (const AliAltroRawStreamV3& stream) | |
118 | { | |
119 | // assignment operator | |
120 | // ... | |
121 | if(&stream == this) return *this; | |
122 | ||
123 | fIsShortDataHeader = stream.fIsShortDataHeader; | |
124 | fDDLNumber = stream.fDDLNumber; | |
125 | fRCUId = stream.fRCUId; | |
126 | fHWAddress = stream.fHWAddress; | |
127 | fRawReader = stream.fRawReader; | |
128 | fData = stream.fData; | |
129 | fPosition = stream.fPosition; | |
130 | fCount = stream.fCount; | |
131 | fStartTimeBin = stream.fStartTimeBin; | |
132 | fBunchLength = stream.fBunchLength; | |
133 | fBadChannel = stream.fBadChannel; | |
134 | fPayloadSize = stream.fPayloadSize; | |
6d4dd848 | 135 | fBunchDataPointer = stream.fBunchDataPointer; |
136 | fBunchDataIndex = stream.fBunchDataIndex; | |
f8e5b5a0 | 137 | fRCUTrailerData = stream.fRCUTrailerData; |
138 | fRCUTrailerSize = stream.fRCUTrailerSize; | |
139 | fFECERRA = stream.fFECERRA; | |
140 | fFECERRB = stream.fFECERRB; | |
141 | fERRREG2 = stream.fERRREG2; | |
142 | fERRREG3 = stream.fERRREG3; | |
f8e5b5a0 | 143 | fActiveFECsA = stream.fActiveFECsA; |
144 | fActiveFECsB = stream.fActiveFECsB; | |
145 | fAltroCFG1 = stream.fAltroCFG1; | |
146 | fAltroCFG2 = stream.fAltroCFG2; | |
147 | ||
148 | for(Int_t i = 0; i < kMaxNTimeBins; i++) fBunchData[i] = stream.fBunchData[i]; | |
149 | ||
0148e633 | 150 | if (stream.fOldStream) { |
151 | if (fOldStream) delete fOldStream; | |
152 | fOldStream = new AliAltroRawStream(stream.fRawReader); | |
153 | *fOldStream = *stream.fOldStream; | |
154 | } | |
155 | ||
f8e5b5a0 | 156 | return *this; |
157 | } | |
158 | ||
159 | //_____________________________________________________________________________ | |
160 | void AliAltroRawStreamV3::Reset() | |
161 | { | |
162 | // Complete reset of raw stream params | |
163 | // Reset of the raw-reader as well | |
164 | ||
165 | fDDLNumber = fRCUId = fHWAddress = -1; | |
166 | fPosition = fCount = -1; | |
167 | fBunchLength = fStartTimeBin = -1; | |
168 | fBadChannel = kFALSE; | |
169 | fPayloadSize = -1; | |
6d4dd848 | 170 | fBunchDataPointer = NULL; |
171 | fBunchDataIndex = -1; | |
f8e5b5a0 | 172 | |
173 | fRCUTrailerData = NULL; | |
174 | fRCUTrailerSize = 0; | |
175 | ||
9283f3a5 | 176 | fFECERRA = fFECERRB = fERRREG2 = fERRREG3 = fActiveFECsA = fActiveFECsB = fAltroCFG1 = fAltroCFG2 = 0; |
f8e5b5a0 | 177 | |
178 | if (fRawReader) fRawReader->Reset(); | |
179 | ||
0148e633 | 180 | if (fOldStream) fOldStream->Reset(); |
f8e5b5a0 | 181 | } |
182 | ||
183 | //_____________________________________________________________________________ | |
184 | Bool_t AliAltroRawStreamV3::NextDDL() | |
185 | { | |
186 | // Read the next DDL payload (CDH + RCU trailer) | |
187 | // Updates the information which is coming from these | |
188 | // two sources | |
189 | ||
190 | fPosition = 0; | |
191 | // Get next DDL payload | |
192 | // return wtih false in case no more data payloads | |
193 | // are found | |
194 | do { | |
195 | if (!fRawReader->ReadNextData(fData)) return kFALSE; | |
196 | } while (fRawReader->GetDataSize() == 0); | |
197 | ||
198 | fDDLNumber = fRawReader->GetDDLID(); | |
199 | ||
200 | UChar_t rcuVer = fRawReader->GetBlockAttributes(); | |
201 | ||
0148e633 | 202 | if (rcuVer < 2) { |
203 | // old altro format data | |
204 | if (!fOldStream) { | |
205 | fOldStream = new AliAltroRawStream(fRawReader); | |
206 | AliInfo(Form("RCU firmware verion %d detected. Using AliAltroRawStream to decode the data.", | |
207 | rcuVer)); | |
208 | } | |
209 | Bool_t status = fOldStream->NextDDL(fData); | |
210 | if (status) { | |
211 | fRCUId = fOldStream->GetRCUId(); | |
212 | fRCUTrailerSize = fOldStream->GetRCUTrailerSize(); | |
213 | fOldStream->GetRCUTrailerData(fRCUTrailerData); | |
214 | fFECERRA = fOldStream->GetFECERRA(); | |
215 | fFECERRB = fOldStream->GetFECERRB(); | |
216 | fERRREG2 = fOldStream->GetERRREG2(); | |
217 | fERRREG3 = ((UInt_t)fOldStream->GetNChAddrMismatch()) | | |
218 | (((UInt_t)fOldStream->GetNChLengthMismatch()) << 12); | |
219 | fActiveFECsA = fOldStream->GetActiveFECsA(); | |
220 | fActiveFECsB = fOldStream->GetActiveFECsB(); | |
221 | fAltroCFG1 = fOldStream->GetAltroCFG1(); | |
222 | fAltroCFG2 = fOldStream->GetAltroCFG2(); | |
223 | } | |
224 | return status; | |
225 | } | |
f8e5b5a0 | 226 | |
0148e633 | 227 | return ReadRCUTrailer(rcuVer); |
f8e5b5a0 | 228 | } |
229 | ||
230 | //_____________________________________________________________________________ | |
231 | Bool_t AliAltroRawStreamV3::NextChannel() | |
232 | { | |
233 | // Read the next Altro channel from the | |
234 | // raw-data stream | |
235 | // Updates the channel hardware address member and | |
236 | // channel data size. Sets the error flag in case | |
237 | // RCU signals readout error in this channel | |
0148e633 | 238 | if (fOldStream) { |
239 | Bool_t status = fOldStream->NextChannel(); | |
240 | if (status) fHWAddress = fOldStream->GetHWAddress(); | |
241 | return status; | |
242 | } | |
243 | ||
f8e5b5a0 | 244 | fCount = -1; |
245 | fBadChannel = kFALSE; | |
6d4dd848 | 246 | fBunchDataIndex = 0; |
f8e5b5a0 | 247 | |
248 | UInt_t word = 0; | |
249 | do { | |
250 | word = Get32bitWord(fPosition++); | |
6d4dd848 | 251 | if (fPosition > fPayloadSize) return kFALSE; |
f8e5b5a0 | 252 | } |
6d4dd848 | 253 | while ((word >> 30) != 1); |
f8e5b5a0 | 254 | |
255 | // check for readout errors | |
6d4dd848 | 256 | fBadChannel = (word >> 29) & 0x1; |
f8e5b5a0 | 257 | |
258 | // extract channel payload and hw address | |
6d4dd848 | 259 | fCount = (word >> 16) & 0x3FF; |
f8e5b5a0 | 260 | fHWAddress = word & 0xFFF; |
261 | ||
6d4dd848 | 262 | // Now unpack the altro data |
263 | // Revert the order of the samples | |
264 | // inside the bunch so that the | |
265 | // first time is first in the samples | |
266 | // array | |
267 | Int_t isample = 0; | |
268 | Int_t nwords = (fCount+2)/3; | |
269 | for (Int_t iword = 0; iword < nwords; iword++) { | |
270 | word = Get32bitWord(fPosition++); | |
271 | if ((word >> 30) != 0) { | |
272 | // Unexpected end of altro channel payload | |
273 | AliWarning(Form("Unexpected end of payload in altro channel payload! Address=0x%x, word=0x%x", | |
274 | fHWAddress,word)); | |
275 | fRawReader->AddMinorErrorLog(kAltroPayloadErr,Form("hw=0x%x",fHWAddress)); | |
276 | fCount = -1; | |
277 | fPosition--; | |
278 | return kFALSE; | |
279 | } | |
280 | fBunchData[isample++] = (word >> 20) & 0x3FF; | |
281 | fBunchData[isample++] = (word >> 10) & 0x3FF; | |
282 | fBunchData[isample++] = word & 0x3FF; | |
283 | } | |
284 | ||
f8e5b5a0 | 285 | return kTRUE; |
286 | } | |
287 | ||
288 | //_____________________________________________________________________________ | |
289 | Bool_t AliAltroRawStreamV3::NextBunch() | |
290 | { | |
291 | // Read next altro bunch from the | |
292 | // raw-data stream. | |
293 | // Updates the start/end time-bins | |
294 | // and the array with altro samples | |
0148e633 | 295 | if (fOldStream) { |
296 | Bool_t status = fOldStream->NextBunch(fBunchData,fBunchLength,fStartTimeBin); | |
297 | if (status) fBunchDataPointer = &fBunchData[0]; | |
298 | else fBunchDataPointer = NULL; | |
299 | return status; | |
300 | } | |
301 | ||
f8e5b5a0 | 302 | fBunchLength = fStartTimeBin = -1; |
6d4dd848 | 303 | fBunchDataPointer = NULL; |
f8e5b5a0 | 304 | |
6d4dd848 | 305 | if ((fBunchDataIndex >= fCount) || fBadChannel) return kFALSE; |
f8e5b5a0 | 306 | |
6d4dd848 | 307 | fBunchLength = fBunchData[fBunchDataIndex]; |
308 | if ((fBunchDataIndex + fBunchLength) > fCount) { | |
f8e5b5a0 | 309 | // Too long bunch detected |
6d4dd848 | 310 | AliWarning(Form("Too long bunch detected in Address=0x%x ! Expected <= %d 10-bit words, found %d !", |
311 | fHWAddress,fCount-fBunchDataIndex,fBunchLength)); | |
f8e5b5a0 | 312 | fRawReader->AddMinorErrorLog(kAltroBunchHeadErr,Form("hw=0x%x",fHWAddress)); |
313 | fCount = fBunchLength = -1; | |
314 | return kFALSE; | |
315 | } | |
6d4dd848 | 316 | fBunchDataIndex++; |
f8e5b5a0 | 317 | fBunchLength -= 2; |
318 | ||
6d4dd848 | 319 | fStartTimeBin = fBunchData[fBunchDataIndex++]; |
f8e5b5a0 | 320 | |
6d4dd848 | 321 | fBunchDataPointer = &fBunchData[fBunchDataIndex]; |
f8e5b5a0 | 322 | |
6d4dd848 | 323 | fBunchDataIndex += fBunchLength; |
f8e5b5a0 | 324 | |
325 | return kTRUE; | |
326 | } | |
327 | ||
328 | //_____________________________________________________________________________ | |
329 | UInt_t AliAltroRawStreamV3::Get32bitWord(Int_t index) const | |
330 | { | |
331 | // This method returns the 32 bit word at a given | |
332 | // position inside the raw data payload. | |
333 | // The 'index' points to the beginning of the word. | |
334 | // The method is supposed to be endian (platform) | |
335 | // independent. | |
336 | ||
337 | index = (index << 2); | |
338 | UInt_t word = 0; | |
339 | word |= fData[index++]; | |
340 | word |= fData[index++] << 8; | |
341 | word |= fData[index++] << 16; | |
342 | word |= fData[index++] << 24; | |
343 | ||
344 | return word; | |
345 | } | |
346 | ||
347 | ///_____________________________________________________________________________ | |
348 | Bool_t AliAltroRawStreamV3::ReadRCUTrailer(UChar_t rcuVer) | |
349 | { | |
350 | // Read the RCU trailer according | |
351 | // to the RCU formware version | |
352 | // specified in CDH | |
353 | // Cross-check with version found in the | |
354 | // trailer | |
355 | ||
356 | fRCUTrailerData = NULL; | |
357 | fRCUTrailerSize = 0; | |
358 | fPayloadSize = -1; | |
359 | ||
360 | Int_t index = fRawReader->GetDataSize()/4; | |
361 | ||
362 | // First read 32-bit word with the | |
363 | // trailer size (7 bits), RCU ID (9 bits) and | |
364 | // RCU firmware version (8 bits?) | |
365 | // The two major bit should be 11 (identifies | |
366 | // the end of the trailer) | |
367 | UInt_t word = Get32bitWord(--index); | |
368 | ||
369 | if ((word >> 30) != 3) { | |
370 | fRawReader->AddFatalErrorLog(kRCUTrailerErr,""); | |
371 | AliError("Last RCU trailer word not found!"); | |
372 | return kFALSE; | |
373 | } | |
374 | ||
375 | UChar_t ver = (word >> 16) & 0xFF; | |
376 | if (ver != rcuVer) { | |
377 | // Wrong RCU firmware version detected | |
378 | fRawReader->AddMajorErrorLog(kRCUVerErr,Form("%d!=%d", | |
379 | ver,rcuVer)); | |
380 | AliDebug(1,Form("Wrong RCU firmware version detected: %d != %d", | |
381 | ver,rcuVer)); | |
382 | } | |
383 | ||
384 | fRCUId = (Int_t)((word >> 7) & 0x1FF); | |
385 | Int_t trailerSize = (word & 0x7F); | |
386 | ||
387 | // Now read the beginning of the trailer | |
388 | // where the payload size is written | |
389 | if (trailerSize < 2) { | |
390 | fRawReader->AddMajorErrorLog(kRCUTrailerErr,Form("tr=%d bytes", | |
391 | trailerSize*4)); | |
392 | AliWarning(Form("Invalid trailer size found (%d bytes) !", | |
393 | trailerSize*4)); | |
394 | return kFALSE; | |
395 | } | |
396 | ||
397 | trailerSize -= 2; | |
398 | fRCUTrailerSize = trailerSize*4; | |
399 | ||
400 | for (; trailerSize > 0; trailerSize--) { | |
401 | word = Get32bitWord(--index); | |
402 | if ((word >> 30) != 2) { | |
403 | fRawReader->AddMinorErrorLog(kRCUTrailerErr,"missing 10"); | |
404 | AliWarning("Missing RCU trailer identifier pattern!"); | |
405 | continue; | |
406 | } | |
407 | Int_t parCode = (word >> 26) & 0xF; | |
408 | Int_t parData = word & 0x3FFFFFF; | |
409 | switch (parCode) { | |
410 | case 1: | |
411 | // ERR_REG1 | |
412 | fFECERRA = ((parData >> 13) & 0x1FFF) << 7; | |
413 | fFECERRB = ((parData & 0x1FFF)) << 7; | |
414 | break; | |
415 | case 2: | |
416 | // ERR_REG2 | |
417 | fERRREG2 = parData & 0x1FF; | |
418 | break; | |
419 | case 3: | |
420 | // ERR_REG3 | |
9283f3a5 | 421 | fERRREG3 = parData & 0x1FFFFFF; |
f8e5b5a0 | 422 | break; |
423 | case 4: | |
f8e5b5a0 | 424 | // FEC_RO_A |
425 | fActiveFECsA = parData & 0xFFFF; | |
426 | break; | |
9283f3a5 | 427 | case 5: |
f8e5b5a0 | 428 | // FEC_RO_B |
429 | fActiveFECsB = parData & 0xFFFF; | |
430 | break; | |
9283f3a5 | 431 | case 6: |
f8e5b5a0 | 432 | // RDO_CFG1 |
433 | fAltroCFG1 = parData & 0xFFFFF; | |
434 | break; | |
9283f3a5 | 435 | case 7: |
f8e5b5a0 | 436 | // RDO_CFG2 |
437 | fAltroCFG2 = parData & 0x1FFFFFF; | |
438 | break; | |
439 | default: | |
440 | fRawReader->AddMinorErrorLog(kRCUTrailerErr,"undef word"); | |
441 | AliWarning(Form("Undefined parameter code %d, ignore it !", | |
442 | parCode)); | |
443 | break; | |
444 | } | |
445 | } | |
446 | ||
447 | if (index < 1) { | |
448 | fRawReader->AddMajorErrorLog(kRCUTrailerErr,Form("tr=%d raw=%d bytes", | |
449 | fRCUTrailerSize+8, | |
450 | fRawReader->GetDataSize())); | |
451 | AliWarning(Form("Invalid trailer size found (%d bytes) ! The size is bigger than the raw data size (%d bytes)!", | |
452 | fRCUTrailerSize, | |
453 | fRawReader->GetDataSize())); | |
454 | } | |
455 | ||
456 | fRCUTrailerData = fData + index*4; | |
457 | ||
458 | // Now read the payload size | |
459 | // (First word in the RCU trailer) | |
460 | fPayloadSize = Get32bitWord(--index) & 0x3FFFFFF; | |
461 | ||
462 | if ((fRawReader->GetDataSize() - fRCUTrailerSize - 8) != (fPayloadSize*4)) { | |
463 | fRawReader->AddMajorErrorLog(kRCUTrailerSizeErr,Form("h=%d tr=%d rcu=%d bytes", | |
464 | fRawReader->GetDataSize(), | |
465 | fRCUTrailerSize+8, | |
466 | fPayloadSize*4)); | |
467 | AliWarning(Form("Inconsistent raw data size ! Raw data size - %d bytes (from CDH), RCU trailer - %d bytes, raw data size (from RCU trailer) - %d bytes !", | |
468 | fRawReader->GetDataSize(), | |
469 | fRCUTrailerSize+8, | |
470 | fPayloadSize*4)); | |
471 | } | |
472 | ||
473 | return kTRUE; | |
474 | } | |
475 | ||
476 | //_____________________________________________________________________________ | |
477 | Int_t AliAltroRawStreamV3::GetBranch() const | |
478 | { | |
479 | // The method provides the RCU branch index (0 or 1) | |
480 | // for the current hardware address. | |
481 | // In case the hardware address has not been yet | |
482 | // initialized, the method returns -1 | |
483 | if (fHWAddress == -1) return -1; | |
484 | ||
485 | return ((fHWAddress >> 11) & 0x1); | |
486 | } | |
487 | ||
488 | //_____________________________________________________________________________ | |
489 | Int_t AliAltroRawStreamV3::GetFEC() const | |
490 | { | |
491 | // The method provides the front-end card index | |
492 | // for the current hardware address. | |
493 | // In case the hardware address has not been yet | |
494 | // initialized, the method returns -1 | |
495 | if (fHWAddress == -1) return -1; | |
496 | ||
497 | return ((fHWAddress >> 7) & 0xF); | |
498 | } | |
499 | ||
500 | //_____________________________________________________________________________ | |
501 | Int_t AliAltroRawStreamV3::GetAltro() const | |
502 | { | |
503 | // The method provides the altro chip index | |
504 | // for the current hardware address. | |
505 | // In case the hardware address has not been yet | |
506 | // initialized, the method returns -1 | |
507 | if (fHWAddress == -1) return -1; | |
508 | ||
509 | return ((fHWAddress >> 4) & 0x7); | |
510 | } | |
511 | ||
512 | //_____________________________________________________________________________ | |
513 | Int_t AliAltroRawStreamV3::GetChannel() const | |
514 | { | |
515 | // The method provides the channel index | |
516 | // for the current hardware address. | |
517 | // In case the hardware address has not been yet | |
518 | // initialized, the method returns -1 | |
519 | if (fHWAddress == -1) return -1; | |
520 | ||
521 | return (fHWAddress & 0xF); | |
522 | } | |
523 | ||
524 | //_____________________________________________________________________________ | |
525 | Bool_t AliAltroRawStreamV3::GetRCUTrailerData(UChar_t*& data) const | |
526 | { | |
527 | // Return a pointer to the RCU trailer | |
528 | // data. Should be called always after | |
529 | // the RCU trailer was already processed | |
530 | // in the GetPosition() method | |
531 | if (!fRCUTrailerSize || !fRCUTrailerData) { | |
532 | AliError("No valid RCU trailer data is found !"); | |
533 | data = NULL; | |
534 | return kFALSE; | |
535 | } | |
536 | ||
537 | data = fRCUTrailerData; | |
538 | ||
539 | return kTRUE; | |
540 | } | |
541 | ||
542 | //_____________________________________________________________________________ | |
543 | void AliAltroRawStreamV3::PrintRCUTrailer() const | |
544 | { | |
545 | // Prints the contents of | |
546 | // the RCU trailer data | |
547 | printf("RCU trailer:\n===========\n"); | |
548 | printf("FECERRA: 0x%x\nFECERRB: 0x%x\n",fFECERRA,fFECERRB); | |
549 | printf("ERRREG2: 0x%x\n",fERRREG2); | |
550 | printf("#channels skipped due to address mismatch: %d\n",GetNChAddrMismatch()); | |
551 | printf("#channels skipped due to bad block length: %d\n",GetNChLengthMismatch()); | |
552 | printf("Active FECs (branch A): 0x%x\nActive FECs (branch B): 0x%x\n",fActiveFECsA,fActiveFECsB); | |
553 | printf("Baseline corr: 0x%x\n",GetBaselineCorr()); | |
554 | printf("Number of presamples: %d\nNumber of postsamples: %d\n",GetNPresamples(),GetNPostsamples()); | |
555 | printf("Second baseline corr: %d\n",GetSecondBaselineCorr()); | |
556 | printf("GlitchFilter: %d\n",GetGlitchFilter()); | |
557 | printf("Number of non-ZS postsamples: %d\nNumber of non-ZS presamples: %d\n",GetNNonZSPostsamples(),GetNNonZSPresamples()); | |
558 | printf("Number of ALTRO buffers: %d\n",GetNAltroBuffers()); | |
559 | printf("Number of pretrigger samples: %d\n",GetNPretriggerSamples()); | |
560 | printf("Number of samples per channel: %d\n",GetNSamplesPerCh()); | |
561 | printf("Sparse readout: %d\n",GetSparseRO()); | |
562 | printf("Sampling time: %e s\n",GetTSample()); | |
563 | printf("L1 Phase: %e s\n",GetL1Phase()); | |
564 | printf("AltroCFG1: 0x%x\nAltroCFG2: 0x%x\n",GetAltroCFG1(),GetAltroCFG2()); | |
565 | printf("===========\n"); | |
566 | } | |
567 | ||
568 | //_____________________________________________________________________________ | |
569 | void AliAltroRawStreamV3::SelectRawData(Int_t detId) | |
570 | { | |
571 | // Select the raw data for specific | |
572 | // detector id | |
573 | AliDebug(1,Form("Selecting raw data for detector %d",detId)); | |
574 | fRawReader->Select(detId); | |
575 | } | |
576 | ||
577 | //_____________________________________________________________________________ | |
578 | void AliAltroRawStreamV3::SelectRawData(const char *detName) | |
579 | { | |
580 | // Select the raw data for specific | |
581 | // detector name | |
582 | AliDebug(1,Form("Selecting raw data for detector %s",detName)); | |
583 | fRawReader->Select(detName); | |
584 | } | |
585 | ||
586 | //_____________________________________________________________________________ | |
587 | Double_t AliAltroRawStreamV3::GetTSample() const | |
588 | { | |
589 | // Returns the sampling time | |
590 | // in seconds. In case the rcu trailer | |
591 | // was note read, return an invalid number (0) | |
592 | ||
593 | if (!fRCUTrailerData) return 0.; | |
594 | ||
595 | const Double_t kLHCTimeSample = 25.0e-9; // LHC clocks runs at 40 MHz | |
596 | UChar_t fq = (fAltroCFG2 >> 5) & 0xF; | |
597 | Double_t tSample; | |
598 | switch (fq) { | |
599 | case 0: | |
600 | // 20 MHz | |
601 | tSample = 2.0*kLHCTimeSample; | |
602 | break; | |
603 | case 1: | |
604 | // 10 Mhz | |
605 | tSample = 4.0*kLHCTimeSample; | |
606 | break; | |
607 | case 2: | |
608 | // 5 MHz | |
609 | tSample = 8.0*kLHCTimeSample; | |
610 | break; | |
611 | default: | |
612 | AliWarning(Form("Invalid sampling frequency value %d !", | |
613 | fq)); | |
614 | tSample = 0.; | |
615 | break; | |
616 | } | |
617 | ||
618 | return tSample; | |
619 | } | |
620 | ||
621 | //_____________________________________________________________________________ | |
622 | Double_t AliAltroRawStreamV3::GetL1Phase() const | |
623 | { | |
624 | // Returns the L1 phase w.r.t to the | |
625 | // LHC clock | |
626 | if (!fRCUTrailerData) return 0.; | |
627 | ||
628 | const Double_t kLHCTimeSample = 25.0e-9; // LHC clocks runs at 40 MHz | |
629 | Double_t phase = ((Double_t)(fAltroCFG2 & 0x1F))*kLHCTimeSample; | |
630 | ||
631 | Double_t tSample = GetTSample(); | |
632 | if (phase >= tSample) { | |
633 | AliWarning(Form("Invalid L1 trigger phase (%f >= %d) !", | |
634 | phase,tSample)); | |
635 | phase = 0.; | |
636 | } | |
637 | ||
638 | return phase; | |
639 | } | |
640 | ||
641 | //_____________________________________________________________________________ | |
642 | void AliAltroRawStreamV3::AddMappingErrorLog(const char *message) | |
643 | { | |
644 | // Signal a mapping error | |
645 | // The method can be used by the TPC,PHOS,EMCAL,FMD raw stream | |
646 | // classes in order to log an error related to bad altro mapping | |
647 | ||
648 | if (fRawReader) fRawReader->AddMinorErrorLog(kBadAltroMapping,message); | |
649 | } |