]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDRawWriter.cxx
C0OB0-D-NOPF-ALLNOTRD trigger added to the cosmic list.
[u/mrichter/AliRoot.git] / FMD / AliFMDRawWriter.cxx
index 4b3c448f085d607a29a789869d9a67bc817eb289..623e872ee24b08cee293049289fac104a1c21261 100644 (file)
@@ -37,9 +37,9 @@
 // that format.  
 //
 // #include <AliLog.h>         // ALILOG_H
-#include "AliFMDDebug.h" // Better debug macros
+#include "AliFMDDebug.h"        // Better debug macros
 #include <AliLoader.h>         // ALILOADER_H
-#include <AliAltroBuffer.h>     // ALIALTROBUFFER_H
+#include <AliAltroBufferV3.h>   // ALIALTROBUFFER_H
 #include "AliFMD.h"            // ALIFMD_H
 #include "AliFMDParameters.h"  // ALIFMDPARAMETERS_H
 #include "AliFMDDigit.h"       // ALIFMDDIGIT_H
@@ -140,14 +140,15 @@ AliFMDRawWriter::Exec(Option_t*)
     return;
   }
   
-  TClonesArray* digits = new TClonesArray("AliFMDDigit", 1000);
   fFMD->SetTreeAddress();
-  TBranch* digitBranch = digitTree->GetBranch(fFMD->GetName());
-  if (!digitBranch) {
-    AliError(Form("no branch for %s", fFMD->GetName()));
-    return;
-  }
-  digitBranch->SetAddress(&digits);
+  TClonesArray* digits = fFMD->Digits(); 
+  // new TClonesArray("AliFMDDigit", 1000);
+  // TBranch* digitBranch = digitTree->GetBranch(fFMD->GetName());
+  // if (!digitBranch) {
+  //   AliError(Form("no branch for %s", fFMD->GetName()));
+  //   return;
+  // }
+  // digitBranch->SetAddress(&digits);
   
   Int_t nEvents = Int_t(digitTree->GetEntries());
   AliFMDDebug(5, ("Got a total of %5d events from tree", nEvents));
@@ -159,16 +160,17 @@ AliFMDRawWriter::Exec(Option_t*)
     WriteDigits(digits);
   }
   loader->UnloadDigits();
+  //delete digits;
 }
 
 #if 1
 //____________________________________________________________________
-void
+Long_t
 AliFMDRawWriter::WriteDigits(TClonesArray* digits)
 {
   // WRite an array of digits to disk file 
   Int_t nDigits = digits->GetEntries();
-  if (nDigits < 1) return;
+  if (nDigits < 1) return 0;
   AliFMDDebug(5, ("Got a total of %5d digits from tree", nDigits));
 
   AliFMDParameters* pars = AliFMDParameters::Instance();
@@ -189,11 +191,12 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
   TArrayF noise(pars->GetChannelsPerAltro() * 8);
 
   // The Altro buffer 
-  AliAltroBuffer* altro = 0;
-  
-  Int_t totalWords = 0;
-  Int_t nCounts    = 0;
+  AliAltroBufferV3* altro = 0;
   
+  Int_t  totalWords = 0;
+  Int_t  nCounts    = 0;
+  Long_t nBits      = 0;
+
   // Loop over the digits in the event.  Note, that we assume the
   // the digits are in order in the branch.   If they were not, we'd
   // have to cache all channels before we could write the data to
@@ -206,9 +209,7 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
     Char_t   ring   = digit->Ring();
     UShort_t sector = digit->Sector();
     UShort_t strip  = digit->Strip();
-    UInt_t   ddl;
-    UInt_t   addr;  
-    UShort_t time;
+    UShort_t ddl, addr, time;
 
     AliFMDDebug(15, ("Processing digit # %5d FMD%d%c[%2d,%3d]", 
                    i, det, ring, sector, strip));
@@ -241,7 +242,8 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
                         time, prevaddr, nWords));
        totalWords += nWords;
        ZeroSuppress(data.fArray, nWords, peds.fArray, noise.fArray, threshold);
-       if (altro) altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
+       if (altro) 
+         /*nBits+=*/altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
        data.Reset(-1);
        peds.Reset(0);
        noise.Reset(0);
@@ -256,18 +258,18 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
          // When the first argument is false, we write the real
          // header. 
          AliFMDDebug(15, ("Closing output"));
-         altro->Flush();
-         altro->WriteDataHeader(kFALSE, kFALSE);
+         /* nBits += */ altro->Flush();
+         /* nBits += */ altro->WriteDataHeader(kFALSE, kFALSE);
          delete altro;
          altro = 0;
        }
        prevddl = ddl;
        // Need to open a new DDL! 
-       TString filename(AliDAQ::DdlFileName(fFMD->GetName(),  ddl));
+       TString filename(AliDAQ::DdlFileName(fFMD ? fFMD->GetName() : "FMD",  ddl));
        AliFMDDebug(5, ("New altro buffer with DDL file %s", filename.Data()));
        // Create a new altro buffer - a `1' as the second argument
        // means `write mode' 
-       altro = new AliAltroBuffer(filename.Data());
+       altro = new AliAltroBufferV3(filename.Data());
        altro->SetMapping(pars->GetAltroMap());      
        // Write a dummy (first argument is true) header to the DDL
        // file - later on, when we close the file, we write the real
@@ -301,13 +303,15 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
   // already 
   if (altro) {
     ZeroSuppress(data.fArray, nWords, peds.fArray, noise.fArray, threshold);
-    if (nWords > 0) altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
-    altro->Flush();
-    altro->WriteDataHeader(kFALSE, kFALSE);
+    if (nWords > 0) 
+      /* nBits += */ altro->WriteChannel(prevaddr,nWords,data.fArray,threshold);
+    /* nBits += */ altro->Flush();
+    /* nBits += */ altro->WriteDataHeader(kFALSE, kFALSE);
     delete altro;
   }
-  AliFMDDebug(5, ("Wrote a total of %d words for %d counts", 
-                 nWords, nCounts));
+  AliFMDDebug(5, ("Wrote a total of %d words in %ld bytes for %d counts", 
+                 nWords, nBits / 8, nCounts));
+  return nBits;
 }
 //____________________________________________________________________
 void
@@ -465,3 +469,4 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
 // 
 // EOF
 //
+