AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpRowSegmentLSpecial.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: AliMpRowSegmentLSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpRowSegmentLSpecial
22 // -----------------------------
23 // Class describing a special inner 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 
29 #include <Riostream.h>
30 #include <TMath.h>
31 
33 #include "AliMpRow.h"
34 #include "AliMpPadRow.h"
35 #include "AliMpVPadRowSegment.h"
36 #include "AliMpMotif.h"
37 #include "AliMpMotifType.h"
38 #include "AliMpMotifMap.h"
39 #include "AliMpMotifPosition.h"
40 #include "AliMpConstants.h"
41 #include "AliMpEncodePair.h"
42 
43 #include "AliLog.h"
44 
45 using std::endl;
49 
50 //______________________________________________________________________________
52  : AliMpVRowSegmentSpecial(row, offsetX)
53 {
55 }
56 
57 //______________________________________________________________________________
60 {
62 }
63 
64 //______________________________________________________________________________
66 {
68 }
69 
70 //
71 // private methods
72 //
73 
74 //______________________________________________________________________________
77 {
79 
80  AliMpVPadRowSegment* found = 0;
81 
82  for (Int_t i=0; i<GetNofPadRows(); i++) {
83  AliMpPadRow* padRow = GetPadRow(i);
84 
85  for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
86  AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
87 
88  if ( padRowSegment->GetMotifPositionId() == motifPositionId &&
89  (!found || padRowSegment->RightBorderX() > found->RightBorderX()))
90 
91  found = padRowSegment;
92  }
93  }
94 
95  return found;
96 }
97 
98 //
99 // protected methods
100 //
101 
102 //______________________________________________________________________________
103 void AliMpRowSegmentLSpecial::MotifCenterSlow(Int_t motifPositionId,
104  Double_t& x, Double_t& y) const
105 {
110 
111  // Find the first (left, down) pad row segment with this motifPositionId.
112  AliMpVPadRowSegment* downPadRowSegment
113  = FindPadRowSegment(motifPositionId);
114  AliMpVPadRowSegment* rightPadRowSegment
115  = FindMostRightPadRowSegment(motifPositionId);
116 
117  // Check if the motifPositionId is present
118  if (!downPadRowSegment || !rightPadRowSegment) {
119  AliErrorStream() << "Outside row segment region" << endl;
120  return;
121  }
122 
123  // Check if both pad row segments have the same motif
124  if (downPadRowSegment->GetMotif() != rightPadRowSegment->GetMotif()) {
125  AliFatal("Outside row segment region");
126  return;
127  }
128 
129  // Get position of found row segment
130  x = rightPadRowSegment->RightBorderX();
131  y = GetRow()->LowBorderY() ;
132 
133  for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++)
134  y += GetPadRow(i)->HalfSizeY()*2.;
135 
136  // Add motifs dimensions
137  x -= downPadRowSegment->GetMotif()->DimensionX();
138  y += downPadRowSegment->GetMotif()->DimensionY();
139 }
140 
141 //
142 // public methods
143 //
144 
145 //______________________________________________________________________________
147 {
150 
151  // Get the neighbour row segment
152  // (the first normal segment)
153  AliMpVRowSegment* neighbour = GetRow()->GetRowSegment(1);
154 
155  // Get the the pads offset of the neighbour row segment
156  // (the first normal segment)
157  MpPair_t offset = neighbour->GetLowIndicesLimit();
158 
159  // Find max nof pads in a row
160  Int_t maxNofPads = MaxNofPadsInRow();
161 
162  // Set limits
163  SetLowIndicesLimit(offset - AliMp::Pair(maxNofPads, 0));
164 
165  // Reset limits in the neighbour row segment
166  // (pad offset is now included in the special segment)
167  neighbour->SetLowIndicesLimit(0, neighbour->GetLowLimitIy());
168 }
169 
170 //______________________________________________________________________________
172 {
175 
176  Double_t leftBorder = DBL_MAX;
177  for (Int_t i=0; i<GetNofPadRows(); i++) {
178  AliMpPadRow* padRow = GetPadRow(i);
179  Double_t border
180  = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX();
181 
182  if (border < leftBorder) leftBorder = border;
183  }
184 
185  return leftBorder;
186 }
187 
188 //______________________________________________________________________________
190 {
193 
194  Double_t sameBorder = GetOffsetX();
195 
196  // Consistence check
197  Double_t rightBorder = -DBL_MAX;
198  for (Int_t i=0; i<GetNofPadRows(); i++) {
199  AliMpPadRow* padRow = GetPadRow(i);
200  Double_t border = padRow->GetPadRowSegment(0)->RightBorderX();
201  if (border > rightBorder) rightBorder = border;
202  }
203 
204  if (TMath::Abs(GetOffsetX() - rightBorder) > 1.e-04) {
205  AliErrorStream() << "WrongBorder" << endl;
206  return sameBorder;
207  }
208 
209  return rightBorder;
210 }
211 
212 //______________________________________________________________________________
214 {
218 
219  return GetOffsetX() - GetDimensionX();
220 }
221 
222 //______________________________________________________________________________
224 {
228 
229  return GetRow()->GetPositionY();
230 }
231 
232 #include <Riostream.h>
233 //______________________________________________________________________________
235 {
237 
238  // Get motif position
239  AliMpMotifPosition* motifPosition
241 
242  // Low limit
243  MpPair_t low
245  AliMp::PairSecond(indices))
247 
248  if (! motifPosition->IsHighLimitValid()) {
249  motifPosition->SetLowIndicesLimit(low);
250  }
251  else {
252  if ( motifPosition->GetLowLimitIx() > AliMp::PairFirst(low) )
253  motifPosition->SetLowIndicesLimit(
254  AliMp::PairFirst(low),
255  motifPosition->GetLowLimitIy());
256 
257  if ( motifPosition->GetLowLimitIy() > AliMp::PairSecond(low) )
258  motifPosition->SetLowIndicesLimit(
259  motifPosition->GetLowLimitIx(),
260  AliMp::PairSecond(low) );
261  }
262 
263  // High limit
264  AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType();
265  MpPair_t high
266  = motifPosition->GetLowIndicesLimit()
267  + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1);
268 
269  motifPosition->SetHighIndicesLimit(high);
270 
271  // Increment index only if last motif position is processed
272  if ( i != GetNofMotifs()-1 )
273  return AliMp::PairFirst(indices);
274  //return 0;
275  else
276  return AliMp::PairFirst(indices) + MaxNofPadsInRow();
277  //return MaxNofPadsInRow();
278 }
279 //______________________________________________________________________________
281 {
285 
286  // Low ix
288  // the pads offset was already defined by Reader
289 
290  // High ix
291  Int_t ixh = ixl + MaxNofPadsInRow() - 1;
292 
293  // Low iy
294  Int_t iyl = AliMpConstants::StartPadIndex();
295  if (rowBefore) {
296  //if (constPadSizeDirection == kY) {
297  iyl = rowBefore->GetHighLimitIy()+1;
298  //}
299  /*
300  else {
301  AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl);
302  AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl);
303  if (!motPos)
304  Fatal("SetGlobalIndices", "Motif position in rowBefore not found.");
305  iyl = motPos->GetHighLimitIy()+1;
306  }
307  */
308  }
309 
310  // High iy
311  Int_t iyh = iyl + GetNofPadRows() - 1;
312 
313  SetLowIndicesLimit(ixl, iyl);
314  SetHighIndicesLimit(ixh, iyh);
315 }
316 
317 
318 
319 
void SetLowIndicesLimit(MpPair_t limit, Bool_t valid=true)
A pad row composed of the pad row segments.
Definition: AliMpPadRow.h:25
virtual Double_t GetPositionX() const
Return the x position of the row segment centre.
virtual AliMpRow * GetRow() const
Return the row.which this row segment belongs to.
Int_t GetLowLimitIx() const
virtual void UpdatePadsOffset()
Update pads offset.
virtual Int_t SetIndicesToMotifPosition(Int_t i, MpPair_t indices)
Set global indices to i-th motif position and returns next index in x.
virtual Double_t RightBorderX() const =0
virtual Double_t DimensionY() const
Return y dimensions.
Definition: AliMpMotif.cxx:102
Bool_t IsHighLimitValid() const
Double_t GetPositionY() const
Definition: AliMpRow.cxx:347
AliMpVPadRowSegment * GetPadRowSegment(Int_t i) const
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
virtual Double_t GetPositionY() const
Return the y position of the row segment centre.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
An interface for a row segment.
void SetHighIndicesLimit(MpPair_t limit, Bool_t valid=true)
AliMpVPadRowSegment * FindMostRightPadRowSegment(Int_t motifPositionId) const
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.
A special inner row segment composed of the pad rows.
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
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
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.
virtual void SetGlobalIndices(AliMpRow *rowBefore)
Set global indices limits.
Int_t MpPair_t
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
AliMpMotifPosition * FindMotifPosition(Int_t motifPositionID) const
virtual Int_t GetNofMotifs() const
Return the number of motifs in this this row segment.
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 . ...
virtual Double_t LeftBorderX() const
Return the x coordinate of the left border in the global coordinate system.
Int_t PairSecond(MpPair_t pair)
Decode the second integer from encoded pair.
virtual Double_t RightBorderX() const
Return the x coordinate of the right border in the global coordinate system.
virtual AliMpPadRow * GetPadRow() const
virtual Int_t GetMotifPositionId() const
AliMpMotifMap * GetMotifMap() const
Return the motif map associated with its sector.
Definition: AliMpRow.h:86
Class that defines the motif properties.
MpPair_t FindRelativeLowIndicesOf(Int_t motifPositionId) const
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.