]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpMotif.cxx
new class AliMUONLoader
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotif.cxx
CommitLineData
5f91c9e8 1// $Id$
2// Category: motif
3//
4// Class AliMpMotif
5// ----------------
6// Class that defines a motif with its unique ID
7// and the motif type.
8//
9// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10
11#include "AliMpMotif.h"
12#include "AliMpMotifType.h"
13#include "AliMpIntPair.h"
14
15ClassImp(AliMpMotif)
16
17//_____________________________________________________________________________
18AliMpMotif::AliMpMotif()
19 : AliMpVMotif(),
20 fPadDimensions(TVector2(0.,0.))
21{
22 //default dummy constructor
23}
24
25//_____________________________________________________________________________
26AliMpMotif::AliMpMotif(const TString &id, AliMpMotifType *motifType,
27 const TVector2& padDimension)
28 : AliMpVMotif(id,motifType),
29 fPadDimensions(padDimension)
30{
31 // Normal constructor.
32 // The dimension in a given direction is calculated by
33 // multiplying the total dimension by the number of pads
34
35}
36
37//_____________________________________________________________________________
38TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
39{
40 // gives the dimension of the specified pad in the motif
41
42 if (GetMotifType()->HasPad(localIndices))
43 return fPadDimensions;
44 else {
45 Warning("GetPadDimensions","indices outside range");
46 return TVector2(0.,0.);
47 }
48}
49
50//_____________________________________________________________________________
51TVector2 AliMpMotif::Dimensions() const
52{
53 // gives the dimension of the motif
54
55 return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
56 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
57}
58
59//_____________________________________________________________________________
60TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const
61{
62 // gives the local position of the pad number (ix,iy)
63 // (0,0 is the center of the motif)
64
65 TVector2 dim=Dimensions();
66 return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
67 (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
68}
69
70//_____________________________________________________________________________
71AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
72{
73 // return the pad indices from a given local position
74 // or (-1,-1) if this position doesn't correspond to any valid
75 // connection
76
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()));
80
81 if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy))) {
82 //Warning("PadIndicesLocal","Position outside motif");
83 return AliMpIntPair::Invalid();
84 }
85 return AliMpIntPair(ix,iy);
86}