]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPayloadTrigger.cxx
Updated READMEmapping
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTrigger.cxx
index 0c780203d50973c7e26f47e7e9d7bf93a2fc98c2..5712694d8f3e0ecd92214dc10827e7cda26c14ca 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+// $Id$
 
-///////////////////////////////////////////////////////////////////////////////
-///
+//-----------------------------------------------------------------------------
+/// \class AliMUONPayloadTrigger
 /// Class Payload
 ///
 /// Decodes rawdata from buffer and stores in TClonesArray.
 /// 
 /// First version implement for Trigger
 ///
-///////////////////////////////////////////////////////////////////////////////
+/// \author Christian Finck
+//-----------------------------------------------------------------------------
 
 #include "AliMUONPayloadTrigger.h"
 
-#include "AliRawReader.h"
-#include "AliRawDataHeader.h"
-
-#ifndef DATE_SYS
-#include "AliLog.h"
-#endif
-
 #include "AliMUONDarcHeader.h"
 #include "AliMUONRegHeader.h"
 #include "AliMUONLocalStruct.h"
 #include "AliMUONDDLTrigger.h"
+#include "AliMUONLogger.h"
 
+#include "AliLog.h"
+
+/// \cond CLASSIMP
 ClassImp(AliMUONPayloadTrigger)
+/// \endcond
 
 AliMUONPayloadTrigger::AliMUONPayloadTrigger()
   : TObject(),
@@ -46,52 +46,69 @@ AliMUONPayloadTrigger::AliMUONPayloadTrigger()
     fMaxLoc(16),
     fDDLTrigger(new AliMUONDDLTrigger()),
     fRegHeader(new AliMUONRegHeader()), 
-    fLocalStruct(new AliMUONLocalStruct())
+    fLocalStruct(new AliMUONLocalStruct()),
+    fLog(new AliMUONLogger(1000)),
+    fDarcEoWErrors(0),
+    fGlobalEoWErrors(0),
+    fRegEoWErrors(0),
+    fLocalEoWErrors(0),
+    fWarnings(kTRUE),
+    fNofRegSet(kFALSE)
 {
-  //
-  // create an object to read MUON raw digits
-  // Default ctor for monitoring purposes
-  //
+  ///
+  /// create an object to read MUON raw digits
+  /// Default ctor for monitoring purposes
+  ///
 
 }
 
 //___________________________________
 AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
 {
-  //
-  // clean up
-  //
+  ///
+  /// clean up
+  ///
   delete fDDLTrigger;
   delete fLocalStruct;
   delete fRegHeader;
+  delete fLog;
 }
 
 
 //______________________________________________________
-Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
+Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer, Bool_t scalerEvent)
 {
-  // decode trigger DDL
-  // store only non-empty structures (TrigY ==0)
+  /// decode trigger DDL
+  /// store only notified cards
 
  // reading DDL for trigger
 
   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
 
-  static Int_t kGlobalHeaderSize = darcHeader->GetGlobalHeaderLength(); 
-  static Int_t kDarcHeaderSize   = darcHeader->GetDarcHeaderLength(); 
-  static Int_t kRegHeaderSize    = fRegHeader->GetHeaderLength();
+  static Int_t kGlobalHeaderSize   = darcHeader->GetGlobalHeaderLength(); 
+  static Int_t kDarcHeaderSize     = darcHeader->GetDarcHeaderLength(); 
+  static Int_t kRegHeaderSize      = fRegHeader->GetHeaderLength();
+  static Int_t kRegEmptySize       = fRegHeader->GetHeaderLength()+1 + 16*(fLocalStruct->GetLength()+1);
+  static Int_t kRegEmptyScalerSize = fRegHeader->GetHeaderLength() + fRegHeader->GetScalerLength() + 1 +
+                                      16*(fLocalStruct->GetLength() + fLocalStruct->GetScalerLength() + 1);
 
-  Bool_t scalerEvent = kFALSE;
-  
   Int_t index = 0;
 
   memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4); 
   index += kDarcHeaderSize;
 
-  if(darcHeader->GetEventType() == 0) {
-    scalerEvent = kTRUE;
-  } else
-    scalerEvent = kFALSE;
+
+  // darc type vadorh
+  if (darcHeader->GetDarcType() == darcHeader->GetDarcVadohrType())
+      fMaxReg = 1;
+    
+  // darc type def.
+  if (darcHeader->GetDarcType() == darcHeader->GetDarcDefaultType())
+      fMaxReg = 8;
+      
+  if(darcHeader->GetEventType() == scalerEvent) 
+      if (fWarnings) AliWarning("Wrong event type obtained from the Darc header, take the one of CDH");
+
 
   if(scalerEvent) {
     // 6 DARC scaler words
@@ -99,13 +116,14 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
     index += darcHeader->GetDarcScalerLength();
   }
 
-  if (buffer[index++] != darcHeader->GetEndOfDarc())
-#ifndef DATE_SYS
-    AliWarning(Form("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc()));
-#else 
-  printf("Wrong end of Darc word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfDarc());
-#endif
+  if (buffer[index++] != darcHeader->GetEndOfDarc()) {
 
+      const Char_t* msg = Form("Wrong end of Darc word %x instead of %x\n",
+                   buffer[index-1], darcHeader->GetEndOfDarc());
+      if (fWarnings) AliWarning(msg);
+      AddErrorMessage(msg);
+      fDarcEoWErrors++;
+  }
   // 4 words of global board input + Global board output
   memcpy(darcHeader->GetGlobalInput(), &buffer[index], (kGlobalHeaderSize)*4); 
   index += kGlobalHeaderSize; 
@@ -116,16 +134,26 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
     index += darcHeader->GetGlobalScalerLength();
   }
 
-  if (buffer[index++] != darcHeader->GetEndOfGlobal())
-#ifndef DATE_SYS
-    AliWarning(Form("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal()));
-#else 
-  printf("Wrong end of Global word %x instead of %x\n",buffer[index-1], darcHeader->GetEndOfGlobal());
-#endif
+  if (buffer[index++] != darcHeader->GetEndOfGlobal()) {
+
+      const Char_t* msg = Form("Wrong end of Global word %x instead of %x\n",
+                     buffer[index-1], darcHeader->GetEndOfGlobal());
+      if (fWarnings) AliWarning(msg);
+      AddErrorMessage(msg);
+      fGlobalEoWErrors++;
+  }
   // 8 regional boards
   for (Int_t iReg = 0; iReg < fMaxReg; iReg++) {           //loop over regeonal card
 
+    // skip empty regaional board (not connected or with error reading)
+    if (buffer[index] == fRegHeader->GetErrorWord()) {
+      fDDLTrigger->AddRegHeader(*fRegHeader);
+      if (scalerEvent)
+        index += kRegEmptyScalerSize;
+      else 
+        index += kRegEmptySize;
+      continue;
+    }
     memcpy(fRegHeader->GetHeader(), &buffer[index], kRegHeaderSize*4);
     index += kRegHeaderSize;
 
@@ -136,13 +164,14 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
       index += fRegHeader->GetScalerLength();
     }
 
-    if (buffer[index++] != fRegHeader->GetEndOfReg())
-#ifndef DATE_SYS
-      AliWarning(Form("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg()));
-#else
-      printf("Wrong end of Reg word %x instead of %x\n",buffer[index-1], fRegHeader->GetEndOfReg());
-#endif
+    if (buffer[index++] != fRegHeader->GetEndOfReg()) {
 
+      const Char_t* msg = Form("Wrong end of Regional word %x instead of %x\n",
+                   buffer[index-1], fRegHeader->GetEndOfReg());
+      if (fWarnings) AliWarning(msg);
+      AddErrorMessage(msg);
+      fRegEoWErrors++;
+    }
     // 16 local cards per regional board
     for (Int_t iLoc = 0; iLoc < fMaxLoc; iLoc++) {         //loop over local card
          
@@ -158,13 +187,19 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
        index += fLocalStruct->GetScalerLength();
       }
 
-      if (buffer[index++] != fLocalStruct->GetEndOfLocal())
-#ifndef DATE_SYS
-       AliWarning(Form("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal()));
-#else
-      printf("Wrong end of local word %x instead of %x\n",buffer[index-1], fLocalStruct->GetEndOfLocal());
-#endif
-         
+      if (buffer[index++] != fLocalStruct->GetEndOfLocal()) {
+
+        const Char_t* msg = Form("Wrong end of Local word %x instead of %x\n",
+                                 buffer[index-1], fLocalStruct->GetEndOfLocal());
+        
+        if (fWarnings) AliWarning(msg);
+        AddErrorMessage(msg);
+       fLocalEoWErrors++;
+      }
+      // fill only if card notified
+      if (fLocalStruct->GetData(0) == fLocalStruct->GetDisableWord())
+         continue;
+
       fDDLTrigger->AddLocStruct(*fLocalStruct, iReg);
 
     } // local card loop
@@ -178,25 +213,45 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
 //______________________________________________________
 void AliMUONPayloadTrigger::ResetDDL()
 {
-  // reseting TClonesArray
-  // after each DDL
-  //
+  /// reseting TClonesArray
+  /// after each DDL
+  ///
   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
   darcHeader->GetRegHeaderArray()->Delete();
+  fDarcEoWErrors   = 0;
+  fGlobalEoWErrors = 0;
+  fRegEoWErrors    = 0;
+  fLocalEoWErrors  = 0;
 }
 
 //______________________________________________________
 void AliMUONPayloadTrigger::SetMaxReg(Int_t reg) 
 {
-  // set regional card number
+  /// set regional card number
   if (reg > 8) reg = 8;
-  fMaxReg = reg;
+   fMaxReg = reg;
+   
+  fNofRegSet = kTRUE;
 }
 
 //______________________________________________________
 void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc) 
 {
-  // set local card number
+  /// set local card number
   if (loc > 16) loc = 16;
   fMaxLoc = loc;
 }
+
+//______________________________________________________
+void AliMUONPayloadTrigger::AddErrorMessage(const Char_t* msg)
+{
+/// adding message to logger
+  TString tmp(msg);
+  
+  Int_t pos = tmp.First("\n");
+  tmp[pos] = 0;
+    
+  fLog->Log(tmp.Data());
+}
+