6 // Class that defines a motif with its unique ID
8 // Included in AliRoot: 2003/05/02
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
11 #include "AliMpMotif.h"
12 #include "AliMpMotifType.h"
13 #include "AliMpIntPair.h"
17 //_____________________________________________________________________________
18 AliMpMotif::AliMpMotif()
20 fPadDimensions(TVector2(0.,0.))
22 //default dummy constructor
25 //_____________________________________________________________________________
26 AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
27 const TVector2& padDimension)
28 : AliMpVMotif(id,motifType),
29 fPadDimensions(padDimension)
31 // Normal constructor.
32 // The dimension in a given direction is calculated by
33 // multiplying the total dimension by the number of pads
36 //_____________________________________________________________________________
37 AliMpMotif::~AliMpMotif()
43 //_____________________________________________________________________________
44 TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
46 // gives the dimension of the specified pad in the motif
48 if (GetMotifType()->HasPad(localIndices))
49 return fPadDimensions;
51 Warning("GetPadDimensions","indices outside range");
52 return TVector2(0.,0.);
56 //_____________________________________________________________________________
57 TVector2 AliMpMotif::Dimensions() const
59 // gives the dimension of the motif
61 return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
62 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
65 //_____________________________________________________________________________
66 TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const
68 // gives the local position of the pad number (ix,iy)
69 // (0,0 is the center of the motif)
71 TVector2 dim=Dimensions();
72 return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
73 (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
76 //_____________________________________________________________________________
77 AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
79 // return the pad indices from a given local position
80 // or (-1,-1) if this position doesn't correspond to any valid
83 TVector2 lowerLeft = localPos+Dimensions();
84 Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X()));
85 Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y()));
87 if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy))) {
88 //Warning("PadIndicesLocal","Position outside motif");
89 return AliMpIntPair::Invalid();
91 return AliMpIntPair(ix,iy);