53 #include "AliRawReader.h"
54 #include "AliRawDataHeaderV3.h"
74 fDetailLevel(kMediumErrorDetail),
75 fEnableMUONErrorLogger(kFALSE),
76 fEnableRawReaderErrorLogger(kFALSE),
81 fBuffer(new UChar_t[8192]),
82 fkCurrentBusPatch(NULL),
88 fTotalNumberOfGlitchErrors(0),
89 fTotalNumberOfParityErrors(0),
90 fTotalNumberOfPaddingErrors(0),
91 fTotalNumberOfTokenLostErrors(0)
99 fDecoder.ExitOnError(
false);
100 fDecoder.SendDataOnParityError(
true);
102 fDecoder.GetHandler().SetMaxStructs(
103 fDecoder.MaxBlocks(),
105 fDecoder.MaxBusPatches()
108 fDecoder.GetHandler().SetRawStream(
this);
114 fRawReader(rawReader),
116 fDetailLevel(kMediumErrorDetail),
117 fEnableMUONErrorLogger(kFALSE),
118 fEnableRawReaderErrorLogger(kFALSE),
123 fBuffer(new UChar_t[8192]),
124 fkCurrentBusPatch(NULL),
130 fTotalNumberOfGlitchErrors(0),
131 fTotalNumberOfParityErrors(0),
132 fTotalNumberOfPaddingErrors(0),
133 fTotalNumberOfTokenLostErrors(0)
142 fDecoder.SendDataOnParityError(
true);
144 fDecoder.GetHandler().SetMaxStructs(
150 fDecoder.GetHandler().SetRawStream(
this);
214 AliDebug(3, Form(
"Skipping DDL %d which does not seem to be there",
fDDL+1));
231 AliDebug(3, Form(
"DDL Number %d\n",
fDDL));
233 Int_t dataSize =
GetReader()->GetDataSize();
246 fBuffer =
new UChar_t[dataSize];
249 catch (
const std::bad_alloc&)
251 AliError(
"Could not allocate more buffer space. Cannot decode DDL.");
262 Swap(reinterpret_cast<UInt_t*>(
fBuffer), dataSize /
sizeof(UInt_t));
275 fHadError = (result ==
true ? kFALSE : kTRUE);
281 catch (
const std::bad_alloc&)
283 AliError(
"Could not allocate more buffer space. Cannot decode DDL.");
317 UChar_t& manuChannel,
319 Bool_t skipParityErrors)
355 if ( skipParityErrors )
396 for (Int_t iBlock = 0; iBlock < (Int_t)
GetBlockCount(); iBlock++)
407 for (Int_t iDsp = 0; iDsp < (Int_t)bh->
GetDspCount(); iDsp++)
438 fDecoder.GetHandler().SetMaxStructs(
451 fDecoder.GetHandler().SetMaxStructs(
462 fDecoder.MaxBusPatches( (UInt_t) bus );
464 fDecoder.GetHandler().SetMaxStructs(
477 cout <<
"CRT info" << endl;
480 cout <<
"Header is NULL" << endl;
498 cout <<
"FRT info" << endl;
501 cout <<
"Header is NULL" << endl;
504 cout <<
"DataKey: 0x" << hex << fHeader->fDataKey << dec << endl;
505 cout <<
"TotalLength: " << fHeader->fTotalLength << endl;
506 cout <<
"Length : " << fHeader->fLength << endl;
507 cout <<
"DspId: " << fHeader->fDSPId << endl;
508 cout <<
"BlkL1ATrigger: " << fHeader->fBlkL1ATrigger << endl;
509 cout <<
"MiniEventId: " << fHeader->fMiniEventId << endl;
510 cout <<
"L1ATrigger: " << fHeader->fL1ATrigger << endl;
511 cout <<
"L1RTrigger: " << fHeader->fL1RTrigger << endl;
512 cout <<
"PaddingWord: " << fHeader->fPaddingWord << endl;
513 cout <<
"ErrorWord: " << fHeader->fErrorWord << endl;
520 cout <<
"Bus patch info" << endl;
523 cout <<
"Header is NULL" << endl;
526 cout <<
"DataKey: 0x" << hex << fHeader->fDataKey << dec << endl;
527 cout <<
"fTotalLength: " << fHeader->fTotalLength << endl;
528 cout <<
"fLength: " << fHeader->fLength << endl;
529 cout <<
"fBusPatchId: " << fHeader->fBusPatchId << endl;
531 if (TString(opt).Contains(
"all"))
533 for (UInt_t i = 0; i < fHeader->fLength; ++i)
534 cout <<
"Data["<< i <<
"] = " << fData[i] << endl;
547 fEndOfBusPatches(NULL),
549 fParityOk(new Bool_t[8192]),
552 fCurrentBusPatch(NULL),
553 fCurrentParityOkFlag(NULL),
571 if (fParityOk != NULL)
delete [] fParityOk;
572 if (fBlocks != NULL)
delete [] fBlocks;
573 if (fDSPs != NULL)
delete [] fDSPs;
574 if (fBusPatches != NULL)
delete [] fBusPatches;
579 UInt_t maxBlocks, UInt_t maxDsps, UInt_t maxBusPatches
595 if (fBusPatches != NULL)
597 delete [] fBusPatches;
600 fCurrentBlock = NULL;
602 fCurrentBusPatch = NULL;
607 fBusPatches =
new AliBusPatch[maxBlocks*maxDsps*maxBusPatches];
608 fEndOfBusPatches = fBusPatches;
610 fMaxBlocks = maxBlocks;
612 fMaxBusPatches = maxBusPatches;
617 const void* buffer, UInt_t bufferSize
626 fBufferStart = buffer;
632 fTokenLostErrors = 0;
638 UInt_t maxChannelsPossible = bufferSize /
sizeof(UInt_t);
639 if (maxChannelsPossible > fMaxChannels)
641 if (fParityOk != NULL)
647 fParityOk =
new Bool_t[maxChannelsPossible];
648 fMaxChannels = maxChannelsPossible;
655 fCurrentBlock = fBlocks-1;
656 fCurrentDSP = fDSPs-1;
657 fCurrentBusPatch = fBusPatches-1;
658 fCurrentParityOkFlag = fParityOk-1;
675 word = (RawWord*) buffer;
677 for (Int_t i = 0; i < size; i++)
679 temp = *(((RawWord*)buffer)+i);
701 assert(fRawStream != NULL);
703 const char* message = NULL;
705 bool logAsMajorError =
true;
708 const char* detail =
"";
711 bool blockPtrOk = fBlockCount > 0;
712 bool dspPtrOk = blockPtrOk ? fCurrentBlock->GetDspCount() > 0 :
false;
713 bool buspatchPtrOk = dspPtrOk ? fCurrentDSP->GetBusPatchCount() > 0 :
false;
717 "At byte %lu in DDL %d, event %d, iBlock %d, iDsp %d [DSP ID: %d (0x%X)],"
718 " iBus %d [bus patch ID: %d (0x%X)].",
719 (
unsigned long)location - (
unsigned long)fBufferStart +
sizeof(AliRawDataHeaderV3),
720 AliDAQ::DdlID(
"MUONTRK", fRawStream->GetDDL()),
721 fRawStream->GetReader()->GetEventIndex(),
723 blockPtrOk ? int(fCurrentBlock->GetDspCount())-1 : -1,
724 blockPtrOk ? fCurrentBlock->GetDspId() : -1,
725 blockPtrOk ? fCurrentBlock->GetDspId() : -1,
726 dspPtrOk ? int(fCurrentDSP->GetBusPatchCount())-1 : -1,
727 buspatchPtrOk ? fCurrentBusPatch->GetBusPatchId() : -1,
728 buspatchPtrOk ? fCurrentBusPatch->GetBusPatchId() : -1
737 switch (fRawStream->GetLoggingDetailLevel())
740 message =
"Glitch error detected.";
744 "Glitch error detected in DSP %d (0x%X), skipping event.",
745 fCurrentBlock->GetDspId(), fCurrentBlock->GetDspId()
750 message = Form(
"%s %s", ErrorCodeToMessage(error), detail);
753 logAsMajorError =
true;
756 case kBadPaddingWord:
758 switch (fRawStream->GetLoggingDetailLevel())
761 message =
"Padding word error detected.";
767 "Padding word error for iBlock %d, iDsp %d, iBus %d.",
769 fCurrentBlock->GetDspCount()-1,
770 fCurrentDSP->GetBusPatchCount()-1
775 message = Form(
"%s %s", ErrorCodeToMessage(error), detail);
778 logAsMajorError =
false;
783 switch (fRawStream->GetLoggingDetailLevel())
786 message =
"Parity error detected.";
790 "Parity error in buspatch %d (0x%X).",
791 fCurrentBusPatch->GetBusPatchId(),
792 fCurrentBusPatch->GetBusPatchId()
801 word = (
reinterpret_cast<size_t>(location) - reinterpret_cast<size_t>(fCurrentBusPatch->GetData()))
804 "Parity error in word %d for manuId %d and channel %d in buspatch %d. %s",
806 fCurrentBusPatch->GetManuId(word),
807 fCurrentBusPatch->GetChannelId(word),
808 fCurrentBusPatch->GetBusPatchId(),
813 logAsMajorError =
false;
818 switch (fRawStream->GetLoggingDetailLevel())
821 message =
"Lost token error detected.";
824 word = *
reinterpret_cast<const UInt_t*
>(location);
826 "Lost token error detected with address 0x%X of DDL %d and code %d.",
827 ((word & 0xFFFF0000)),
828 fRawStream->GetDDL(),
834 word = *
reinterpret_cast<const UInt_t*
>(location);
836 "Lost token error detected with address 0x%X and code %d. %s",
837 ((word & 0xFFFF0000)),
843 logAsMajorError =
false;
847 switch (fRawStream->GetLoggingDetailLevel())
850 message = ErrorCodeToMessage(error);
855 ErrorCodeToMessage(error),
856 (
unsigned long)location - (
unsigned long)fBufferStart +
sizeof(AliRawDataHeaderV3)
862 "%s Error code: %d (%s). %s",
863 ErrorCodeToMessage(error),
864 error, ErrorCodeToString(error),
869 logAsMajorError =
true;
874 if (fRawStream->IsRawReaderErrorLoggerEnabled())
877 fRawStream->GetReader()->AddMajorErrorLog(Int_t(error), message);
879 fRawStream->GetReader()->AddMinorErrorLog(Int_t(error), message);
881 if (fRawStream->IsMUONErrorLoggerEnabled())
886 logger->
Log(message);
891 "AliMUONRawStreamTrackerHP::AliDecoderEventHandler",
892 "Enabled logging to AliMUONLogger, but the logger object"
893 " was not set with SetMUONErrorLogger()."
897 if (fRawStream->IsWarningsEnabled())
900 "AliMUONRawStreamTrackerHP::AliDecoderEventHandler",
A high performance stream decoder for muon tracking DDL streams.
const AliMUONBusPatchHeaderStruct * GetHeader() const
Return raw data of header.
Int_t * GetHeader()
Return header.
const AliBusPatch * Next()
Returns the next batch of decoded channel data.
virtual AliMUONDDLTracker * GetDDLTracker() const
Construct and return a pointer to the DDL payload object.
void Print(const Option_t *opt="") const
Print the contents of the bus patch to screen.
UChar_t * fBuffer
! This is the buffer in which we store the DDL payload read from AliRawReader.
Logs a medium level of detail in the error messages.
const UInt_t * fkCurrentData
! The current data word to return by Next().
AliMUONDDLTracker * fDDLObject
! Temporary DDL object used by GetDDLTracker() for caching.
virtual void SetMaxBus(Int_t bus)
Set maximum number of Buspatch per Dsp allowed.
UInt_t GetDataCount() const
Returns the number of raw data words within this bus patch.
Int_t Log(const char *message)
void SetDspId(Int_t d)
Set Dsp number for monitoring.
Int_t GetLength() const
Return length of raw data.
UInt_t * GetData() const
Return data.
UInt_t fTotalNumberOfGlitchErrors
! number of glitch errors since First() was called
virtual ~AliMUONRawStreamTrackerHP()
Default destructor.
void AddBusPatch(const AliMUONBusStruct &busPatch, Int_t iBlock, Int_t iDsp)
void SetMaxStructs(UInt_t maxBlocks, UInt_t maxDsps, UInt_t maxBusPatches)
Sets the internal arrays based on the maximum number of structures allowed.
AliMUONRawStreamTrackerHP()
Default constructor.
Bool_t IsParityOk(UInt_t n) const
A logger that keeps track of the number of times a message appeared.
static void UnpackADC(UInt_t data, UShort_t &manuId, UChar_t &channelId, UShort_t &adc)
Implementation of a high performance DDL decoder for the muon tracking stations.
Int_t GetBusPatchId() const
Return bus patch id.
Int_t fBufferSize
! This is the buffer size in bytes of fBuffer.
virtual Bool_t IsDone() const
Whether the iteration is finished or not.
const UInt_t * GetData() const
Return raw digit data.
void OnNewBuffer(const void *buffer, UInt_t bufferSize)
New buffer handler.
UInt_t fTotalNumberOfTokenLostErrors
! number of token lost errors since First() was called
AliDecoderEventHandler()
Default constructor.
Bool_t fDone
! Flag indicating if the iteration is done or not.
Logs minimal information in the error messages.
UInt_t fTotalNumberOfPaddingErrors
! number of padding errors since First() was called
void AddBlkHeader(const AliMUONBlockHeader &blkHeader)
virtual void SetMaxDsp(Int_t dsp)
Set maximum number of Dsp per block allowed.
virtual void Swap(UInt_t *buffer, Int_t size) const
swap method for Power PC
Int_t GetMaxDDL() const
Return max number of tracker DDLs.
void SetAlloc(Int_t size)
virtual void First()
Initialize iterator.
AliMUONTrackerDDLDecoder< AliDecoderEventHandler > fDecoder
! The decoder for the DDL payload.
Light weight interface class to the bus patch data.
const UInt_t * fkEndOfData
! The last data word in the current bus patch.
void OnError(ErrorCode error, const void *location)
Error handler.
Int_t fDDL
! The current DDL number being handled.
Bool_t fHadError
! Flag indicating if there was a decoding error or not.
virtual AliRawReader * GetReader()
Get object for reading the raw data.
void AddDspHeader(const AliMUONDspHeader &dspHeader, Int_t iBlock)
virtual ~AliDecoderEventHandler()
Default destructor.
UInt_t GetBlockCount() const
Return the number of blocks in the DDL payload.
Declaration of the high performance decoder for muon trigger chamber raw streams. ...
virtual void SetMaxBlock(Int_t blk)
Set maximum number of blocks per DDL allowed.
const AliBusPatch * Next() const
Return the next bus patch header.
MUON buspatch structure for tracker.
const AliBusPatch * fkCurrentBusPatch
! The current bus patch being handled by Next().
virtual Bool_t NextDDL()
DDL iterator.
const AliBlockHeader * GetBlockHeader(UInt_t i) const
Return the i'th block header or NULL if not found.
UInt_t fTotalNumberOfParityErrors
! number of parity errors since First() was called
void SetBlockId(Int_t b)
Set block numer for monitoring.
ErrorCode
All the possible error codes for the parsing.