]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawReader.cxx
Whoops - stupid mistake - sorry
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.cxx
index 1ce4a1b97e249e66404d7420ed69ce810772aad2..07088db3d4e8733d0cbfcf783d432581d358814d 100644 (file)
@@ -86,13 +86,19 @@ AliFMDRawReader::AliFMDRawReader(AliRawReader* reader, TTree* tree)
     fMinStrip(0),
     fMaxStrip(127), 
     fPreSamp(14+5),
-    fSeen(0)
+    fSeen(0), 
+    fVerbose(false), 
+    fErrors("TObject"),
+    fNErrChanLen(0), 
+    fNErrAddress(0)
 {
   // Default CTOR
   for (Int_t i = 0; i < 3; i++) { 
     fSampleRate[i]   = 0;
     fZeroSuppress[i] = kFALSE;
     fNoiseFactor[i]  = 1;
+    fL1Phase[i]      = 0;
+    fNErrors[i]      = 0;
   }
 }
 
@@ -116,6 +122,41 @@ AliFMDRawReader::Exec(Option_t*)
   delete array;
 }
 
+//____________________________________________________________________
+void
+AliFMDRawReader::AddError(Int_t ddl, Int_t hwaddr)
+{
+  Int_t nErr = fErrors.GetEntries();
+  TObject* o = new (fErrors[nErr]) TObject;
+  o->SetUniqueID((ddl & 0xFF) << 12 & (hwaddr & 0xFFF));
+}
+//____________________________________________________________________
+void
+AliFMDRawReader::ReadbackError(const AliAltroRawStreamV3& input,
+                              const char* format, ...)
+{
+  static char buf[512];
+  va_list ap;
+  va_start(ap, format);
+  vsnprintf(buf, 511, format, ap);
+  buf[511] = '\0';
+  va_end(ap);
+
+  // { AliWarning(buf); }
+  if (AliDebugLevel() > 10) {
+    AliLog::Flush();
+    AliWarning(buf);
+    input.HexDumpChannel();
+  }
+
+  Int_t    ddl    = input.GetDDLNumber();
+  Int_t    hwaddr = input.GetHWAddress();
+  
+  fReader->AddMinorErrorLog(AliAltroRawStreamV3::kAltroPayloadErr,buf);
+  AddError(ddl, hwaddr); 
+  fNErrors[ddl]++;
+}
+
 //____________________________________________________________________
 Int_t
 AliFMDRawReader::NewDDL(AliAltroRawStreamV3& input, UShort_t& det)
@@ -220,12 +261,18 @@ AliFMDRawReader::NewDDL(AliAltroRawStreamV3& input, UShort_t& det)
   // Get Errors seen 
   Int_t nChAddrMismatch = input.GetNChAddrMismatch();
   Int_t nChLenMismatch  = input.GetNChLengthMismatch();
-  if (nChAddrMismatch != 0) 
-    AliWarning(Form("Got %d channels with address mis-matches for 0x%03x",
-                   nChAddrMismatch, ddl));
-  if (nChLenMismatch != 0) 
-    AliWarning(Form("Got %d channels with length mis-matches for 0x%03x",
-                   nChLenMismatch, ddl));
+  if (nChAddrMismatch != 0) {
+    ReadbackError(input, 
+                 "Got %d channels with address mis-matches for 0x%03x",
+                 nChAddrMismatch, ddl);
+    fNErrAddress += nChAddrMismatch;
+  }
+  if (nChLenMismatch != 0) {
+    ReadbackError(input, 
+                 "Got %d channels with length mis-matches for 0x%03x",
+                 nChLenMismatch, ddl);
+    fNErrChanLen += nChLenMismatch;
+  }
 
   // Map DDL number to the detector number 
   AliFMDParameters*    pars   = AliFMDParameters::Instance();
@@ -260,12 +307,8 @@ AliFMDRawReader::NewChannel(const AliAltroRawStreamV3& input,  UShort_t det,
   Int_t    ddl    = input.GetDDLNumber();
   Int_t    hwaddr = input.GetHWAddress();
   if (input.IsChannelBad()) { 
-    const char* msg = Form("Ignoring channel %03d/0x%03x with errors", 
-                          ddl, hwaddr); 
-    AliWarning(msg); 
-    if (AliDebugLevel() > 10) input.HexDumpChannel();
-    fReader->AddMinorErrorLog(AliAltroRawStreamV3::kAltroPayloadErr,msg);
-    fNErrors[ddl] += 1;
+    ReadbackError(input, "Ignoring channel %03d/0x%03x with errors", 
+                 ddl, hwaddr); 
     return 0xFFFF;
   }
   
@@ -286,8 +329,11 @@ AliFMDRawReader::NewChannel(const AliAltroRawStreamV3& input,  UShort_t det,
   fMinStrip = pars->GetMinStrip(det, ring, sec, strbase);
   fMaxStrip = pars->GetMaxStrip(det, ring, sec, strbase);
   fPreSamp  = pars->GetPreSamples(det, ring, sec, strbase);
-  if (fSampleRate[ddl] == 0) 
+  if (fSampleRate[ddl] == 0) {
+    AliDebug(3,Form("Get sample rate for RCU @ DDL %d from OCDB", ddl));
     fSampleRate[ddl] = pars->GetSampleRate(det, ring, sec, strbase);
+  }
+  AliDebug(3,Form("RCU @ DDL %d sample rate: %d", ddl,fSampleRate[ddl]));
 
   return hwaddr;
 }
@@ -307,33 +353,24 @@ AliFMDRawReader::NewBunch(const AliAltroRawStreamV3& input,
   length            = input.GetBunchLength();
 
   if (tstart >= nSamples) {
-    const char* msg = Form("Bunch in %03d/0x%03x has an start time greater "
-                          "than number of samples: 0x%x >= 0x%x", 
-                          ddl, hwaddr, tstart, nSamples);
-    AliWarning(msg);
-    if (AliDebugLevel() > 10) input.HexDumpChannel();
-    fReader->AddMinorErrorLog(AliAltroRawStreamV3::kAltroPayloadErr,msg);
-    fNErrors[ddl]++;
+    ReadbackError(input, 
+                 "Bunch in %03d/0x%03x has an start time greater "
+                 "than number of samples: 0x%x >= 0x%x", 
+                 ddl, hwaddr, tstart, nSamples);
     return false;
   }
   if ((int(tstart) - length + 1) < 0) { 
-    const char* msg = Form("Bunch in %03d/0x%03x has an invalid length and "
-                          "start time: 0x%x,0x%x (%d-%d+1=%d<0)", 
-                          ddl, hwaddr, length, tstart, tstart, length, 
-                          int(tstart)-length+1);
-    AliWarning(msg);
-    if (AliDebugLevel() > 10) input.HexDumpChannel();
-    fReader->AddMinorErrorLog(AliAltroRawStreamV3::kAltroPayloadErr,msg);
-    fNErrors[ddl]++;                           
+    ReadbackError(input, 
+                 "Bunch in %03d/0x%03x has an invalid length and "
+                 "start time: 0x%x,0x%x (%d-%d+1=%d<0)", 
+                 ddl, hwaddr, length, tstart, tstart, length, 
+                 int(tstart)-length+1);
     return false;
   }
   if (tstart >= start) { 
-    const char* msg = Form("Bunch in %03d/0x%03x has early start time: "
-                          "0x%x >= 0x%x", ddl, hwaddr, tstart, start);
-    AliWarning(msg);
-    if (AliDebugLevel() > 10) input.HexDumpChannel();
-    fReader->AddMinorErrorLog(AliAltroRawStreamV3::kAltroPayloadErr,msg);
-    fNErrors[ddl]++;
+    ReadbackError(input, 
+                 "Bunch in %03d/0x%03x has early start time: "
+                 "0x%x >= 0x%x", ddl, hwaddr, tstart, start);
     return false;
   }
   start = tstart;
@@ -441,7 +478,7 @@ AliFMDRawReader::NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec,
   static Short_t             tstr     = 0;   
   static Short_t             bstr     = -1;
   static UShort_t            tsam     = 0;   
-  static UInt_t              trate    = 0;
+  // static UInt_t           trate    = 0;
   static Int_t               hwaddr   = -1;
   static UShort_t            start    = 0;
   static UShort_t            length   = 0;
@@ -458,7 +495,7 @@ AliFMDRawReader::NextSample(UShort_t& det, Char_t&   rng, UShort_t& sec,
 
     // Reset variables
     ddl    = -1;  
-    trate  = 0;   
+    // trate= 0;   
     tdet   = 0;   
     trng   = '\0';
     tsec   = 0;   
@@ -614,8 +651,12 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
     AliError("No TClonesArray passed");
     return kFALSE;
   }
+  // static ULong_t unique = 0;
   const UShort_t kUShortMax = (1 << 16) - 1;
   fSeen.Reset(kUShortMax);
+  fErrors.Clear();
+  fNErrChanLen = 0;
+  fNErrAddress = 0;
   for (Int_t ddl = 0; ddl < kNDDL; ddl++) fNErrors[ddl] = 0;
 
   AliAltroRawStreamV3  input(fReader);
@@ -706,6 +747,29 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
       // if (errors && (AliDebugLevel() > 0)) input.HexDumpChannel();
     } // while (channel)
   } // while (ddl)
+  if (fNErrors[0] > 0 || fNErrors[1] > 0 || fNErrors[2] > 0 || 
+      fNErrChanLen > 0 || fNErrAddress > 0) {
+    // AliLog::Flush();
+    AliLog::SetPrintRepetitions(false);
+    AliWarningF("R/O errors: FMD1=%d, FMD2=%d, FMD3=%d, "
+               "Channel Length=%d, address=%d", 
+               fNErrors[0], fNErrors[1], fNErrors[2], 
+               fNErrChanLen, fNErrAddress);
+    AliLog::SetPrintRepetitions(true);
+  }
+  if (fVerbose && fErrors.GetEntries() > 0) {
+    TString msg;
+    Int_t   nErr = fErrors.GetEntries();
+    for (Int_t i = 0; i < nErr; i++) {
+      UInt_t where = fErrors.At(i)->GetUniqueID();
+      if (i % 6 == 0) msg.Append("\n");
+      msg.Append(Form("  %3d/0x%03x", (where >> 12) & 0xFF, (where & 0xFFF)));
+    }
+    // AliLog::Flush();
+    AliLog::SetPrintRepetitions(false);
+    AliWarningF("Got %d errors in channels %s", nErr, msg.Data());
+    AliLog::SetPrintRepetitions(true);
+  }
   return kTRUE;
 }
 //____________________________________________________________________
@@ -716,7 +780,7 @@ AliFMDRawReader::ReadAdcs(AliFMDUShortMap& map)
   // objects. 
   AliDebug(3,Form("Reading ADC values into a map"));
 
-  const UShort_t kUShortMax = (1 << 16) - 1;
+  // const UShort_t kUShortMax = (1 << 16) - 1;
   for (Int_t ddl = 0; ddl < kNDDL; ddl++) fNErrors[ddl] = 0;
 
   AliAltroRawStreamV3  input(fReader);
@@ -747,7 +811,7 @@ AliFMDRawReader::ReadAdcs(AliFMDUShortMap& map)
       // Loop over bunches 
       while (input.NextBunch()) { 
        // Get Lenght of bunch, and pointer to the data 
-       const UShort_t* data   = input.GetSignals();
+       // const UShort_t* data   = input.GetSignals();
        UShort_t        length;
        if (!NewBunch(input, start, length)) {
          errors = true;