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