ClassImp(AliRawReaderRoot)
+AliRawReaderRoot::AliRawReaderRoot() :
+ fFile(NULL),
+ fBranch(NULL),
+ fEventIndex(-1),
+ fEvent(NULL),
+ fSubEventIndex(0),
+ fSubEvent(NULL),
+ fEquipmentIndex(0),
+ fEquipment(NULL),
+ fRawData(NULL),
+ fPosition(NULL),
+ fEnd(NULL)
+{
+// default constructor
+
+}
AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber) :
fFile(NULL),
dir->cd();
if (!fFile || !fFile->IsOpen()) {
Error("AliRawReaderRoot", "could not open file %s", fileName);
+ fIsValid = kFALSE;
return;
}
TTree* tree = (TTree*) fFile->Get("RAW");
if (!tree) {
Error("AliRawReaderRoot", "no raw data tree found");
+ fIsValid = kFALSE;
return;
}
fBranch = tree->GetBranch("rawevent");
if (!fBranch) {
Error("AliRawReaderRoot", "no raw data branch found");
+ fIsValid = kFALSE;
return;
}
if (fEventIndex >= 0) {
if (fBranch->GetEntry(fEventIndex) <= 0) {
Error("AliRawReaderRoot", "no event with number %d found", fEventIndex);
+ fIsValid = kFALSE;
return;
}
}
fEnd(NULL)
{
// create an object to read digits from the given raw event
-
+ if (!fEvent) fIsValid = kFALSE;
}
AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) :
if (!fFile || !fFile->IsOpen()) {
Error("AliRawReaderRoot", "could not open file %s",
rawReader.fFile->GetName());
+ fIsValid = kFALSE;
return;
}
TTree* tree = (TTree*) fFile->Get("RAW");
if (!tree) {
Error("AliRawReaderRoot", "no raw data tree found");
+ fIsValid = kFALSE;
return;
}
fBranch = tree->GetBranch("rawevent");
if (!fBranch) {
Error("AliRawReaderRoot", "no raw data branch found");
+ fIsValid = kFALSE;
return;
}
if (fBranch->GetEntry(fEventIndex) <= 0) {
Error("AliRawReaderRoot", "no event with number %d found",
fEventIndex);
+ fIsValid = kFALSE;
return;
}
}
}
}
+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
{
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()->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;
// "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) {
- Warning("ReadHeader",
- "raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
- fHeader->fSize, fEnd - fPosition);
+ 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);
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 {
delete fEvent;
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();
+}
+
+Bool_t AliRawReaderRoot::GotoEvent(Int_t event)
+{
+ // go to a particular event
+ // Uses the absolute event index inside the
+ // raw-data file
+
+ if (!fBranch) return kFALSE;
+
+ delete fEvent;
+ fEvent = new AliRawEvent;
+ fBranch->SetAddress(&fEvent);
+ if (fBranch->GetEntry(event) <= 0)
+ return kFALSE;
+ fEventIndex = event;
+ fEventNumber++;
return Reset();
}
+Int_t AliRawReaderRoot::GetNumberOfEvents() const
+{
+ // Get the total number of events in
+ // the raw-data tree
+
+ if (!fBranch) return -1;
+
+ return fBranch->GetEntries();
+}
Int_t AliRawReaderRoot::CheckData() const
{
// check consistency of data size in the header and in the equipment
AliRawDataHeader* header = (AliRawDataHeader*) position;
if ((position + header->fSize) != end) {
- Warning("ReadHeader",
- "raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
- header->fSize, end - position);
+ 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;
}