AliMpReader splitted into AliMpMotifReader and AliMpSectorReader
[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.
dbe945cc 8// Included in AliRoot: 2003/05/02
5f91c9e8 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}
2998a151 36//_____________________________________________________________________________
37AliMpMotif::~AliMpMotif()
38{
39 // destructor
40}
41
5f91c9e8 42
43//_____________________________________________________________________________
44TVector2 AliMpMotif::GetPadDimensions(const AliMpIntPair& localIndices) const
45{
46 // gives the dimension of the specified pad in the motif
47
48 if (GetMotifType()->HasPad(localIndices))
49 return fPadDimensions;
50 else {
51 Warning("GetPadDimensions","indices outside range");
52 return TVector2(0.,0.);
53 }
54}
55
56//_____________________________________________________________________________
57TVector2 AliMpMotif::Dimensions() const
58{
59 // gives the dimension of the motif
60
61 return TVector2(GetMotifType()->GetNofPadsX()*fPadDimensions.X(),
62 GetMotifType()->GetNofPadsY()*fPadDimensions.Y());
63}
64
65//_____________________________________________________________________________
66TVector2 AliMpMotif::PadPositionLocal(const AliMpIntPair& localIndices) const
67{
68 // gives the local position of the pad number (ix,iy)
69 // (0,0 is the center of the motif)
70
71 TVector2 dim=Dimensions();
72 return TVector2((2.*localIndices.GetFirst()+1.)*fPadDimensions.X()-dim.X(),
73 (2.*localIndices.GetSecond()+1.)*fPadDimensions.Y()-dim.Y());
74}
75
76//_____________________________________________________________________________
77AliMpIntPair AliMpMotif::PadIndicesLocal(const TVector2& localPos) const
78{
79 // return the pad indices from a given local position
80 // or (-1,-1) if this position doesn't correspond to any valid
81 // connection
82
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()));
86
87 if (!GetMotifType()->FindConnectionByLocalIndices(AliMpIntPair(ix,iy))) {
88 //Warning("PadIndicesLocal","Position outside motif");
89 return AliMpIntPair::Invalid();
90 }
91 return AliMpIntPair(ix,iy);
92}