]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGlobalTriggerBoard.cxx
In AliMUONTriggerQAChecker:
[u/mrichter/AliRoot.git] / MUON / AliMUONGlobalTriggerBoard.cxx
index e2e412c317a3a9542b4b257dde29fec01c634ae3..ba237679a1eae2bd01fe2ab7b6c128062f4e4e36 100644 (file)
@@ -201,21 +201,9 @@ void AliMUONGlobalTriggerBoard::BuildGlobalInput()
   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 bits in regional response ?
-    rs.Set(8,&fRegionalResponse[iReg]);
-    for (Int_t i = 0; i < 4; i++) {
-      // ... YES
-      //rsi[2*i]   = rs[2*i+1];
-      //rsi[2*i+1] = rs[2*i];
-      // ... NO
-      rsi[2*i]   = rs[2*i];
-      rsi[2*i+1] = rs[2*i+1];
-    }
-    regRespInv = 0;
-    rsi.Get(&regRespInv);
+    regRespInv = InvertPairBits(iReg);
 
     if (iReg < 8) {    // right
       // Lpt word
@@ -239,17 +227,22 @@ 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++) {
+    fGlobalInput[i] &= fMask[i];
     gitmp[i] = fGlobalInput[i];
-    gitmp[i] &= fMask[i];
   }
 
+  RecomputeRegional(gitmp);
+}
+
+
+//___________________________________________
+void AliMUONGlobalTriggerBoard::RecomputeRegional(UInt_t gitmp[4])
+{
+  //
+  /// Recomput regional response from global input
+  //
   for (Int_t iReg = 0; iReg < 16; iReg++) {
     fRegionalResponse[iReg] = 0;
     if (iReg < 8) {    // right
@@ -263,18 +256,9 @@ void AliMUONGlobalTriggerBoard::MaskGlobalInput()
       // Hpt
       fRegionalResponse[iReg] |= ((gitmp[3] >> (4*(iReg-8))) & 0xF) << 4;
     }
-    // invert bits 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);
-    // uncomment if ... YES
-    //fRegionalResponse[iReg] = regRespInv;
-  }
 
+    fRegionalResponse[iReg] = InvertPairBits(iReg);
+  }
 }
 
 //___________________________________________
@@ -312,3 +296,26 @@ void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
    printf("\n");
 }
 
+
+//___________________________________________
+UShort_t AliMUONGlobalTriggerBoard::InvertPairBits(Int_t iReg)
+{
+  //
+  /// invert "pair" bits in regional response
+  /// [+, -, US, LS] becomes [+, -, LS, US]
+  //
+  TBits rs(8), rsi(8);
+  rs.Set(8,&fRegionalResponse[iReg]);
+    for (Int_t i = 0; i < 4; i++) {
+      if (i%2 == 0) {
+       rsi[2*i]   = rs[2*i+1];
+       rsi[2*i+1] = rs[2*i];
+      } else {
+       rsi[2*i]   = rs[2*i];
+       rsi[2*i+1] = rs[2*i+1];
+      }
+    }
+    UShort_t regRespInv = 0;
+    rsi.Get(&regRespInv);
+    return regRespInv;
+}