]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawStream.cxx
Fix to access the efficiency map file
[u/mrichter/AliRoot.git] / FMD / AliFMDRawStream.cxx
index 7502788bbb8427b06b0decb95b206c612e7b0061..485e40fae3f1a99fb9bff8e39458098a532bd4ac 100644 (file)
@@ -32,6 +32,8 @@
 #include "AliFMDDebug.h" // Better debug macros
 // #include <iomanip>
 // #include <iostream>
+#include "AliRawReader.h"
+#include <climits>
 
 //____________________________________________________________________
 ClassImp(AliFMDRawStream)
@@ -44,7 +46,7 @@ AliFMDRawStream::AliFMDRawStream(AliRawReader* reader)
   : AliAltroRawStream(reader)
 {
   // CTOR 
-  fNoAltroMapping = kFALSE;
+  reader->Reset();
   // Select FMD DDL's 
   SelectRawData("FMD");
 }
@@ -52,7 +54,7 @@ AliFMDRawStream::AliFMDRawStream(AliRawReader* reader)
 //_____________________________________________________________________________
 Bool_t 
 AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr, 
-                            UInt_t& len, UShort_t* data)
+                            UInt_t& len, volatile UShort_t* data)
 {
   // Read one channel and return.   Returns 0 when there's no more
   // data. 
@@ -67,7 +69,7 @@ AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr,
       if(!next){
        AliFMDDebug(15, ("Read word # %d (!next)", l));
        addr = GetPrevHWAddress();
-       ddl  = GetPrevDDLNumber();
+       ddl  = (GetPrevDDLNumber() < 0 ? UINT_MAX: UInt_t(GetPrevDDLNumber()));
        len  = l+1; // Need to add one - l points to last valid index
        last = signal;
        break;
@@ -77,16 +79,39 @@ AliFMDRawStream::ReadChannel(UInt_t& ddl, UInt_t& addr,
        AliFMDDebug(15, ("New hardware address, was 0x%x, now 0x%x", 
                          GetPrevHWAddress(), GetHWAddress()));
        addr = GetPrevHWAddress();
-       ddl  = GetPrevDDLNumber();
+       ddl  = (GetPrevDDLNumber() < 0 ? UINT_MAX : UInt_t(GetPrevDDLNumber()));
        len  = l+1; // Need to add one - l points to last valid index
        last = signal;
        break;
       }
     }
+    // Sanity check - if the total bunch length is less than 1, then
+    // read until we get the next bunch. 
+    Int_t b  = GetTimeLength();
+    if (b < 1) { 
+      AliWarning(Form("Bunch length %0d is less than 0 for "
+                     "DDL %4d address 0x%03x", 
+                     b, ddl, addr));
+      last = 0xFFFF;
+      continue;
+    }
+
+    // Sanity check - if the current time is less than 0, then read
+    // until we get a new bunch. 
     Int_t t  = GetTime();
+    if (t < 0) {
+      AliWarning(Form("Time %0d is less than 0 for DDL %4d address 0x%03x", 
+                     t, ddl, addr));
+      last = 0xFFFF;
+      continue;
+    }
     l        = TMath::Max(l, t);
     data[t]  = signal;
     last     = 0xFFFF;
+#if 0
+    AliFMDDebug(signal > 512 ? 1 : 0, ("Signal @ %d (%d) is %d", 
+                                      time, t, data[t]));
+#endif
   } while (next);
   return next;
 }