]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderDateV3.cxx
Fix for report #72089 changes to AliTOFPIDResponse to be commited in STEER (Roberto)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderDateV3.cxx
index 3bc53c8560794b739baf7a2589d1eea67cd5fade..4553a27ca56f897559c903feae2faf307c78a555 100644 (file)
@@ -77,6 +77,7 @@ AliRawReaderDateV3::AliRawReaderDateV3(const char* fileName,
   fFile = fopen(fileName, "rb");
   if (!fFile) {
     Error("AliRawReaderDateV3", "could not open file %s", fileName);
+    fIsValid = kFALSE;
     return;
   }
   if (eventNumber < 0) return;
@@ -86,7 +87,7 @@ AliRawReaderDateV3::AliRawReaderDateV3(const char* fileName,
   while (fread(&header, 1, headerSize, fFile) == headerSize) {
     if (eventNumber == 0) {
       UChar_t* buffer = new UChar_t[header.size];
-      fseek(fFile, -headerSize, SEEK_CUR);
+      fseek(fFile, -(long)headerSize, SEEK_CUR);
       if (Int_t(fread(buffer, 1, header.size, fFile)) != header.size) break;
       fEvent = (eventHeaderStruct*) buffer;
       break;
@@ -199,6 +200,13 @@ UInt_t AliRawReaderDateV3::GetGDCId() const
   return UInt_t(-1);
 }
 
+UInt_t AliRawReaderDateV3::GetTimestamp() const
+{
+// get the timestamp from the event header
+
+  if (!fEvent) return 0;
+  return fEvent->time;
+}
 
 Int_t AliRawReaderDateV3::GetEquipmentSize() const
 {
@@ -298,7 +306,7 @@ Bool_t AliRawReaderDateV3::ReadHeader()
       // check that there are enough bytes left for the data header
       if (fPosition + sizeof(AliRawDataHeader) > fEnd) {
        Error("ReadHeader", "could not read data header data!");
-       Warning("ReadHeader", "skipping %d bytes\n"
+       Warning("ReadHeader", "skipping %ld bytes\n"
                " run: %d  event: %d\n", 
                fEnd - fPosition, fSubEvent->runNb, fSubEvent->nbInRun);
        fCount = 0;
@@ -310,9 +318,10 @@ Bool_t AliRawReaderDateV3::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);
+       if (fHeader->fSize != 0xFFFFFFFF)
+         Warning("ReadHeader",
+                 "raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
+                 fHeader->fSize, fEnd - fPosition);
        fHeader->fSize = fEnd - fPosition;
       }
       fPosition += sizeof(AliRawDataHeader);
@@ -324,7 +333,7 @@ Bool_t AliRawReaderDateV3::ReadHeader()
       // check consistency of data size in the header and in the sub event
       if (fPosition + fCount > fEnd) {
        Error("ReadHeader", "size in data header exceeds event size!");
-       Warning("ReadHeader", "skipping %d bytes\n"
+       Warning("ReadHeader", "skipping %ld bytes\n"
                " run: %d  event: %d\n", 
                fEnd - fPosition, fSubEvent->runNb, fSubEvent->nbInRun);
        fCount = 0;
@@ -404,13 +413,14 @@ Bool_t AliRawReaderDateV3::NextEvent()
       continue;
     }
     UChar_t* buffer = new UChar_t[header.size];
-    fseek(fFile, -headerSize, SEEK_CUR);
+    fseek(fFile, -(long)headerSize, SEEK_CUR);
     if (Int_t(fread(buffer, 1, header.size, fFile)) != header.size) {
       Error("NextEvent", "could not read event from file");
       delete[] buffer;
       break;
     }
     fEvent = (eventHeaderStruct*) buffer;
+    fEventNumber++;
     return kTRUE;
   };
 
@@ -425,6 +435,7 @@ Bool_t AliRawReaderDateV3::RewindEvents()
   if (!fFile) return kFALSE;
 
   fseek(fFile, 0, SEEK_SET);
+  fEventNumber = -1;
   return Reset();
 }
 
@@ -478,9 +489,10 @@ Int_t AliRawReaderDateV3::CheckData() const
       // 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);
+       if (header->fSize != 0xFFFFFFFF)
+         Warning("ReadHeader",
+                 "raw data size found in the header is wrong (%d != %ld)! Using the equipment size instead !",
+                 header->fSize, end - position);
        header->fSize = end - position;
        result |= kErrSize;
       }