AliAltroRawStream::AliAltroRawStream(AliRawReader* rawReader) :
fNoAltroMapping(kTRUE),
fIsOldRCUFormat(kFALSE),
+ fIsShortDataHeader(kFALSE),
fDDLNumber(-1),
fPrevDDLNumber(-1),
fRCUId(-1),
TObject(stream),
fNoAltroMapping(kTRUE),
fIsOldRCUFormat(kFALSE),
+ fIsShortDataHeader(kFALSE),
fDDLNumber(-1),
fPrevDDLNumber(-1),
fRCUId(-1),
fRawReader->Select(detId);
}
+//_____________________________________________________________________________
+void AliAltroRawStream::SelectRawData(const char *detName)
+{
+ // Select the raw data for specific
+ // detector name
+ AliDebug(1,Form("Selecting raw data for detector %s",detName));
+ fRawReader->Select(detName);
+}
+
//_____________________________________________________________________________
UShort_t AliAltroRawStream::GetNextWord()
{
UShort_t temp;
Int_t nFillWords = 0;
while ((temp = GetNextWord()) == 0x2AA) nFillWords++;
- if (nFillWords == 0)
+ if (nFillWords == 0) {
+ PrintDebug();
AliFatal("Incorrect trailer found ! Expected 0x2AA not found !");
+ }
//Then read the trailer
- if (fPosition <= 4)
+ if (fPosition <= 4) {
+ PrintDebug();
AliFatal(Form("Incorrect raw data size ! Expected at lest 4 words but found %d !",fPosition));
+ }
fCount = (temp << 4) & 0x3FF;
- if ((temp >> 6) != 0xA)
+ if ((temp >> 6) != 0xA) {
+ PrintDebug();
AliFatal(Form("Incorrect trailer found ! Expecting 0xA but found %x !",temp >> 6));
+ }
temp = GetNextWord();
fHWAddress = (temp & 0x3) << 10;
- if (((temp >> 2) & 0xF) != 0xA)
+ if (((temp >> 2) & 0xF) != 0xA) {
+ PrintDebug();
AliFatal(Form("Incorrect trailer found ! Expecting second 0xA but found %x !",(temp >> 2) & 0xF));
+ }
fCount |= ((temp & 0x3FF) >> 6);
if (fCount == 0) return kFALSE;
{
// Read altro payload in
// backward direction
- if (fPosition <= 0)
+ if (fPosition <= 0) {
+ PrintDebug();
AliFatal("Could not read bunch length !");
+ }
fBunchLength = GetNextWord() - 2;
fTimeBunch = fBunchLength;
fCount--;
- if (fPosition <= 0)
+ if (fPosition <= 0) {
+ PrintDebug();
AliFatal("Could not read time bin !");
+ }
fTime = GetNextWord();
fCount--;
void AliAltroRawStream::ReadAmplitude()
{
// Read next time bin amplitude
- if (fPosition <= 0)
+ if (fPosition <= 0) {
+ PrintDebug();
AliFatal("Could not read sample amplitude !");
+ }
fSignal = GetNextWord();
fCount--;
// Now read the beginning of the trailer
// where the payload size is written
- if (trailerSize < 2)
+ if (trailerSize < 2) {
+ PrintDebug();
AliFatal(Form("Invalid trailer size found (%d bytes) !",trailerSize*4));
+ }
fRCUTrailerSize = (trailerSize-2)*4;
index -= fRCUTrailerSize;
- if (index < 4)
+ 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()));
+ }
fRCUTrailerData = fData + index;
Int_t position = Get32bitWord(index);
// The size is specified in a number of 40bits
position *= 5;
// Check the consistency of the header and trailer
- if ((fRawReader->GetDataSize() - trailerSize*4) != position)
+ if ((fRawReader->GetDataSize() - trailerSize*4) != position) {
+ PrintDebug();
AliFatal(Form("Inconsistent raw data size ! Raw data size - %d bytes (from the header), RCU trailer - %d bytes, raw data paylod - %d bytes !",
fRawReader->GetDataSize(),
trailerSize*4,
position));
+ }
return position * 8 / 10;
}
// Therefore we need to transform it to number of bytes
position *= 5;
- // Check the consistency of the header and trailer
- if ((fRawReader->GetDataSize() - 4) != position)
- AliFatal(Form("Inconsistent raw data size ! Expected %d bytes (from the header), found %d bytes (in the RCU trailer)!",
- fRawReader->GetDataSize()-4,
- position));
+ if (!fIsShortDataHeader) {
+ // Check the consistency of the header and trailer
+ if ((fRawReader->GetDataSize() - 4) != position) {
+ PrintDebug();
+ AliFatal(Form("Inconsistent raw data size ! Expected %d bytes (from the header), found %d bytes (in the RCU trailer)!",
+ fRawReader->GetDataSize()-4,
+ position));
+ }
+ }
+ else {
+ // Check the consistency of the header and trailer
+ // In this case the header is shorter by 4 bytes
+ if (fRawReader->GetDataSize() != position) {
+ PrintDebug();
+ AliFatal(Form("Inconsistent raw data size ! Expected %d bytes (from the header), found %d bytes (in the RCU trailer)!",
+ fRawReader->GetDataSize(),
+ position));
+ }
+
+ // 7 32-bit words Common Data Header
+ // therefore we have to shift back by 4 bytes
+ // the pointer to the raw data payload
+ fData -= 4;
+ }
+
// Return the position in units of 10-bit words
return position*8/10;
}
// The 'index' points to the beginning of the next word.
// The method is supposed to be endian (platform)
// independent.
- if (!fData)
+ if (!fData) {
+ PrintDebug();
AliFatal("Raw data paylod buffer is not yet initialized !");
- if (index < 4)
+ }
+
+ if (index < 4) {
+ PrintDebug();
AliFatal(Form("Invalid raw data payload index (%d) !",index));
+ }
UInt_t word = 0;
word = fData[--index] << 24;
return kTRUE;
}
+
+//_____________________________________________________________________________
+void AliAltroRawStream::PrintDebug() const
+{
+ // The method prints all the available
+ // debug information.
+ // Its is used in case of decoding errors.
+
+ AliError("Start of debug printout\n--------------------");
+
+ Dump();
+ if (fRawReader) fRawReader->Dump();
+
+ AliError("End of debug printout\n--------------------");
+}
+
+//_____________________________________________________________________________
+Int_t AliAltroRawStream::GetBranch() const
+{
+ // The method provides the RCU branch index (0 or 1)
+ // for the current hardware address.
+ // In case the hardware address has not been yet
+ // initialized, the method returns -1
+ if (fHWAddress == -1) return -1;
+
+ return ((fHWAddress >> 11) & 0x1);
+}
+
+//_____________________________________________________________________________
+Int_t AliAltroRawStream::GetFEC() const
+{
+ // The method provides the front-end card index
+ // for the current hardware address.
+ // In case the hardware address has not been yet
+ // initialized, the method returns -1
+ if (fHWAddress == -1) return -1;
+
+ return ((fHWAddress >> 7) & 0xF);
+}
+
+//_____________________________________________________________________________
+Int_t AliAltroRawStream::GetAltro() const
+{
+ // The method provides the altro chip index
+ // for the current hardware address.
+ // In case the hardware address has not been yet
+ // initialized, the method returns -1
+ if (fHWAddress == -1) return -1;
+
+ return ((fHWAddress >> 4) & 0x7);
+}
+
+//_____________________________________________________________________________
+Int_t AliAltroRawStream::GetChannel() const
+{
+ // The method provides the channel index
+ // for the current hardware address.
+ // In case the hardware address has not been yet
+ // initialized, the method returns -1
+ if (fHWAddress == -1) return -1;
+
+ return (fHWAddress & 0xF);
+}