#include <Riostream.h>
#include "AliRawReader.h"
#include "AliDAQ.h"
+#include "AliLog.h"
ClassImp(AliRawReader)
fSelectMaxEquipmentId(-1),
fSkipInvalid(kFALSE),
fSelectEventType(-1),
- fErrorCode(0)
+ fErrorCode(0),
+ fEventNumber(-1),
+ fErrorLogs("AliRawDataErrorLog",100),
+ fHeaderSwapped(NULL)
{
// default constructor: initialize data members
+// Allocate the swapped header in case of Mac
+#ifndef R__BYTESWAP
+ fHeaderSwapped=new AliRawDataHeader();
+#endif
}
Bool_t AliRawReader::LoadEquipmentIdsMap(const char *fileName)
fSelectMaxEquipmentId(rawReader.fSelectMaxEquipmentId),
fSkipInvalid(rawReader.fSkipInvalid),
fSelectEventType(rawReader.fSelectEventType),
- fErrorCode(0)
+ fErrorCode(0),
+ fEventNumber(-1),
+ fErrorLogs("AliRawDataErrorLog",100),
+ fHeaderSwapped(NULL)
{
// copy constructor
+// Allocate the swapped header in case of Mac
+#ifndef R__BYTESWAP
+ fHeaderSwapped=new AliRawDataHeader(*rawReader.fHeaderSwapped);
+#endif
}
AliRawReader& AliRawReader::operator = (const AliRawReader& rawReader)
fErrorCode = rawReader.fErrorCode;
+ fEventNumber = rawReader.fEventNumber;
+ fErrorLogs = *((TClonesArray*)rawReader.fErrorLogs.Clone());
+
return *this;
}
// initialized
if (fEquipmentIdsIn) delete fEquipmentIdsIn;
if (fEquipmentIdsOut) delete fEquipmentIdsOut;
+ fErrorLogs.Delete();
+ if (fHeaderSwapped) delete fHeaderSwapped;
}
Int_t AliRawReader::GetMappedEquipmentId() const
return kTRUE;
}
+UInt_t AliRawReader::SwapWord(UInt_t x) const
+{
+ // Swap the endianess of the integer value 'x'
+
+ return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) << 8) |
+ ((x & 0x00ff0000U) >> 8) | ((x & 0xff000000U) >> 24));
+}
+
+UShort_t AliRawReader::SwapShort(UShort_t x) const
+{
+ // Swap the endianess of the short value 'x'
+
+ return (((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8)) ;
+}
Bool_t AliRawReader::ReadNextInt(UInt_t& data)
{
Error("ReadNextInt", "could not read data!");
return kFALSE;
}
+#ifndef R__BYTESWAP
+ data=SwapWord(data);
+#endif
return kTRUE;
}
Error("ReadNextShort", "could not read data!");
return kFALSE;
}
+#ifndef R__BYTESWAP
+ data=SwapShort(data);
+#endif
return kTRUE;
}
} while (ReadHeader());
}
+
+void AliRawReader::AddErrorLog(AliRawDataErrorLog::ERawDataErrorLevel level,
+ Int_t code,
+ const char *message)
+{
+ // Add a raw data error message to the list
+ // of raw-data decoding errors
+ if (fEventNumber < 0) {
+ AliError("No events have read so far! Impossible to add a raw data error log!");
+ return;
+ }
+ Int_t ddlId = GetEquipmentId();
+ if (ddlId < 0) {
+ AliError("No ddl raw data have been read so far! Impossible to add a raw data error log!");
+ return;
+ }
+
+ Int_t prevEventNumber = -1;
+ Int_t prevDdlId = -1;
+ Int_t prevErrorCode = -1;
+ AliRawDataErrorLog *prevLog = (AliRawDataErrorLog *)fErrorLogs.Last();
+ if (prevLog) {
+ prevEventNumber = prevLog->GetEventNumber();
+ prevDdlId = prevLog->GetDdlID();
+ prevErrorCode = prevLog->GetErrorCode();
+ }
+
+ if ((prevEventNumber != fEventNumber) ||
+ (prevDdlId != ddlId) ||
+ (prevErrorCode != code)) {
+ new (fErrorLogs[fErrorLogs.GetEntriesFast()])
+ AliRawDataErrorLog(fEventNumber,
+ ddlId,
+ level,
+ code,
+ message);
+ }
+ else
+ if (prevLog) prevLog->AddCount();
+
+}