1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpMotif.cxx,v 1.8 2006/05/24 13:58:41 ivana Exp $
22 // Class that defines a motif with its unique ID
23 // and the motif type.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 #include "AliMpMotif.h"
29 #include "AliMpConstants.h"
30 #include "AliMpIntPair.h"
31 #include "AliMpMotifType.h"
37 //_____________________________________________________________________________
38 AliMpMotif::AliMpMotif()
40 fPadDimensions(TVector2(0.,0.))
42 /// Default constructor
45 //_____________________________________________________________________________
46 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
47 const TVector2& padDimension)
48 : AliMpVMotif(id,motifType),
49 fPadDimensions(padDimension)
51 /// Standard constructor. \n
52 /// The dimension in a given direction is calculated by
53 /// multiplying the total dimension by the number of pads
56 //_____________________________________________________________________________
57 AliMpMotif::~AliMpMotif()
63 //_____________________________________________________________________________
64 TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
66 /// Give the dimension of the specified pad in the motif
68 if (GetMotifType()->HasPad(localIndices))
69 return fPadDimensions;
71 Warning("GetPadDimensions","indices outside range");
72 return TVector2(0.,0.);
76 //_____________________________________________________________________________
77 TVector2 AliMpMotif::Dimensions() const
79 /// Give the dimension of the motif
81 return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
82 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
85 //_____________________________________________________________________________
86 TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const
88 /// Give the local position of the pad number (ix,iy)
89 /// (0,0 is the center of the motif)
91 TVector2 dim=Dimensions();
92 return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
93 (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
96 //_____________________________________________________________________________
97 AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
99 /// Return the pad indices from a given local position
100 /// or (-1,-1) if this position doesn't correspond to any valid
103 TVector2 lowerLeft(localPos);
105 lowerLeft += Dimensions();
107 if ( lowerLeft.X() < - AliMpConstants::LengthTolerance() ||
108 lowerLeft.Y() < - AliMpConstants::LengthTolerance() )
110 return AliMpIntPair::Invalid();
113 Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X()));
114 Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y()));
116 if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy)))
118 return AliMpIntPair::Invalid();
120 return AliMpIntPair(ix,iy);