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