]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
Write trigger digits if SAVEDIGITS activated (Bogdan)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index 18976b54b33a30949e091b168c03fff21684bf8c..f720d42146591c86f75c1b8659bb00f4ce0bd23c 100644 (file)
@@ -321,23 +321,18 @@ Int_t AliRawReaderRoot::GetEquipmentHeaderSize() const
 }
 
 // _________________________________________________________________________
-UInt_t AliRawReaderRoot::SwapWord(UInt_t x) const
-{
-   // Swap the endianess of the integer value 'x'
-
-   return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) <<  8) |
-           ((x & 0x00ff0000U) >>  8) | ((x & 0xff000000U) >> 24));
-}
-
 void AliRawReaderRoot::SwapData(const void* inbuf, const void* outbuf, UInt_t size) {
   // The method swaps the contents of the
   // raw-data event header
-  UInt_t  intCount = size/sizeof(UInt_t);
+  UInt_t  intCount = (size+3)/sizeof(UInt_t);
 
   UInt_t* buf = (UInt_t*) inbuf;    // temporary integers buffer
   for (UInt_t i=0; i<intCount; i++, buf++) {
       UInt_t value = SwapWord(*buf);
-      memcpy((UInt_t*)outbuf+i, &value, sizeof(UInt_t));
+      if (i==(intCount-1))
+         memcpy((UInt_t*)outbuf+i, &value, size%sizeof(UInt_t));
+      else
+         memcpy((UInt_t*)outbuf+i, &value, sizeof(UInt_t));
   }
 }
 // _________________________________________________________________________
@@ -416,9 +411,10 @@ Bool_t AliRawReaderRoot::ReadHeader()
       fHeader=fHeaderSwapped;
 #endif
       if ((fPosition + fHeader->fSize) != fEnd) {
-       Warning("ReadHeader",
-               "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
-               fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
+       if (fHeader->fSize != 0xFFFFFFFF)
+         Warning("ReadHeader",
+                 "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+                 fEquipment->GetEquipmentHeader()->GetId(),fHeader->fSize, fEnd - fPosition);
        fHeader->fSize = fEnd - fPosition;
       }
       fPosition += sizeof(AliRawDataHeader);
@@ -474,6 +470,7 @@ Bool_t AliRawReaderRoot::ReadNext(UChar_t* data, Int_t size)
     return kFALSE;
   }
   memcpy(data, fPosition, size);
+
   fPosition += size;
   fCount -= size;
   return kTRUE;
@@ -582,9 +579,10 @@ Int_t AliRawReaderRoot::CheckData() const
       // check consistency of data size in the header and in the equipment
       AliRawDataHeader* header = (AliRawDataHeader*) position;
       if ((position + header->fSize) != end) {
-       Warning("ReadHeader",
-               "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
-               equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
+       if (header->fSize != 0xFFFFFFFF)
+         Warning("ReadHeader",
+                 "Equipment %d : raw data size found in the header is wrong (%d != %d)! Using the equipment size instead !",
+                 equipment->GetEquipmentHeader()->GetId(),header->fSize, end - position);
        header->fSize = end - position;
        result |= kErrSize;
       }