]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONRegionalTriggerBoard.cxx
next50 trigger mask in AliHLTGlobalEsdConverterComponent
[u/mrichter/AliRoot.git] / MUON / AliMUONRegionalTriggerBoard.cxx
index 865c6ecca8c16b0082e40cbb7b9c107fc44f1ad5..ef620d23fa5f6d5523f00589e22635ab6abc6987 100644 (file)
 
 /* $Id$ */
 
-//*-- Author: Rachid Guernane (LPCCFd)
+//-----------------------------------------------------------------------------
+/// \class AliMUONRegionalTriggerBoard
+/// Dimuon regional trigger implementation:
+/// - entry are local board responses
+/// - output is 12-bit word
+/// - algorithm is similar to the global one
+///
+/// \author Rachid Guernane (LPCCFd)
+/// Corrected by Christian Finck (Subatech)
+//-----------------------------------------------------------------------------
 
 #include "AliMUONRegionalTriggerBoard.h"
 
+#include "AliLog.h"
+
 #include "TBits.h"
 
 #include <Riostream.h>
 
+using std::endl;
+using std::cout;
+/// \cond CLASSIMP
 ClassImp(AliMUONRegionalTriggerBoard)
+/// \endcond
 
 //___________________________________________
 AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard()
+  : AliMUONTriggerBoard(),
+    fMask(0x0)   
 {
+/// Default constructor
    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
 }
 
 //___________________________________________
-AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
+AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a) 
+  : AliMUONTriggerBoard(name, a),
+    fMask(0x0)   
 {
+/// Standard constructor
    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
 }
 
+//___________________________________________
+AliMUONRegionalTriggerBoard::~AliMUONRegionalTriggerBoard()
+{
+/// Destructor
+}
+
 //___________________________________________
 void AliMUONRegionalTriggerBoard::Response()
 {
-   Int_t t[16];
+/// response is given following the regional algorithm
+// output from local trigger algorithm
+// [+, -] * [Hpt, Lpt]
+// transformed to [+, -, US, LS] * [Hpt, Lpt]
+
+  if ( IsNull() ) return; // Do nothing if all local responses are null
 
-   for (Int_t i=0;i<16;i++) t[i] = fLocalResponse[i];
+  Int_t t[16];
 
+   for (Int_t i = 0; i < 16; ++i)
+   {
+     if ((fMask >> i) & 0x1)
+      t[i] = fLocalResponse[i];
+     else
+       t[i] = 0;
+   }
+   
    Int_t rank = 8;
 
-   for (Int_t i=0;i<4;i++)
+   for (Int_t i = 0; i < 4; ++i)
    {
       Int_t ip = 0;
       
-      for (Int_t j=0;j<rank;j++)
+      for (Int_t j = 0; j < rank; ++j)
       {
-         UShort_t athres = Algo(t[2*j],t[2*j+1],"APT",i);
+         UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i);
+                
+         UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 4;
 
-         UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i); lthres <<= 4;
-
-         UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 8;
-
-         t[ip] = athres | lthres | hthres;
+         t[ip] = lthres | hthres;
 
          ip++;
       }
@@ -66,19 +104,27 @@ void AliMUONRegionalTriggerBoard::Response()
       rank /= 2; 
    }
 
-   fResponse = t[0]; // 12-bit [H4:L4:A4]
+   fResponse = t[0]; // 8-bit [H4:L4]
 }
 
 //___________________________________________
-UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres, Int_t level)
+UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres, Int_t level)
 {
-   TBits a(12), b(12); a.Set(12,&i); b.Set(12,&j);
+/// implementation of the regional algorithm
+/// similar to the global algorithm except for the
+/// input layer
+
+/// level = 0  a ,b = local response = Hpt (+|-) | Lpt (+|-)    
+/// level > 0  a ,b = reg  response  =  Hpt (+|-|us|ls) |  Lpt (+|-|us|ls)    
+   
+  TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
 
    TBits trg1(2), trg2(2), trg(2);
 
-   if (!strcmp(thres,"APT"))
+   if (!strcmp(thres,"LPT"))
    {
-      if (!level)
+  
+      if (!level) 
       {         
          trg1[0] = a[0]; trg1[1] = a[1]; 
          trg2[0] = b[0]; trg2[1] = b[1];
@@ -89,7 +135,7 @@ UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres,
          trg2[0] = b[2]; trg2[1] = b[3];
       }
    }
-   else if (!strcmp(thres,"LPT"))
+   else
    {
       if (!level)
       {         
@@ -99,20 +145,7 @@ UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres,
       else
       {
          trg1[0] = a[6]; trg1[1] = a[7]; 
-         trg2[0] = b[6]; trg2[1] = b[7];
-      }
-   }
-   else
-   {
-      if (!level)
-      {         
-         trg1[0] = a[4]; trg1[1] = a[5]; 
-         trg2[0] = b[4]; trg2[1] = b[5];
-      }
-      else
-      {
-         trg1[0] = a[10]; trg1[1] = a[11]; 
-         trg2[0] = b[10]; trg2[1] = b[11];         
+         trg2[0] = b[6]; trg2[1] = b[7];         
       }
    }
        
@@ -124,20 +157,19 @@ UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres,
    }
    else
    {
-      if (!strcmp(thres,"APT"))
+       if (!strcmp(thres,"LPT"))
       {
-         trgLS1[0] = a[1]; trgUS1[0] = a[0]; 
-         trgLS2[0] = b[1]; trgUS2[0] = b[0];
-      }
-      else if (!strcmp(thres,"LPT"))
-      {
-         trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
-         trgLS2[0] = b[5]; trgUS2[0] = b[4];
+         //trgLS1[0] = a[1]; trgUS1[0] = a[0]; 
+         //trgLS2[0] = b[1]; trgUS2[0] = b[0];
+         trgLS1[0] = a[0]; trgUS1[0] = a[1]; 
+         trgLS2[0] = b[0]; trgUS2[0] = b[1];
       }
       else
       {
-         trgLS1[0] = a[9]; trgUS1[0] = a[8]; 
-         trgLS2[0] = b[9]; trgUS2[0] = b[8];         
+         //trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
+         //trgLS2[0] = b[5]; trgUS2[0] = b[4];         
+         trgLS1[0] = a[4]; trgUS1[0] = a[5]; 
+         trgLS2[0] = b[4]; trgUS2[0] = b[5];         
       }
    }
 
@@ -149,21 +181,58 @@ UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres,
    
    TBits v(4);
    
-   v[0] = trgUS[0];
-   v[1] = trgLS[0];
+   //v[0] = trgUS[0]; 
+   //v[1] = trgLS[0];
+   v[0] = trgLS[0]; 
+   v[1] = trgUS[0];
    v[2] = trg[0];
    v[3] = trg[1];
-   
    UShort_t rv = 0;
    v.Get(&rv);
-
    return rv;
 }
+
+//___________________________________________
+void AliMUONRegionalTriggerBoard::Scan(Option_t*) const
+{
+/// scan local board entries 
+
+  for (Int_t i=0; i<16; i++) 
+   {
+      TBits b;
+      b.Set(6,&fLocalResponse[i]);
+      
+      cout << "Entry " << i << " is " << b << endl;
+      
+   }
+   
+}
 //___________________________________________
-void AliMUONRegionalTriggerBoard::Scan(Option_t*)
+void AliMUONRegionalTriggerBoard::Mask(UShort_t mask)
 {
+/// mask entry index
 
+    fMask = mask;
 }
 
+//___________________________________________
+Bool_t AliMUONRegionalTriggerBoard::IsNull()
+{
+  /// Check if all local response are null
+  for (Int_t i=0; i<16; i++) {
+    if ( fLocalResponse[i] ) return kFALSE;
+  }
+  return kTRUE;
+}
 
-ClassImp(AliMUONRegionalTriggerBoard)
+
+//___________________________________________
+void AliMUONRegionalTriggerBoard::Reset()
+{
+  /// Reset board
+
+  for (Int_t i=0; i<16; ++i) fLocalResponse[i] = 0;
+
+  fResponse = 0;
+  
+}