Fixes for generating raw data from digits. Now
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 26 Aug 2011 12:42:58 +0000 (12:42 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 26 Aug 2011 12:42:58 +0000 (12:42 +0000)
write proper information to RCU trailer.

FMD/AliFMDRawReader.cxx
FMD/AliFMDRawWriter.cxx
FMD/AliFMDRawWriter.h

index 8f85d15..ec36652 100644 (file)
@@ -288,8 +288,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;
 }
index dec8f4e..d7676da 100644 (file)
@@ -176,6 +176,7 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
 
   AliFMDParameters* pars = AliFMDParameters::Instance();
   UShort_t threshold    = 0;
+  UShort_t factor       = 0;
   UInt_t   prevddl      = 0xFFFF;
   UInt_t   prevaddr     = 0xFFF;
   // UShort_t prevStrip    = 0;
@@ -217,10 +218,11 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
     threshold  = pars->GetZeroSuppression(det, ring, sector, strip);
     sampleRate = pars->GetSampleRate(det, ring, sector, strip);
     preSamples = pars->GetPreSamples(det, ring, sector, strip);
+    factor     = pars->GetPedestalFactor();
 
     if (det != oldDet) {
       AliFMDDebug(5, ("Got new detector: %d (was %d)", det, oldDet));
-      oldDet = det;
+      oldDet = det;      
     }
     AliFMDDebug(15, ("Sample rate is %d", sampleRate));
     
@@ -259,8 +261,8 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
          // When the first argument is false, we write the real
          // header. 
          AliFMDDebug(15, ("Closing output"));
-         /* nBits += */ altro->Flush();
-         /* nBits += */ altro->WriteDataHeader(kFALSE, kFALSE);
+         WriteRCUTrailer(altro, prevddl, threshold > 0, factor, sampleRate); 
+    
          delete altro;
          altro = 0;
        }
@@ -306,8 +308,7 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
     ZeroSuppress(data.fArray, nWords, peds.fArray, noise.fArray, threshold);
     if (nWords > 0) 
       /* nBits += */ altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
-    /* nBits += */ altro->Flush();
-    /* nBits += */ altro->WriteDataHeader(kFALSE, kFALSE);
+    WriteRCUTrailer(altro, prevddl, threshold > 0, factor, sampleRate); 
     delete altro;
   }
   AliFMDDebug(5, ("Wrote a total of %d words in %ld bytes for %d counts", 
@@ -316,6 +317,39 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
 }
 //____________________________________________________________________
 void
+AliFMDRawWriter::WriteRCUTrailer(AliAltroBufferV3* altro,
+                                UInt_t ddl,
+                                Bool_t zs,
+                                UShort_t factor,
+                                UShort_t rate) const
+{
+  // Flush and write the data header
+  altro->Flush();
+  altro->WriteDataHeader(kFALSE, kFALSE);
+    
+  // Set parameters in RCU trailer. 
+  // Zero-suppression flag
+  altro->SetZeroSupp(zs); // bool
+  // WARNING: We store the noise factor in the 2nd baseline
+  // filters excluded post samples, since we'll never use that
+  // mode. 
+  altro->SetNPostsamples(factor); // 
+  // WARNING: We store the sample rate in the number of pre-trigger
+  // samples, since we'll never use that mode.
+  altro->SetNPretriggerSamples(rate); // fSampleRate[ddl]
+  // Active front-end cars 
+  altro->SetActiveFECsA((ddl == 0 ? 0x1 : 0x3));
+  altro->SetActiveFECsB((ddl == 0 ? 0x1 : 0x3));
+
+  // Calculate number of samples 
+  altro->SetNSamplesPerCh(rate * 128);
+  AliDebug(5,Form("Writing RCU trailer @ DDL %d w/zs=%d, factor=%d, rate=%d",
+                 ddl, zs > 0, factor, rate));
+  altro->WriteRCUTrailer(ddl);
+}
+
+//____________________________________________________________________
+void
 AliFMDRawWriter::ZeroSuppress(Int_t*& data, Int_t nWords, 
                              const Float_t* peds, 
                              const Float_t* noise, UShort_t threshold) const
index e2c2947..b998f6d 100644 (file)
@@ -26,6 +26,7 @@
 //____________________________________________________________________
 class AliFMD;
 class AliAltroBuffer;
+class AliAltroBufferV3;
 class TArrayI;
 class TArrayF;
 class TClonesArray;
@@ -75,6 +76,11 @@ protected:
       fThreshold(o.fThreshold)
   {}
   AliFMDRawWriter& operator=(const AliFMDRawWriter&) { return *this; }
+  void WriteRCUTrailer(AliAltroBufferV3* altro,
+                      UInt_t ddl,
+                      Bool_t zs,
+                      UShort_t factor,
+                      UShort_t rate) const;
   AliFMD*       fFMD;              //! Pointer to detector description 
   UShort_t      fSampleRate;       // The sample rate (0 -> inferred from data)
   UShort_t      fChannelsPerAltro; // Number of pre-amp. channels/adc channel