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