6 // Class that defines a motif with its unique ID
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
37 //_____________________________________________________________________________
38 TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
40 // gives the dimension of the specified pad in the motif
42 if (GetMotifType()->HasPad(localIndices))
43 return fPadDimensions;
45 Warning("GetPadDimensions","indices outside range");
46 return TVector2(0.,0.);
50 //_____________________________________________________________________________
51 TVector2 AliMpMotif::Dimensions() const
53 // gives the dimension of the motif
55 return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
56 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
59 //_____________________________________________________________________________
60 TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const
62 // gives the local position of the pad number (ix,iy)
63 // (0,0 is the center of the motif)
65 TVector2 dim=Dimensions();
66 return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
67 (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
70 //_____________________________________________________________________________
71 AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
73 // return the pad indices from a given local position
74 // or (-1,-1) if this position doesn't correspond to any valid
77 TVector2 lowerLeft = localPos+Dimensions();
78 Int_t ix = (Int_t)(lowerLeft.X()/(2.*fPadDimensions.X()));
79 Int_t iy = (Int_t)(lowerLeft.Y()/(2.*fPadDimensions.Y()));
81 if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy))) {
82 //Warning("PadIndicesLocal","Position outside motif");
83 return AliMpIntPair::Invalid();
85 return AliMpIntPair(ix,iy);