AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpRowSegment.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpRowSegment.cxx,v 1.10 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpRowSegment
22 // ---------------------
23 // Class describing a row segment composed of the
24 // the identic motifs.
25 // Included in AliRoot: 2003/05/02
26 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 //-----------------------------------------------------------------------------
28 
29 #include "AliMpRowSegment.h"
30 #include "AliMpRow.h"
31 #include "AliMpVMotif.h"
32 #include "AliMpMotifType.h"
34 #include "AliMpMotifMap.h"
35 #include "AliMpMotifPosition.h"
36 #include "AliMpConstants.h"
37 #include "AliMpEncodePair.h"
38 
39 #include "AliLog.h"
40 
41 #include <TMath.h>
42 #include <Riostream.h>
43 
44 using std::endl;
48 
49 //_____________________________________________________________________________
51  Int_t padOffsetX, Int_t padOffsetY,
52  Int_t nofMotifs,
53  Int_t motifPositionId, Int_t motifPositionDId)
54  : AliMpVRowSegment(),
55  fNofMotifs(nofMotifs),
56  fLPadOffset(AliMp::Pair(padOffsetX,padOffsetY)),
57  fOffsetX(0.),
58  fOffsetY(0.),
59  fRow(row),
60  fMotif(motif),
61  fMotifPositionId(motifPositionId),
62  fMotifPositionDId(motifPositionDId)
63 {
65 
66  // Keep pad offset in the low indices limits
67  SetLowIndicesLimit(fLPadOffset);
68 }
69 
70 //_____________________________________________________________________________
72  : AliMpVRowSegment(),
73  fNofMotifs(0),
74  fLPadOffset(0),
75  fOffsetX(0.),
76  fOffsetY(0.),
77  fRow(0),
78  fMotif(0),
79  fMotifPositionId(0),
80  fMotifPositionDId(0)
81 {
83 }
84 
85 //_____________________________________________________________________________
87 {
89 }
90 
91 //
92 // private methods
93 //
94 
95 //_____________________________________________________________________________
97 {
100 
101  return fOffsetX;
102 }
103 
104 //_____________________________________________________________________________
106 {
109 
110  return fOffsetX + 2.*(fNofMotifs-1)*fMotif->DimensionX();
111 }
112 
113 //_____________________________________________________________________________
114 Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const
115 {
118 
119  // Check if x is in the row segment range
120  if (! HasMotifPosition(motifPositionId)) {
121  AliErrorStream() << "Outside row segment region" << endl;
122  return 0;
123  }
124 
125  // Find the position number in the segment
126  Int_t num = (motifPositionId - fMotifPositionId) * fMotifPositionDId;
127 
128  return fOffsetX + num*(fMotif->DimensionX() * 2.0);
129 }
130 
131 //_____________________________________________________________________________
132 Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const
133 {
136 
137  // Check if x is in the row segment range
138  if (! HasMotifPosition(motifPositionId)) {
139  AliErrorStream() << "Outside row segment region" << endl;
140  return 0;
141  }
142 
143  return GetRow()->GetPositionY() + fOffsetY;
144 }
145 
146 //_____________________________________________________________________________
147 Bool_t AliMpRowSegment::IsInside(Double_t x, Double_t y, Bool_t warn) const
148 {
150 
151  Double_t minY = GetRow()->GetPositionY() + fOffsetY - fMotif->DimensionY();
152  Double_t maxY = GetRow()->GetPositionY() + fOffsetY + fMotif->DimensionY();
153 
154  if ( x < LeftBorderX() || x > RightBorderX() ||
155  y < minY || y > maxY ) {
156 
157  if (warn)
158  AliWarningStream() << "Outside row segment region" << endl;
159  return false;
160  }
161  else
162  return true;
163 }
164 
165 //
166 // public methods
167 //
168 
169 //_____________________________________________________________________________
171 {
174 
175  return FirstMotifCenterX() - fMotif->DimensionX();
176 }
177 
178 //_____________________________________________________________________________
180 {
183 
184  return LastMotifCenterX() + fMotif->DimensionX();
185 }
186 
187 //_____________________________________________________________________________
189 {
191 
192  return fMotif->DimensionY() + fOffsetY;
193 }
194 
195 //_____________________________________________________________________________
196 AliMpVMotif* AliMpRowSegment::FindMotif(Double_t x, Double_t y) const
197 {
199 
200  if ( IsInside(x, y, false) )
201  return fMotif;
202  else
203  return 0;
204 }
205 
206 //_____________________________________________________________________________
207 Int_t AliMpRowSegment::FindMotifPositionId(Double_t x, Double_t y) const
208 {
211 
212  if ( ! IsInside(x, y, false) ) return 0;
213 
214  // Find the position number in the segment
215  Int_t num
216  = Int_t((x - LeftBorderX()) / (fMotif->DimensionX() * 2.0));
217 
218  // Calculate the position Id
219  return fMotifPositionId + num*fMotifPositionDId;
220 }
221 
222 //_____________________________________________________________________________
223 Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const
224 {
227 
228  Int_t minId = TMath::Min(fMotifPositionId,
230  Int_t maxId = TMath::Max(fMotifPositionId,
232 
233  if (motifPositionId >= minId && motifPositionId <= maxId) {
234  return true;
235  }
236  else
237  return false;
238 }
239 
240 //_____________________________________________________________________________
241 void AliMpRowSegment::MotifCenter(Int_t motifPositionId,
242  Double_t& x, Double_t& y) const
243 {
246 
247  x = MotifCenterX(motifPositionId);
248  y = MotifCenterY(motifPositionId);
249 }
250 
251 //_____________________________________________________________________________
253 {
255 
256  return (LeftBorderX() + RightBorderX())/2.;
257 }
258 
259 //_____________________________________________________________________________
261 {
263 
264  return GetRow()->GetPositionY();
265 }
266 
267 //_____________________________________________________________________________
269 {
271 // ---
272 
273  return (RightBorderX() - LeftBorderX())/2.;
274 }
275 
276 //_____________________________________________________________________________
278 {
280 // ---
281 
282  return GetRow()->GetDimensionY();
283 }
284 
285 //_____________________________________________________________________________
286 void AliMpRowSegment::SetOffset(Double_t x, Double_t y)
287 {
290 
292  iter.First();
293 
294  Int_t ix = iter.CurrentItem().GetIx();
295  Int_t iy = iter.CurrentItem().GetIy();
296 
297  Double_t dx, dy;
298  fMotif->GetPadDimensionsByIndices(ix, iy, dx, dy);
299 
300  fOffsetX
301  = x + 2.*AliMp::PairFirst(fLPadOffset) * dx + fMotif->DimensionX();
302 
303  fOffsetY
304  = y + AliMp::PairSecond(fLPadOffset) * dy;
305 }
306 
307 //_____________________________________________________________________________
309 {
311 
312  // The low/high indices limits has to be taken as the highest/lowest from all
313  // motif positions
314  Int_t ixl = 9999;
315  Int_t iyl = 9999;
316  Int_t ixh = AliMpConstants::StartPadIndex();
317  Int_t iyh = AliMpConstants::StartPadIndex();
318 
319  for (Int_t i=0; i<GetNofMotifs(); i++) {
320 
321  AliMpMotifPosition* mPos
323 
324  // Check if the motif positions has the limits set
325  if ( !mPos->HasValidIndices() )
326  Fatal("SetGlobalIndices",
327  "Indices of motif positions have to be set first.");
328 
329  if ( mPos->GetLowLimitIx() < ixl )
330  ixl = mPos->GetLowLimitIx();
331 
332  if ( mPos->GetLowLimitIy() < iyl )
333  iyl = mPos->GetLowLimitIy();
334 
335  if ( mPos->GetHighLimitIx() > ixh )
336  ixh = mPos->GetHighLimitIx();
337 
338  if ( mPos->GetHighLimitIy() > iyh )
339  iyh = mPos->GetHighLimitIy();
340  }
341 
342  SetLowIndicesLimit(ixl, iyl);
343  SetHighIndicesLimit(ixh, iyh);
344 }
345 
346 //_____________________________________________________________________________
348 {
351 
352  // Get motif position
353  AliMpMotifPosition* motifPosition
355 
356  // Low limit
357  MpPair_t low = indices + AliMp::Pair(0, GetLowLimitIy());
358  motifPosition->SetLowIndicesLimit(low);
359 
360  // High limit
361  AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
362  MpPair_t high
363  = motifPosition->GetLowIndicesLimit()
364  + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
365  motifPosition->SetHighIndicesLimit(high);
366 
367  // Return next index in x
368  return AliMp::PairFirst(high)+1;
369  // return motifType->GetNofPadsX();
370 }
371 
372 
373 //_____________________________________________________________________________
375 {
377 
378  return fRow;
379 }
380 
381 //_____________________________________________________________________________
383 {
385 
386  return fNofMotifs;
387 }
388 
389 //_____________________________________________________________________________
391 {
393 
395 }
396 
397 //_____________________________________________________________________________
399 {
401 
402  return fMotif;
403 }
void SetLowIndicesLimit(MpPair_t limit, Bool_t valid=true)
virtual Double_t GetDimensionX() const
Return the x dimension of the row segment centre.
Int_t fMotifPositionId
the first motif position id
Int_t GetLowLimitIx() const
Int_t fNofMotifs
number of motifs
virtual ~AliMpRowSegment()
Int_t fMotifPositionDId
+1 if ids are increasing, -1 if decreasing
AliMpRow * fRow
the row containing this segment
Double_t fOffsetY
the y position of the centre of the first motif wrt to row center
virtual Double_t DimensionY() const =0
Return y dimensions.
virtual void SetOffset(Double_t x, Double_t y)
Calculate offset.
An iterator over the pads of a given motif type.
Double_t GetPositionY() const
Definition: AliMpRow.cxx:347
virtual Bool_t HasMotifPosition(Int_t motifPositionId) const
Has the motif position with the given Id ?
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
Int_t GetLowLimitIy() const
Int_t GetHighLimitIy() const
virtual void First()
Set iterator to the first pad.
virtual Double_t LeftBorderX() const
Return the x coordinate of the left border in the global coordinate system.
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
AliMpVMotif * fMotif
the motif
Double_t GetDimensionY() const
Definition: AliMpRow.cxx:364
Double_t MotifCenterX(Int_t motifPositionId) const
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
An interface for a row segment.
virtual Double_t GetPositionX() const
Return the x position of the row segment centre.
void SetHighIndicesLimit(MpPair_t limit, Bool_t valid=true)
virtual AliMpRow * GetRow() const
Return the row.which this row segment belongs to.
virtual Double_t GetPositionY() const
Return the y position of the row segment centre.
virtual void MotifCenter(Int_t motifPositionId, Double_t &x, Double_t &y) const
Fill the coordinates of the motif specified with the given motif position Id.
A placed motif.
Int_t GetNofPadsX() const
Return number of pads in x direction.
Double_t fOffsetX
the x position of the centre of the first motif wrt to left border
Int_t GetNofPadsY() const
Return number of pads in y direction.
A row segment composed of the the identic motifs.
MpPair_t GetLowIndicesLimit() const
virtual AliMpVMotif * GetMotif(Int_t) const
Return the i-th motif of this row segment.
virtual Int_t SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
Set global indices to i-th motif position and returns next index in x.
AliMpVMotif * GetMotif() const
Return motif.
virtual Double_t HalfSizeY() const
Return the half size in y of this row segment.
A row composed of the row segments.
Definition: AliMpRow.h:26
virtual AliMpVMotif * FindMotif(Double_t x, Double_t y) const
Find the motif in the given positions.
virtual Double_t DimensionX() const =0
Return x dimensions.
Double_t FirstMotifCenterX() const
static Int_t StartPadIndex()
Return global pad indices start value.
MpPair_t fLPadOffset
the offset in nof pads
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
Int_t MpPair_t
Double_t MotifCenterY(Int_t motifPositionId) const
virtual Int_t GetMotifPositionId(Int_t i) const
Return the i-th motif position Id of this row segment.
virtual Int_t GetNofMotifs() const
Return the number of motifs in this this row segment.
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
AliMpMotifPosition * FindMotifPosition(Int_t motifPositionID) const
virtual Int_t FindMotifPositionId(Double_t x, Double_t y) const
Find the motif position Id in the given positions.
virtual Double_t GetDimensionY() const
Return the y dimension of the row segment centre.
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
Int_t GetHighLimitIx() const
virtual void SetGlobalIndices(AliMpRow *rowBefore)
Set global indices limits.
Double_t LastMotifCenterX() const
virtual Double_t RightBorderX() const
Return the x coordinate of the right border in the global coordinate system.
AliMpMotifMap * GetMotifMap() const
Return the motif map associated with its sector.
Definition: AliMpRow.h:86
Bool_t HasValidIndices() const
Class that defines the motif properties.
Bool_t IsInside(Double_t x, Double_t y, Bool_t warn=true) const
virtual void GetPadDimensionsByIndices(MpPair_t localIndices, Double_t &dx, Double_t &dy) const =0
Return the dimensions of the pad specified by localIndices.