46 #include "AliRawReader.h"
76 fBuffer(new UChar_t[8192]),
77 fkCurrentLocalStruct(NULL),
81 fTotalNumberOfDarcEoWErrors(0),
82 fTotalNumberOfGlobalEoWErrors(0),
83 fTotalNumberOfRegEoWErrors(0),
84 fTotalNumberOfLocalEoWErrors(0)
97 fDecoder.GetHandler().SetRawStream(
this);
106 fBuffer(new UChar_t[8192]),
107 fkCurrentLocalStruct(NULL),
111 fTotalNumberOfDarcEoWErrors(0),
112 fTotalNumberOfGlobalEoWErrors(0),
113 fTotalNumberOfRegEoWErrors(0),
114 fTotalNumberOfLocalEoWErrors(0)
122 fDecoder.GetHandler().SetMaxStructs(
127 fDecoder.GetHandler().SetRawStream(
this);
189 AliDebug(3, Form(
"Skipping DDL %d which does not seem to be there",
fDDL+1));
206 AliDebug(3, Form(
"DDL Number %d\n",
fDDL));
208 Int_t dataSize =
GetReader()->GetDataSize();
221 fBuffer =
new UChar_t[dataSize];
224 catch (
const std::bad_alloc&)
226 AliError(
"Could not allocate more buffer space. Cannot decode DDL.");
237 Swap(reinterpret_cast<UInt_t*>(
fBuffer), dataSize /
sizeof(UInt_t));
246 if (!reader)
return kFALSE;
248 const AliRawDataHeader * cdh = reader->GetDataHeader();
249 const AliRawDataHeaderV3 * cdh3 = reader->GetDataHeaderV3();
251 if (!cdh && !cdh3)
return kFALSE;
253 bool scalerEvent = ((cdh ? cdh->GetL1TriggerMessage() : cdh3->GetL1TriggerMessage()) & 0x1) == 0x1;
261 fHadError = (result ==
true ? kFALSE : kTRUE);
267 catch (
const std::bad_alloc&)
269 AliError(
"Could not allocate more buffer space. Cannot decode DDL.");
290 UChar_t&
id, UChar_t& dec, Bool_t& trigY,
291 UChar_t& yPos, UChar_t& sXDev, UChar_t& xDev,
292 UChar_t& xPos, Bool_t& triggerY, Bool_t& triggerX,
293 TArrayS& xPattern, TArrayS& yPattern
301 if (localStruct == NULL)
return kFALSE;
303 id = localStruct->
GetId();
304 dec = localStruct->
GetDec();
345 memcpy(darcHeader->
GetHeader(), &word,
sizeof(word));
371 while (lstruct != NULL)
385 triggerBits &= ~(0xF << 19);
389 lstruct = lstruct->
Next();
401 fDecoder.MaxRegionals( (UInt_t) reg );
403 fDecoder.GetHandler().SetMaxStructs(
416 fDecoder.GetHandler().SetMaxStructs(
428 cout <<
"===== DARC info =====" << endl;
429 cout <<
"Header bits : 0x" << hex <<
fDarcHeader << dec << endl;
451 cout <<
"Scalars == NULL" << endl;
454 cout <<
"===== Global info =====" << endl;
455 for (
int i = 0; i < 4; i++)
468 for (
int j = 0; j < 4; j++)
480 cout <<
"Scalars == NULL" << endl;
488 cout <<
"===== Regional card info =====" << endl;
489 cout <<
"DarcWord : " << fHeader->fDarcWord <<
" (0x"
490 << hex << fHeader->fDarcWord << dec <<
")" << endl;
491 cout <<
"Word : " << fHeader->fWord <<
" (0x"
492 << hex << fHeader->fWord << dec <<
")" << endl;
493 cout <<
"Input[0] : " << fHeader->fInput[0] <<
" (0x"
494 << hex << fHeader->fInput[0] << dec <<
")" << endl;
495 cout <<
"Input[1] : " << fHeader->fInput[1] <<
" (0x"
496 << hex << fHeader->fInput[1] << dec <<
")" << endl;
497 cout <<
"L0/Mask : " << fHeader->fL0CountAndMask <<
" (0x"
498 << hex << fHeader->fL0CountAndMask << dec <<
")" << endl;
499 if (fScalars != NULL)
501 cout <<
"Clock : " << fScalars->fClk <<
" (0x"
502 << hex << fScalars->fClk << dec <<
")" << endl;
503 for (
int i = 0; i < 8; i++)
505 cout <<
"Scaler[" << i <<
"] : " << fScalars->fScaler[i] <<
" (0x"
506 << hex << fScalars->fScaler[i] << dec <<
")" << endl;
508 cout <<
"Hold : " << fScalars->fHold <<
" (0x"
509 << hex << fScalars->fHold << dec <<
")" << endl;
513 cout <<
"Scalars == NULL" << endl;
521 cout <<
"===== Local card info =====" << endl;
522 cout <<
"X2X1 : " << fLocalStruct->fX2X1 <<
" (0x"
523 << hex << fLocalStruct->fX2X1 << dec <<
")" << endl;
524 cout <<
"X4X3 : " << fLocalStruct->fX4X3 <<
" (0x"
525 << hex << fLocalStruct->fX4X3 << dec <<
")" << endl;
526 cout <<
"Y2Y1 : " << fLocalStruct->fY2Y1 <<
" (0x"
527 << hex << fLocalStruct->fY2Y1 << dec <<
")" << endl;
528 cout <<
"Y4Y3 : " << fLocalStruct->fY4Y3 <<
" (0x"
529 << hex << fLocalStruct->fY4Y3 << dec <<
")" << endl;
530 cout <<
"Trigger bits : " << fLocalStruct->fTriggerBits <<
" (0x"
531 << hex << fLocalStruct->fTriggerBits << dec <<
")" << endl;
532 if (fScalars != NULL)
534 cout <<
"L0 : " << fScalars->fL0 <<
" (0x"
535 << hex << fScalars->fL0 << dec <<
")" << endl;
536 cout <<
"Hold : " << fScalars->fHold <<
" (0x"
537 << hex << fScalars->fHold << dec <<
")" << endl;
538 cout <<
"Clock : " << fScalars->fClk <<
" (0x"
539 << hex << fScalars->fClk << dec <<
")" << endl;
540 cout <<
"LPtNTrig : " << fScalars->fLPtNTrig <<
" (0x"
541 << hex << fScalars->fLPtNTrig << dec <<
")" << endl;
542 cout <<
"HPtNTrig : " << fScalars->fHPtNTrig <<
" (0x"
543 << hex << fScalars->fHPtNTrig << dec <<
")" << endl;
544 cout <<
"LPtRTrig : " << fScalars->fLPtRTrig <<
" (0x"
545 << hex << fScalars->fLPtRTrig << dec <<
")" << endl;
546 cout <<
"HPtRTrig : " << fScalars->fHPtRTrig <<
" (0x"
547 << hex << fScalars->fHPtRTrig << dec <<
")" << endl;
548 cout <<
"LPtLTrig : " << fScalars->fLPtLTrig <<
" (0x"
549 << hex << fScalars->fLPtLTrig << dec <<
")" << endl;
550 cout <<
"HPtLTrig : " << fScalars->fHPtLTrig <<
" (0x"
551 << hex << fScalars->fHPtLTrig << dec <<
")" << endl;
552 cout <<
"LPtSTrig : " << fScalars->fLPtSTrig <<
" (0x"
553 << hex << fScalars->fLPtSTrig << dec <<
")" << endl;
554 cout <<
"HPtSTrig : " << fScalars->fHPtSTrig <<
" (0x"
555 << hex << fScalars->fHPtSTrig << dec <<
")" << endl;
556 for (
int i = 0; i < 8*4; i++)
558 cout <<
"Scaler[" << i <<
"] : " << fScalars->fScaler[i] <<
" (0x"
559 << hex << fScalars->fScaler[i] << dec <<
")" << endl;
561 cout <<
"EOS : " << fScalars->fEOS <<
" (0x"
562 << hex << fScalars->fEOS << dec <<
")" << endl;
563 cout <<
"Reset : " << fScalars->fReset <<
" (0x"
564 << hex << fScalars->fReset << dec <<
")" << endl;
568 cout <<
"Scalars == NULL" << endl;
584 fCurrentRegional(NULL),
600 if (fRegionals != NULL)
delete [] fRegionals;
601 if (fLocals != NULL)
delete [] fLocals;
606 UInt_t maxRegionals, UInt_t maxLocals
612 if (fRegionals != NULL)
614 delete [] fRegionals;
623 fCurrentRegional = NULL;
624 fCurrentLocal = NULL;
629 fEndOfLocals = fLocals;
631 fRegionalsCount = maxRegionals;
636 const void* buffer, UInt_t
642 assert( fRawStream != NULL );
645 fBufferStart = buffer;
649 fGlobalEoWErrors = 0;
656 fCurrentLocal = fLocals-1;
658 fCurrentRegional = NULL;
661 for (UInt_t i = 0; i+1 < fRegionalsCount; i++)
664 fRegionals[i].SetNext(&fRegionals[i+1]);
667 fRegionals[fRegionalsCount-1] =
AliRegionalHeader(fLocals, &fgkEmptyHeader, NULL);
683 assert( fRawStream != NULL );
684 assert( fRawStream->GetReader() != NULL );
686 Char_t* message = NULL;
691 case kWrongEventType:
692 message = Form(
"Wrong event type obtained from the Darc header, take the one of CDH");
698 "Wrong end of Darc word %x instead of %x\n",
699 *reinterpret_cast<const UInt_t*>(location),
702 fRawStream->GetReader()->AddMajorErrorLog(
kDarcEoWErr, message);
705 case kBadEndOfGlobal:
708 "Wrong end of Global word %x instead of %x\n",
709 *reinterpret_cast<const UInt_t*>(location),
712 fRawStream->GetReader()->AddMajorErrorLog(
kGlobalEoWErr, message);
715 case kBadEndOfRegional:
718 "Wrong end of Regional word %x instead of %x\n",
719 *reinterpret_cast<const UInt_t*>(location),
722 fRawStream->GetReader()->AddMajorErrorLog(
kRegEoWErr, message);
728 "Wrong end of Local word %x instead of %x\n",
729 *reinterpret_cast<const UInt_t*>(location),
732 fRawStream->GetReader()->AddMajorErrorLog(
kLocalEoWErr, message);
737 "%s (At byte %lu in DDL.)",
738 ErrorCodeToMessage(error),
739 (
unsigned long)location - (
unsigned long)fBufferStart +
sizeof(AliRawDataHeaderV3)
741 fRawStream->GetReader()->AddMajorErrorLog(error, message);
748 "AliMUONRawStreamTriggerHP::AliDecoderEventHandler",
UInt_t fScaler[6]
Global card ouput scalars.
void GetXPattern(TArrayS &array) const
return X pattern array
UChar_t GetYPos() const
Return Upos.
const AliHeader * GetHeaders() const
Returns the DARC and global headers plus scalars if they exist.
Light weight interface class to the local trigger card data.
The optional DARC board scalars.
void OnNewBuffer(const void *buffer, UInt_t bufferSize)
New buffer handler.
static UInt_t RegionalErrorWord()
Returns the regional error word.
Int_t fBufferSize
! This is the buffer size in bytes of fBuffer.
Rawdata local card structure for trigger.
UInt_t fL2R
DARC L2 reject.
const AliLocalStruct * Next()
Returns the next local trigger structure.
Optional regional card scalars.
virtual void Swap(UInt_t *buffer, Int_t size) const
swap method for Power PC
UChar_t GetId() const
Return Id.
ErrorCode
All the possible error codes from the parsing.
end of Regional word error
A high performance decoder class for MUON trigger DDL data.
virtual Bool_t NextDDL()
DDL iterator.
const AliRegionalHeader * GetRegionalHeader(UInt_t i) const
Return the i'th regional header or NULL if not found.
Higher performance decoder stream class for reading MUON raw trigger data.
virtual void SetMaxReg(Int_t reg)
Set the maximum number of regional cards in the DDL.
Local card trigger information.
UInt_t fSpare
Global spare word.
Local card trigger scalars.
UInt_t fL0R
DARC L0 received and used.
UInt_t GetData(Int_t n) const
Return local data.
void OnError(ErrorCode error, const void *location)
Error handler.
UInt_t fClk
Global number of clock cycles.
AliMUONDarcHeader * GetDarcHeader() const
get AliMUONDarcHeader
Base class for reading MUON raw trigger data.
UInt_t fHold
Global number of hold (dead time)
Bool_t fHadError
! Flag indicating if there was a decoding error or not.
UInt_t fL0
Global number of L0 triggers.
static bool GetOverrideIdFlag()
Returns the override flag indicating if the GetId method should return the calculated Id value or not...
UInt_t fL1S
DARC L1 software.
void SetMaxStructs(UInt_t maxRegionals, UInt_t maxLocals)
Sets the internal arrays based on the maximum number of structures allowed.
UChar_t GetXDev() const
Get X deviation.
The optional global card scalars.
virtual ~AliMUONRawStreamTriggerHP()
UInt_t fL2A
DARC L2 accept.
Bool_t GetSXDev() const
Get Sign of X deviation.
virtual void SetMaxLoc(Int_t loc)
Sets the maximum number of local cards in the DDL.
UInt_t fTotalNumberOfLocalEoWErrors
! The total number of end of local word errors since the last call to First().
AliMUONTriggerDDLDecoder< AliDecoderEventHandler > fDecoder
! The decoder for the DDL payload.
Bool_t fDone
! Flag indicating if the iteration is done or not.
void Print() const
Print the contents of the local trigger structure and contents to screen.
AliMUONRawStreamTriggerHP()
void GetYPattern(TArrayS &array) const
return Y pattern array
virtual ~AliDecoderEventHandler()
Default destructor.
UChar_t GetXPos() const
Return Xpos.
UInt_t fTotalNumberOfDarcEoWErrors
! The total number of end of DARC word errors since the last call to First().
virtual Int_t GetMaxDDL() const
Return maximum number of DDLs.
const AliLocalStruct * fkCurrentLocalStruct
! The current local trigger structure being handled by Next().
Bool_t GetTriggerY() const
Return TriggerY.
UChar_t * fBuffer
! This is the buffer in which we store the DDL payload read from AliRawReader.
const AliMUONLocalScalarsStruct * GetScalars() const
virtual Bool_t IsDone() const
Whether the iteration is finished or not.
UInt_t GetRegionalHeaderCount() const
Return the number of regional structures in the DDL payload.
void AddRegHeader(const AliMUONRegHeader ®Header)
UInt_t * GetScalers()
Return scalers.
AliMUONDDLTrigger * fDDLObject
! Temporary DDL object used by GetDDLTrigger() for caching.
Bool_t GetTrigY() const
Return TrigY.
AliDecoderEventHandler()
Default constructor.
UInt_t fL1P
DARC L1 physics.
const AliLocalStruct * Next() const
Return the next local trigger structure.
Int_t fDDL
! The current DDL number being handled.
UChar_t GetDec() const
Return Dec.
virtual AliMUONDDLTrigger * GetDDLTrigger() const
Construct and return a pointer to the DDL payload object.
UInt_t fSpare
DARC Empty slot (for the moment)
Bool_t GetTriggerX() const
Return TriggerX.
UInt_t GetData(Int_t n) const
Return local data.
UInt_t fTotalNumberOfRegEoWErrors
! The total number of end of regional word errors since the last call to First(). ...
virtual void First()
Initialize iterator.
UInt_t fTotalNumberOfGlobalEoWErrors
! The total number of end of global word errors since the last call to First().
virtual AliRawReader * GetReader()
Get object for reading the raw data.
void AddLocStruct(const AliMUONLocalStruct &loc, Int_t iReg)
UInt_t fHold
DARC hold (dead time)
UInt_t fTriggerBits
Trigger bits and deviation.