LCOV - code coverage report
Current view: top level - MUON/MUONmapping - AliMpMotif.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 34 42 81.0 %
Date: 2016-06-14 17:26:59 Functions: 13 15 86.7 %

          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             : // $MpId: AliMpMotif.cxx,v 1.8 2006/05/24 13:58:41 ivana Exp $
      18             : // Category: motif
      19             : 
      20             : //-----------------------------------------------------------------------------
      21             : // Class AliMpMotif
      22             : // ----------------
      23             : // Class that defines a motif with its unique ID
      24             : // and the motif type.
      25             : // Included in AliRoot: 2003/05/02
      26             : // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
      27             : //-----------------------------------------------------------------------------
      28             : 
      29             : #include "AliMpMotif.h"
      30             : 
      31             : #include "AliMpConstants.h"
      32             : #include "AliMpEncodePair.h"
      33             : #include "AliMpMotifType.h"
      34             : 
      35             : /// \cond CLASSIMP
      36          18 : ClassImp(AliMpMotif)
      37             : /// \endcond
      38             : 
      39             : //_____________________________________________________________________________
      40             : AliMpMotif::AliMpMotif()
      41           0 :   : AliMpVMotif(),
      42           0 :     fPadDimensionX(0.),
      43           0 :     fPadDimensionY(0.)
      44           0 : {
      45             :   /// Default constructor
      46           0 : }
      47             : 
      48             : //_____________________________________________________________________________
      49             : AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
      50             :                        Double_t dx, Double_t dy)
      51         807 :   : AliMpVMotif(id,motifType),
      52         807 :     fPadDimensionX(dx),
      53         807 :     fPadDimensionY(dy)
      54        4035 : {
      55             :   /// Standard constructor.                                                \n
      56             :   /// The dimension in a given direction is calculated by
      57             :   /// multiplying the total dimension by the number of pads
      58             : 
      59        1614 : }
      60             : //_____________________________________________________________________________
      61             : AliMpMotif::~AliMpMotif()
      62        2152 : {
      63             :   /// Destructor
      64        2152 : }
      65             : 
      66             : 
      67             : //_____________________________________________________________________________
      68             : void AliMpMotif::GetPadDimensionsByIndices(MpPair_t localIndices,
      69             :                                            Double_t& dx, Double_t& dy) const
      70             : {
      71             :   /// Give the dimension of the specified pad in the motif
      72             : 
      73    11014042 :   if ( GetMotifType()->HasPadByLocalIndices(localIndices) ) {
      74     5507021 :     dx = fPadDimensionX;
      75     5507021 :     dy = fPadDimensionY;
      76     5507021 :   }   
      77             :   else {
      78           0 :     Warning("GetPadDimensionsByIndices","indices outside range");
      79           0 :     dx = 0.;
      80           0 :     dy = 0.;
      81             :   }
      82     5507021 : }
      83             : 
      84             : //_____________________________________________________________________________
      85             : void AliMpMotif::GetPadDimensionsByIndices(Int_t ixLocal, Int_t iyLocal,
      86             :                                            Double_t& dx, Double_t& dy) const
      87             : {
      88             :   /// Give the dimension of the specified pad in the motif
      89             : 
      90         996 :   GetPadDimensionsByIndices(AliMp::Pair(ixLocal, iyLocal), dx, dy);
      91         498 : }
      92             : 
      93             : //_____________________________________________________________________________
      94             : Double_t AliMpMotif::DimensionX() const
      95             : {
      96             :   /// Give the x dimension of the motif
      97             : 
      98    11149608 :   return GetMotifType()->GetNofPadsX()*fPadDimensionX;
      99             : }
     100             : 
     101             : //_____________________________________________________________________________
     102             : Double_t AliMpMotif::DimensionY() const
     103             : {
     104             :   /// Give the y dimension of the motif
     105             : 
     106    11075328 :   return GetMotifType()->GetNofPadsY()*fPadDimensionY;
     107             : }
     108             : 
     109             : //_____________________________________________________________________________
     110             : void AliMpMotif::PadPositionLocal(MpPair_t localIndices,
     111             :                          Double_t& posx, Double_t& posy ) const 
     112             : {
     113             :   /// Give the local position of the pad number (ix,iy)
     114             :   /// (0,0 is the center of the motif)
     115             : 
     116    16519569 :   PadPositionLocal(AliMp::PairFirst(localIndices), 
     117     5506523 :                    AliMp::PairSecond(localIndices),
     118             :                    posx, posy);
     119     5506523 : }
     120             : 
     121             : //_____________________________________________________________________________
     122             : void AliMpMotif::PadPositionLocal(Int_t ixLocal, Int_t iyLocal,
     123             :                          Double_t& posx, Double_t& posy) const 
     124             : {
     125             :   /// Give the local position of the pad number (ix,iy)
     126             :   /// (0,0 is the center of the motif)
     127             : 
     128    11013046 :   posx = (2.*ixLocal+1.)*fPadDimensionX - DimensionX();
     129     5506523 :   posy = (2.*iyLocal+1.)*fPadDimensionY - DimensionY();
     130     5506523 : }
     131             : 
     132             : //_____________________________________________________________________________
     133             : MpPair_t AliMpMotif::PadIndicesLocal(Double_t localPosX, Double_t localPosY) const
     134             : {
     135             :   /// Return the pad indices from a given local position
     136             :   /// or (-1,-1) if this position doesn't correspond to any valid
     137             :   /// connection
     138             : 
     139             :   Double_t lowerLeftX = localPosX;
     140             :   Double_t lowerLeftY = localPosY;
     141             :   
     142       10752 :   lowerLeftX += DimensionX();
     143        5376 :   lowerLeftY += DimensionY();
     144             : 
     145       10384 :   if ( lowerLeftX < - AliMpConstants::LengthTolerance() || 
     146        5008 :        lowerLeftY < - AliMpConstants::LengthTolerance() ) 
     147             :     {
     148         370 :       return -1;
     149             :     }
     150             : 
     151        5006 :   Int_t ix = (Int_t)(lowerLeftX/(2.*fPadDimensionX));
     152        5006 :   Int_t iy = (Int_t)(lowerLeftY/(2.*fPadDimensionY));
     153             :   
     154        5006 :   if ( ! GetMotifType()->FindConnectionByLocalIndices(ix,iy) )
     155             :   {
     156         915 :     return -1;
     157             :   }
     158             :   
     159        4091 :   return AliMp::Pair(ix,iy);
     160        5376 : }

Generated by: LCOV version 1.11