]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDate.cxx
Export AliDAQ header file into include
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDate.cxx
index 4c4d8da774b382f24c74a773d114b8849eba27f2..cce49d515c04d8c593e54ebf2602e2d8e7587ab5 100644 (file)
@@ -39,7 +39,6 @@ AliRawReaderDate::AliRawReaderDate(
                                   void* /* event */
 #endif
                                   ) :
-  fRequireHeader(kTRUE),
   fFile(NULL),
   fEvent(NULL),
   fSubEvent(NULL),
@@ -64,7 +63,6 @@ AliRawReaderDate::AliRawReaderDate(
                                   Int_t /*eventNumber*/
 #endif
                                   ) :
-  fRequireHeader(kTRUE),
   fFile(NULL),
   fEvent(NULL),
   fSubEvent(NULL),
@@ -103,7 +101,6 @@ AliRawReaderDate::AliRawReaderDate(
 
 AliRawReaderDate::AliRawReaderDate(const AliRawReaderDate& rawReader) :
   AliRawReader(rawReader),
-  fRequireHeader(rawReader.fRequireHeader),
   fFile(rawReader.fFile),
   fEvent(rawReader.fEvent),
   fSubEvent(rawReader.fSubEvent),
@@ -250,11 +247,15 @@ UInt_t AliRawReaderDate::GetGDCId() const
 
 Int_t AliRawReaderDate::GetEquipmentSize() const
 {
-// get the size of the equipment
+// get the size of the equipment (including the header)
 
 #ifdef ALI_DATE
   if (!fEquipment) return 0;
-  return fEquipment->equipmentSize;
+  if (fSubEvent->eventVersion <= 0x00030001) {
+    return fEquipment->equipmentSize + sizeof(equipmentHeaderStruct);
+  } else {
+    return fEquipment->equipmentSize;
+  }
 #else
   return 0;
 #endif
@@ -308,6 +309,16 @@ Int_t AliRawReaderDate::GetEquipmentElementSize() const
 #endif
 }
 
+Int_t AliRawReaderDate::GetEquipmentHeaderSize() const
+{
+  // Get the equipment header size
+  // 28 bytes by default
+#ifdef ALI_DATE
+  return sizeof(equipmentHeaderStruct);
+#else
+  return 0;
+#endif
+}
 
 Bool_t AliRawReaderDate::ReadHeader()
 {
@@ -374,7 +385,7 @@ Bool_t AliRawReaderDate::ReadHeader()
 
       fCount = 0;
       fPosition = ((UChar_t*)fEquipment) + sizeof(equipmentHeaderStruct);
-      if (fSubEvent->eventVersion <= 0x00030002) {
+      if (fSubEvent->eventVersion <= 0x00030001) {
         fEnd = fPosition + fEquipment->equipmentSize;
       } else {
         fEnd = ((UChar_t*)fEquipment) + fEquipment->equipmentSize;
@@ -401,6 +412,12 @@ Bool_t AliRawReaderDate::ReadHeader()
 
       // "read" the data header
       fHeader = (AliRawDataHeader*) fPosition;
+      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);
+       fHeader->fSize = fEnd - fPosition;
+      }
       fPosition += sizeof(AliRawDataHeader);
     }
 
@@ -571,25 +588,25 @@ Int_t AliRawReaderDate::CheckData() const
     // 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;
-      position = end;
-      continue;
-    }
+      if (position + sizeof(AliRawDataHeader) > end) {
+       result |= kErrNoDataHeader;
+       position = end;
+       continue;
+      }
 
-    // check consistency of data size in the data header and in the sub event
-    AliRawDataHeader* header = (AliRawDataHeader*) position;
-    if (header->fSize != 0xFFFFFFFF) {
-      if (position + header->fSize > end) {
+      // check consistency of data size in the data header and in the sub event
+      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);
+       header->fSize = end - position;
        result |= kErrSize;
-       position = end;
-      } else {
-       position += header->fSize;
       }
-    } else {
-      position = end;
     }
+    position = end;
   };
 
 #endif