]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpMotif.cxx
Coding conventions
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotif.cxx
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 "AliMpIntPair.h"
33 #include "AliMpMotifType.h"
34
35 /// \cond CLASSIMP
36 ClassImp(AliMpMotif)
37 /// \endcond
38
39 //_____________________________________________________________________________
40 AliMpMotif::AliMpMotif()
41   : AliMpVMotif(),
42     fPadDimensions(TVector2(0.,0.))
43 {
44   /// Default constructor
45 }
46
47 //_____________________________________________________________________________
48 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
49                        const TVector2& padDimension)
50   : AliMpVMotif(id,motifType),
51     fPadDimensions(padDimension)
52 {
53   /// Standard constructor.                                                \n
54   /// The dimension in a given direction is calculated by
55   /// multiplying the total dimension by the number of pads
56
57 }
58 //_____________________________________________________________________________
59 AliMpMotif::~AliMpMotif()
60 {
61   /// Destructor
62 }
63
64
65 //_____________________________________________________________________________
66 TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
67 {
68   /// Give the dimension of the specified pad in the motif
69
70   if (GetMotifType()->HasPad(localIndices))
71     return fPadDimensions;
72   else {
73     Warning("GetPadDimensions","indices outside range");
74     return TVector2(0.,0.);
75   }
76 }
77
78 //_____________________________________________________________________________
79 TVector2 AliMpMotif::Dimensions() const
80 {
81   /// Give the dimension of the motif
82
83   return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
84                 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
85 }
86
87 //_____________________________________________________________________________
88 TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const 
89 {
90   /// Give the local position of the pad number (ix,iy)
91   /// (0,0 is the center of the motif)
92
93   TVector2 dim=Dimensions();
94   return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
95                   (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
96 }
97
98 //_____________________________________________________________________________
99 AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
100 {
101   /// Return the pad indices from a given local position
102   /// or (-1,-1) if this position doesn't correspond to any valid
103   /// connection
104
105   TVector2 lowerLeft(localPos);
106   
107   lowerLeft += Dimensions();
108
109   if ( lowerLeft.X() < - AliMpConstants::LengthTolerance() || 
110        lowerLeft.Y() < - AliMpConstants::LengthTolerance() ) 
111     {
112       return AliMpIntPair::Invalid();
113     }
114
115   Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X()));
116   Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y()));
117   
118   if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy)))
119   {
120     return AliMpIntPair::Invalid();
121   }
122   return AliMpIntPair(ix,iy);
123 }