LCOV - code coverage report
Current view: top level - MUON/MUONtrigger - AliMUONRegionalTriggerBoard.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 70 81 86.4 %
Date: 2016-06-14 17:26:59 Functions: 11 14 78.6 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : //-----------------------------------------------------------------------------
      19             : /// \class AliMUONRegionalTriggerBoard
      20             : /// Dimuon regional trigger implementation:
      21             : /// - entry are local board responses
      22             : /// - output is 12-bit word
      23             : /// - algorithm is similar to the global one
      24             : ///
      25             : /// \author Rachid Guernane (LPCCFd)
      26             : /// Corrected by Christian Finck (Subatech)
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include "AliMUONRegionalTriggerBoard.h"
      30             : 
      31             : #include "AliLog.h"
      32             : 
      33             : #include "TBits.h"
      34             : 
      35             : #include <Riostream.h>
      36             : 
      37             : using std::endl;
      38             : using std::cout;
      39             : /// \cond CLASSIMP
      40          18 : ClassImp(AliMUONRegionalTriggerBoard)
      41             : /// \endcond
      42             : 
      43             : //___________________________________________
      44             : AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard()
      45          96 :   : AliMUONTriggerBoard(),
      46          96 :     fMask(0x0)   
      47         480 : {
      48             : /// Default constructor
      49        3264 :    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
      50         192 : }
      51             : 
      52             : //___________________________________________
      53             : AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a) 
      54           0 :   : AliMUONTriggerBoard(name, a),
      55           0 :     fMask(0x0)   
      56           0 : {
      57             : /// Standard constructor
      58           0 :    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
      59           0 : }
      60             : 
      61             : //___________________________________________
      62             : AliMUONRegionalTriggerBoard::~AliMUONRegionalTriggerBoard()
      63         384 : {
      64             : /// Destructor
      65         384 : }
      66             : 
      67             : //___________________________________________
      68             : void AliMUONRegionalTriggerBoard::Response()
      69             : {
      70             : /// response is given following the regional algorithm
      71             : // output from local trigger algorithm
      72             : // [+, -] * [Hpt, Lpt]
      73             : // transformed to [+, -, US, LS] * [Hpt, Lpt]
      74             : 
      75       22688 :   if ( IsNull() ) return; // Do nothing if all local responses are null
      76             : 
      77         756 :   Int_t t[16];
      78             : 
      79       25704 :    for (Int_t i = 0; i < 16; ++i)
      80             :    {
      81       24192 :      if ((fMask >> i) & 0x1)
      82       23765 :       t[i] = fLocalResponse[i];
      83             :      else
      84         427 :        t[i] = 0;
      85             :    }
      86             :    
      87             :    Int_t rank = 8;
      88             : 
      89        7560 :    for (Int_t i = 0; i < 4; ++i)
      90             :    {
      91             :       Int_t ip = 0;
      92             :       
      93       28728 :       for (Int_t j = 0; j < rank; ++j)
      94             :       {
      95       11340 :          UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i);
      96             :                  
      97       11340 :          UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 4;
      98             : 
      99       11340 :          t[ip] = lthres | hthres;
     100             : 
     101       11340 :          ip++;
     102             :       }
     103             :       
     104        3024 :       rank /= 2; 
     105             :    }
     106             : 
     107         756 :    fResponse = t[0]; // 8-bit [H4:L4]
     108       12100 : }
     109             : 
     110             : //___________________________________________
     111             : UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres, Int_t level)
     112             : {
     113             : /// implementation of the regional algorithm
     114             : /// similar to the global algorithm except for the
     115             : /// input layer
     116             : 
     117             : /// level = 0  a ,b = local response = Hpt (+|-) | Lpt (+|-)    
     118             : /// level > 0  a ,b = reg  response  =  Hpt (+|-|us|ls) |  Lpt (+|-|us|ls)    
     119             :    
     120       68040 :   TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
     121             : 
     122       68040 :    TBits trg1(2), trg2(2), trg(2);
     123             : 
     124       68040 :    if (!strcmp(thres,"LPT"))
     125             :    {
     126             :   
     127       11340 :       if (!level) 
     128             :       {         
     129       42336 :          trg1[0] = a[0]; trg1[1] = a[1]; 
     130       42336 :          trg2[0] = b[0]; trg2[1] = b[1];
     131        6048 :       }
     132             :       else
     133             :       {
     134       37044 :          trg1[0] = a[2]; trg1[1] = a[3]; 
     135       37044 :          trg2[0] = b[2]; trg2[1] = b[3];
     136             :       }
     137             :    }
     138             :    else
     139             :    {
     140       34020 :       if (!level)
     141             :       {         
     142       42336 :          trg1[0] = a[2]; trg1[1] = a[3]; 
     143       42336 :          trg2[0] = b[2]; trg2[1] = b[3];
     144        6048 :       }
     145             :       else
     146             :       {
     147       37044 :          trg1[0] = a[6]; trg1[1] = a[7]; 
     148       37044 :          trg2[0] = b[6]; trg2[1] = b[7];         
     149             :       }
     150             :    }
     151             :        
     152      136080 :    TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
     153             : 
     154       22680 :    if (!level) 
     155             :    {
     156      108864 :       trgLS1[0] = trgUS1[0] = trgLS2[0] = trgUS2[0] = 0;
     157       12096 :    }
     158             :    else
     159             :    {
     160       21168 :        if (!strcmp(thres,"LPT"))
     161             :       {
     162             :          //trgLS1[0] = a[1]; trgUS1[0] = a[0]; 
     163             :          //trgLS2[0] = b[1]; trgUS2[0] = b[0];
     164       37044 :          trgLS1[0] = a[0]; trgUS1[0] = a[1]; 
     165       37044 :          trgLS2[0] = b[0]; trgUS2[0] = b[1];
     166        5292 :       }
     167             :       else
     168             :       {
     169             :          //trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
     170             :          //trgLS2[0] = b[5]; trgUS2[0] = b[4];         
     171       37044 :          trgLS1[0] = a[4]; trgUS1[0] = a[5]; 
     172       37044 :          trgLS2[0] = b[4]; trgUS2[0] = b[5];         
     173             :       }
     174             :    }
     175             : 
     176      249480 :    trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
     177      249480 :    trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
     178             :    
     179      113400 :    trg[0] = trg1[0] | trg2[0];
     180      113400 :    trg[1] = trg1[1] | trg2[1];
     181             :    
     182       22680 :    TBits v(4);
     183             :    
     184             :    //v[0] = trgUS[0]; 
     185             :    //v[1] = trgLS[0];
     186       90720 :    v[0] = trgLS[0]; 
     187       90720 :    v[1] = trgUS[0];
     188       90720 :    v[2] = trg[0];
     189       90720 :    v[3] = trg[1];
     190       22680 :    UShort_t rv = 0;
     191       22680 :    v.Get(&rv);
     192       22680 :    return rv;
     193       22680 : }
     194             : 
     195             : //___________________________________________
     196             : void AliMUONRegionalTriggerBoard::Scan(Option_t*) const
     197             : {
     198             : /// scan local board entries 
     199             : 
     200           0 :   for (Int_t i=0; i<16; i++) 
     201             :    {
     202           0 :       TBits b;
     203           0 :       b.Set(6,&fLocalResponse[i]);
     204             :       
     205           0 :       cout << "Entry " << i << " is " << b << endl;
     206             :       
     207           0 :    }
     208             :    
     209           0 : }
     210             : //___________________________________________
     211             : void AliMUONRegionalTriggerBoard::Mask(UShort_t mask)
     212             : {
     213             : /// mask entry index
     214             : 
     215         192 :     fMask = mask;
     216          96 : }
     217             : 
     218             : //___________________________________________
     219             : Bool_t AliMUONRegionalTriggerBoard::IsNull()
     220             : {
     221             :   /// Check if all local response are null
     222      393612 :   for (Int_t i=0; i<16; i++) {
     223      176008 :     if ( fLocalResponse[i] ) return kFALSE;
     224             :   }
     225       10588 :   return kTRUE;
     226       11344 : }
     227             : 
     228             : 
     229             : //___________________________________________
     230             : void AliMUONRegionalTriggerBoard::Reset()
     231             : {
     232             :   /// Reset board
     233             : 
     234      401520 :   for (Int_t i=0; i<16; ++i) fLocalResponse[i] = 0;
     235             : 
     236       11472 :   fResponse = 0;
     237             :   
     238       11472 : }

Generated by: LCOV version 1.11