1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSectorPadIterator.cxx,v 1.6 2006/05/24 13:58:46 ivana Exp $
20 // Class AliMpSectorPadIterator
21 // ----------------------------
22 // Class, which defines an iterator over the pads of a sector
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpSectorPadIterator.h"
27 #include "AliMpIntPair.h"
28 #include "AliMpSector.h"
29 #include "AliMpMotifType.h"
32 #include "AliMpVRowSegment.h"
33 #include "AliMpMotifMap.h"
34 #include "AliMpMotifPosition.h"
37 ClassImp(AliMpSectorPadIterator)
40 //______________________________________________________________________________
41 AliMpSectorPadIterator::AliMpSectorPadIterator()
42 : AliMpVPadIterator(),
48 /// Default constructor, set the current position to "invalid"
51 //______________________________________________________________________________
52 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
53 : AliMpVPadIterator(),
59 /// Standard constructor, set *this to invalid position
62 //______________________________________________________________________________
63 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
64 : AliMpVPadIterator(right),
75 //______________________________________________________________________________
76 AliMpSectorPadIterator::~AliMpSectorPadIterator()
85 //______________________________________________________________________________
86 AliMpSectorPadIterator&
87 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
89 /// Assignment operator
91 // check assignment to self
92 if (this == &right) return *this;
94 // base class assignment
95 AliMpVPadIterator::operator=(right);
97 fkSector = right.fkSector;
98 fCurrentIndex = right.fCurrentIndex,
99 fMotifPos = right.fMotifPos;
100 fIterator = right.fIterator;
107 //______________________________________________________________________________
108 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
110 /// Find the AliMpMotifType object associated with the triplet
111 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
112 /// place it in the private fMotifType member and return it.
114 if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
119 fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
120 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
126 //______________________________________________________________________________
127 Bool_t AliMpSectorPadIterator::IsValid() const
129 /// Is the iterator in a valid position?
131 return (fkSector!=0) && (fMotifPos!=0);
138 //______________________________________________________________________________
139 void AliMpSectorPadIterator::First()
141 /// Reset the iterator, so that it points to the first available
142 /// pad in the sector
149 ResetToCurrentMotifPosition();
154 //______________________________________________________________________________
155 void AliMpSectorPadIterator::Next()
157 /// Move the iterator to the next valid pad.
159 if (!IsValid()) return;
163 if (!fIterator.IsDone()) return;
166 // Go to the next motif, in the current segment
168 if (ResetToCurrentMotifPosition()) return;
175 //______________________________________________________________________________
176 Bool_t AliMpSectorPadIterator::IsDone() const
178 /// Is the iterator in the end?
183 //______________________________________________________________________________
184 AliMpPad AliMpSectorPadIterator::CurrentItem () const
186 /// Return current pad.
189 return AliMpPad::Invalid();
192 // no more verification, since IsValid() is TRUE here.
193 return fIterator.CurrentItem();
196 //______________________________________________________________________________
197 void AliMpSectorPadIterator::Invalidate()
199 /// Let the iterator point to the invalid position
201 fIterator.Invalidate();