#include "AliLog.h"
#include <cassert>
#include <iostream>
-#include <iomanip>
using std::cout;
using std::endl;
using std::hex;
/// \endcond
const Int_t AliMUONRawStreamTriggerHP::fgkMaxDDL = 2;
+bool AliMUONRawStreamTriggerHP::AliLocalStruct::fgOverrideId = true;
+
+const AliMUONRegionalHeaderStruct
+AliMUONRawStreamTriggerHP::AliDecoderEventHandler::fgkEmptyHeader = {
+ AliMUONTriggerDDLDecoder<AliDecoderEventHandler>::RegionalErrorWord(),
+ 0,
+ {0, 0},
+ 0
+};
AliMUONRawStreamTriggerHP::AliMUONRawStreamTriggerHP() :
fDDL(0),
fBufferSize(8192),
fBuffer(new UChar_t[8192]),
- fCurrentLocalStruct(NULL),
+ fkCurrentLocalStruct(NULL),
fHadError(kFALSE),
fDone(kFALSE),
fDDLObject(NULL)
fDDL(0),
fBufferSize(8192),
fBuffer(new UChar_t[8192]),
- fCurrentLocalStruct(NULL),
+ fkCurrentLocalStruct(NULL),
fHadError(kFALSE),
fDone(kFALSE),
fDDLObject(NULL)
fDDLObject = NULL;
}
- fCurrentLocalStruct = NULL;
+ fkCurrentLocalStruct = NULL;
while (fDDL < GetMaxDDL())
{
Swap(reinterpret_cast<UInt_t*>(fBuffer), dataSize / sizeof(UInt_t)); // Swap needed for mac power pc.
#endif
+ // Check if this is a scalar event.
+ bool scalerEvent = (GetReader()->GetDataHeader()->GetL1TriggerMessage() & 0x1) == 0x1;
+
bool result = false;
try
{
// Since we might allocate memory inside OnNewBuffer in the event
// handler we need to trap any memory allocation exception to be robust.
- result = fDecoder.Decode(fBuffer, dataSize);
+ result = fDecoder.Decode(fBuffer, dataSize, scalerEvent);
fHadError = (result == true ? kFALSE : kTRUE);
}
catch (const std::bad_alloc&)
}
// Update the current local structure pointer.
- fCurrentLocalStruct = fDecoder.GetHandler().FirstLocalStruct();
+ fkCurrentLocalStruct = fDecoder.GetHandler().FirstLocalStruct();
fDDL++; // Remember to increment index to next DDL.
return kTRUE;
TArrayS& xPattern, TArrayS& yPattern
)
{
+ /// Advance one step in the iteration. Returns kFALSE if finished.
+ /// If kTRUE is returned then the output parameters are filled with
+ /// the values found in the next local trigger circuit structure.
+
const AliLocalStruct* localStruct = Next();
if (localStruct == NULL) return kFALSE;
}
fDDLObject->AddRegHeader(regHeader);
- const AliLocalStruct* ls = rh->GetFirstLocalStruct();
- while (ls != NULL)
+ const AliLocalStruct* lstruct = rh->GetFirstLocalStruct();
+ while (lstruct != NULL)
{
// Copy local structure and scalars and add everything into DDL object.
- memcpy(localStruct.GetData(), ls->GetData(), sizeof(AliMUONLocalInfoStruct));
- if (ls->GetScalars() != NULL)
+ memcpy(localStruct.GetData(), lstruct->GetData(), sizeof(AliMUONLocalInfoStruct));
+ if (lstruct->GetScalars() != NULL)
{
- memcpy(localStruct.GetScalers(), ls->GetScalars(), sizeof(AliMUONLocalScalarsStruct));
+ memcpy(localStruct.GetScalers(), lstruct->GetScalars(), sizeof(AliMUONLocalScalarsStruct));
+ }
+ if (AliMUONRawStreamTriggerHP::AliLocalStruct::GetOverrideIdFlag() == true)
+ {
+ // Since the override ID flag is set, we need to replace the
+ // ID in the structure with the calculated one returned by GetId().
+ AliMUONLocalInfoStruct* strptr = reinterpret_cast<AliMUONLocalInfoStruct*>( localStruct.GetData() );
+ UInt_t triggerBits = strptr->fTriggerBits;
+ triggerBits &= (0xF << 19);
+ strptr->fTriggerBits = triggerBits | (lstruct->GetId() << 19);
}
fDDLObject->AddLocStruct(localStruct, iReg);
- ls = ls->Next();
+ lstruct = lstruct->Next();
}
}
}
-void AliMUONRawStreamTriggerHP::SetMaxRegAllowed(Int_t reg)
+void AliMUONRawStreamTriggerHP::SetMaxReg(Int_t reg)
{
/// Set the maximum allowed number of regional cards in the DDL.
fRegionals = new AliRegionalHeader[maxRegionals];
fLocals = new AliLocalStruct[maxRegionals*maxLocals];
fEndOfLocals = fLocals;
+
+ fRegionalsCount = maxRegionals;
}
fRegEoWErrors = 0;
fLocalEoWErrors = 0;
- // Reset the current pointers which will be used to track where we need to
- // fill fRegionals and fLocals. We have to subtract one space because we
- // will increment the pointer the first time in the OnNewRegionalStruct
- // and OnLocalStruct methods.
- fCurrentRegional = fRegionals-1;
+ // Reset the current local structure pointer which will be used to track
+ // where we need to fill fLocals. We have to subtract one space because we
+ // will increment the pointer the first time in the OnLocalStruct method.
fCurrentLocal = fLocals-1;
- fRegionalsCount = 0;
+
+ fCurrentRegional = NULL;
+
+ // Reset and link up all the regional structures together.
+ for (UInt_t i = 0; i+1 < fRegionalsCount; i++)
+ {
+ fRegionals[i] = AliRegionalHeader(fLocals, &fgkEmptyHeader, NULL);
+ fRegionals[i].SetNext(&fRegionals[i+1]);
+ }
+ // Reset the last structure.
+ fRegionals[fRegionalsCount-1] = AliRegionalHeader(fLocals, &fgkEmptyHeader, NULL);
}