AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpVRowSegmentSpecial.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: AliMpVRowSegmentSpecial.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $
18 // Category: sector
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpVRowSegmentSpecial
22 // ----------------------------
23 // Class describing a special 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 <Riostream.h>
40 
44 
45 const Int_t AliMpVRowSegmentSpecial::fgkMaxNofMotifPositionIds = 20;
46 
47 //______________________________________________________________________________
49  : AliMpVRowSegment(),
50  fRow(row),
51  fOffsetX(offsetX),
52  fPadRows(),
53  fMotifs(),
54  fMotifPositionIds(),
55  fNofMotifPositionIds(0)
56 {
58 }
59 
60 //______________________________________________________________________________
62  : AliMpVRowSegment(),
63  fRow(0),
64  fOffsetX(0.),
65  fPadRows(),
66  fMotifs(),
67  fMotifPositionIds(),
68  fNofMotifPositionIds(0)
69 {
71 
73 }
74 
75 //______________________________________________________________________________
77 {
79 
80  for (Int_t i=0; i<GetNofPadRows(); i++)
81  delete fPadRows[i];
82 }
83 
84 //
85 // protected methods
86 //
87 
88 //______________________________________________________________________________
90 {
92 
93  Double_t lowBorder = fRow->LowBorderY();
94  Double_t highBorder = fRow->LowBorderY();
95 
96  for (Int_t i=0; i<GetNofPadRows(); i++) {
97 
98  AliMpPadRow* padRow = GetPadRow(i);
99  highBorder += 2.*padRow->HalfSizeY();
100 
101  if ( y >= lowBorder && y <= highBorder)
102  return padRow;
103 
104  lowBorder = highBorder;
105  }
106 
107  return 0;
108 }
109 
110 //______________________________________________________________________________
112 AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const
113 {
115 
116  for (Int_t i=0; i<GetNofPadRows(); i++) {
117  AliMpPadRow* padRow = GetPadRow(i);
118 
119  for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
120  AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
121 
122  if (padRowSegment->GetMotifPositionId() == motifPositionId)
123  return padRowSegment;
124  }
125  }
126  return 0;
127 }
128 
129 //______________________________________________________________________________
130 MpPair_t
132 {
135 
136  Int_t ans0Ix = 0;
137  Int_t ans0Iy = 1000;
138  Int_t ansIx = 0;
139  Int_t ansIy = 1000;
140 
141  Int_t maxNofPadsX=0;
142 
143  for (Int_t i=0; i<GetNofPadRows(); i++) {
144  AliMpPadRow* padRow = GetPadRow(i);
145 
146  Int_t nofPadsX=0;
147  for ( Int_t j=0; j<padRow->GetNofPadRowSegments(); j++ ) {
148  AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j);
149  nofPadsX += padRowSegment->GetNofPads();
150  if (padRowSegment->GetMotifPositionId() == motifPositionId) {
151  if ( ansIx < nofPadsX ) ansIx = nofPadsX;
152  if ( ansIy >i ) ansIy = i;
153  // ansIx = max (nof pads of this pos ID)
154  // ansIy = min of pad row number
155  }
156  }
157  if ( nofPadsX > maxNofPadsX ) maxNofPadsX = nofPadsX;
158  }
159  if ( ansIx == ans0Ix && ansIy == ans0Iy ) return -1;
160 
161  return AliMp::Pair(maxNofPadsX-ansIx, ansIy);
162 }
163 
164 //______________________________________________________________________________
166 {
168 
169  Int_t maxNofPads = 0;
170 
171  for (Int_t i=0; i<GetNofPadRows(); i++){
172  Int_t nofPads = GetPadRow(i)->GetNofPads();
173 
174  // Find maximum
175  if (nofPads > maxNofPads) maxNofPads = nofPads;
176  }
177 
178  return maxNofPads;
179 }
180 
181 //______________________________________________________________________________
183 {
186 
187  for (Int_t i=0; i<fMotifs.GetEntriesFast(); i++)
188  if (fMotifs[i] == (const TObject*)motif) return true;
189 
190  return false;
191 }
192 
193 //______________________________________________________________________________
195 {
197 
198  return fPadRows.GetEntriesFast();
199 }
200 
201 //______________________________________________________________________________
203 {
205 
206  return (AliMpPadRow*)fPadRows[i];
207 }
208 
209 //
210 // public methods
211 //
212 
213 //______________________________________________________________________________
215 {
217 
218  padRow->SetOffsetX(fOffsetX);
219  padRow->SetID(GetNofPadRows());
220 
221  fPadRows.Add(padRow);
222 }
223 
224 //______________________________________________________________________________
226 {
229 
230  for (Int_t i=0; i<GetNofPadRows(); i++) {
231  AliMpPadRow* padRow = GetPadRow(i);
232 
233  for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) {
234  AliMpVMotif* motif = padRow->GetPadRowSegment(j)->GetMotif();
235 
236  if (!HasMotif(motif)) {
237  fMotifs.Add(motif);
238 
239  // resize array if needed
241  fMotifPositionIds.Set(fMotifPositionIds.GetSize()+
243  fMotifPositionIds.AddAt(
244  padRow->GetPadRowSegment(j)->GetMotifPositionId(),
246  }
247  }
248  }
249 }
250 
251 //______________________________________________________________________________
253 {
255 
256  Double_t halfSizeY = 0.;
257  for (Int_t i=0; i<GetNofPadRows(); i++) {
258  halfSizeY += GetPadRow(i)->HalfSizeY();
259  }
260 
261  return halfSizeY;
262 }
263 
264 //______________________________________________________________________________
265 AliMpVMotif* AliMpVRowSegmentSpecial::FindMotif(Double_t x, Double_t y) const
266 {
268 
269  AliMpPadRow* padRow = FindPadRow(y);
270 
271  if ( ! padRow ) return 0;
272 
273  AliMpVPadRowSegment* padRowSegment = padRow->FindPadRowSegment(x);
274 
275  if (! padRowSegment ) return 0;
276 
277  return padRowSegment->GetMotif();
278 }
279 
280 //______________________________________________________________________________
281 Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(Double_t x, Double_t y) const
282 {
285 
286  AliMpPadRow* padRow = FindPadRow(y);
287 
288  if ( ! padRow ) return 0;
289 
290  AliMpVPadRowSegment* padRowSegment = padRow->FindPadRowSegment(x);
291 
292  if ( ! padRowSegment ) return 0;
293 
294  return padRowSegment->GetMotifPositionId();
295 }
296 
297 //______________________________________________________________________________
298 Bool_t AliMpVRowSegmentSpecial::HasMotifPosition(Int_t motifPositionId) const
299 {
302 
303  if (FindPadRowSegment(motifPositionId))
304  return true;
305  else
306  return false;
307 }
308 
309 //______________________________________________________________________________
310 void AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId,
311  Double_t& x, Double_t& y) const
312 {
315 
316  // Try to get the motif position from the motif map first
317  AliMpMotifPosition* motifPosition
318  = GetRow()->GetMotifMap()->FindMotifPosition(motifPositionId);
319 
320  if (motifPosition) {
321  x = motifPosition->GetPositionX(),
322  y = motifPosition->GetPositionY();
323  }
324  else {
325  MotifCenterSlow(motifPositionId, x, y);
326  }
327 }
328 
329 //______________________________________________________________________________
331 {
333 
334  Double_t x = 0.;
335  for (Int_t i=0; i<GetNofPadRows(); i++) {
336  AliMpPadRow* padRow = GetPadRow(i);
337 
338  // Find the biggest pad rows x halfsize
339  Double_t xx
340  = (padRow->GetPadRowSegment(0)->RightBorderX() -
341  padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX())/2.;
342  if (xx > x) x = xx;
343  }
344 
345  return x;
346 }
347 
348 //______________________________________________________________________________
350 {
352 
353  Double_t y = 0.;
354  for (Int_t i=0; i<GetNofPadRows(); i++) {
355  AliMpPadRow* padRow = GetPadRow(i);
356 
357  // Add all pad rows y halfsizes
358  y += padRow->HalfSizeY();
359  }
360 
361  return y;
362 }
363 
364 //______________________________________________________________________________
366 {
368 
369  return fRow;
370 }
371 
372 //______________________________________________________________________________
374 {
376 
377  return fMotifs.GetEntriesFast();
378 }
379 
380 //______________________________________________________________________________
382 {
384 
385  return (AliMpVMotif*)fMotifs[i];
386 }
387 
388 //______________________________________________________________________________
390 {
392 
393  return fMotifPositionIds[i];
394 }
395 
Double_t GetPositionY() const
Return y position.
AliMpPadRow * FindPadRow(Double_t y) const
A pad row composed of the pad row segments.
Definition: AliMpPadRow.h:25
static const Int_t fgkMaxNofMotifPositionIds
dimension of fMotifPositionIds
virtual AliMpRow * GetRow() const
Return the row.which this row segment belongs to.
Bool_t HasMotif(const AliMpVMotif *motif) const
void AddPadRow(AliMpPadRow *padRow)
virtual Double_t GetDimensionY() const
Return the y dimension of the row segment centre.
virtual Double_t RightBorderX() const =0
void SetOffsetX(Double_t offsetX)
AliMpVPadRowSegment * GetPadRowSegment(Int_t i) const
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
AliMpRow * fRow
the row containing this segment
TObjArray fMotifs
motifs vector
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.
void SetID(Int_t id)
AliMpPadRow * GetPadRow(Int_t i) const
virtual Bool_t HasMotifPosition(Int_t motifPositionId) const
Has the motif position with the given Id ?
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
An interface for a row segment.
TObjArray fPadRows
pad rows vector
Double_t HalfSizeY() const
Int_t GetNofPadRowSegments() const
A placed motif.
Int_t GetNofPads() const
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.
TArrayI fMotifPositionIds
motifs position Ids vector
virtual Double_t GetDimensionX() const
Return the x dimension of the row segment centre.
Double_t fOffsetX
the x position of the border that touches a standard row segment
virtual AliMpVMotif * FindMotif(Double_t x, Double_t y) const
Find the motif in the given positions.
AliMpVPadRowSegment * FindPadRowSegment(Int_t motifPositionId) const
virtual AliMpMotif * GetMotif() const
AliMpVPadRowSegment * FindPadRowSegment(Double_t x) const
A row composed of the row segments.
Definition: AliMpRow.h:26
virtual AliMpVMotif * GetMotif(Int_t i) const
Return the i-th motif of this row segment.
Abstract base class for a special row segment composed of the pad rows.
Abstract base class for a motif with its unique ID and the motif type.
Definition: AliMpVMotif.h:24
Int_t MpPair_t
virtual void MotifCenterSlow(Int_t motifPositionId, Double_t &x, Double_t &y) const =0
Return the coordinates of the motif specified with the given motif position Id . ...
virtual Double_t HalfSizeY() const
Return the half size in y of this row segment.
AliMpMotifPosition * FindMotifPosition(Int_t motifPositionID) const
Int_t GetNofPads() const
Return number of pads.
virtual Int_t GetNofMotifs() const
Return the number of motifs in this this row segment.
Double_t GetPositionX() const
Return x position.
virtual Double_t LeftBorderX() const =0
Return the x coordinate of the left border in the global coordinate system.
Int_t fNofMotifPositionIds
number of motif positions Ids
virtual Int_t GetMotifPositionId() const
AliMpMotifMap * GetMotifMap() const
Return the motif map associated with its sector.
Definition: AliMpRow.h:86
MpPair_t FindRelativeLowIndicesOf(Int_t motifPositionId) const
The abstract base class for a pad row segment composed of the the identic pads.
virtual Int_t FindMotifPositionId(Double_t x, Double_t y) const
Find the motif position Id in the given positions.