]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGlobalTriggerBoard.cxx
Adding classes forgotten in previous commit
[u/mrichter/AliRoot.git] / MUON / AliMUONGlobalTriggerBoard.cxx
index 0882d83ab042ef665f42a993c7963cd141dfb95c..c2ed96ece4ebd45b6a8af876e19b099a9d1b9de9 100644 (file)
@@ -21,9 +21,9 @@
 /// - inputs are regional responses
 /// - output is a 12-bit word
 /// - 4 bits per trigger level
-/// \todo Change member functions comments in capital letters to normal text
 ///
-/// \author Rachid Guernane (LPCCFd)
+/// \author Rachid Guernane (LPCCFd), 
+/// Corrected by Christian Finck (Subatech)
 //-----------------------------------------------------------------------------
 
 #include "AliMUONGlobalTriggerBoard.h"
 
 #include <Riostream.h>
 
+/// \cond CLASSIMP
 ClassImp(AliMUONGlobalTriggerBoard)
+/// \endcond
 
 //___________________________________________
-AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard()
+AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(): AliMUONTriggerBoard()
 {
 /// Default constructor
 
    for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
+   for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
 }
 
 //___________________________________________
@@ -48,6 +51,7 @@ AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(const char *name, Int_t a)
 /// Standard constructor
 
    for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
+   for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
 }
 
 //___________________________________________
@@ -57,32 +61,40 @@ AliMUONGlobalTriggerBoard::~AliMUONGlobalTriggerBoard()
 }
 
 //___________________________________________
-void AliMUONGlobalTriggerBoard::Mask(Int_t index, UShort_t mask)
+void AliMUONGlobalTriggerBoard::Mask(Int_t index, UInt_t mask)
 {
-  /// MASK GLOBAL TRIGGER BOARD INPUT index WITH VALUE mask
-  if ( index>=0 && index < 16 ) 
+  /// mask global trigger board input index with value mask
+  if ( index >= 0 && index < 4 ) 
   {
     fMask[index]=mask;
   }
   else
   {
-    AliError(Form("Index %d out of bounds (max %d)",index,16));
+    AliError(Form("Index %d out of bounds (max %d)",index,3));
   }  
 }
 
 //___________________________________________
 void AliMUONGlobalTriggerBoard::Response()
 {
-   /// COMPUTE THE GLOBAL TRIGGER BOARD
-   /// RESPONSE ACCORDING TO THE Algo() METHOD
+   /// compute the global trigger board
+   /// response according to the algo() method
 // output from global trigger algorithm
-// [+, -, LS, US] * [Hpt, Lpt]
+// [+, -, US, LS] * [Hpt, Lpt]
 // transformed to [usHpt, usLpt, lsHpt, lsLpt, sHpt, sLpt] according
 // to Global Trigger Unit user manual
 
    Int_t t[16];
-   for (Int_t i=0;i<16;i++) t[i] = fRegionalResponse[i] & fMask[i];
 
+   BuildGlobalInput();
+   MaskGlobalInput();
+
+   for (Int_t i = 0; i < 16; ++i) 
+   {
+     t[i] = fRegionalResponse[i];
+   }
+   
+   
    Int_t rank = 8;
 
    for (Int_t i=0;i<4;i++)
@@ -105,10 +117,10 @@ void AliMUONGlobalTriggerBoard::Response()
    UChar_t sLpt, sHpt, lsLpt, lsHpt, usLpt, usHpt;
    sLpt  = ((t[0] & 0xC)  != 0);
    sHpt  = ((t[0] & 0xC0) != 0);
-   lsLpt = ((t[0] & 0x2)  != 0);
-   lsHpt = ((t[0] & 0x20) != 0);
-   usLpt = ((t[0] & 0x1 ) != 0);
-   usHpt = ((t[0] & 0x10) != 0);
+   lsLpt = ((t[0] & 0x1)  != 0);
+   lsHpt = ((t[0] & 0x10) != 0);
+   usLpt = ((t[0] & 0x2 ) != 0);
+   usHpt = ((t[0] & 0x20) != 0);
 
    sHpt  <<= 1;
    lsLpt <<= 2;
@@ -117,12 +129,16 @@ void AliMUONGlobalTriggerBoard::Response()
    usHpt <<= 5;
 
    fResponse = sLpt | sHpt | lsLpt | lsHpt | usLpt |usHpt;
+   
+
 }
 
 //___________________________________________
-UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
+UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres)
 {
-   /// GLOBAL TRIGGER ALGORITHM
+/// global trigger algorithm
+///   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);
@@ -142,13 +158,13 @@ UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
 
    if (!strcmp(thres,"LPT"))
    {
-      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[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];         
    }
 
    trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
@@ -159,8 +175,8 @@ UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
    
    TBits v(4);
    
-   v[0] = trgUS[0];
-   v[1] = trgLS[0];
+   v[0] = trgLS[0];
+   v[1] = trgUS[0];
    v[2] = trg[0];
    v[3] = trg[1];
 
@@ -170,11 +186,92 @@ UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
    return rv;
 }
 
+//___________________________________________
+void AliMUONGlobalTriggerBoard::BuildGlobalInput()
+{
+  /// build the 4 words (32bits) global input from the regional responses
+  /// the order of regional responses is:
+  /// 1R, 2R, 2-3R, 3R, 4R, 5R, 6R, 7R, 1L, 2L, 2-3L, 3L, 4L, 5L, 6L, 7L
+
+  for (Int_t i=0;i< 4;i++) fGlobalInput[i] = 0;
+
+  UShort_t regRespInv;
+  TBits rs(8), rsi(8);
+  for (Int_t iReg = 0; iReg < 16; iReg++) {
+
+    // invert bit in regional response
+    rs.Set(8,&fRegionalResponse[iReg]);
+    for (Int_t i = 0; i < 4; i++) {
+      rsi[2*i]   = rs[2*i+1];
+      rsi[2*i+1] = rs[2*i];
+    }
+    regRespInv = 0;
+    rsi.Get(&regRespInv);
+
+    if (iReg < 8) {    // right
+      // Lpt word
+      fGlobalInput[0] |=  (regRespInv & 0x0F)       << (4*iReg);
+      // Hpt word
+      fGlobalInput[2] |= ((regRespInv & 0xF0) >> 4) << (4*iReg);
+    } else {           // left
+      // Lpt word
+      fGlobalInput[1] |=  (regRespInv & 0x0F)       << (4*(iReg-8));
+      // Hpt word
+      fGlobalInput[3] |= ((regRespInv & 0xF0) >> 4) << (4*(iReg-8));
+    }
+
+  }
+
+}
+
+//___________________________________________
+void AliMUONGlobalTriggerBoard::MaskGlobalInput()
+{
+  /// Apply masks to global input and recalculate regional inputs before
+  /// applying the global response
+
+  UShort_t regRespInv;
+  TBits rs(8), rsi(8);
+
+  // global input with masks applied
+  UInt_t gitmp[4];
+
+  for (Int_t i = 0; i < 4; i++) {
+    gitmp[i] = fGlobalInput[i];
+    gitmp[i] &= fMask[i];
+  }
+
+  for (Int_t iReg = 0; iReg < 16; iReg++) {
+    fRegionalResponse[iReg] = 0;
+    if (iReg < 8) {    // right
+      // Lpt
+      fRegionalResponse[iReg] |=  (gitmp[0] >> (4*iReg))     & 0xF;
+      // Hpt
+      fRegionalResponse[iReg] |= ((gitmp[2] >> (4*iReg))     & 0xF) << 4;
+    } else {           // left
+      // Lpt
+      fRegionalResponse[iReg] |=  (gitmp[1] >> (4*(iReg-8))) & 0xF;
+      // Hpt
+      fRegionalResponse[iReg] |= ((gitmp[3] >> (4*(iReg-8))) & 0xF) << 4;
+    }
+    // invert bit in regional response
+    rs.Set(8,&fRegionalResponse[iReg]);
+    for (Int_t i = 0; i < 4; i++) {
+      rsi[2*i]   = rs[2*i+1];
+      rsi[2*i+1] = rs[2*i];
+    }
+    regRespInv = 0;
+    rsi.Get(&regRespInv);
+    fRegionalResponse[iReg] = regRespInv;
+  }
+
+}
+
 //___________________________________________
 void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
 {
-  /// PRINT GLOBAL TRIGGER OUTPUT 
-  TBits w(8); w.Set(8,&fResponse);
+  /// print global trigger output 
+  TBits w(6); w.Set(6,&fResponse);
 
 // TRG[1:0]
 // 00 noth
@@ -182,43 +279,18 @@ void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
 // 10 positive track
 // 11 undef
 
-   Int_t iSP[2] = {0,0}, iSM[2] = {0,0}, iSU[2] = {0,0};
+   Int_t iS[2] = {0,0};
 
-   TBits a(2), n(2), p(2), u(2);
-   
-   UShort_t val;
+   iS[0] = (Int_t)w.TestBitNumber(0);
+   iS[1] = (Int_t)w.TestBitNumber(1);
 
-   val = 1; n.Set(2,&val);
-   val = 2; p.Set(2,&val);
-   val = 3; u.Set(2,&val);
-   
-   a[0] = w[2];
-   a[1] = w[3];
-   
-   if      (a==p) iSP[0] = 1;
-   else if (a==n) iSM[0] = 1;
-   else if (a==u) iSU[0] = 1;   
-
-   a[0] = w[6];
-   a[1] = w[7];
-
-   if      (a==p) iSP[1] = 1;
-   else if (a==n) iSM[1] = 1;
-   else if (a==u) iSU[1] = 1;
-   
-   Int_t iPU[2] = {w[0],w[4]};
-   Int_t iPL[2] = {w[1],w[5]};
+   Int_t iPU[2] = {w[4],w[5]};
+   Int_t iPL[2] = {w[2],w[3]};
 
    printf("============================================\n");
    printf(" Global Trigger output       Low pt  High pt\n");
-   printf(" number of Single Plus      :\t");
-   for (Int_t i=0; i<2; i++) printf("%i\t",iSP[i]);
-   printf("\n");
-   printf(" number of Single Minus     :\t");
-   for (Int_t i=0; i<2; i++) printf("%i\t",iSM[i]);
-   printf("\n");
-   printf(" number of Single Undefined :\t"); 
-   for (Int_t i=0; i<2; i++) printf("%i\t",iSU[i]);
+   printf(" number of Single           :\t");
+   for (Int_t i=0; i<2; i++) printf("%i\t",iS[i]);
    printf("\n");
    printf(" number of UnlikeSign pair  :\t"); 
    for (Int_t i=0; i<2; i++) printf("%i\t",iPU[i]);
@@ -230,4 +302,3 @@ void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
    printf("\n");
 }
 
-ClassImp(AliMUONGlobalTriggerBoard)