]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderRoot.cxx
generates TOF CDB reconstruction parameters (AliTOFRecoParam)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderRoot.cxx
index 8d2f04227961546769d0890b1af6325513b82782..18976b54b33a30949e091b168c03fff21684bf8c 100644 (file)
@@ -266,6 +266,11 @@ UInt_t AliRawReaderRoot::GetGDCId() const
   return fEvent->GetHeader()->Get("GdcId");
 }
 
+UInt_t AliRawReaderRoot::GetTimestamp() const
+{
+  if (!fEvent) return 0;
+  return fEvent->GetHeader()->Get("Timestamp");
+}
 
 Int_t AliRawReaderRoot::GetEquipmentSize() const
 {
@@ -315,6 +320,27 @@ Int_t AliRawReaderRoot::GetEquipmentHeaderSize() const
   return fEquipment->GetEquipmentHeader()->HeaderSize();
 }
 
+// _________________________________________________________________________
+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* 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));
+  }
+}
+// _________________________________________________________________________
 
 Bool_t AliRawReaderRoot::ReadHeader()
 {
@@ -385,6 +411,10 @@ Bool_t AliRawReaderRoot::ReadHeader()
 
       // "read" the data header
       fHeader = (AliRawDataHeader*) fPosition;
+#ifndef R__BYTESWAP
+      SwapData((void*) fHeader, (void*) fHeaderSwapped, sizeof(AliRawDataHeader));
+      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 !",
@@ -471,7 +501,7 @@ Bool_t AliRawReaderRoot::NextEvent()
 {
 // go to the next event in the root file
 
-  if (!fFile) return kFALSE;
+  if (!fBranch) return kFALSE;
 
   do {
     delete fEvent;
@@ -489,7 +519,7 @@ Bool_t AliRawReaderRoot::RewindEvents()
 {
 // go back to the beginning of the root file
 
-  if (!fFile) return kFALSE;
+  if (!fBranch) return kFALSE;
 
   fEventIndex = -1;
   delete fEvent;