]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MUONTRGda.cxx
RAW QA only for calibration events
[u/mrichter/AliRoot.git] / MUON / MUONTRGda.cxx
index b8a360d1d593a5f8d29fbced8c29895f17fe493b..d3c02f05026a0d857426d80966845491d1174cc8 100644 (file)
@@ -3,27 +3,20 @@ MTR DA for online
 
 Contact: Franck Manso <manso@clermont.in2p3.fr>
 Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
-Reference run: 61898, 63698 (dead channels), 63701 (noisy channels)
-Run Type:  PHYSICS (noisy channels), STANDALONE (dead channels)
+Reference run: 61898
+Run Type:  PHYSICS
 DA Type: MON
-Number of events needed: 1000 events for noisy and dead channels
-Input Files: Rawdata file (DATE format)
-Input Files from DB:
-MtgGlobalCrate-<version>.dat
-MtgRegionalCrate-<version>.dat
-MtgLocalMask-<version>.dat
-MtgLocalLut-<version>.dat
-MtgCurrent.dat
-
-Output Files: local dir (not persistent) 
-ExportedFiles.dat
+Number of events needed: 1000 events
+Input files: MtgGlobalCrate.dat MtgRegionalCrate.dat MtgLocalMask.dat MtgLocalLut.dat MtgCurrent.dat DAConfig.dat
+Output Files: ExportedFiles.dat MtgGlobalCrate.dat
+Trigger types used: PHYSICS_EVENT CALIBRATION_EVENT
 */
 
 //////////////////////////////////////////////////////////////////////////////
 // Detector Algorithm for the MUON trigger configuration.                   //
 //                                                                          //
 // Calculates masks for the global trigger input, by looking at dead        //
-// channels in calibration runs and at noisy channels in physics runs.      //
+// channels in calibration events and at noisy channels in physics events.  //
 // Transfers trigger configuration files to the File Exchange Server and    //
 // writes them (if modified) into the trigger configuration data base.      //
 //                                                                          //
@@ -34,6 +27,8 @@ ExportedFiles.dat
 //                                                                          //
 //////////////////////////////////////////////////////////////////////////////
 
+//#define OFFLINE
+
 extern "C" {
 #include <daqDA.h>
 }
@@ -50,6 +45,7 @@ extern "C" {
 
 #include "AliMpConstants.h"
 #include "AliMUONRawStreamTrigger.h"
+#include "AliMUONRawStreamTriggerHP.h"
 #include "AliMUONDarcHeader.h"
 #include "AliMUONDDLTrigger.h"
 #include "AliMUONVStore.h"
@@ -72,7 +68,7 @@ class AliDAConfig : TObject {
 public:
 
   AliDAConfig() : 
-    fDAConfigFileName("DAConfig.txt"),
+    fDAConfigFileName("DAConfig.dat"),
     fCurrentFileName("MtgCurrent.dat"), 
     fLastCurrentFileName("MtgLastCurrent.dat"), 
     fSodName(""),
@@ -108,6 +104,7 @@ public:
     fSkipEvents(0),
     fMaxEvents(65535),
     fWithWarnings(false),
+    fUseFastDecoder(false),
     fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1)
   {
     /// default constructor
@@ -122,8 +119,6 @@ public:
     fGlobalMasks   = new AliMUONGlobalCrateConfig();
   }
 
-  AliDAConfig (const AliDAConfig& cfg); // copy constructor
-  AliDAConfig& operator=(const AliDAConfig& cfg);  // assignment operator
   virtual ~AliDAConfig()
   {
     /// destructor
@@ -145,164 +140,249 @@ public:
     printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
   }
 
+     /// name of the DA configuration file from detector DB
   const Char_t* GetDAConfigFileName()    { return fDAConfigFileName.Data(); }
+     /// file with current versions of the configuration files, usually MtgCurrent.dat
   const Char_t* GetCurrentFileName()     { return fCurrentFileName.Data(); }
+     /// last known versions of the configuration files, usually MtgLastCurrent.dat
   const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
 
+     /// name of the Start-of-data field in MtgCurrent.dat
   const Char_t* GetSodName() { return fSodName.Data(); }
+     /// flag value of the Start-of-data field in MtgCurrent.dat
   Int_t GetSodFlag() const { return fSodFlag; }
 
+     /// name of the Detector Algorithm field in MtgCurrent.dat
   const Char_t* GetDAName() { return fDAName.Data(); }
+     /// flag value of the Detector Algorithm field in MtgCurrent.dat
   Int_t GetDAFlag() const { return fDAFlag; }
 
+     /// global crate configuration file name
   const Char_t* GetGlobalFileName()    { return fGlobalFileName.Data(); }
+     /// regional crate configuration file name
   const Char_t* GetRegionalFileName()  { return fRegionalFileName.Data(); }
+     /// masks for the local cards, file name
   const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
+     /// transverse momentum Look-Up-Table, file name
   const Char_t* GetLocalLutFileName()  { return fLocalLutFileName.Data(); }
+     /// signature file name
   const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
 
+     /// version of the global crate configuration in the detector DB
   Int_t GetGlobalFileVersion()    const { return fGlobalFileVersion; }
+     /// version of the regional crate configuration in the detector DB
   Int_t GetRegionalFileVersion()  const { return fRegionalFileVersion; }
+     /// version of the masks for the local cards in the detector DB
   Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; }
+     /// version of the transverse momentum Look-Up-Table in the detector DB
   Int_t GetLocalLutFileVersion()  const { return fLocalLutFileVersion; }
+     /// version of the signature file in the detector DB
   Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; }
 
+     /// last known version of the global crate configuration
   Int_t GetGlobalFileLastVersion()    const { return fGlobalFileLastVersion; }
+     /// last known version of the regional crate configuration
   Int_t GetRegionalFileLastVersion()  const { return fRegionalFileLastVersion; }
+     /// last known version of the masks for the local cards
   Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; }
+     /// last known version of the transverse momentum Look-Up-Table
   Int_t GetLocalLutFileLastVersion()  const { return fLocalLutFileLastVersion; }
 
+     /// store for the masks for the local cards (own)
   AliMUONVStore*                GetLocalMasks()    const { return fLocalMasks; }
+     /// configuration object for the regional crate (own)
   AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; }
+     /// configuration object for the global crate (own)
   AliMUONGlobalCrateConfig*     GetGlobalMasks()   const { return fGlobalMasks; }
 
+     /// read/write configurations, masks and LUT to/from online files (own)
   AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; }
 
+     /// number of accumulated PHYSICS events for noisy channels analysis
   Int_t GetEventsN() const { return fEventsN; }
+     /// number of accumulated CALIBRATION events for dead channels analysis
   Int_t GetEventsD() const { return fEventsD; }
 
+     /// print verbosity of the DA
   Int_t GetPrintLevel() const { return fPrintLevel; }
 
+     /// select PHYSICS events for noisy channels analysis
   Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
+     /// select CALIBRATION events for dead channels analysis
   Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
 
+     /// threshold for noisy inputs (fraction of events)
   Float_t GetThrN() const { return fThrN; }
+     /// threshold for dead inputs (fraction of events)
   Float_t GetThrD() const { return fThrD; }
 
+     /// minumum nr of events for rate calculation
   Int_t GetMinEvents()  const { return fMinEvents; }
+     /// maximum number of events to analyze
   Int_t GetMaxEvents()  const { return fMaxEvents; }
+     /// number of events to skip from start
   Int_t GetSkipEvents() const { return fSkipEvents; }
 
+     /// show warnings from the raw data decoder
   Bool_t WithWarnings() const { return fWithWarnings; }
+     /// use the high-performance (HP) decoder
+  Bool_t UseFastDecoder() const { return fUseFastDecoder; }
 
+     /// number of global input words
   Int_t GetGlobalInputs()      const { return kGlobalInputs; }
+    /// length in bits of a global input word
   Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
 
+     /// get accumulated values for bit "ib" from global input word "ii", PHYSICS events
   Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
+     /// get accumulated values for bit "ib" from global input word "ii", CALIBRATION events
   Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
 
+     /// set the name of the Start-of-data field in MtgCurrent.dat
   void SetSodName(Char_t *name) { fSodName = TString(name); }
+     /// set the flag value of the Start-of-data field in MtgCurrent.dat
   void SetSodFlag(Int_t flag)   { fSodFlag = flag; }
 
+     /// set the name of the Detector Algorithm field in MtgCurrent.dat
   void SetDAName(Char_t *name) { fDAName = TString(name); }
+     /// set the flag value of the Detector Algorithm field in MtgCurrent.dat
   void SetDAFlag(Int_t flag)   { fDAFlag = flag; }
 
+     /// set the global crate configuration file name
   void SetGlobalFileName(const Char_t *name)    { fGlobalFileName = TString(name); }
+     /// set the regional crate configuration file name
   void SetRegionalFileName(const Char_t *name)  { fRegionalFileName = TString(name); }
+     /// set the masks for the local cards, file name
   void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
+     /// set the transverse momentum Look-Up-Table, file name
   void SetLocalLutFileName(const Char_t *name)  { fLocalLutFileName = TString(name); }
+     /// set the signature file name
   void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
 
+     /// set the version of the global crate configuration in the detector DB
   void SetGlobalFileVersion(Int_t ver)    { fGlobalFileVersion = ver; }
+     /// set the version of the regional crate configuration in the detector DB
   void SetRegionalFileVersion(Int_t ver)  { fRegionalFileVersion = ver; }
+     /// set the version of the masks for the local cards in the detector DB
   void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; }
+     /// set the version of the transverse momentum Look-Up-Table in the detector DB
   void SetLocalLutFileVersion(Int_t ver)  { fLocalLutFileVersion = ver; }
+     /// set the version of the signature file in the detector DB
   void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; }
 
+     /// set the last known version of the global crate configuration
   void SetGlobalFileLastVersion(Int_t ver)    { fGlobalFileLastVersion = ver; }
+     /// set the last known version of the regional crate configuration
   void SetRegionalFileLastVersion(Int_t ver)  { fRegionalFileLastVersion = ver; }
+     /// set the last known version of the masks for the local cards
   void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; }
+     /// set the last known version of the transverse momentum Look-Up-Table
   void SetLocalLutFileLastVersion(Int_t ver)  { fLocalLutFileLastVersion = ver; }
 
+     /// increment the number of selected PHYSICS events
   void IncNoiseEvent() { fEventsN++; }
+     /// increment the number of selected CALIBRATION events
   void IncDeadcEvent() { fEventsD++; }
 
+     /// count the value of the bit "ib" of global input word "ii" (PHYSICS events)
   void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
+     /// count the value of the bit "ib" of global input word "ii" (CALIBRATION events)
   void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
 
+     /// set the print verbosity level of the DA
   void SetPrintLevel(Int_t level) { fPrintLevel = level; }
 
+     /// select PHYSICS events for noisy channels analysis
   void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
+     /// select CALIBRATION events for dead channels analysis
   void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
 
+     /// set the threshold for noisy inputs (fraction of events)
   void SetThrN(Float_t val) { fThrN = val; }
+     /// set the threshold for dead inputs (fraction of events)
   void SetThrD(Float_t val) { fThrD = val; }
 
+     /// set the minumum nr of events for rate calculation
   void SetMinEvents(Int_t val)  { fMinEvents = val; }
+     /// set the maximum number of events to analyze
   void SetMaxEvents(Int_t val)  { fMaxEvents = val; }
+     /// set the number of events to skip from start
   void SetSkipEvents(Int_t val) { fSkipEvents = val; }
 
+     /// set/unset to show warnings from the raw data decoder
   void SetWithWarnings() { fWithWarnings = true; }
+     /// set/unset the use of the high-performance (HP) decoder
+  void SetUseFastDecoder() { fUseFastDecoder = true; }
 
+    /// increment version of the global crate configuration file
   void IncGlobalFileVersion() { fGlobalFileVersion++; }
+    /// count skipped events
   void DecSkipEvents() { fSkipEvents--; }
 
 private:
 
-  const TString fDAConfigFileName;
-  const TString fCurrentFileName;
-  const TString fLastCurrentFileName;
+  /// copy constructor, not implemented
+  AliDAConfig (const AliDAConfig& cfg);
+  /// assignment operator, not implemented
+  AliDAConfig& operator=(const AliDAConfig& cfg);
+
+  const TString fDAConfigFileName;    //!< name of the DA configuration file from detector DB
+  const TString fCurrentFileName;     //!< usually MtgCurrent.dat
+  const TString fLastCurrentFileName; //!< usually MtgLastCurrent.dat
 
-  TString fSodName;
-  Int_t   fSodFlag;
+  TString fSodName; //!< name of the Start-of-data field in MtgCurrent.dat
+  Int_t   fSodFlag; //!< flag value of the Start-of-data field in MtgCurrent.dat
 
-  TString fDAName;
-  Int_t   fDAFlag;
+  TString fDAName;  //!< name of the Detector Algorithm field in MtgCurrent.dat 
+  Int_t   fDAFlag;  //!< flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled)
 
-  TString fGlobalFileName;
-  TString fRegionalFileName;
-  TString fLocalMaskFileName;
-  TString fLocalLutFileName;
-  TString fSignatureFileName;
+  TString fGlobalFileName;    //!< global crate configuration, file name
+  TString fRegionalFileName;  //!< regional crate configuration, file name
+  TString fLocalMaskFileName; //!< masks for the local cards, file name
+  TString fLocalLutFileName;  //!< transverse momentum Look-Up-Table, file name
+  TString fSignatureFileName; //!< signature file name
 
-  Int_t   fGlobalFileVersion;
-  Int_t   fRegionalFileVersion;
-  Int_t   fLocalMaskFileVersion;
-  Int_t   fLocalLutFileVersion;
-  Int_t   fSignatureFileVersion;
+  Int_t   fGlobalFileVersion;    //!< version of the global crate configuration in the detector DB
+  Int_t   fRegionalFileVersion;  //!< version of the regional crate configuration in the detector DB
+  Int_t   fLocalMaskFileVersion; //!< version of the masks for the local cards in the detector DB
+  Int_t   fLocalLutFileVersion;  //!< version of the transverse momentum Look-Up-Table in the detector DB
+  Int_t   fSignatureFileVersion; //!< version of the signature file in the detector DB
   
-  Int_t   fGlobalFileLastVersion;
-  Int_t   fRegionalFileLastVersion;
-  Int_t   fLocalMaskFileLastVersion;
-  Int_t   fLocalLutFileLastVersion;
+  Int_t   fGlobalFileLastVersion;    //!< last known version of the global crate configuration
+  Int_t   fRegionalFileLastVersion;  //!< last known version of the regional crate configuration
+  Int_t   fLocalMaskFileLastVersion; //!< last known version of the masks for the local cards
+  Int_t   fLocalLutFileLastVersion;  //!< last known version of the transverse momentum Look-Up-Table
 
-  Int_t   fEventsN;
-  Int_t   fEventsD;
+  Int_t   fEventsN; //!< number of accumulated PHYSICS events
+  Int_t   fEventsD; //!< number of accumulated CALIBRATION events
 
-  Int_t   fPrintLevel;
+  Int_t   fPrintLevel;  //!< print verbosity of the DA
 
-  AliMUONVStore*                fLocalMasks;
-  AliMUONRegionalTriggerConfig* fRegionalMasks;
-  AliMUONGlobalCrateConfig*     fGlobalMasks;    
+  AliMUONVStore*                fLocalMasks;    //!< store for the masks for the local cards
+  AliMUONRegionalTriggerConfig* fRegionalMasks; //!< configuration object for the regional crate
+  AliMUONGlobalCrateConfig*     fGlobalMasks;   //!< configuration object for the global crate
 
-  AliMUONTriggerIO *fTriggerIO;
+  AliMUONTriggerIO *fTriggerIO;  //!< read/write masks and LUT to/from online files
 
-  Bool_t fAlgoNoisyInput;
-  Bool_t fAlgoDeadcInput;
+  Bool_t fAlgoNoisyInput; //!< select PHYSICS events for noisy channels analysis
+  Bool_t fAlgoDeadcInput; //!< select CALIBRATION events for dead channels analysis
 
-  Float_t fThrN;
-  Float_t fThrD;
-  Int_t   fMinEvents;
-  Int_t   fSkipEvents;
-  Int_t   fMaxEvents;
-  Bool_t  fWithWarnings;
+  Float_t fThrN;           //!< threshold for noisy inputs (fraction of events)
+  Float_t fThrD;           //!< threshold for dead inputs (fraction of events)
+  Int_t   fMinEvents;      //!< minumum nr of events for rate calculation
+  Int_t   fSkipEvents;     //!< number of events to skip from start
+  Int_t   fMaxEvents;      //!< maximum number of events to analyze
+  Bool_t  fWithWarnings;   //!< show warnings from the raw data decoder
+  Bool_t  fUseFastDecoder; //!< use the high-performance (HP) decoder
 
-  const Int_t fNLocalBoard;
+  const Int_t fNLocalBoard; //!< number of local boards
 
-  enum { kGlobalInputs = 4, kGlobalInputLength = 32 };
+  enum { kGlobalInputs = 4,         //!< number of global input words
+        kGlobalInputLength = 32    //!< length in bits of a global input word
+  };
 
-  Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength];
-  Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength];
+  Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (PHYSICS events)
+  Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (CALIBRATION events)
 
 };
 
@@ -366,6 +446,12 @@ Bool_t ReadDAConfig(AliDAConfig& cfg)
     tmp = tmp(0,pos);
     if (tmp.Atoi() != 0) cfg.SetWithWarnings();
     
+    in.getline(line,80);  
+    tmp = line;
+    pos = tmp.First(" ");
+    tmp = tmp(0,pos);
+    if (tmp.Atoi() != 0) cfg.SetUseFastDecoder();
+    
     return true;
 
 }
@@ -528,16 +614,16 @@ Bool_t ExportFiles(AliDAConfig& cfg)
     // setenv DATE_ROLE_NAME
     // setenv DATE_DETECTOR_CODE
 
-    // offline:
-    //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
-
-    // offline: use a dummy FES (local directory)
-    //gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
+#ifdef OFFLINE
+    gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
+    gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
+#endif
 
     // update files
     Int_t status = 0;
 
     Bool_t modified = false;
+    Bool_t globalExported = false;
 
     ofstream out;
     TString fileExp("ExportedFiles.dat");
@@ -556,21 +642,10 @@ Bool_t ExportFiles(AliDAConfig& cfg)
       initFES = true;
     if (initFES) printf("Copy all configuration files to the FES.\n");
 
-    file = cfg.GetGlobalFileName();
-    if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || initFES) {
-      status = daqDA_FES_storeFile(file.Data(), file.Data());
-      if (status) {
-       printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
-       return false;
-      }
-      if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
-      out << cfg.GetGlobalFileName() << endl;
-    }
-
     file = cfg.GetLocalMaskFileName();  
     if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
       modified = true;
-      status = daqDA_FES_storeFile(file.Data(), file.Data());
+      status = daqDA_FES_storeFile(file.Data(), "LOCAL");
       if (status) {
        printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
        return false;
@@ -582,7 +657,7 @@ Bool_t ExportFiles(AliDAConfig& cfg)
     file = cfg.GetLocalLutFileName();
     if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
       modified = true;
-      status = daqDA_FES_storeFile(file.Data(), file.Data());
+      status = daqDA_FES_storeFile(file.Data(), "LUT");
       if (status) {
        printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
        return false;
@@ -592,22 +667,47 @@ Bool_t ExportFiles(AliDAConfig& cfg)
 
     }
 
-    // exported regional file whenever mask or/and Lut are modified
+    file = cfg.GetGlobalFileName();
+    if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) {
+      modified = true;
+      globalExported = true;
+      status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
+      if (status) {
+       printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
+       return false;
+      }
+      if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
+      out << cfg.GetGlobalFileName() << endl;
+    }
+
     file = cfg.GetRegionalFileName();
     if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
-      status = daqDA_FES_storeFile(file.Data(), file.Data());
+      status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
       if (status) {
        printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
        return false;
       }
       if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
       out << cfg.GetRegionalFileName() << endl;
+
+      // needed for the initialisation of the mapping
+      if (!globalExported) {
+       file = cfg.GetGlobalFileName();
+       status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
+       if (status) {
+         printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
+         return false;
+       }
+       if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
+       out << cfg.GetGlobalFileName() << endl;
+      }
+
     }
 
     out.close();
 
     // export Exported file to FES anyway
-    status = daqDA_FES_storeFile(fileExp.Data(), fileExp.Data());
+    status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
     if (status) {
       printf("Failed to export file: %s\n", fileExp.Data());
       return false;
@@ -632,8 +732,9 @@ Bool_t ImportFiles(AliDAConfig& cfg)
 
     Int_t status = 0;
 
-    // offline:
-    //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+#ifdef OFFLINE
+    gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+#endif
 
     status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
     if (status) {
@@ -642,13 +743,13 @@ Bool_t ImportFiles(AliDAConfig& cfg)
     }
  
     ReadDAConfig(cfg);
-
+    
     status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
     if (status) {
       printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
       return false;
     }
+    
     ReadFileNames(cfg);
 
     status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
@@ -723,8 +824,9 @@ void UpdateGlobalMasks(AliDAConfig& cfg)
 {
   /// update the global masks
   
-  // offline:
-  //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+#ifdef OFFLINE
+  gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+#endif
 
   Float_t rateN = 0.0, rateD = 0.0;
   UInt_t gmask[4], omask;
@@ -752,7 +854,8 @@ void UpdateGlobalMasks(AliDAConfig& cfg)
       if (!withEvN && !withEvD) {
        // - copy the bit from the old mask
        gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
-       printf("Mask not changed (just copy the old values)\n");
+       if (cfg.GetPrintLevel()) 
+         printf("Mask not changed (just copy the old values)\n");
       }
       if (!withEvN && withEvD) {
        if (!deadc) {
@@ -764,7 +867,8 @@ void UpdateGlobalMasks(AliDAConfig& cfg)
        } else {
          // - create a new mask, set the bit to 0
          gmask[ii] |= 0x0 << ib;
-         printf("Found dead  channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
+         if (cfg.GetPrintLevel()) 
+           printf("Found dead  channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
        }
       }
       if (withEvN && !withEvD) {
@@ -777,7 +881,8 @@ void UpdateGlobalMasks(AliDAConfig& cfg)
        } else {
          // - create a new mask, set the bit to 0
          gmask[ii] |= 0x0 << ib;
-         printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
+         if (cfg.GetPrintLevel()) 
+           printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
        }
       }
       if (withEvN && withEvD) {
@@ -790,10 +895,12 @@ void UpdateGlobalMasks(AliDAConfig& cfg)
        } else {
          // - create a new mask, set the bit to 0
          gmask[ii] |= 0x0 << ib;
-         if (noise)
-           printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
-         if (deadc)
-           printf("Found dead  channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
+         if (cfg.GetPrintLevel()) {
+           if (noise)
+             printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
+           if (deadc)
+             printf("Found dead  channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
+         }
        }
       }
     }
@@ -866,14 +973,17 @@ int main(Int_t argc, Char_t **argv)
 
     // decoding the events
   
-    Int_t status;
+    Int_t status = 0;
     Int_t nDateEvents = 0;
 
     void* event;
 
     // containers
+    // old decoder
     AliMUONDDLTrigger*       ddlTrigger  = 0x0;
     AliMUONDarcHeader*       darcHeader  = 0x0;
+    // new (fast) decoder
+    const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
 
     TStopwatch timers;
 
@@ -888,22 +998,36 @@ int main(Int_t argc, Char_t **argv)
     
     ReadMaskFiles(cfg);
 
-    // offline: the run number extracted from the file name
-    //TString tmp(inputFile);
-    //Int_t pos = tmp.First("daq");
-    //tmp = tmp(pos+3,5);
-    //gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
-    //gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
+#ifdef OFFLINE
+    // the run number extracted from the file name
+    TString tmp(inputFile);
+    Int_t pos = tmp.First("daq");
+    tmp = tmp(pos+3,5);
+    gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
+    gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
+#endif
 
     if(!ExportFiles(cfg)) {
       printf("ExportFiles failed\n");
       return -1;
     }
 
+    if (!cfg.GetDAFlag()) {
+
+      cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
+      cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
+      
+      printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
+
+      return status;
+
+    }
+
     // FET is triggered by CTP
+    Bool_t modeFET3 = kTRUE;
     if (GetFetMode(cfg) != 3) {
-      printf("FET is not in mode 3\n");
-      return -1;
+      printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
+      modeFET3 = kFALSE;
     }
 
     // All 5 global cards are controlled by the Mts proxy
@@ -941,7 +1065,7 @@ int main(Int_t argc, Char_t **argv)
 
     cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
 
-    UInt_t *globalInput;
+    UInt_t *globalInput = new UInt_t[4];
     Bool_t doUpdate = false;
     Int_t runNumber = 0;
     Int_t nEvents = 0;
@@ -949,9 +1073,10 @@ int main(Int_t argc, Char_t **argv)
     while(1) 
     {
       if (nEvents >= cfg.GetMaxEvents()) break;
-      if (nEvents && nEvents % 100 == 0)       
+      if (cfg.GetPrintLevel()) {
+       if (nEvents && nEvents % 1000 == 0)     
          cout<<"Cumulated events " << nEvents << endl;
-
+      }
       // check shutdown condition 
       if (daqDA_checkShutdown()) 
          break;
@@ -987,7 +1112,7 @@ int main(Int_t argc, Char_t **argv)
        cfg.SetAlgoNoisyInput(true);
        doUpdate = true;
        cfg.IncNoiseEvent();
-      } else if (eventType == CALIBRATION_EVENT) {
+      } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
        cfg.SetAlgoDeadcInput(true);
        doUpdate = true;
        cfg.IncDeadcEvent();
@@ -996,10 +1121,16 @@ int main(Int_t argc, Char_t **argv)
       }
       
       nEvents++;
-      if (cfg.GetPrintLevel()) printf("\nEvent # %d\n",nEvents);
+      if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
 
       // decoding MUON payload
-      AliMUONRawStreamTrigger* rawStream  = new AliMUONRawStreamTrigger(rawReader);
+      AliMUONVRawStreamTrigger   *rawStream   = 0x0;
+      if (cfg.UseFastDecoder()) {
+       rawStream = new AliMUONRawStreamTriggerHP(rawReader);
+      } else {
+       rawStream = new AliMUONRawStreamTrigger(rawReader);
+      }
+
       // ... without warnings from the decoder !!!
       if (!cfg.WithWarnings())
        rawStream->DisableWarnings();
@@ -1007,14 +1138,20 @@ int main(Int_t argc, Char_t **argv)
       // loops over DDL 
       while((status = rawStream->NextDDL())) {
 
-       if (cfg.GetPrintLevel()) printf("iDDL %d\n", rawStream->GetDDL());
-
-       ddlTrigger = rawStream->GetDDLTrigger();
-       darcHeader = ddlTrigger->GetDarcHeader();
+       if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
 
        if (rawStream->GetDDL() == 0) {
-         if (cfg.GetPrintLevel()) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
-         globalInput = darcHeader->GetGlobalInput();
+         if (cfg.UseFastDecoder()) {
+           darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
+           if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
+           for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) 
+             globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
+         } else {
+           ddlTrigger = rawStream->GetDDLTrigger();
+           darcHeader = ddlTrigger->GetDarcHeader();
+           if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
+           globalInput = darcHeader->GetGlobalInput();
+         }
          StoreGlobalInput(cfg,globalInput);
        }
 
@@ -1026,28 +1163,28 @@ int main(Int_t argc, Char_t **argv)
     } // while (1)
 
     // update configuration files ifrequested event types were found
-    if (doUpdate && cfg.GetDAFlag()
+    if (doUpdate) 
       UpdateGlobalMasks(cfg);
 
     timers.Stop();
 
-    cout << "MUONTRGda: DA enable: \t" << cfg.GetDAFlag() << endl;
-    cout << "MUONTRGda: Run number: \t" << runNumber << endl;
-    cout << "MUONTRGda: Nb of DATE events: \t" << nDateEvents << endl;
-    cout << "MUONTRGda: Nb of events used: \t" << nEvents << endl;
-    cout << "MUONTRGda: Nb of events used (noise): \t" << cfg.GetEventsN() << endl;
-    cout << "MUONTRGda: Nb of events used (deadc): \t" << cfg.GetEventsD() << endl;
-    cout << "MUONTRGda: Minumum nr of events for rate calculation: \t" << cfg.GetMinEvents() << endl;
-    cout << "MUONTRGda: Maximum nr of analyzed events: \t" << cfg.GetMaxEvents() << endl;
-    cout << "MUONTRGda: Skip events from start: \t" << cfg.GetSkipEvents() << endl;
-    cout << "MUONTRGda: Threshold for noisy inputs: \t" << 100*cfg.GetThrN() << "%" << endl;
-    cout << "MUONTRGda: Threshold for dead inputs: \t" << 100*cfg.GetThrD() << "%" << endl;
-    cout << "MUONTRGda: Print level: \t" << cfg.GetPrintLevel() << endl;
-    cout << "MUONTRGda: Show decoder warnings: \t" << cfg.WithWarnings() << endl;
+    cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
+    cout << "MUONTRGda: Run number: " << runNumber << endl;
+    cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl;
+    cout << "MUONTRGda: Nb of events used: " << nEvents << endl;
+    cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
+    cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
+    cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
+    cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
+    cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl;
+    cout << "MUONTRGda: Threshold for noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
+    cout << "MUONTRGda: Threshold for dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
+    cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
+    cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl;
+    cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
 
     printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
 
-
     return status;
 
 }