//-----------------------------------------------------------------------------
#include "AliMUONRawStreamTrackerHP.h"
+#include "AliMUONTrackerDDLDecoder.h"
#include "AliMUONDspHeader.h"
#include "AliMUONBlockHeader.h"
#include "AliMUONBusStruct.h"
#include "AliLog.h"
#include <cassert>
#include <iostream>
-#include <iomanip>
using std::cout;
using std::endl;
using std::hex;
ClassImp(AliMUONRawStreamTrackerHP)
/// \endcond
+const Int_t AliMUONRawStreamTrackerHP::fgkMaxDDL = 20;
AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP() :
- AliMUONVRawStreamTracker(),
+ TObject(),
+ fEnableErrorLogger(kFALSE),
fDecoder(),
fDDL(0),
fBufferSize(8192),
fBuffer(new UChar_t[8192]),
- fCurrentBusPatch(NULL),
- fCurrentData(NULL),
- fEndOfData(NULL),
+ fkCurrentBusPatch(NULL),
+ fkCurrentData(NULL),
+ fkEndOfData(NULL),
fHadError(kFALSE),
fDone(kFALSE),
- fDDLObject(NULL)
+ fDDLObject(NULL),
+ fTotalNumberOfGlitchErrors(0),
+ fTotalNumberOfParityErrors(0),
+ fTotalNumberOfPaddingErrors(0),
+ fTotalNumberOfTokenLostErrors(0)
{
///
/// Default constructor.
fDecoder.MaxDSPs(),
fDecoder.MaxBusPatches()
);
-
- fDecoder.GetHandler().SetRawStream(this);
}
AliMUONRawStreamTrackerHP::AliMUONRawStreamTrackerHP(AliRawReader* rawReader) :
- AliMUONVRawStreamTracker(rawReader),
+ TObject(),
+ fEnableErrorLogger(kFALSE),
fDecoder(),
fDDL(0),
fBufferSize(8192),
fBuffer(new UChar_t[8192]),
- fCurrentBusPatch(NULL),
- fCurrentData(NULL),
- fEndOfData(NULL),
+ fkCurrentBusPatch(NULL),
+ fkCurrentData(NULL),
+ fkEndOfData(NULL),
fHadError(kFALSE),
fDone(kFALSE),
- fDDLObject(NULL)
+ fDDLObject(NULL),
+ fTotalNumberOfGlitchErrors(0),
+ fTotalNumberOfParityErrors(0),
+ fTotalNumberOfPaddingErrors(0),
+ fTotalNumberOfTokenLostErrors(0)
{
///
/// Constructor with AliRawReader as argument.
fDecoder.MaxBusPatches()
);
- fDecoder.GetHandler().SetRawStream(this);
+ fDecoder.GetHandler().SetReader(rawReader);
}
fDDL = 0;
fDone = kFALSE;
NextDDL();
+ fTotalNumberOfGlitchErrors = 0;
+ fTotalNumberOfPaddingErrors = 0;
+ fTotalNumberOfParityErrors = 0;
+ fTotalNumberOfTokenLostErrors = 0;
}
}
// Better to reset these pointers.
- fCurrentBusPatch = NULL;
- fCurrentData = NULL;
- fEndOfData = NULL;
+ fkCurrentBusPatch = NULL;
+ fkCurrentData = NULL;
+ fkEndOfData = NULL;
while (fDDL < GetMaxDDL())
{
// handler we need to trap any memory allocation exception to be robust.
result = fDecoder.Decode(fBuffer, dataSize);
fHadError = (result == true ? kFALSE : kTRUE);
+ fTotalNumberOfGlitchErrors += fDecoder.GetHandler().GlitchErrorCount();
+ fTotalNumberOfParityErrors += fDecoder.GetHandler().ParityErrorCount();
+ fTotalNumberOfPaddingErrors += fDecoder.GetHandler().PaddingErrorCount();
+ fTotalNumberOfTokenLostErrors += fDecoder.GetHandler().TokenLostCount();
}
catch (const std::bad_alloc&)
{
}
// Update the current bus patch pointers.
- fCurrentBusPatch = fDecoder.GetHandler().FirstBusPatch();
- if (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
+ fkCurrentBusPatch = fDecoder.GetHandler().FirstBusPatch();
+ if (fkCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
{
- fCurrentData = fCurrentBusPatch->GetData();
- fEndOfData = fCurrentData + fCurrentBusPatch->GetDataCount();
+ fkCurrentData = fkCurrentBusPatch->GetData();
+ fkEndOfData = fkCurrentData + fkCurrentBusPatch->GetDataCount();
}
else
{
// If the DDL did not have any bus patches then mark both fCurrentData
// and fEndOfData as NULL so that in Next() we are forced to find the
// first non empty DDL.
- fCurrentData = fEndOfData = NULL;
+ fkCurrentData = fkEndOfData = NULL;
}
fDDL++; // Remember to increment index to next DDL.
}
-Bool_t AliMUONRawStreamTrackerHP::Next(
- Int_t& busPatchId, UShort_t& manuId, UChar_t& manuChannel,
- UShort_t& adc
- )
+Bool_t AliMUONRawStreamTrackerHP::Next(Int_t& busPatchId,
+ UShort_t& manuId,
+ UChar_t& manuChannel,
+ UShort_t& adc,
+ Bool_t skipParityErrors)
{
/// Advance one step in the iteration. Returns false if finished.
/// [out] \param busPatchId This is filled with the bus patch ID of the digit.
/// [out] \param manuId This is filled with the MANU ID of the digit.
/// [out] \param manuChannel This is filled with the MANU channel ID of the digit.
/// [out] \param adc This is filled with the ADC signal value of the digit.
+ /// [in] \param skipParityErrors If this is kTRUE, we'll skip the buspatches that
+ /// have some parity errors
/// \return kTRUE if we read another digit and kFALSE if we have read all the
/// digits already, i.e. at the end of the iteration.
- if (fCurrentData == NULL) return kFALSE;
+ if (fkCurrentData == NULL) return kFALSE;
retry:
// Check if we still have data to be returned for the current bus patch.
- if (fCurrentData != fEndOfData)
+ if (fkCurrentData != fkEndOfData)
{
- busPatchId = fCurrentBusPatch->GetBusPatchId();
- AliMUONTrackerDDLDecoderEventHandler::UnpackADC(*fCurrentData, manuId, manuChannel, adc);
- fCurrentData++;
+ busPatchId = fkCurrentBusPatch->GetBusPatchId();
+ AliMUONTrackerDDLDecoderEventHandler::UnpackADC(*fkCurrentData, manuId, manuChannel, adc);
+ fkCurrentData++;
return kTRUE;
}
else
// bus patches to process for the current DDL. If we do, then increment
// the current bus patch, make sure it is not the last one and then try
// reading the first element again.
- if (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
+ if (fkCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
{
- fCurrentBusPatch++;
- if (fCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
+ fkCurrentBusPatch++;
+ if (fkCurrentBusPatch != fDecoder.GetHandler().EndOfBusPatch())
{
- fCurrentData = fCurrentBusPatch->GetData();
- fEndOfData = fCurrentData + fCurrentBusPatch->GetDataCount();
+ fkCurrentData = fkCurrentBusPatch->GetData();
+ fkEndOfData = fkCurrentData + fkCurrentBusPatch->GetDataCount();
+ if ( skipParityErrors )
+ {
+ Bool_t ok(kTRUE);
+ for ( Int_t i = 0; i < fkCurrentBusPatch->GetLength() && ok; ++ i )
+ {
+ ok = fkCurrentBusPatch->IsParityOk(i);
+ }
+ if (!ok) fkCurrentData = fkEndOfData;
+ }
goto retry;
}
}
);
}
+AliRawReader* AliMUONRawStreamTrackerHP::GetReader()
+{
+ return fDecoder.GetHandler().GetReader();
+}
+
+void AliMUONRawStreamTrackerHP::SetReader(AliRawReader* reader)
+{
+ fDecoder.GetHandler().SetReader(reader);
+}
+
///////////////////////////////////////////////////////////////////////////////
void AliMUONRawStreamTrackerHP::AliBlockHeader::Print() const
///////////////////////////////////////////////////////////////////////////////
AliMUONRawStreamTrackerHP::AliDecoderEventHandler::AliDecoderEventHandler() :
- fRawStream(NULL),
+ fRawReader(0x0),
fBufferStart(NULL),
fBlockCount(0),
fBlocks(NULL),
fParityErrors(0),
fGlitchErrors(0),
fPaddingErrors(0),
- fWarnings(kTRUE)
+ fTokenLostErrors(0),
+ fWarnings(kTRUE),
+ fMaxBlocks(),
+ fMaxDsps(),
+ fMaxBusPatches()
{
/// Default constructor initialises the internal parity flags buffer to
/// store 8192 elements. This array will grow dynamically if needed.
fDSPs = new AliDspHeader[maxBlocks*maxDsps];
fBusPatches = new AliBusPatch[maxBlocks*maxDsps*maxBusPatches];
fEndOfBusPatches = fBusPatches;
+
+ fMaxBlocks = maxBlocks;
+ fMaxDsps = maxDsps;
+ fMaxBusPatches = maxBusPatches;
}
/// \param buffer The pointer to the buffer storing the DDL payload.
/// \param bufferSize The size of the buffer in bytes.
- assert( fRawStream != NULL );
-
// remember the start of the buffer to be used in OnError.
fBufferStart = buffer;
fParityErrors = 0;
fGlitchErrors = 0;
fPaddingErrors = 0;
+ fTokenLostErrors = 0;
// Check if we will have enough space in the fParityOk array.
// If we do not then we need to resize the array.
/// \param location A pointer to the location within the DDL payload buffer
/// being decoded where the problem with the data was found.
- assert( fRawStream != NULL );
- assert( fRawStream->GetReader() != NULL );
+ assert( fRawReader != NULL );
Char_t* message = NULL;
UInt_t word = 0;
case kGlitchFound:
fGlitchErrors++;
message = Form(
- "Glitch error detected in DSP %d, skipping event ",
- fCurrentBlock->GetDspId()
+ "Glitch error detected in DSP %d (0x%X), skipping event ",
+ fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId()
);
- fRawStream->GetReader()->AddMajorErrorLog(error, message);
+ fRawReader->AddMajorErrorLog(error, message);
break;
case kBadPaddingWord:
fCurrentBlock->GetDspCount()-1,
fCurrentDSP->GetBusPatchCount()-1
);
- fRawStream->GetReader()->AddMinorErrorLog(error, message);
+ fRawReader->AddMinorErrorLog(error, message);
break;
case kParityError:
fCurrentBusPatch->GetChannelId(word),
fCurrentBusPatch->GetBusPatchId()
);
- fRawStream->GetReader()->AddMinorErrorLog(error, message);
+ fRawReader->AddMinorErrorLog(error, message);
+ break;
+
+ case kTokenLost:
+ fTokenLostErrors++;
+ word = *reinterpret_cast<const UInt_t*>(location);
+ message = Form(
+ "Lost token error detected in DSP %d (0x%X) with address 0x%X and code %d.",
+ fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId(),
+ ((word & 0xFFFF0000) >> 16),
+ (word & 0xF)
+ );
+ fRawReader->AddMinorErrorLog(error, message);
break;
default:
ErrorCodeToMessage(error),
(unsigned long)location - (unsigned long)fBufferStart + sizeof(AliRawDataHeader)
);
- fRawStream->GetReader()->AddMajorErrorLog(error, message);
+ fRawReader->AddMajorErrorLog(error, message);
break;
}