]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
readers updated (mini header -> data header)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index ec45eff76fc6926c374aaa34b7d8817779d8c50c..cb52604f8a26f94e92959f9eaa1c9c70556e0604 100644 (file)
@@ -61,7 +61,7 @@ AliRawReaderRoot::AliRawReaderRoot(const char* fileName, Int_t eventNumber)
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
-  fMiniHeader = NULL;
+  fHeader = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
@@ -77,7 +77,7 @@ AliRawReaderRoot::AliRawReaderRoot(AliRawEvent* event)
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
-  fMiniHeader = NULL;
+  fHeader = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
@@ -94,7 +94,7 @@ AliRawReaderRoot::AliRawReaderRoot(const AliRawReaderRoot& rawReader) :
   fSubEventIndex = rawReader.fSubEventIndex;
   fSubEvent = rawReader.fSubEvent;
   fRawData = rawReader.fRawData;
   fSubEventIndex = rawReader.fSubEventIndex;
   fSubEvent = rawReader.fSubEvent;
   fRawData = rawReader.fRawData;
-  fMiniHeader = rawReader.fMiniHeader;
+  fHeader = rawReader.fHeader;
 
   fCount = rawReader.fCount;
   fPosition = rawReader.fPosition;
 
   fCount = rawReader.fCount;
   fPosition = rawReader.fPosition;
@@ -171,6 +171,14 @@ const UInt_t* AliRawReaderRoot::GetAttributes() const
   return fEvent->GetHeader()->GetTypeAttribute();
 }
 
   return fEvent->GetHeader()->GetTypeAttribute();
 }
 
+UInt_t AliRawReaderRoot::GetLDCId() const
+{
+// get the LDC Id from the event header
+
+  if (!fEvent || !fEvent->GetSubEvent(fSubEventIndex)) return 0;
+  return fEvent->GetSubEvent(fSubEventIndex)->GetHeader()->GetLDCId();
+}
+
 UInt_t AliRawReaderRoot::GetGDCId() const
 {
 // get the GDC Id from the event header
 UInt_t AliRawReaderRoot::GetGDCId() const
 {
 // get the GDC Id from the event header
@@ -180,10 +188,51 @@ UInt_t AliRawReaderRoot::GetGDCId() const
 }
 
 
 }
 
 
-Bool_t AliRawReaderRoot::ReadMiniHeader()
+Int_t AliRawReaderRoot::GetEquipmentSize() const
 {
 {
-// read a mini header at the current position
-// returns kFALSE if the mini header could not be read
+// get the size of the equipment
+
+  if (!fEvent || !fEvent->GetEquipmentHeader()) return 0;
+  return fEvent->GetEquipmentHeader()->GetEquipmentSize();
+}
+
+Int_t AliRawReaderRoot::GetEquipmentType() const
+{
+// get the type from the equipment header
+
+  if (!fEvent || !fEvent->GetEquipmentHeader()) return -1;
+  return fEvent->GetEquipmentHeader()->GetEquipmentType();
+}
+
+Int_t AliRawReaderRoot::GetEquipmentId() const
+{
+// get the ID from the equipment header
+
+  if (!fEvent || !fEvent->GetEquipmentHeader()) return -1;
+  return fEvent->GetEquipmentHeader()->GetId();
+}
+
+const UInt_t* AliRawReaderRoot::GetEquipmentAttributes() const
+{
+// get the attributes from the equipment header
+
+  if (!fEvent || !fEvent->GetEquipmentHeader()) return NULL;
+  return fEvent->GetEquipmentHeader()->GetTypeAttribute();
+}
+
+Int_t AliRawReaderRoot::GetEquipmentElementSize() const
+{
+// get the basic element size from the equipment header
+
+  if (!fEvent || !fEvent->GetEquipmentHeader()) return 0;
+  return fEvent->GetEquipmentHeader()->GetBasicSizeType();
+}
+
+
+Bool_t AliRawReaderRoot::ReadHeader()
+{
+// read a data header at the current position
+// returns kFALSE if the data header could not be read
 
   fErrorCode = 0;
   if (!fEvent) return kFALSE;
 
   fErrorCode = 0;
   if (!fEvent) return kFALSE;
@@ -201,7 +250,7 @@ Bool_t AliRawReaderRoot::ReadMiniHeader()
 
       // check the magic word of the sub event
       if (!fSubEvent->GetHeader()->IsValid()) {
 
       // check the magic word of the sub event
       if (!fSubEvent->GetHeader()->IsValid()) {
-       Error("ReadMiniHeader", "wrong magic number in sub event!");
+       Error("ReadHeader", "wrong magic number in sub event!");
        fSubEvent->GetHeader()->Dump();
        fErrorCode = kErrMagic;
        return kFALSE;
        fSubEvent->GetHeader()->Dump();
        fErrorCode = kErrMagic;
        return kFALSE;
@@ -216,35 +265,30 @@ Bool_t AliRawReaderRoot::ReadMiniHeader()
     // continue with the next sub event if no data left in the payload
     if (fPosition >= fEnd) continue;
 
     // continue with the next sub event if no data left in the payload
     if (fPosition >= fEnd) continue;
 
-    // check that there are enough bytes left for the mini header
-    if (fPosition + sizeof(AliMiniHeader) > fEnd) {
-      Error("ReadMiniHeader", "could not read mini header data!");
-      Warning("ReadMiniHeader", "skipping %d bytes", fEnd - fPosition);
+    // 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);
       fSubEvent->GetHeader()->Dump();
       fCount = 0;
       fPosition = fEnd;
       fSubEvent->GetHeader()->Dump();
       fCount = 0;
       fPosition = fEnd;
-      fErrorCode = kErrNoMiniHeader;
+      fErrorCode = kErrNoDataHeader;
       continue;
     }
 
       continue;
     }
 
-    // "read" and check the mini header
-    fMiniHeader = (AliMiniHeader*) fPosition;
-    fPosition += sizeof(AliMiniHeader);
-    if (!CheckMiniHeader()) {
-      Error("ReadMiniHeader", "wrong magic word in mini header!");
-      Warning("ReadMiniHeader", "skipping %d bytes", fEnd - fPosition);
-      fSubEvent->GetHeader()->Dump();
-      fCount = 0;
-      fPosition = fEnd;
-      fErrorCode = kErrMiniMagic;
-      continue;
+    // "read" the data header
+    fHeader = (AliRawDataHeader*) fPosition;
+    fPosition += sizeof(AliRawDataHeader);
+    if (fHeader->fSize != 0xFFFFFFFF) {
+      fCount = fHeader->fSize - sizeof(AliRawDataHeader);
+    } else {
+      fCount = fEnd - fPosition;
     }
     }
-    fCount = fMiniHeader->fSize;
 
 
-    // check consistency of data size in the mini header and in the sub event
+    // check consistency of data size in the header and in the sub event
     if (fPosition + fCount > fEnd) {  
     if (fPosition + fCount > fEnd) {  
-      Error("ReadMiniHeader", "size in mini header exceeds event size!");
-      Warning("ReadMiniHeader", "skipping %d bytes", fEnd - fPosition);
+      Error("ReadHeader", "size in data header exceeds event size!");
+      Warning("ReadHeader", "skipping %d bytes", fEnd - fPosition);
       fSubEvent->GetHeader()->Dump();
       fCount = 0;
       fPosition = fEnd;
       fSubEvent->GetHeader()->Dump();
       fCount = 0;
       fPosition = fEnd;
@@ -264,7 +308,7 @@ Bool_t AliRawReaderRoot::ReadNextData(UChar_t*& data)
 
   fErrorCode = 0;
   while (fCount == 0) {
 
   fErrorCode = 0;
   while (fCount == 0) {
-    if (!ReadMiniHeader()) return kFALSE;
+    if (!ReadHeader()) return kFALSE;
   }
   data = fPosition;
   fPosition += fCount;  
   }
   data = fPosition;
   fPosition += fCount;  
@@ -297,7 +341,7 @@ Bool_t AliRawReaderRoot::Reset()
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
   fSubEventIndex = 0;
   fSubEvent = NULL;
   fRawData = NULL;
-  fMiniHeader = NULL;
+  fHeader = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
 
   fCount = 0;
   fPosition = fEnd = NULL;
@@ -339,24 +383,26 @@ Int_t AliRawReaderRoot::CheckData() const
     // continue with the next sub event if no data left in the payload
     if (position >= end) continue;
 
     // continue with the next sub event if no data left in the payload
     if (position >= end) continue;
 
-    // check that there are enough bytes left for the mini header
-    if (position + sizeof(AliMiniHeader) > end) {
-      result |= kErrNoMiniHeader;
+    // check that there are enough bytes left for the data header
+    if (position + sizeof(AliRawDataHeader) > end) {
+      result |= kErrNoDataHeader;
       position = end;
       continue;
     }
 
       position = end;
       continue;
     }
 
-    // "read" and check the mini header
-    AliMiniHeader* miniHeader = (AliMiniHeader*) position;
-    position += sizeof(AliMiniHeader);
-    if (!CheckMiniHeader(miniHeader)) {
-      result |= kErrMiniMagic;
+    // check consistency of data size in the header and in the sub event
+    AliRawDataHeader* header = (AliRawDataHeader*) position;
+    if (fHeader->fSize != 0xFFFFFFFF) {
+      if (position + header->fSize > end) {
+       result |= kErrSize;
+       position = end;
+      } else {
+       position += header->fSize;
+      }
+    } else {
       position = end;
       position = end;
-      continue;
     }
     }
-
-    // check consistency of data size in the mini header and in the sub event
-    if (position + miniHeader->fSize > end) result |= kErrSize;
-    position += miniHeader->fSize;
   };
   };
+
+  return result;
 }
 }