]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
Adding the fitting for transformation with
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index ec110c08b174a1a4dd8af824e0f9be2287434223..f720d42146591c86f75c1b8659bb00f4ce0bd23c 100644 (file)
@@ -321,18 +321,10 @@ 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)-1)/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++) {
@@ -419,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);
@@ -476,62 +469,7 @@ Bool_t AliRawReaderRoot::ReadNext(UChar_t* data, Int_t size)
     fErrorCode = kErrOutOfBounds;
     return kFALSE;
   }
-#ifndef R__BYTESWAP
-  // relative position in the raw data buffer
-  UInt_t pos  = (UInt_t) (fPosition-(UChar_t*)fRawData->GetBuffer());  
-
-  UInt_t gapL = pos%sizeof(UInt_t);
-  UInt_t gapR = (pos+size)%sizeof(UInt_t);
-  if ( gapR > 0 ) gapR = sizeof(UInt_t) - gapR;
-
-  if (gapL>0 || gapR>0) printf("AliRawReaderRoot::ReadNext: relative pos in buffer=%d, buffer size=%d, gapLeft=%d, gapRight=%d\n", pos, size, gapL, gapR);
-
-  UChar_t* firstWord = fPosition - gapL;          // pointer to the begin of the 1st word
-  UChar_t* lastWord  = fPosition + size + gapR;   // pointer to the begin of the 1st word following the buffer and not included
-
-  // Loop through the all words and write each of them swapped
-  UInt_t   bytesRead = 0;
-  while (firstWord < lastWord) 
-  {
-      UInt_t* value   = (UInt_t*) firstWord;
-      UInt_t valueInv = SwapWord( *value );
-
-      if ( (pos/sizeof(UInt_t)) == ((pos+size)/sizeof(UInt_t)) ) 
-      {
-         // invert only byte(s) within the 1st (and unique) read word 
-         bytesRead += size;
-         memcpy((UInt_t*)(data+bytesRead), &valueInv+gapL, size);
-      }
-      else 
-      {
-         if ( gapL>0 ) 
-         {
-            // 1st word unaligned
-            bytesRead += sizeof(UInt_t) - gapL;
-            memcpy((UInt_t*)(data+bytesRead), &valueInv+gapL, sizeof(UInt_t)-gapL);
-         }
-         else 
-         {
-            if ( gapR>0 ) 
-            {
-               // last word unaligned
-               bytesRead += sizeof(UInt_t) - gapR;
-               memcpy((UInt_t*)(data+bytesRead), &valueInv, sizeof(UInt_t)-gapR);
-            }
-            else
-            { 
-               // no unalignements
-               bytesRead += sizeof(UInt_t);
-               memcpy((UInt_t*)(data+bytesRead), &valueInv, sizeof(UInt_t));
-            }            
-         }
-      }
-
-      firstWord += sizeof(UInt_t);
-  }
-#else
   memcpy(data, fPosition, size);
-#endif
 
   fPosition += size;
   fCount -= size;
@@ -641,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;
       }