AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpRowSegmentRSpecial.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: AliMpRowSegmentRSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpRowSegmentRSpecial
22 // -----------------------------
23 // Class describing a special outer row segment composed of the
24 // pad rows.
25 // Included in AliRoot: 2003/05/02
26 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 //-----------------------------------------------------------------------------
28 
30 #include "AliMpRow.h"
31 #include "AliMpPadRow.h"
32 #include "AliMpVPadRowSegment.h"
33 #include "AliMpMotif.h"
34 #include "AliMpMotifType.h"
35 #include "AliMpMotifMap.h"
36 #include "AliMpMotifPosition.h"
37 #include "AliMpConstants.h"
38 
39 #include "AliLog.h"
40 
41 #include <Riostream.h>
42 #include <TMath.h>
43 
44 using std::endl;
48 
49 //______________________________________________________________________________
51  : AliMpVRowSegmentSpecial(row, offsetX)
52 {
54 }
55 
56 //______________________________________________________________________________
59 {
61 }
62 
63 //______________________________________________________________________________
65 {
67 }
68 
69 //
70 // private methods
71 //
72 
73 //______________________________________________________________________________
76 {
78 
79  AliMpVPadRowSegment* found = 0;
80 
81  for (Int_t i=0; i<GetNofPadRows(); i++) {
82  AliMpPadRow* padRow = GetPadRow(i);
83 
84  for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
85  AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
86 
87  if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
88  (!found || padRowSegment->LeftBorderX() < found->LeftBorderX()))
89 
90  found = padRowSegment;
91  }
92  }
93 
94  return found;
95 }
96 
97 //______________________________________________________________________________
99 {
101 
102  // Last normal row segment in the row
103  // (preceding this special row segment)
104  AliMpVRowSegment* rowSegment
105  = GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2);
106 
107  // Set low indices limit to continue indices of the
108  // preceding row segment
109  Int_t ix = rowSegment->GetHighLimitIx() + 1;
110  Int_t iy = rowSegment->GetLowLimitIy();
111 
112  SetLowIndicesLimit(ix, iy);
113 }
114 
115 //
116 // protected methods
117 //
118 
119 //______________________________________________________________________________
120 void AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId,
121  Double_t& x, Double_t& y) const
122 {
127 
128  // Find the first (left, down) pad row segment with this motifPositionId.
129  AliMpVPadRowSegment* downPadRowSegment
130  = FindPadRowSegment(motifPositionId);
131  AliMpVPadRowSegment* leftPadRowSegment
132  = FindMostLeftPadRowSegment(motifPositionId);
133 
134  // Check if the motifPositionId is present
135  if (!downPadRowSegment || !leftPadRowSegment) {
136  AliErrorStream() << "Outside row segment region" << endl;
137  return;
138  }
139 
140  // Check if both pad row segments have the same motif
141  if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) {
142  AliFatal("Outside row segment region");
143  return;
144  }
145 
146  // Get position of found row segment
147  x = leftPadRowSegment->LeftBorderX();
148  y = GetRow()->LowBorderY() ;
149 
150  for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
151  y += GetPadRow(i)->HalfSizeY()*2.;
152 
153  // Add motifs dimensions
154  x += downPadRowSegment->GetMotif()->DimensionX();
155  y += downPadRowSegment->GetMotif()->DimensionY();
156 }
157 
158 //
159 // public methods
160 //
161 
162 //______________________________________________________________________________
164 {
167 
168  // The right edge of the last normal segment
169  Double_t sameBorder = GetOffsetX();
170 
171  // Consistence check
172  Double_t leftBorder = DBL_MAX;
173  for (Int_t i=0; i<GetNofPadRows(); i++) {
174  AliMpPadRow* padRow = GetPadRow(i);
175  Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX();
176  if (border < leftBorder) leftBorder = border;
177  }
178 
179  if (TMath::Abs(sameBorder - leftBorder) > 1.e-04) {
180  AliErrorStream() << "WrongBorder" << endl;;
181  return sameBorder;
182  }
183 
184  return leftBorder;
185 
186 }
187 
188 //______________________________________________________________________________
190 {
193 
194  Double_t rightBorder = -DBL_MAX;
195  for (Int_t i=0; i<GetNofPadRows(); i++) {
196  AliMpPadRow* padRow = GetPadRow(i);
197  Double_t border
198  = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)
199  ->RightBorderX();
200 
201  if (border > rightBorder) rightBorder = border;
202  }
203 
204  return rightBorder;
205 }
206 
207 //______________________________________________________________________________
209 {
213 
214  // The right edge of the last normal segment
215  return GetOffsetX() + GetDimensionX();
216 }
217 
218 //______________________________________________________________________________
220 {
224 
225  // The right edge of the last normal segment
226  return GetRow()->GetPositionY();
227 }
228 
229 //______________________________________________________________________________
231 {
233 
234  // Update low indices limit for this row segment
236 
237  // Check for consistence
238  if ( GetLowLimitIx() != AliMp::PairFirst(indices) )
239  AliFatal("Inconsistent indices");
240 
241  // Get motif position
242  AliMpMotifPosition* motifPosition
244 
245  // Set limits only once
246  if ( motifPosition->IsHighLimitValid() )
247  return AliMp::PairFirst(indices);
248 
249  // Low limit
250  //
251  Int_t ixl = GetLowLimitIx();
252  Int_t iyl = GetLowLimitIy();
253 
254  // Find the most down pad row segment with this motifPositionId.
256  Int_t padRowID = padRowSegment->GetPadRow()->GetID();
257  iyl += padRowID;
258 
259  // Add pads offset of this motif position in the row segment
260  for ( Int_t im=0; im<i; im++ ) {
261  AliMpVPadRowSegment* rs = GetPadRow(padRowID)->GetPadRowSegment(im);
262  if ( rs->GetMotifPositionId() == GetMotifPositionId(i) ) break;
263  ixl += rs->GetNofPads();
264  }
265  motifPosition->SetLowIndicesLimit(ixl, iyl);
266 
267  // High limit
268  //
269  AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
270  MpPair_t high
271  = motifPosition->GetLowIndicesLimit()
272  + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
273  motifPosition->SetHighIndicesLimit(high);
274 
275  // No increment index needed (this is always the last element)
276  return AliMp::PairFirst(indices);
277 }
278 
279 //______________________________________________________________________________
281 {
285 
286  // Get first motif position
287  AliMpMotifPosition* firstMotifPosition
289 
290  // Low ix
291  Int_t ixl = firstMotifPosition->GetLowLimitIx();
292  // We have to take the motif position limit
293  // as it can overlap over more rows and the indices
294  // of the right border of the precedent normal segment
295  // differ from one row to another
296 
297  // High ix
298  Int_t ixh = ixl + MaxNofPadsInRow() - 1;
299 
300  // Low iy
301  Int_t iyl = AliMpConstants::StartPadIndex();
302  if (rowBefore) {
303  //if (constPadSizeDirection == kY) {
304  iyl = rowBefore->GetHighLimitIy()+1;
305  //}
306  /*
307  else {
308  AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
309  AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
310  if (!motPos)
311  Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
312  iyl = motPos->GetHighLimitIy()+1;
313  }
314  */
315  }
316 
317  // High iy
318  Int_t iyh = iyl + GetNofPadRows() - 1;
319 
320  SetLowIndicesLimit(ixl, iyl);
321  SetHighIndicesLimit(ixh, iyh);
322 }
323 
324 
void SetLowIndicesLimit(MpPair_t limit, Bool_t valid=true)
A pad row composed of the pad row segments.
Definition: AliMpPadRow.h:25
virtual AliMpRow * GetRow() const
Return the row.which this row segment belongs to.
virtual Double_t LeftBorderX() const
Return the x coordinate of the left border in the global coordinate system.
Int_t GetLowLimitIx() const
virtual Double_t DimensionY() const
Return y dimensions.
Definition: AliMpMotif.cxx:102
Bool_t IsHighLimitValid() const
AliMpVPadRowSegment * FindMostLeftPadRowSegment(Int_t motifPositionId) const
Double_t GetPositionY() const
Definition: AliMpRow.cxx:347
virtual Double_t LeftBorderX() const =0
AliMpVPadRowSegment * GetPadRowSegment(Int_t i) const
virtual Int_t SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
Set global indices to i-th motif position and returns next index in x.
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
Double_t LowBorderY() const
Definition: AliMpRow.cxx:197
virtual Int_t GetMotifPositionId(Int_t i) const
Return the i-th motif position Id of this row segment.
AliMpPadRow * GetPadRow(Int_t i) const
AliMpMotifType * GetMotifType() const
Return the motif type.
Definition: AliMpVMotif.h:87
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
An interface for a row segment.
void SetHighIndicesLimit(MpPair_t limit, Bool_t valid=true)
Double_t HalfSizeY() const
Int_t GetNofPadRowSegments() const
AliMpVRowSegment * GetRowSegment(Int_t i) const
Definition: AliMpRow.cxx:433
A placed motif.
Int_t GetNofPadsX() const
Return number of pads in x direction.
Int_t GetNofPadsY() const
Return number of pads in y direction.
virtual Double_t GetDimensionX() const
Return the x dimension of the row segment centre.
MpPair_t GetLowIndicesLimit() const
Int_t GetID() const
A special outer row segment composed of the pad rows.
virtual Double_t RightBorderX() const
Return the x coordinate of the right border in the global coordinate system.
AliMpVPadRowSegment * FindPadRowSegment(Int_t motifPositionId) const
AliMpVMotif * GetMotif() const
Return motif.
virtual AliMpMotif * GetMotif() const
A row composed of the row segments.
Definition: AliMpRow.h:26
virtual void MotifCenterSlow(Int_t motifPositionId, Double_t &x, Double_t &y) const
Return the coordinates of the motif specified with the given motif position Id . ...
Abstract base class for a special row segment composed of the pad rows.
virtual Double_t DimensionX() const
Return x dimensions.
Definition: AliMpMotif.cxx:94
static Int_t StartPadIndex()
Return global pad indices start value.
Int_t MpPair_t
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
AliMpMotifPosition * FindMotifPosition(Int_t motifPositionID) const
Int_t GetNofPads() const
Return number of pads.
virtual void SetGlobalIndices(AliMpRow *rowBefore)
Set global indices limits.
Int_t GetHighLimitIx() const
virtual AliMpPadRow * GetPadRow() const
virtual Double_t GetPositionX() const
Return the x position of the row segment centre.
virtual Int_t GetMotifPositionId() const
AliMpMotifMap * GetMotifMap() const
Return the motif map associated with its sector.
Definition: AliMpRow.h:86
virtual Double_t GetPositionY() const
Return the y position of the row segment centre.
Class that defines the motif properties.
Double_t GetOffsetX() const
Return the x position of the border that touches a standard row segment.
The abstract base class for a pad row segment composed of the the identic pads.