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