]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONPayloadTrigger.cxx
Adding a commented line demsostrating how to switch off
[u/mrichter/AliRoot.git] / MUON / AliMUONPayloadTrigger.cxx
index 5511f46e98485fd1f170ba3567e12be0188be976..6a6b1a37ab91e7831f60701da0a03504c4232f96 100644 (file)
@@ -13,7 +13,9 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+// $Id$
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONPayloadTrigger
 /// Class Payload
 ///
@@ -22,6 +24,7 @@
 /// First version implement for Trigger
 ///
 /// \author Christian Finck
+//-----------------------------------------------------------------------------
 
 #include "AliMUONPayloadTrigger.h"
 
@@ -29,6 +32,7 @@
 #include "AliMUONRegHeader.h"
 #include "AliMUONLocalStruct.h"
 #include "AliMUONDDLTrigger.h"
+#include "AliMUONLogger.h"
 
 #include "AliLog.h"
 
@@ -42,7 +46,14 @@ 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
@@ -60,6 +71,7 @@ AliMUONPayloadTrigger::~AliMUONPayloadTrigger()
   delete fDDLTrigger;
   delete fLocalStruct;
   delete fRegHeader;
+  delete fLog;
 }
 
 
@@ -84,23 +96,36 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
   memcpy(darcHeader->GetHeader(), &buffer[index], (kDarcHeaderSize)*4); 
   index += kDarcHeaderSize;
 
-  if(darcHeader->GetEventType() == 0) {
-    scalerEvent = kTRUE;
-  } else
-    scalerEvent = kFALSE;
-
+  if (!fNofRegSet) // if regional board number not set, set it with darc type
+  { 
+    // darc type vardorh
+    if (darcHeader->GetDarcType() == 4)
+      fMaxReg = 1;
+    
+    // darc type def.
+    if (darcHeader->GetDarcType() == 6)
+      fMaxReg = 8;
+      
+    if(darcHeader->GetEventType() == 0) {
+      scalerEvent = kTRUE;
+    } else
+      scalerEvent = kFALSE;
+  }
+  
   if(scalerEvent) {
     // 6 DARC scaler words
     memcpy(darcHeader->GetDarcScalers(), &buffer[index], darcHeader->GetDarcScalerLength()*4);
     index += darcHeader->GetDarcScalerLength();
   }
 
-  if (buffer[index++] != darcHeader->GetEndOfDarc())
-
-      AliError(Form("Wrong end of Darc word %x instead of %x\n",
-                   buffer[index-1], darcHeader->GetEndOfDarc()));
-
+  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; 
@@ -111,12 +136,14 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
     index += darcHeader->GetGlobalScalerLength();
   }
 
-  if (buffer[index++] != darcHeader->GetEndOfGlobal())
-
-  AliError(Form("Wrong end of Global word %x instead of %x\n",
-               buffer[index-1], darcHeader->GetEndOfGlobal()));
+  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
 
@@ -130,12 +157,14 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
       index += fRegHeader->GetScalerLength();
     }
 
-    if (buffer[index++] != fRegHeader->GetEndOfReg())
-
-      AliError(Form("Wrong end of Reg word %x instead of %x\n",
-                   buffer[index-1], fRegHeader->GetEndOfReg()));
-
+    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
          
@@ -151,11 +180,15 @@ Bool_t AliMUONPayloadTrigger::Decode(UInt_t *buffer)
        index += fLocalStruct->GetScalerLength();
       }
 
-      if (buffer[index++] != fLocalStruct->GetEndOfLocal())
-
-      AliError(Form("Wrong end of local word %x instead of %x\n",
-                   buffer[index-1], fLocalStruct->GetEndOfLocal()));
+      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;
@@ -178,6 +211,10 @@ void AliMUONPayloadTrigger::ResetDDL()
   ///
   AliMUONDarcHeader* darcHeader = fDDLTrigger->GetDarcHeader();
   darcHeader->GetRegHeaderArray()->Delete();
+  fDarcEoWErrors   = 0;
+  fGlobalEoWErrors = 0;
+  fRegEoWErrors    = 0;
+  fLocalEoWErrors  = 0;
 }
 
 //______________________________________________________
@@ -185,7 +222,9 @@ void AliMUONPayloadTrigger::SetMaxReg(Int_t reg)
 {
   /// set regional card number
   if (reg > 8) reg = 8;
-  fMaxReg = reg;
+   fMaxReg = reg;
+   
+  fNofRegSet = kTRUE;
 }
 
 //______________________________________________________
@@ -195,3 +234,17 @@ void AliMUONPayloadTrigger::SetMaxLoc(Int_t loc)
   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());
+}
+