#include <TTree.h>
#include "AliRawReaderRoot.h"
#include "AliRawEvent.h"
-#include "AliRawEventHeader.h"
+#include "AliRawEventHeaderBase.h"
#include "AliRawEquipment.h"
#include "AliRawEquipmentHeader.h"
#include "AliRawData.h"
}
}
+const AliRawEventHeaderBase* AliRawReaderRoot::GetEventHeader() const
+{
+ // Get the even header
+ // Return NULL in case of failure
+ if (!fEvent) return NULL;
+ return fEvent->GetHeader();
+}
UInt_t AliRawReaderRoot::GetType() const
{
// get the type from the event header
if (!fEvent) return 0;
- return fEvent->GetHeader()->GetType();
+ return fEvent->GetHeader()->Get("Type");
}
UInt_t AliRawReaderRoot::GetRunNumber() const
// get the run number from the event header
if (!fEvent) return 0;
- return fEvent->GetHeader()->GetRunNumber();
+ return fEvent->GetHeader()->Get("RunNb");
}
const UInt_t* AliRawReaderRoot::GetEventId() const
// get the event id from the event header
if (!fEvent) return NULL;
- return fEvent->GetHeader()->GetId();
+ return fEvent->GetHeader()->GetP("Id");
}
const UInt_t* AliRawReaderRoot::GetTriggerPattern() const
// get the trigger pattern from the event header
if (!fEvent) return NULL;
- return fEvent->GetHeader()->GetTriggerPattern();
+ return fEvent->GetHeader()->GetP("TriggerPattern");
}
const UInt_t* AliRawReaderRoot::GetDetectorPattern() const
// get the detector pattern from the event header
if (!fEvent) return NULL;
- return fEvent->GetHeader()->GetDetectorPattern();
+ return fEvent->GetHeader()->GetP("DetectorPattern");
}
const UInt_t* AliRawReaderRoot::GetAttributes() const
// get the type attributes from the event header
if (!fEvent) return NULL;
- return fEvent->GetHeader()->GetTypeAttribute();
+ return fEvent->GetHeader()->GetP("TypeAttribute");
+}
+
+const UInt_t* AliRawReaderRoot::GetSubEventAttributes() const
+{
+// get the type attributes from the sub event header
+
+ if (!fSubEvent) return NULL;
+ return fSubEvent->GetHeader()->GetP("TypeAttribute");
}
UInt_t AliRawReaderRoot::GetLDCId() const
// get the LDC Id from the event header
if (!fEvent || !fSubEvent) return 0;
- return fSubEvent->GetHeader()->GetLDCId();
+ return fSubEvent->GetHeader()->Get("LdcId");
}
UInt_t AliRawReaderRoot::GetGDCId() const
// get the GDC Id from the event header
if (!fEvent) return 0;
- return fEvent->GetHeader()->GetGDCId();
+ return fEvent->GetHeader()->Get("GdcId");
}
+UInt_t AliRawReaderRoot::GetTimestamp() const
+{
+ if (!fEvent) return 0;
+ return fEvent->GetHeader()->Get("Timestamp");
+}
Int_t AliRawReaderRoot::GetEquipmentSize() const
{
return fEquipment->GetEquipmentHeader()->GetBasicSizeType();
}
+Int_t AliRawReaderRoot::GetEquipmentHeaderSize() const
+{
+// get the size of the equipment header (28 bytes by default)
+
+ if (!fEvent || !fEquipment || !fEquipment->GetEquipmentHeader()) return 0;
+ return fEquipment->GetEquipmentHeader()->HeaderSize();
+}
+
+// _________________________________________________________________________
+void AliRawReaderRoot::SwapData(const void* inbuf, const void* outbuf, UInt_t size) {
+ // The method swaps the contents of the
+ // raw-data event header
+ UInt_t intCount = (size+3)/sizeof(UInt_t);
+
+ UInt_t* buf = (UInt_t*) inbuf; // temporary integers buffer
+ for (UInt_t i=0; i<intCount; i++, buf++) {
+ UInt_t value = SwapWord(*buf);
+ if (i==(intCount-1))
+ memcpy((UInt_t*)outbuf+i, &value, size%sizeof(UInt_t));
+ else
+ memcpy((UInt_t*)outbuf+i, &value, sizeof(UInt_t));
+ }
+}
+// _________________________________________________________________________
Bool_t AliRawReaderRoot::ReadHeader()
{
fCount = 0;
fEquipment = fSubEvent->GetEquipment(fEquipmentIndex++);
if (!fEquipment) continue;
+ if (!IsSelected()) {
+ fPosition = fEnd;
+ continue;
+ }
fRawData = fEquipment->GetRawData();
if (!fRawData) {
fPosition = fEnd;
// continue with the next equipment if no data left in the payload
if (fPosition >= fEnd) continue;
- // check that there are enough bytes left for the data header
- if (fPosition + sizeof(AliRawDataHeader) > fEnd) {
- Error("ReadHeader", "could not read data header!");
- Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
- fEquipment->GetEquipmentHeader()->Dump();
- fCount = 0;
- fPosition = fEnd;
- fErrorCode = kErrNoDataHeader;
- continue;
+ if (fRequireHeader) {
+ // check that there are enough bytes left for the data header
+ if (fPosition + sizeof(AliRawDataHeader) > fEnd) {
+ Error("ReadHeader", "could not read data header!");
+ Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
+ fEquipment->GetEquipmentHeader()->Dump();
+ fCount = 0;
+ fPosition = fEnd;
+ fErrorCode = kErrNoDataHeader;
+ continue;
+ }
+
+ // "read" the data header
+ fHeader = (AliRawDataHeader*) fPosition;
+#ifndef R__BYTESWAP
+ SwapData((void*) fHeader, (void*) fHeaderSwapped, sizeof(AliRawDataHeader));
+ fHeader=fHeaderSwapped;
+#endif
+ if ((fPosition + fHeader->fSize) != fEnd) {
+ if (fHeader->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+ fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
+ fHeader->fSize = fEnd - fPosition;
+ }
+ fPosition += sizeof(AliRawDataHeader);
}
- // "read" the data header
- fHeader = (AliRawDataHeader*) fPosition;
- fPosition += sizeof(AliRawDataHeader);
- if (fHeader->fSize != 0xFFFFFFFF) {
+ if (fHeader && (fHeader->fSize != 0xFFFFFFFF)) {
fCount = fHeader->fSize - sizeof(AliRawDataHeader);
+
+ // check consistency of data size in the header and in the sub event
+ if (fPosition + fCount > fEnd) {
+ Error("ReadHeader", "size in data header exceeds event size!");
+ Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
+ fEquipment->GetEquipmentHeader()->Dump();
+ fCount = 0;
+ fPosition = fEnd;
+ fErrorCode = kErrSize;
+ continue;
+ }
+
} else {
fCount = fEnd - fPosition;
}
- // check consistency of data size in the header and in the sub event
- if (fPosition + fCount > fEnd) {
- Error("ReadHeader", "size in data header exceeds event size!");
- Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
- fEquipment->GetEquipmentHeader()->Dump();
- fCount = 0;
- fPosition = fEnd;
- fErrorCode = kErrSize;
- continue;
- }
-
} while (!IsSelected());
return kTRUE;
return kFALSE;
}
memcpy(data, fPosition, size);
+
fPosition += size;
fCount -= size;
return kTRUE;
{
// go to the next event in the root file
- if (!fFile) return kFALSE;
+ if (!fBranch) return kFALSE;
do {
- if (fBranch->GetEntry(fEventIndex+1) <= 0) {
- delete fEvent;
- fEvent = new AliRawEvent;
- fBranch->SetAddress(&fEvent);
+ delete fEvent;
+ fEvent = new AliRawEvent;
+ fBranch->SetAddress(&fEvent);
+ if (fBranch->GetEntry(fEventIndex+1) <= 0)
return kFALSE;
- }
fEventIndex++;
} while (!IsEventSelected());
+ fEventNumber++;
return Reset();
}
{
// go back to the beginning of the root file
- if (!fFile) return kFALSE;
+ if (!fBranch) return kFALSE;
fEventIndex = -1;
delete fEvent;
fEvent = new AliRawEvent;
fBranch->SetAddress(&fEvent);
+ fEventNumber = -1;
return Reset();
}
// continue with the next sub event if no data left in the payload
if (position >= end) continue;
+ if (fRequireHeader) {
// check that there are enough bytes left for the data header
- if (position + sizeof(AliRawDataHeader) > end) {
- result |= kErrNoDataHeader;
- continue;
- }
+ if (position + sizeof(AliRawDataHeader) > end) {
+ result |= kErrNoDataHeader;
+ continue;
+ }
- // check consistency of data size in the header and in the equipment
- AliRawDataHeader* header = (AliRawDataHeader*) position;
- if (header->fSize != 0xFFFFFFFF) {
- if (position + header->fSize > end) {
+ // check consistency of data size in the header and in the equipment
+ AliRawDataHeader* header = (AliRawDataHeader*) position;
+ if ((position + header->fSize) != end) {
+ if (header->fSize != 0xFFFFFFFF)
+ Warning("ReadHeader",
+ "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+ equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
+ header->fSize = end - position;
result |= kErrSize;
}
}
+ position = end;
};
return result;