]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
Added comments (Laurent)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index a32bafc508cd08aa4ddfdf5e649dc45de748c033..71aabc0b3f4cb4ab74781d85a19760f499d16bfa 100644 (file)
@@ -300,6 +300,14 @@ Int_t AliRawReaderRoot::GetEquipmentElementSize() 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();
+}
+
 
 Bool_t AliRawReaderRoot::ReadHeader()
 {
@@ -366,6 +374,12 @@ Bool_t AliRawReaderRoot::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);
     }
 
@@ -449,12 +463,11 @@ Bool_t AliRawReaderRoot::NextEvent()
   if (!fFile) 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());
   return Reset();
@@ -525,10 +538,15 @@ Int_t AliRawReaderRoot::CheckData() const
 
       // 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) result |= kErrSize;
+      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;
   };
 
   return result;