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