//_____________________________________________________________________________
AliAltroRawStream::AliAltroRawStream(AliRawReader* rawReader) :
fNoAltroMapping(kTRUE),
- fIsOldRCUFormat(kFALSE),
fIsShortDataHeader(kFALSE),
fDDLNumber(-1),
fPrevDDLNumber(-1),
AliAltroRawStream::AliAltroRawStream(const AliAltroRawStream& stream) :
TObject(stream),
fNoAltroMapping(stream.fNoAltroMapping),
- fIsOldRCUFormat(stream.fIsOldRCUFormat),
fIsShortDataHeader(stream.fIsShortDataHeader),
fDDLNumber(stream.fDDLNumber),
fPrevDDLNumber(stream.fPrevDDLNumber),
if(&stream == this) return *this;
fNoAltroMapping = stream.fNoAltroMapping;
- fIsOldRCUFormat = stream.fIsOldRCUFormat;
fIsShortDataHeader = stream.fIsShortDataHeader;
fDDLNumber = stream.fDDLNumber;
fPrevDDLNumber = stream.fPrevDDLNumber;
}
fCount |= ((temp & 0x3FF) >> 6);
if (fCount == 0) return kFALSE;
-
+ if (fCount >= fPosition) {
+ fRawReader->AddMajorErrorLog(kAltroTrailerErr,"invalid size");
+ // PrintDebug();
+ AliWarning(Form("Incorrect trailer found ! The altro payload size is invalid (%d >= %d) !",fCount,fPosition));
+ fCount = 0;
+ return kFALSE;
+ }
temp = GetNextWord();
fHWAddress |= temp;
{
// Read altro payload in
// backward direction
- if (fPosition <= 0) {
+ if (fCount <= 2) {
fRawReader->AddMinorErrorLog(kBunchLengthReadErr,"");
// PrintDebug();
- AliWarning("Could not read bunch length !");
+ AliWarning(Form("Could not read bunch length and time bin ! Only %d 10-bit words are left !",fCount));
+ fBunchLength = fTimeBunch = fCount = 0;
+ return;
}
fBunchLength = GetNextWord() - 2;
- fTimeBunch = fBunchLength;
- fCount--;
-
- if (fPosition <= 0) {
- fRawReader->AddMinorErrorLog(kTimeBinReadErr,"");
+ if (fBunchLength > fCount) {
+ fRawReader->AddMinorErrorLog(kBunchLengthReadErr,Form("bl=%d",fBunchLength));
// PrintDebug();
- AliWarning("Could not read time bin !");
+ AliWarning(Form("Could not read bunch length ! Bunch length = %d (>%d)",fBunchLength,fCount));
+ fBunchLength = fTimeBunch = fCount = 0;
+ return;
}
+ fTimeBunch = fBunchLength;
+ fCount--;
fTime = GetNextWord();
fCount--;
void AliAltroRawStream::ReadAmplitude()
{
// Read next time bin amplitude
- if (fPosition <= 0) {
+ if (fCount <= 0) {
fRawReader->AddMinorErrorLog(kAmplitudeReadErr,"");
// PrintDebug();
AliWarning("Could not read sample amplitude !");
+ fCount = fSignal = fBunchLength = 0;
+ return;
}
fSignal = GetNextWord();
+
fCount--;
fBunchLength--;
// The RCU trailer format is described
// in details in the RCU manual.
- if (!fIsOldRCUFormat) {
- // First read 32-bit word with the
- // trailer size (22 bits) and RCU ID (the rest)
- Int_t index = fRawReader->GetDataSize();
- UInt_t word = Get32bitWord(index);
- fRCUId = (Int_t)(word >> 22);
- Int_t trailerSize = (word & 0x3FFFFF);
+ // We use the last word of the payload
+ // in order to decide which RCU firmware
+ // was used during the data taking.
+ // The firmware v2 adds 0xAAAA as 16
+ // most significant bits and since the
+ // payload size (firmware v1) can not be
+ // that big, we use this as a unique
+ // label of the firmware version.
+
+ Int_t index = fRawReader->GetDataSize();
+ UInt_t word = Get32bitWord(index);
+ if (((word >> 16) == 0xaaaa) || (word == 2)) {
+ // This is RCU formware v2
+ // The statement word==2 is needed only temporary
+ // in order to be able to read previously generated
+ // aliroot raw data
+
+ Int_t trailerSize = 0;
+ if (word == 2) {
+ AliInfo("Old simulated raw data is assumed!");
+ trailerSize = 2;
+ fRCUId = 0;
+ }
+ else {
+ // First read 32-bit word with the
+ // trailer size (7 bits), RCU ID (9 bits) and
+ // 0xAAA (the rest - 16 bits)
+ fRCUId = (Int_t)((word >> 7) & 0x1ff);
+ trailerSize = (word & 0x7F);
+ }
// Now read the beginning of the trailer
// where the payload size is written
fRCUTrailerSize = (trailerSize-2)*4;
index -= fRCUTrailerSize;
if (index < 4) {
- PrintDebug();
- AliFatal(Form("Invalid trailer size found (%d bytes) ! The size is bigger than the raw data size (%d bytes)!",
- trailerSize*4,
- fRawReader->GetDataSize()));
+ fRawReader->AddMajorErrorLog(kRCUTrailerErr,Form("tr=%d raw=%d bytes",
+ trailerSize*4,
+ fRawReader->GetDataSize()));
+ AliWarning(Form("Invalid trailer size found (%d bytes) ! The size is bigger than the raw data size (%d bytes)!",
+ trailerSize*4,
+ fRawReader->GetDataSize()));
}
fRCUTrailerData = fData + index;
Int_t position = Get32bitWord(index);
// In case of the Old RCU trailer format
// we have to read just the size of altro payload
// in units of 40-bit words
- Int_t index = fRawReader->GetDataSize();
- Int_t position = Get32bitWord(index);
+ Int_t position = (Int_t)word;
fRCUId = -1;
fRCUTrailerSize = 0;