]>
Commit | Line | Data |
---|---|---|
5f91c9e8 | 1 | // $Id$ |
2 | // Category: sector | |
3 | // | |
4 | // Class AliMpSectorSegmentation | |
5 | // ----------------------------- | |
6 | // Class describing the segmentation of the sector. | |
7 | // Provides methods related to pads: | |
8 | // conversion between pad indices, pad location, pad position; | |
9 | // finding pad neighbour. | |
10 | // | |
11 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
12 | ||
13 | #include <Riostream.h> | |
14 | #include <TMath.h> | |
fb1bf5c0 | 15 | #include <TError.h> |
5f91c9e8 | 16 | |
17 | #include "AliMpSectorSegmentation.h" | |
18 | #include "AliMpSector.h" | |
19 | #include "AliMpZone.h" | |
2998a151 | 20 | #include "AliMpSubZone.h" |
5f91c9e8 | 21 | #include "AliMpRow.h" |
22 | #include "AliMpVRowSegment.h" | |
23 | #include "AliMpMotifMap.h" | |
24 | #include "AliMpVMotif.h" | |
25 | #include "AliMpMotifPosition.h" | |
26 | #include "AliMpConnection.h" | |
27 | #include "AliMpNeighboursPadIterator.h" | |
28 | #include "AliMpSectorAreaHPadIterator.h" | |
29 | #include "AliMpSectorAreaVPadIterator.h" | |
2998a151 | 30 | #include "AliMpIntPair.h" |
31 | #include "AliMpArea.h" | |
5f91c9e8 | 32 | #include "AliMpConstants.h" |
33 | ||
34 | ClassImp(AliMpSectorSegmentation) | |
35 | ||
f79c58a5 | 36 | #ifdef WITH_ROOT |
bcf37928 | 37 | const Double_t AliMpSectorSegmentation::fgkS1 = 10000.; |
38 | const Double_t AliMpSectorSegmentation::fgkS2 = 100.; | |
f79c58a5 | 39 | #endif |
40 | ||
5f91c9e8 | 41 | //______________________________________________________________________________ |
42 | AliMpSectorSegmentation::AliMpSectorSegmentation(const AliMpSector* sector) | |
43 | : AliMpVSegmentation(), | |
580c28fd | 44 | fkSector(sector), |
45 | fMaxIndexInX(0), | |
46 | fMaxIndexInY(0) | |
5f91c9e8 | 47 | { |
48 | // | |
49 | fPadBuffer = new AliMpPad(AliMpPad::Invalid()); | |
50 | ||
51 | FillPadDimensionsMap(); | |
52 | } | |
53 | ||
54 | //______________________________________________________________________________ | |
55 | AliMpSectorSegmentation::AliMpSectorSegmentation() | |
56 | : AliMpVSegmentation(), | |
57 | fkSector(0), | |
58 | fPadBuffer(0), | |
580c28fd | 59 | fPadDimensionsMap(), |
60 | fMaxIndexInX(0), | |
61 | fMaxIndexInY(0) | |
5f91c9e8 | 62 | { |
63 | // | |
64 | } | |
65 | ||
fb1bf5c0 | 66 | //_____________________________________________________________________________ |
67 | AliMpSectorSegmentation::AliMpSectorSegmentation( | |
68 | const AliMpSectorSegmentation& right) | |
69 | : AliMpVSegmentation(right) { | |
70 | // | |
71 | Fatal("AliMpSectorSegmentation", "Copy constructor not provided."); | |
72 | } | |
73 | ||
5f91c9e8 | 74 | //______________________________________________________________________________ |
75 | AliMpSectorSegmentation::~AliMpSectorSegmentation() { | |
76 | // | |
77 | delete fPadBuffer; | |
78 | } | |
79 | ||
fb1bf5c0 | 80 | // |
81 | // operators | |
82 | // | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | AliMpSectorSegmentation& | |
86 | AliMpSectorSegmentation::operator=(const AliMpSectorSegmentation& right) | |
87 | { | |
88 | // check assignement to self | |
89 | if (this == &right) return *this; | |
90 | ||
91 | Fatal("operator =", "Assignement operator not provided."); | |
92 | ||
93 | return *this; | |
94 | } | |
95 | ||
5f91c9e8 | 96 | // |
97 | // private methods | |
98 | // | |
99 | ||
f79c58a5 | 100 | #ifdef WITH_ROOT |
101 | //______________________________________________________________________________ | |
102 | Long_t AliMpSectorSegmentation::GetIndex(const TVector2& vector2) const | |
103 | { | |
bcf37928 | 104 | // Converts the two vector to long. |
f79c58a5 | 105 | // --- |
106 | ||
bcf37928 | 107 | return Long_t(TMath::Floor((vector2.X()*fgkS1 + vector2.Y())*fgkS2)); |
f79c58a5 | 108 | } |
109 | ||
110 | //______________________________________________________________________________ | |
111 | TVector2 AliMpSectorSegmentation::GetVector(Long_t index) const | |
112 | { | |
113 | // Converts the long index to twovector. | |
114 | // --- | |
115 | ||
bcf37928 | 116 | return TVector2( TMath::Floor(index/fgkS1)/fgkS2, |
117 | (index - TMath::Floor(index/fgkS1)*fgkS1)/fgkS2 ); | |
f79c58a5 | 118 | } |
119 | #endif | |
120 | ||
5f91c9e8 | 121 | //______________________________________________________________________________ |
122 | void AliMpSectorSegmentation::FillPadDimensionsMap() | |
123 | { | |
124 | // Fills the maps between zone ids and pad dimensions. | |
125 | // --- | |
126 | ||
127 | for (Int_t i=0; i<fkSector->GetNofZones(); i++) { | |
128 | AliMpZone* zone = fkSector->GetZone(i+1); | |
129 | Int_t zoneID = zone->GetID(); | |
130 | ||
131 | if (!AliMpConstants::IsEqual(zone->GetPadDimensions(), TVector2())) { | |
f79c58a5 | 132 | |
5f91c9e8 | 133 | // regular zone |
f79c58a5 | 134 | #ifdef WITH_STL |
5f91c9e8 | 135 | fPadDimensionsMap[zoneID*10] = zone->GetPadDimensions(); |
f79c58a5 | 136 | #endif |
137 | #ifdef WITH_ROOT | |
bcf37928 | 138 | fPadDimensionsMap.Add((Long_t)(zoneID*10), |
f79c58a5 | 139 | GetIndex(zone->GetPadDimensions())); |
140 | #endif | |
5f91c9e8 | 141 | } |
142 | else { | |
143 | // special zone | |
144 | Int_t subIndex = 0; | |
145 | for (Int_t j=0; j<zone->GetNofSubZones(); j++) { | |
146 | AliMpSubZone* subZone = zone->GetSubZone(j); | |
147 | AliMpVMotif* motif = subZone->GetMotif(); | |
148 | ||
149 | for (Int_t k=0; k<motif->GetNofPadDimensions(); k++) { | |
150 | Int_t index = zoneID*10 + subIndex++; | |
f79c58a5 | 151 | #ifdef WITH_STL |
5f91c9e8 | 152 | fPadDimensionsMap[index] = motif->GetPadDimensions(k); |
f79c58a5 | 153 | #endif |
154 | #ifdef WITH_ROOT | |
155 | fPadDimensionsMap.Add((Long_t)(index), | |
156 | GetIndex(motif->GetPadDimensions(k))); | |
157 | #endif | |
5f91c9e8 | 158 | } |
159 | } | |
160 | } | |
161 | } | |
162 | } | |
163 | ||
164 | //______________________________________________________________________________ | |
165 | AliMpMotifPosition* | |
166 | AliMpSectorSegmentation::FindMotifPosition(const AliMpIntPair& indices) const | |
167 | { | |
168 | // Find the motif position which contains the given pad indices | |
169 | // return 0 if not found | |
170 | // --- | |
171 | ||
172 | switch (fkSector->GetDirection()) { | |
173 | case kX : { | |
174 | // Case where all the pads have the same size along X direction | |
175 | ||
176 | for (Int_t irow=0; irow<fkSector->GetNofRows(); ++irow) { | |
177 | AliMpRow* row = fkSector->GetRow(irow); | |
178 | if (row->GetLowIndicesLimit().GetFirst()<=indices.GetFirst() && | |
179 | row->GetHighIndicesLimit().GetFirst()>=indices.GetFirst()) { | |
180 | ||
181 | for (Int_t iseg=0;iseg<row->GetNofRowSegments();++iseg){ | |
182 | AliMpVRowSegment* seg = row->GetRowSegment(iseg); | |
183 | if (seg->GetLowIndicesLimit().GetFirst()<=indices.GetFirst() && | |
184 | seg->GetHighIndicesLimit().GetFirst()>=indices.GetFirst()) { | |
185 | ||
186 | AliMpMotifPosition* motifPos; | |
187 | for (Int_t imot=0;imot<seg->GetNofMotifs();++imot) { | |
188 | motifPos | |
189 | = fkSector->GetMotifMap() | |
190 | ->FindMotifPosition(seg->GetMotifPositionId(imot)); | |
191 | if (motifPos && motifPos->HasPad(indices)) return motifPos; | |
192 | } | |
193 | } | |
194 | } | |
195 | } | |
196 | } | |
197 | return 0; | |
198 | } | |
199 | break; | |
200 | //////////////////////////////////////////////////////////////////////////////// | |
201 | case kY : { | |
202 | // Case where all the pads have the same size along Y direction | |
203 | // look for the row which contains the indices | |
204 | AliMpRow* row=0; | |
205 | Int_t irow; | |
206 | for (irow=0; irow<fkSector->GetNofRows(); ++irow) { | |
207 | row = fkSector->GetRow(irow); | |
208 | AliMpVRowSegment* lastSeg = row->GetRowSegment(row->GetNofRowSegments()-1); | |
209 | if (lastSeg->GetLowIndicesLimit().GetSecond()<=indices.GetSecond() && | |
210 | lastSeg->GetHighIndicesLimit().GetSecond()>=indices.GetSecond()) break; | |
211 | // NOTE : We use the last row segment in order to ensure that | |
212 | // we are not on a special motif | |
213 | } | |
214 | if (irow==fkSector->GetNofRows()) return 0; | |
215 | // look for the row segment, in the found row, which contains the indices | |
216 | AliMpVRowSegment* seg=0; | |
217 | Int_t iseg; | |
218 | for (iseg=0;iseg<row->GetNofRowSegments();++iseg){ | |
219 | seg = row->GetRowSegment(iseg); | |
220 | if (seg->HasIndices(indices)) break; | |
221 | } | |
222 | if (iseg==row->GetNofRowSegments()) return 0; | |
223 | ||
224 | // look for the motif position which contains the indices | |
225 | AliMpMotifPosition* motifPos=0; | |
226 | Int_t imot=0; | |
227 | for (imot=0;imot<seg->GetNofMotifs();++imot) { | |
228 | motifPos | |
229 | = fkSector->GetMotifMap() | |
230 | ->FindMotifPosition(seg->GetMotifPositionId(imot)); | |
231 | if (motifPos && motifPos->HasPad(indices)) break; | |
232 | } | |
233 | if (imot==seg->GetNofMotifs()) return 0; | |
234 | ||
235 | return motifPos; | |
236 | } | |
237 | default: return 0; | |
238 | } | |
239 | } | |
240 | ||
241 | //______________________________________________________________________________ | |
242 | AliMpPad | |
243 | AliMpSectorSegmentation::PadByXDirection(const TVector2& startPosition, | |
244 | Double_t maxX) const | |
245 | { | |
246 | // Find the first valid pad from starting position in the | |
247 | // direction of pad lines up to distance dx. | |
248 | // --- | |
249 | ||
250 | // Define step limits | |
251 | Double_t stepX = fkSector->GetMinPadDimensions().X(); | |
252 | ||
253 | // Search in X direction | |
254 | AliMpPad pad; | |
255 | TVector2 position(startPosition); | |
256 | do { | |
257 | pad = PadByPosition(position, false); | |
258 | position += TVector2(stepX, 0.); | |
259 | } | |
260 | while ( !pad.IsValid() && position.X() < maxX ); | |
261 | ||
262 | // Invalidate pad if it is outside limits | |
263 | if ((pad.Position().X() - pad.Dimensions().X()) > maxX) | |
264 | pad = AliMpPad::Invalid(); | |
265 | ||
266 | return pad; | |
267 | } | |
268 | ||
269 | //______________________________________________________________________________ | |
270 | AliMpPad | |
271 | AliMpSectorSegmentation::PadByYDirection(const TVector2& startPosition, | |
272 | Double_t maxY) const | |
273 | { | |
274 | // Find the first valid pad from starting position in the | |
275 | // direction of pad columns up to distance dx. | |
276 | // --- | |
277 | ||
278 | // Define step limits | |
279 | Double_t stepY = fkSector->GetMinPadDimensions().Y(); | |
280 | ||
281 | // Search in Y direction | |
282 | AliMpPad pad; | |
283 | TVector2 position(startPosition); | |
284 | do { | |
285 | pad = PadByPosition(position, false); | |
286 | position += TVector2(0., stepY); | |
287 | } | |
288 | while ( !pad.IsValid() && position.Y() < maxY ); | |
289 | ||
290 | // Invalidate pad if it is outside limits | |
291 | if ((pad.Position().Y() - pad.Dimensions().Y()) > maxY) | |
292 | pad = AliMpPad::Invalid(); | |
293 | ||
294 | return pad; | |
295 | } | |
296 | ||
297 | //______________________________________________________________________________ | |
298 | AliMpVPadIterator* AliMpSectorSegmentation::CreateIterator() const | |
299 | { | |
300 | // The inherited method cannot be used | |
301 | ||
302 | Fatal("CreateIterator", "Center pad has to be specified."); | |
303 | return 0; | |
304 | } | |
305 | ||
306 | ||
307 | // | |
308 | // public methods | |
309 | // | |
310 | ||
311 | //______________________________________________________________________________ | |
312 | AliMpVPadIterator* | |
313 | AliMpSectorSegmentation::CreateIterator(const AliMpArea& area) const | |
314 | { | |
315 | // Creates the are iterator. | |
316 | // (The inherited method cannot be used) | |
317 | // --- | |
318 | ||
319 | switch (fkSector->GetDirection()) { | |
320 | ||
321 | case kX: return new AliMpSectorAreaVPadIterator(this, area); | |
322 | ;; | |
323 | case kY: return new AliMpSectorAreaHPadIterator(this, area); | |
324 | ;; | |
325 | } | |
326 | ||
327 | Fatal("CreateIterator", "Incomplete switch on Sector direction"); | |
328 | return 0; | |
329 | } | |
330 | ||
331 | //______________________________________________________________________________ | |
332 | AliMpVPadIterator* | |
333 | AliMpSectorSegmentation::CreateIterator(const AliMpPad& centerPad, | |
334 | Bool_t includeCenter) const | |
335 | { | |
336 | // Creates the neighbours pad iterator. | |
337 | // (The inherited method cannot be used) | |
338 | ||
339 | return new AliMpNeighboursPadIterator(this, centerPad, includeCenter); | |
340 | } | |
341 | ||
342 | //______________________________________________________________________________ | |
343 | AliMpPad | |
344 | AliMpSectorSegmentation::PadByLocation(const AliMpIntPair& location, | |
345 | Bool_t warning) const | |
346 | { | |
347 | // Find the pad which corresponds to the given location | |
348 | ||
349 | if ((*fPadBuffer).GetLocation()==location) return (*fPadBuffer); | |
350 | ||
351 | AliMpMotifPosition* motifPos = | |
352 | fkSector->GetMotifMap()->FindMotifPosition(location.GetFirst()); | |
353 | if (!motifPos){ | |
354 | if (warning) Warning("PadByLocation","The pad motif position ID doesn't exists"); | |
355 | return AliMpPad::Invalid(); | |
356 | } | |
357 | ||
358 | AliMpVMotif* motif = motifPos->GetMotif(); | |
359 | AliMpIntPair localIndices = | |
360 | motif->GetMotifType()->FindLocalIndicesByGassiNum(location.GetSecond()); | |
361 | if (! localIndices.IsValid()) { | |
362 | if (warning) Warning("PadByLocation","The pad number doesn't exists"); | |
363 | return AliMpPad::Invalid(); | |
364 | } | |
365 | TVector2 delta = motif->PadPositionLocal(localIndices); | |
366 | return (*fPadBuffer) = AliMpPad(location, | |
367 | motifPos->GlobalIndices(localIndices), | |
368 | motifPos->Position()+delta, | |
369 | motif->GetPadDimensions(localIndices)); | |
370 | ||
371 | } | |
372 | //______________________________________________________________________________ | |
373 | AliMpPad | |
374 | AliMpSectorSegmentation::PadByIndices(const AliMpIntPair& indices, | |
375 | Bool_t warning ) const | |
376 | { | |
377 | // Find the pad which corresponds to the given indices | |
378 | ||
379 | if ((*fPadBuffer).GetIndices()==indices) return (*fPadBuffer); | |
380 | ||
381 | AliMpMotifPosition* motifPos = FindMotifPosition(indices); | |
382 | if (!motifPos) { | |
580c28fd | 383 | if (warning) { |
384 | cout << "indices " << indices << endl; | |
385 | Warning("PadByIndices","Pad indices not contained in any motif!"); | |
386 | } | |
5f91c9e8 | 387 | return AliMpPad::Invalid(); |
388 | } | |
389 | ||
390 | // retrieve the local indices in the found motif | |
391 | AliMpVMotif* motif = motifPos->GetMotif(); | |
392 | AliMpIntPair localIndices = indices - motifPos->GetLowIndicesLimit(); | |
393 | ||
394 | AliMpConnection* connection= | |
395 | motif->GetMotifType()->FindConnectionByLocalIndices(localIndices); | |
396 | ||
397 | if (!connection){ | |
398 | if (warning) Warning("PadByIndices","No connection with the given indices!"); | |
399 | return AliMpPad::Invalid(); | |
400 | } | |
401 | ||
402 | TVector2 localPos = motif->PadPositionLocal(localIndices); | |
403 | ||
404 | return (*fPadBuffer) | |
405 | = AliMpPad(AliMpIntPair(motifPos->GetID(),connection->GetGassiNum()), | |
406 | indices, | |
407 | motifPos->Position()+localPos, | |
408 | motif->GetPadDimensions(localIndices)); | |
409 | ||
410 | } | |
411 | //______________________________________________________________________________ | |
412 | AliMpPad | |
413 | AliMpSectorSegmentation::PadByPosition(const TVector2& position, | |
414 | Bool_t warning) const | |
415 | { | |
416 | // Find the pad which corresponds to the given position | |
417 | ||
418 | if ((*fPadBuffer).Position().X()==position.X() && | |
419 | (*fPadBuffer).Position().Y()==position.Y()) return (*fPadBuffer); | |
420 | ||
421 | Int_t motifPosID = fkSector->FindMotifPositionId(position); | |
422 | AliMpMotifPosition* motifPos | |
423 | = fkSector->GetMotifMap() | |
424 | ->FindMotifPosition(motifPosID); | |
425 | ||
426 | if (!motifPos){ | |
427 | if (warning) Warning("PadByPosition","Position outside limits"); | |
428 | return AliMpPad::Invalid(); | |
429 | } | |
430 | ||
431 | AliMpVMotif* motif = motifPos->GetMotif(); | |
432 | AliMpIntPair localIndices | |
433 | = motif->PadIndicesLocal(position-motifPos->Position()); | |
434 | ||
435 | AliMpConnection* connect = | |
436 | motif->GetMotifType()->FindConnectionByLocalIndices(localIndices); | |
437 | ||
438 | if (!connect){ | |
439 | if (warning) Warning("PadByPosition","Position outside motif limits"); | |
440 | return AliMpPad::Invalid(); | |
441 | } | |
442 | ||
443 | return (*fPadBuffer) | |
444 | = AliMpPad(AliMpIntPair(motifPosID,connect->GetGassiNum()), | |
445 | motifPos->GlobalIndices(localIndices), | |
446 | motifPos->Position()+motif->PadPositionLocal(localIndices), | |
447 | motif->GetPadDimensions(localIndices)); | |
448 | ||
449 | } | |
450 | ||
451 | //______________________________________________________________________________ | |
452 | AliMpPad | |
453 | AliMpSectorSegmentation::PadByDirection(const TVector2& startPosition, | |
454 | Double_t distance) const | |
455 | { | |
456 | // Find the first valid pad from starting position in the | |
457 | // direction of pad lines/columns up to the specified distance. | |
458 | // Pad lines are the lines of pads in the sector with constant pad y size, | |
459 | // pad columns are the columns of pads in the sector with constant pad x size. | |
460 | // --- | |
461 | ||
462 | switch (fkSector->GetDirection()) { | |
463 | ||
464 | case kX: return PadByYDirection(startPosition, distance); | |
465 | ;; | |
466 | case kY: return PadByXDirection(startPosition, distance); | |
467 | ;; | |
468 | } | |
469 | ||
470 | Fatal("PadByDirection", "Incomplete switch on Sector direction"); | |
471 | return AliMpPad::Invalid(); | |
472 | } | |
473 | ||
580c28fd | 474 | //______________________________________________________________________________ |
475 | Int_t AliMpSectorSegmentation::MaxPadIndexX() | |
476 | { | |
477 | // Return maximum pad index in x | |
478 | ||
479 | if (fMaxIndexInX) return fMaxIndexInX; | |
480 | ||
481 | for (Int_t i=0; i<fkSector->GetNofRows(); i++) { | |
482 | Int_t ixh = fkSector->GetRow(i)->GetHighIndicesLimit().GetFirst(); | |
483 | if ( ixh > fMaxIndexInX ) fMaxIndexInX = ixh; | |
484 | } | |
485 | return fMaxIndexInX; | |
486 | } | |
487 | ||
488 | //______________________________________________________________________________ | |
489 | Int_t AliMpSectorSegmentation::MaxPadIndexY() | |
490 | { | |
491 | // Return maximum pad index in y | |
492 | ||
493 | if (fMaxIndexInY) return fMaxIndexInY; | |
494 | ||
495 | for (Int_t i=0; i<fkSector->GetNofRows(); i++) { | |
496 | Int_t iyh = fkSector->GetRow(i)->GetHighIndicesLimit().GetSecond(); | |
497 | if ( iyh > fMaxIndexInY ) fMaxIndexInY = iyh; | |
498 | } | |
499 | return fMaxIndexInY; | |
500 | } | |
501 | ||
5f91c9e8 | 502 | //______________________________________________________________________________ |
503 | Bool_t AliMpSectorSegmentation::HasPad(const AliMpIntPair& indices) const | |
504 | { | |
505 | // Does the pad specified by <indices> exist ? | |
506 | // --- | |
507 | ||
508 | return PadByIndices(indices,kFALSE) != AliMpPad::Invalid(); | |
509 | } | |
510 | ||
511 | //______________________________________________________________________________ | |
512 | Bool_t AliMpSectorSegmentation::HasMotifPosition(Int_t motifPositionID) const | |
513 | { | |
514 | // Does the motif position specified by motifPositionID exist ? | |
515 | // --- | |
516 | ||
517 | return (fkSector->GetMotifMap()->FindMotifPosition(motifPositionID) != 0); | |
518 | } | |
519 | ||
520 | //______________________________________________________________________________ | |
521 | TVector2 AliMpSectorSegmentation::GetMinPadDimensions() const | |
522 | { | |
523 | // Returnes the dimensions of the smallest pad. | |
524 | // --- | |
525 | ||
526 | return fkSector->GetMinPadDimensions(); | |
527 | } | |
528 | ||
529 | //______________________________________________________________________________ | |
530 | Int_t AliMpSectorSegmentation::Zone(const AliMpPad& pad, Bool_t warning) const | |
531 | { | |
532 | // Returns the zone index of the zone containing the specified pad. | |
533 | // This zone index is different from the zone ID, | |
534 | // as it is unique for each pad dimensions. | |
535 | // It is composed in this way: | |
536 | // zoneID*10 + specific index | |
537 | // Specific index is present only for zones containing special motifs. | |
538 | // --- | |
539 | ||
540 | if (!pad.IsValid()) { | |
541 | if (warning) Warning("Zone(AliMpPad)", "Invalid pad"); | |
542 | return 0; | |
543 | } | |
544 | ||
f79c58a5 | 545 | #ifdef WITH_STL |
2998a151 | 546 | PadDimensionsMapCIterator it; |
5f91c9e8 | 547 | for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) { |
548 | if (AliMpConstants::IsEqual(it->second, pad.Dimensions())) | |
549 | return it->first; | |
550 | } | |
f79c58a5 | 551 | #endif |
552 | ||
553 | #ifdef WITH_ROOT | |
554 | PadDimensionsMapCIterator it(&fPadDimensionsMap); | |
555 | Long_t key, value; | |
556 | while ( it.Next(key, value) ) { | |
557 | TVector2 dimensions = GetVector(value); | |
558 | if (AliMpConstants::IsEqual(dimensions, pad.Dimensions())) | |
559 | return (Int_t)key; | |
bcf37928 | 560 | } |
f79c58a5 | 561 | #endif |
5f91c9e8 | 562 | |
563 | // Should never happen | |
bcf37928 | 564 | Error("Zone(AliMpPad)", "not found"); |
565 | cerr << pad << endl; | |
5f91c9e8 | 566 | return 0; |
567 | } | |
568 | ||
569 | //______________________________________________________________________________ | |
570 | TVector2 | |
571 | AliMpSectorSegmentation::PadDimensions(Int_t zone, Bool_t warning) const | |
572 | { | |
573 | // Returns the pad dimensions for the zone with the specified zone index. | |
574 | // --- | |
575 | ||
f79c58a5 | 576 | #ifdef WITH_STL |
2998a151 | 577 | PadDimensionsMapCIterator it = fPadDimensionsMap.find(zone); |
5f91c9e8 | 578 | if (it != fPadDimensionsMap.end()) return it->second; |
f79c58a5 | 579 | #endif |
580 | ||
581 | #ifdef WITH_ROOT | |
582 | Long_t value = fPadDimensionsMap.GetValue(zone); | |
583 | if (value) return GetVector(value); | |
584 | #endif | |
5f91c9e8 | 585 | |
586 | if (warning) Warning("PadDimensions(zone)", "not found"); | |
587 | return TVector2(); | |
588 | } | |
589 | ||
590 | //______________________________________________________________________________ | |
591 | Bool_t AliMpSectorSegmentation::CircleTest(const AliMpIntPair& indices) const | |
592 | { | |
593 | // Verifies that all methods for retrieving pads are consistents between them. | |
594 | // Returns true if the pad with specified indices was found and verified, | |
595 | // false otherwise. | |
596 | // --- | |
597 | ||
598 | if (!HasPad(indices)) return false; | |
599 | ||
600 | // Verify the indice->location->position->indice way | |
601 | AliMpIntPair location = PadByIndices(indices).GetLocation(); | |
602 | TVector2 position = PadByLocation(location).Position(); | |
603 | AliMpIntPair retIndices = PadByPosition(position).GetIndices(); | |
604 | ||
605 | if (retIndices != indices) { | |
606 | cout << "Pad " << indices << " lead to inconsistency" << endl; | |
607 | cout << "in indice->location->position->indice way..." << endl; | |
608 | cout << "starting from " << indices << "-->" << location << "-->" | |
609 | << '(' << position.X() << ',' << position.Y() << ')' | |
610 | << " and retIndices: " << retIndices << endl; | |
611 | } | |
612 | ||
613 | ||
614 | // Verify the indice->position->location->indice way | |
615 | position = PadByIndices(indices).Position(); | |
616 | location = PadByPosition(position).GetLocation(); | |
617 | retIndices = PadByLocation(location).GetIndices(); | |
618 | ||
619 | if (retIndices != indices) { | |
620 | cout << "Pad " << indices << " lead to inconsistency" << endl; | |
621 | cout << "in indice->position->location->indice way..." <<endl; | |
622 | cout << "starting from " << indices | |
623 | << " and retIndices: " << retIndices << endl; | |
624 | } | |
625 | ||
626 | return true; | |
627 | } | |
bcf37928 | 628 | |
629 | //______________________________________________________________________________ | |
630 | void AliMpSectorSegmentation::PrintZones() const | |
631 | { | |
632 | // Prints all zones and pads dimensions from the map. | |
633 | // --- | |
634 | ||
635 | cout << "Zones: " << endl; | |
636 | ||
637 | #ifdef WITH_STL | |
638 | PadDimensionsMapCIterator it; | |
639 | for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) { | |
640 | cout << " zone: " << setw(4) << it->first; | |
641 | cout << " pad dimensions: ( " | |
642 | << it->second.X() << ", " << it->second.Y() << ")" << endl; | |
643 | } | |
644 | #endif | |
645 | ||
646 | #ifdef WITH_ROOT | |
647 | PadDimensionsMapCIterator it(&fPadDimensionsMap); | |
648 | Long_t key, value; | |
649 | while ( it.Next(key, value) ) { | |
650 | //cout << "Iterating over: " << key << ", " << value << endl; | |
651 | TVector2 dimensions = GetVector(value); | |
652 | ||
653 | cout << " zone: " << setw(4) << key; | |
654 | cout << " pad dimensions: ( " | |
655 | << dimensions.X() << ", " << dimensions.Y() << ")" << endl; | |
656 | } | |
657 | #endif | |
658 | } | |
659 |