4 // Class AliMpTransformer
5 // ------------------------
6 // Class contains definition of transformation and
7 // provides functions for transforming pads.
8 // Included in AliRoot: 2003/05/02
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
11 #include "AliMpTransformer.h"
13 ClassImp(AliMpTransformer)
15 ///_____________________________________________________________________________
16 AliMpTransformer::AliMpTransformer(const TVector2& offset,
17 const AliMpIntPair& scale)
25 ///_____________________________________________________________________________
26 AliMpTransformer::AliMpTransformer()
29 fScale(AliMpIntPair(1,1))
34 //_____________________________________________________________________________
35 AliMpTransformer::~AliMpTransformer() {
43 //_____________________________________________________________________________
44 void AliMpTransformer::CutInterval(Double_t x1, Double_t x2, Double_t x0,
45 Double_t s, Double_t& pos, Double_t& dx) const
47 // Cuts the interval <x1,x2> into <x1', x2'>
48 // by position x0 in direction of s*x.
49 // Returns the centre of the new interval (pos) and its half size.
54 Double_t sx0 = s * x0;
55 Double_t sx1 = s * x1;
56 Double_t sx2 = s * x2;
59 // when inversion, replace x1 and x2
66 // the interval outside region
71 // x0 cuts the interval
76 // the interval inside region
78 pos = s * ((sx2 + sx1)/2.);
86 //_____________________________________________________________________________
87 AliMpIntPair AliMpTransformer::Scale(const AliMpIntPair& pair) const
89 // Returns the pair with values scaled by the given scale.
95 //_____________________________________________________________________________
96 TVector2 AliMpTransformer::Scale(const TVector2& vector) const
98 // Returns vector with values scaled by the given scale.
101 return TVector2(vector.X()*fScale.GetFirst(), vector.Y()*fScale.GetSecond());
104 //_____________________________________________________________________________
105 AliMpIntPair AliMpTransformer::ScaleLocation(const AliMpIntPair& orig) const
107 // Returns location with values scaled by the given scale.
110 return AliMpIntPair(orig.GetFirst() * fScale.GetSecond(), orig.GetSecond(),
114 //_____________________________________________________________________________
115 AliMpPad AliMpTransformer::Scale(const AliMpPad& pad) const
117 // Returns pad with indices scaled by the given scale.
120 return AliMpPad(ScaleLocation(pad.GetLocation()),
121 Scale(pad.GetIndices()),
122 Scale(pad.Position()),
127 //_____________________________________________________________________________
128 TVector2 AliMpTransformer::Transform(const TVector2& vector) const
130 // Transforms given vector with scale and corresponding translation
131 // from sector (local) to plane (global).
134 return Scale(vector) + fOffset;
137 //_____________________________________________________________________________
138 TVector2 AliMpTransformer::ITransform(const TVector2& vector) const
140 // Transforms given vector with scale and corresponding translation
141 // from plane (global) to sector (local).
144 return Scale(vector - fOffset);
147 //_____________________________________________________________________________
148 AliMpPad AliMpTransformer::Transform(const AliMpPad& pad) const
150 // Returns pad with characteristics transformed with given scale and
151 // corresponding translation from sector (local) to plane (global).
154 return AliMpPad(ScaleLocation(pad.GetLocation()),
155 Scale(pad.GetIndices()),
156 Transform(pad.Position()),
162 //_____________________________________________________________________________
163 AliMpPad AliMpTransformer::ITransform(const AliMpPad& pad) const
165 // Returns pad with characteristics transformed with given scale and
166 // corresponding translation from plane (global) to sector (local).
169 return AliMpPad(ScaleLocation(pad.GetLocation()),
170 Scale(pad.GetIndices()),
171 ITransform(pad.Position()),
176 //_____________________________________________________________________________
177 AliMpArea AliMpTransformer::CutArea(const AliMpArea& area) const
179 // Cuts the area with its offset in the quadrant defined by scale
180 // and transforms its position into its local system.
184 CutInterval(area.LeftBorder(), area.RightBorder(), fOffset.X(),
185 fScale.GetFirst(), posx, dx);
188 CutInterval(area.DownBorder(), area.UpBorder(), fOffset.Y(),
189 fScale.GetSecond(), posy, dy);
191 return AliMpArea(ITransform(TVector2(posx, posy)), TVector2(dx, dy));