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