]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDate.cxx
Interface to the new class for storing and retrieving of the raw-data decoding errors...
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDate.cxx
index 0a07ae290b8b108c0923c3373b91183684dc6723..89732d1fe8c8c71942531c63def2a86b5ea32b87 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,14 +247,14 @@ UInt_t AliRawReaderDate::GetGDCId() const
 
 Int_t AliRawReaderDate::GetEquipmentSize() const
 {
-// get the size of the equipment (without header)
+// get the size of the equipment (including the header)
 
 #ifdef ALI_DATE
   if (!fEquipment) return 0;
   if (fSubEvent->eventVersion <= 0x00030001) {
-    return fEquipment->equipmentSize;
+    return fEquipment->equipmentSize + sizeof(equipmentHeaderStruct);
   } else {
-    return fEquipment->equipmentSize - sizeof(equipmentHeaderStruct);
+    return fEquipment->equipmentSize;
   }
 #else
   return 0;
@@ -312,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()
 {
@@ -405,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);
     }
 
@@ -510,6 +523,7 @@ Bool_t AliRawReaderDate::NextEvent()
       break;
     }
     fEvent = (eventHeaderStruct*) buffer;
+    fEventNumber++;
     return kTRUE;
   };
 
@@ -526,6 +540,7 @@ Bool_t AliRawReaderDate::RewindEvents()
   if (!fFile) return kFALSE;
 
   fseek(fFile, 0, SEEK_SET);
+  fEventNumber = -1;
   return Reset();
 }
 
@@ -575,25 +590,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