LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpLocalBoard.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 41 63 65.1 %
Date: 2016-06-14 17:26:59 Functions: 15 17 88.2 %

          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 AliMpLocalBoard
      20             : // --------------------
      21             : // The class defines the properties of local board
      22             : // Author: Ch. Finck, Subatech Nantes
      23             : //-----------------------------------------------------------------------------
      24             : 
      25             : #include "AliMpLocalBoard.h"
      26             : #include "AliMpConstants.h"
      27             : #include "AliMpEncodePair.h"
      28             : 
      29             : #include "AliLog.h"
      30             : 
      31             : #include <TString.h>
      32             : #include <Riostream.h>
      33             : 
      34             : using std::endl;
      35             : /// \cond CLASSIMP
      36          18 : ClassImp(AliMpLocalBoard)
      37             : /// \endcond
      38             : 
      39             : 
      40             : //_____________________________________________________________________________
      41             : AliMpLocalBoard::AliMpLocalBoard(Int_t id, const Char_t* name, Int_t slot)
      42         726 :     : TNamed(name, "mapping trigger local board"),
      43         726 :       fId(id),
      44         726 :       fSlot(slot),
      45         726 :       fTC(true),
      46         726 :       fCrate(),
      47         726 :       fSwitch(0),
      48         726 :       fNotified(true),
      49         726 :       fDEId(false),
      50         726 :       fInputXfrom(0),
      51         726 :       fInputXto(0),
      52         726 :       fInputYfrom(0),
      53         726 :       fInputYto(0)
      54        3630 : {
      55             : /// Default constructor
      56        1452 : }
      57             : 
      58             : //______________________________________________________________________________
      59             : AliMpLocalBoard::AliMpLocalBoard(TRootIOCtor* /*ioCtor*/)
      60           0 :     : TNamed(),
      61           0 :       fId(),
      62           0 :       fSlot(),
      63           0 :       fTC(),
      64           0 :       fCrate(),
      65           0 :       fSwitch(),
      66           0 :       fNotified(),
      67           0 :       fDEId(),
      68           0 :       fInputXfrom(0),
      69           0 :       fInputXto(0),
      70           0 :       fInputYfrom(0),
      71           0 :       fInputYto(0)
      72           0 : {
      73             : /// Root IO constructor
      74           0 : }
      75             : 
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMpLocalBoard::~AliMpLocalBoard() 
      79        2904 : {
      80             : /// Destructor
      81             : 
      82        1452 : }
      83             : 
      84             : //_____________________________________________________________________________
      85             : Int_t AliMpLocalBoard::GetIndex(Int_t chamberId) const
      86             : {
      87             : /// Return the index from chamver Id.
      88             : /// chamberId could range from 10-13 in absolute value
      89             : /// chamberId could also range from 0-3 in relative value
      90             : 
      91             :    Int_t index = chamberId;
      92             :    
      93       41050 :    if ( chamberId >= AliMpConstants::NofTrackingChambers() && 
      94        2304 :         chamberId <  AliMpConstants::NofChambers() )
      95             :    {
      96        2304 :        index -= AliMpConstants::NofTrackingChambers();
      97        2304 :    } 
      98             : 
      99       38746 :    if (index < 0 || index >=  AliMpConstants::NofTriggerChambers() ) 
     100             :    {
     101           0 :      AliError(Form("chamber# %d not a valid trigger chamber Id, [0-3] or [10-13]", chamberId));
     102           0 :      return -1;
     103             :    }
     104             : 
     105       19373 :    return index;
     106       19373 : }
     107             : 
     108             : 
     109             : //______________________________________________________________________________
     110             : Bool_t AliMpLocalBoard::AddDE(Int_t detElemId)
     111             : {
     112             : /// Add detection element with given detElemId.
     113             : /// Return true if the detection element was added
     114             : 
     115        5616 :  if ( HasDEId(detElemId) ) {
     116           0 :     AliWarningStream() 
     117           0 :       << "Detection element Id = " << detElemId << " already present."
     118           0 :       << endl;
     119           0 :     return false;
     120             :  }
     121             : 
     122        2808 :   fDEId.Add(detElemId);
     123        2808 :   return true;
     124        2808 : }   
     125             : 
     126             : 
     127             : //______________________________________________________________________________
     128             : Int_t AliMpLocalBoard::GetNofDEs() const
     129             : {  
     130             : /// Return the number of detection elements connected to this crate
     131             : 
     132        7068 :   return fDEId.GetSize(); 
     133             : }
     134             : 
     135             : //______________________________________________________________________________
     136             : Int_t  AliMpLocalBoard::GetDEId(Int_t index) const
     137             : {  
     138             : /// Return the detection element by index (in loop)
     139             : 
     140        5616 :   return fDEId.GetValue(index); 
     141             : }
     142             : 
     143             : //______________________________________________________________________________
     144             : Int_t  AliMpLocalBoard::GetDEIdByChamber(Int_t chamberId) const
     145             : {  
     146             : /// Return the detection element by index (in loop)
     147             : 
     148       38746 :   return fDEId.GetValue(GetIndex(chamberId)); 
     149             : }
     150             : 
     151             : //______________________________________________________________________________
     152             : Bool_t  AliMpLocalBoard::HasDEId(Int_t detElemId) const
     153             : {  
     154             : /// Return true if the detection element Id is present
     155             : 
     156        5616 :   return fDEId.HasValue(detElemId); 
     157             : }
     158             : 
     159             : //______________________________________________________________________________
     160             : void AliMpLocalBoard::SetSwitch(UInt_t swit) 
     161             : {
     162             : /// set compact switch 
     163             :   
     164        1452 :   fSwitch = swit;
     165             :  
     166         726 : }
     167             : 
     168             : //______________________________________________________________________________
     169             : Int_t  AliMpLocalBoard::GetSwitch(Int_t index) const
     170             : {
     171             : /// Return switch bit wise
     172             : 
     173     2210084 :     if (index > 9) {
     174           0 :         AliWarning("Switch index too large");
     175           0 :         return -1;
     176             :     }
     177     1105042 :     return  (fSwitch >> (9-index)) & 0x1;
     178     1105042 : }
     179             : 
     180             : //______________________________________________________________________________
     181             : MpPair_t AliMpLocalBoard::GetPosition() const
     182             : {
     183             : /// gives position of the local board in (line, col)
     184             : 
     185        8352 :     const Char_t* boardName = GetName();
     186        4176 :     Int_t iLine = boardName[4] - '0';
     187        4176 :     Int_t iCol = boardName[2] - '0';
     188             : 
     189        4176 :     return AliMp::Pair(iLine, iCol);
     190             : }
     191             : 

Generated by: LCOV version 1.11