]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawWriter.cxx
ALIROOT-5486 Add method to get trigger deviation sign
[u/mrichter/AliRoot.git] / FMD / AliFMDRawWriter.cxx
index 623e872ee24b08cee293049289fac104a1c21261..1bd500224c4ee535afd79a6d0cc0f4491125f277 100644 (file)
@@ -50,6 +50,7 @@
 #include <TArrayF.h>           // ROOT_TArrayI
 #include <TArrayC.h>           // ROOT_TArrayI
 #include <TClonesArray.h>      // ROOT_TClonesArray
+#include <TTree.h>
 // #include <fstream>
 #include "AliDAQ.h"
 
@@ -175,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;
@@ -216,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     = UShort_t(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));
     
@@ -258,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;
        }
@@ -305,14 +308,47 @@ 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", 
                  nWords, nBits / 8, nCounts));
   return nBits;
 }
+//____________________________________________________________________
+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); // 
+  altro->SetNNonZSPostsamples(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, 
@@ -381,6 +417,9 @@ AliFMDRawWriter::ZeroSuppress(Int_t*& data, Int_t nWords,
 void
 AliFMDRawWriter::WriteDigits(TClonesArray* digits)
 {
+  // 
+  // Write digits to file 
+  //
   Int_t nDigits = digits->GetEntries();
   if (nDigits < 1) return;