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 //-----------------------------------------------------------------------------
21 // Class AliMpSectorPadIterator
22 // ----------------------------
23 // Class, which defines an iterator over the pads of a sector
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
29 #include "AliMpSectorPadIterator.h"
30 #include "AliMpIntPair.h"
31 #include "AliMpSector.h"
32 #include "AliMpMotifType.h"
35 #include "AliMpVRowSegment.h"
36 #include "AliMpMotifMap.h"
37 #include "AliMpMotifPosition.h"
40 ClassImp(AliMpSectorPadIterator)
43 //______________________________________________________________________________
44 AliMpSectorPadIterator::AliMpSectorPadIterator()
45 : AliMpVPadIterator(),
51 /// Default constructor, set the current position to "invalid"
54 //______________________________________________________________________________
55 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
56 : AliMpVPadIterator(),
62 /// Standard constructor, set *this to invalid position
65 //______________________________________________________________________________
66 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
67 : AliMpVPadIterator(right),
78 //______________________________________________________________________________
79 AliMpSectorPadIterator::~AliMpSectorPadIterator()
88 //______________________________________________________________________________
89 AliMpSectorPadIterator&
90 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
92 /// Assignment operator
94 // check assignment to self
95 if (this == &right) return *this;
97 // base class assignment
98 AliMpVPadIterator::operator=(right);
100 fkSector = right.fkSector;
101 fCurrentIndex = right.fCurrentIndex,
102 fMotifPos = right.fMotifPos;
103 fIterator = right.fIterator;
110 //______________________________________________________________________________
111 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
113 /// Find the AliMpMotifType object associated with the triplet
114 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
115 /// place it in the private fMotifType member and return it.
117 if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
122 fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
123 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
129 //______________________________________________________________________________
130 Bool_t AliMpSectorPadIterator::IsValid() const
132 /// Is the iterator in a valid position?
134 return (fkSector!=0) && (fMotifPos!=0);
141 //______________________________________________________________________________
142 void AliMpSectorPadIterator::First()
144 /// Reset the iterator, so that it points to the first available
145 /// pad in the sector
152 ResetToCurrentMotifPosition();
157 //______________________________________________________________________________
158 void AliMpSectorPadIterator::Next()
160 /// Move the iterator to the next valid pad.
162 if (!IsValid()) return;
166 if (!fIterator.IsDone()) return;
169 // Go to the next motif, in the current segment
171 if (ResetToCurrentMotifPosition()) return;
178 //______________________________________________________________________________
179 Bool_t AliMpSectorPadIterator::IsDone() const
181 /// Is the iterator in the end?
186 //______________________________________________________________________________
187 AliMpPad AliMpSectorPadIterator::CurrentItem () const
189 /// Return current pad.
192 return AliMpPad::Invalid();
195 // no more verification, since IsValid() is TRUE here.
196 return fIterator.CurrentItem();
199 //______________________________________________________________________________
200 void AliMpSectorPadIterator::Invalidate()
202 /// Let the iterator point to the invalid position
204 fIterator.Invalidate();