]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpRow.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpRow |
22 | // -------------- | |
23 | // Class describing a row composed of the row segments. | |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
5f91c9e8 | 27 | |
5f91c9e8 | 28 | #include "AliMpRow.h" |
29 | #include "AliMpVRowSegment.h" | |
348e0500 | 30 | #include "AliMpVRowSegmentSpecial.h" |
31 | #include "AliMpRowSegmentRSpecial.h" | |
5f91c9e8 | 32 | #include "AliMpVMotif.h" |
33 | #include "AliMpMotifType.h" | |
34 | #include "AliMpMotifPosition.h" | |
35 | #include "AliMpMotifMap.h" | |
36 | #include "AliMpConstants.h" | |
37 | ||
cddd101e | 38 | #include "AliLog.h" |
39 | ||
2c605e66 | 40 | #include <TMath.h> |
41 | #include <Riostream.h> | |
42 | ||
13985652 | 43 | /// \cond CLASSIMP |
5f91c9e8 | 44 | ClassImp(AliMpRow) |
13985652 | 45 | /// \endcond |
5f91c9e8 | 46 | |
47 | //_____________________________________________________________________________ | |
48 | AliMpRow::AliMpRow(Int_t id, AliMpMotifMap* motifMap) | |
49 | : AliMpVIndexed(), | |
50 | fID(id), | |
51 | fOffsetY(0.), | |
52 | fSegments(), | |
53 | fMotifMap(motifMap) | |
54 | { | |
dee1d5f1 | 55 | /// Standard constructor |
5f91c9e8 | 56 | } |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliMpRow::AliMpRow() | |
60 | : AliMpVIndexed(), | |
61 | fID(0), | |
62 | fOffsetY(0.), | |
63 | fSegments(), | |
64 | fMotifMap(0) | |
65 | { | |
dee1d5f1 | 66 | /// Default constructor |
5f91c9e8 | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
dee1d5f1 | 70 | AliMpRow::~AliMpRow() |
71 | { | |
72 | /// Destructor | |
5f91c9e8 | 73 | |
f79c58a5 | 74 | fSegments.Delete(); |
5f91c9e8 | 75 | } |
76 | ||
77 | // | |
78 | // private methods | |
79 | // | |
80 | ||
81 | //_____________________________________________________________________________ | |
82 | AliMpVRowSegment* AliMpRow::FindRowSegment(Int_t ix) const | |
83 | { | |
dee1d5f1 | 84 | /// Find first normal row segment with low indices limit >= ix. |
5f91c9e8 | 85 | |
86 | for (Int_t i=0; i<GetNofRowSegments(); i++) { | |
87 | AliMpVRowSegment* segment = GetRowSegment(i); | |
88 | ||
348e0500 | 89 | if (!dynamic_cast<AliMpVRowSegmentSpecial*>(segment) && |
168e9c4d | 90 | segment->GetHighLimitIx() >= ix) |
5f91c9e8 | 91 | |
92 | return segment; | |
93 | } | |
348e0500 | 94 | |
5f91c9e8 | 95 | return 0; |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | AliMpMotifPosition* | |
100 | AliMpRow::FindMotifPosition(AliMpVRowSegment* segment, Int_t ix) const | |
101 | { | |
dee1d5f1 | 102 | /// Find first motif position in the specified row segment |
103 | /// with high indices limit >= ix. | |
5f91c9e8 | 104 | |
105 | if (!segment) return 0; | |
106 | ||
107 | for (Int_t i=0; i<segment->GetNofMotifs(); i++){ | |
108 | AliMpMotifPosition* motifPosition | |
109 | = GetMotifMap()->FindMotifPosition(segment->GetMotifPositionId(i)); | |
110 | ||
111 | if(!motifPosition) { | |
112 | Fatal("FindMotifPosition", "Not found."); | |
113 | return 0; | |
114 | } | |
115 | ||
168e9c4d | 116 | if (motifPosition->GetHighLimitIx()>=ix) |
5f91c9e8 | 117 | return motifPosition; |
118 | } | |
119 | ||
120 | return 0; | |
121 | } | |
122 | ||
123 | ||
124 | //_____________________________________________________________________________ | |
125 | void AliMpRow::SetHighIndicesLimits(Int_t iy) | |
126 | { | |
dee1d5f1 | 127 | /// Set the global indices high limit to its row segments, |
128 | /// motif positions with a given value. | |
129 | /// Keep ix unmodified. | |
5f91c9e8 | 130 | |
131 | for (Int_t j=0; j<GetNofRowSegments(); j++) { | |
132 | AliMpVRowSegment* rowSegment = GetRowSegment(j); | |
133 | rowSegment | |
168e9c4d | 134 | ->SetHighIndicesLimit(rowSegment->GetHighLimitIx(),iy); |
5f91c9e8 | 135 | |
136 | for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) { | |
137 | ||
138 | Int_t motifPositionId = rowSegment->GetMotifPositionId(k); | |
139 | AliMpMotifPosition* motifPosition | |
140 | = GetMotifMap()->FindMotifPosition(motifPositionId); | |
141 | ||
142 | motifPosition | |
168e9c4d | 143 | ->SetHighIndicesLimit(motifPosition->GetHighLimitIx(), iy); |
5f91c9e8 | 144 | |
145 | } | |
146 | } | |
147 | } | |
148 | ||
149 | //_____________________________________________________________________________ | |
150 | void AliMpRow::CheckEmpty() const | |
151 | { | |
dee1d5f1 | 152 | /// Give a fatal if the row is empty. |
5f91c9e8 | 153 | |
154 | if (GetNofRowSegments() == 0) | |
155 | Fatal("CheckEmpty", "Empty row"); | |
156 | } | |
157 | ||
158 | // | |
159 | // public methods | |
160 | // | |
161 | ||
162 | //_____________________________________________________________________________ | |
163 | void AliMpRow::AddRowSegment(AliMpVRowSegment* rowSegment) | |
164 | { | |
dee1d5f1 | 165 | /// Add row segment at the end. |
5f91c9e8 | 166 | |
f79c58a5 | 167 | fSegments.Add(rowSegment); |
5f91c9e8 | 168 | } |
169 | ||
170 | //_____________________________________________________________________________ | |
171 | void AliMpRow::AddRowSegmentInFront(AliMpVRowSegment* rowSegment) | |
172 | { | |
dee1d5f1 | 173 | /// Insert row segment in the first vector position. |
5f91c9e8 | 174 | |
f79c58a5 | 175 | fSegments.AddFirst(rowSegment); |
5f91c9e8 | 176 | } |
177 | ||
178 | //_____________________________________________________________________________ | |
179 | AliMpVRowSegment* AliMpRow::FindRowSegment(Double_t x) const | |
180 | { | |
dee1d5f1 | 181 | /// Find the row segment for the specified x position; |
182 | /// return 0 if no row segment is found. | |
5f91c9e8 | 183 | |
184 | for (Int_t i=0; i<GetNofRowSegments(); i++) { | |
f79c58a5 | 185 | |
f79c58a5 | 186 | AliMpVRowSegment* rs = (AliMpVRowSegment*)fSegments.At(i); |
f79c58a5 | 187 | |
5f91c9e8 | 188 | if (x >= rs->LeftBorderX() && x <= rs->RightBorderX()) |
189 | return rs; | |
190 | } | |
191 | ||
192 | return 0; | |
193 | } | |
194 | ||
195 | //_____________________________________________________________________________ | |
196 | Double_t AliMpRow::LowBorderY() const | |
197 | { | |
dee1d5f1 | 198 | /// Return the lowest row offset (the Y coordinate of the position of the |
199 | /// low border of motif). | |
5f91c9e8 | 200 | |
201 | CheckEmpty(); | |
202 | ||
203 | return fOffsetY - GetRowSegment(0)->HalfSizeY(); | |
204 | } | |
205 | ||
206 | //_____________________________________________________________________________ | |
207 | Double_t AliMpRow::UpperBorderY() const | |
208 | { | |
dee1d5f1 | 209 | /// Return the uppermost row offset (the Y coordinate of the position of the |
210 | /// upper border of motif). | |
211 | \ | |
5f91c9e8 | 212 | CheckEmpty(); |
213 | ||
214 | return fOffsetY + GetRowSegment(0)->HalfSizeY(); | |
215 | } | |
216 | ||
217 | //_____________________________________________________________________________ | |
218 | AliMpVPadIterator* AliMpRow::CreateIterator() const | |
219 | { | |
dee1d5f1 | 220 | /// Iterator is not implemented. |
5f91c9e8 | 221 | |
dee1d5f1 | 222 | Fatal("CreateIterator", "Iterator is not implemented."); |
5f91c9e8 | 223 | |
224 | return 0; | |
225 | } | |
226 | ||
227 | //_____________________________________________________________________________ | |
228 | void AliMpRow::SetMotifPositions() | |
229 | { | |
dee1d5f1 | 230 | /// Create motif positions objects and fills them in the motif map. |
5f91c9e8 | 231 | |
232 | CheckEmpty(); | |
233 | ||
234 | for (Int_t j=0; j<GetNofRowSegments(); j++) { | |
235 | AliMpVRowSegment* rowSegment = GetRowSegment(j); | |
236 | ||
237 | for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) { | |
238 | // Get values | |
239 | Int_t motifPositionId = rowSegment->GetMotifPositionId(k); | |
240 | AliMpVMotif* motif = rowSegment->GetMotif(k); | |
6e97fbb8 | 241 | |
242 | Double_t posx, posy; | |
243 | rowSegment->MotifCenter(motifPositionId, posx, posy); | |
5f91c9e8 | 244 | |
245 | AliMpMotifPosition* motifPosition | |
6e97fbb8 | 246 | = new AliMpMotifPosition(motifPositionId, motif, posx, posy); |
247 | ||
5f91c9e8 | 248 | // set the initial value to of HighIndicesLimit() Invalid() |
249 | // (this is used for calculation of indices in case of | |
250 | // special row segments) | |
168e9c4d | 251 | motifPosition->SetHighIndicesLimit(0, 0, false); |
5f91c9e8 | 252 | |
348e0500 | 253 | //Bool_t warn = (rowSegment->GetNofMotifs()==1); |
254 | Bool_t warn = true; | |
255 | if (dynamic_cast<AliMpVRowSegmentSpecial*>(rowSegment)) warn = false; | |
5f91c9e8 | 256 | // supress warnings for special row segments |
257 | // which motifs can overlap the row borders | |
258 | ||
259 | Bool_t added = GetMotifMap()->AddMotifPosition(motifPosition, warn); | |
260 | ||
261 | if (!added) delete motifPosition; | |
262 | } | |
263 | } | |
264 | } | |
265 | ||
266 | //_____________________________________________________________________________ | |
cddd101e | 267 | void AliMpRow::SetGlobalIndices(AliMp::Direction constPadSizeDirection, |
5f91c9e8 | 268 | AliMpRow* rowBefore) |
269 | { | |
dee1d5f1 | 270 | /// Set the global indices limits to its row segments, motif positions |
271 | /// and itself. | |
5f91c9e8 | 272 | |
273 | Int_t ix = AliMpConstants::StartPadIndex(); | |
274 | Int_t iy = AliMpConstants::StartPadIndex(); | |
275 | ||
276 | for (Int_t j=0; j<GetNofRowSegments(); j++) { | |
277 | AliMpVRowSegment* rowSegment = GetRowSegment(j); | |
278 | ||
168e9c4d | 279 | ix += rowSegment->GetLowLimitIx(); |
5f91c9e8 | 280 | |
281 | for (Int_t k=0; k<rowSegment->GetNofMotifs(); k++) { | |
282 | ||
283 | // Find the y index value of the low edge | |
284 | if (rowBefore) { | |
cddd101e | 285 | if (constPadSizeDirection == AliMp::kY) { |
168e9c4d | 286 | iy = rowBefore->GetHighLimitIy()+1; |
5f91c9e8 | 287 | } |
288 | else { | |
348e0500 | 289 | AliMpVRowSegment* seg = rowBefore->FindRowSegment(ix); |
5f91c9e8 | 290 | AliMpMotifPosition* motPos = FindMotifPosition(seg, ix); |
348e0500 | 291 | if (!dynamic_cast<AliMpRowSegmentRSpecial*>(rowSegment)) { |
292 | if (!motPos) | |
293 | Fatal("SetGlobalIndices", "Motif position in rowBefore not found."); | |
5f91c9e8 | 294 | |
168e9c4d | 295 | iy = motPos->GetHighLimitIy()+1; |
348e0500 | 296 | } |
5f91c9e8 | 297 | } |
298 | } | |
299 | ||
300 | // Set (ix, iy) to k-th motif position and update ix | |
168e9c4d | 301 | ix = rowSegment->SetIndicesToMotifPosition(k, AliMp::Pair(ix, iy)); |
5f91c9e8 | 302 | } |
580c28fd | 303 | rowSegment->SetGlobalIndices(rowBefore); |
5f91c9e8 | 304 | } |
305 | ||
580c28fd | 306 | // The low/high indices limits has to be taken as the highest/lowest from all |
307 | // row segments | |
308 | Int_t ixl = 9999; | |
309 | Int_t iyl = 9999; | |
310 | Int_t ixh = AliMpConstants::StartPadIndex(); | |
311 | Int_t iyh = AliMpConstants::StartPadIndex(); | |
5f91c9e8 | 312 | |
580c28fd | 313 | for (Int_t i=0; i<GetNofRowSegments(); i++) { |
314 | ||
315 | AliMpVRowSegment* rowSegment = GetRowSegment(i); | |
316 | ||
168e9c4d | 317 | if ( rowSegment->GetLowLimitIx() < ixl ) |
318 | ixl = rowSegment->GetLowLimitIx(); | |
580c28fd | 319 | |
168e9c4d | 320 | if ( rowSegment->GetLowLimitIy() < iyl ) |
321 | iyl = rowSegment->GetLowLimitIy(); | |
580c28fd | 322 | |
168e9c4d | 323 | if ( rowSegment->GetHighLimitIx() > ixh ) |
324 | ixh = rowSegment->GetHighLimitIx(); | |
580c28fd | 325 | |
168e9c4d | 326 | if ( rowSegment->GetHighLimitIy() > iyh ) |
327 | iyh = rowSegment->GetHighLimitIy(); | |
580c28fd | 328 | } |
329 | ||
168e9c4d | 330 | SetLowIndicesLimit(ixl, iyl); |
331 | SetHighIndicesLimit(ixh, iyh); | |
5f91c9e8 | 332 | } |
333 | ||
334 | //_____________________________________________________________________________ | |
6e97fbb8 | 335 | Double_t AliMpRow::GetPositionX() const |
5f91c9e8 | 336 | { |
dee1d5f1 | 337 | /// Return the position of the row centre. |
5f91c9e8 | 338 | |
6e97fbb8 | 339 | return ( GetRowSegment(0)->LeftBorderX() + |
340 | GetRowSegment(GetNofRowSegments()-1)->RightBorderX() )/2.; | |
341 | } | |
342 | ||
343 | //_____________________________________________________________________________ | |
344 | Double_t AliMpRow::GetPositionY() const | |
345 | { | |
346 | /// Return the position of the row centre. | |
347 | ||
348 | return fOffsetY; | |
5f91c9e8 | 349 | } |
350 | ||
351 | //_____________________________________________________________________________ | |
6e97fbb8 | 352 | Double_t AliMpRow::GetDimensionX() const |
5f91c9e8 | 353 | { |
dee1d5f1 | 354 | /// Return the maximum halflengths of the row in x, y. |
5f91c9e8 | 355 | |
6e97fbb8 | 356 | return ( GetRowSegment(GetNofRowSegments()-1)->RightBorderX() - |
357 | GetRowSegment(0)->LeftBorderX() )/2.; | |
358 | } | |
359 | ||
360 | //_____________________________________________________________________________ | |
361 | Double_t AliMpRow::GetDimensionY() const | |
362 | { | |
363 | /// Return the maximum halflengths of the row in x, y. | |
364 | ||
365 | return GetRowSegment(0)->HalfSizeY(); | |
5f91c9e8 | 366 | } |
367 | ||
368 | //_____________________________________________________________________________ | |
6e97fbb8 | 369 | void AliMpRow::SetRowSegmentOffsets(Double_t offsetx) |
5f91c9e8 | 370 | { |
dee1d5f1 | 371 | /// Set the row segments offsets in X . |
5f91c9e8 | 372 | |
373 | CheckEmpty(); | |
374 | ||
375 | AliMpVRowSegment* previous = 0; | |
376 | ||
377 | for (Int_t j=0; j<GetNofRowSegments(); j++) { | |
378 | AliMpVRowSegment* rowSegment = GetRowSegment(j); | |
379 | ||
380 | Double_t offsetX; | |
381 | if (previous) | |
382 | offsetX = previous->RightBorderX(); | |
383 | else | |
6e97fbb8 | 384 | offsetX = offsetx; |
5f91c9e8 | 385 | |
6e97fbb8 | 386 | rowSegment->SetOffset(offsetX, 0.); |
5f91c9e8 | 387 | previous = rowSegment; |
388 | } | |
389 | } | |
390 | ||
391 | ||
392 | //_____________________________________________________________________________ | |
393 | Double_t AliMpRow::SetOffsetY(Double_t offsetY) | |
394 | { | |
dee1d5f1 | 395 | /// Set the row offset (the Y coordinate of the position of the |
396 | /// center of motif) and returns the offset of the top border. | |
5f91c9e8 | 397 | |
398 | CheckEmpty(); | |
399 | ||
400 | AliMpVRowSegment* first = GetRowSegment(0); | |
401 | Double_t rowSizeY = first->HalfSizeY(); | |
402 | ||
403 | // Check if all next row segments have motif of | |
404 | // the same size in y | |
405 | for (Int_t i=1; i<GetNofRowSegments(); i++) { | |
406 | Double_t sizeY = GetRowSegment(i)->HalfSizeY(); | |
407 | ||
408 | if (TMath::Abs(sizeY - rowSizeY) >= AliMpConstants::LengthTolerance()) { | |
5f91c9e8 | 409 | Fatal("SetOffsetY", "Motif with different Y size in one row"); |
410 | return 0.; | |
411 | } | |
412 | } | |
413 | ||
414 | offsetY += rowSizeY ; | |
415 | ||
416 | fOffsetY = offsetY; | |
417 | ||
418 | return offsetY += rowSizeY; | |
419 | } | |
420 | ||
421 | //_____________________________________________________________________________ | |
422 | Int_t AliMpRow::GetNofRowSegments() const | |
423 | { | |
dee1d5f1 | 424 | /// Return number of row segments. |
5f91c9e8 | 425 | |
f79c58a5 | 426 | return fSegments.GetSize(); |
5f91c9e8 | 427 | } |
428 | ||
429 | //_____________________________________________________________________________ | |
430 | AliMpVRowSegment* AliMpRow::GetRowSegment(Int_t i) const | |
431 | { | |
dee1d5f1 | 432 | /// Return i-th row segment. |
fb1bf5c0 | 433 | |
5f91c9e8 | 434 | if (i<0 || i>=GetNofRowSegments()) { |
2c605e66 | 435 | AliWarningStream() << "Index outside range" << endl; |
5f91c9e8 | 436 | return 0; |
437 | } | |
438 | ||
f79c58a5 | 439 | return (AliMpVRowSegment*)fSegments.At(i); |
5f91c9e8 | 440 | } |
441 |