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 "AliMpSector.h"
31 #include "AliMpMotifType.h"
34 #include "AliMpVRowSegment.h"
35 #include "AliMpMotifMap.h"
36 #include "AliMpMotifPosition.h"
39 ClassImp(AliMpSectorPadIterator)
42 //______________________________________________________________________________
43 AliMpSectorPadIterator::AliMpSectorPadIterator()
44 : AliMpVPadIterator(),
50 /// Default constructor, set the current position to "invalid"
53 //______________________________________________________________________________
54 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* sector)
55 : AliMpVPadIterator(),
61 /// Standard constructor, set *this to invalid position
64 //______________________________________________________________________________
65 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
66 : AliMpVPadIterator(right),
77 //______________________________________________________________________________
78 AliMpSectorPadIterator::~AliMpSectorPadIterator()
87 //______________________________________________________________________________
88 AliMpSectorPadIterator&
89 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
91 /// Assignment operator
93 // check assignment to self
94 if (this == &right) return *this;
96 // base class assignment
97 AliMpVPadIterator::operator=(right);
99 fkSector = right.fkSector;
100 fCurrentIndex = right.fCurrentIndex,
101 fMotifPos = right.fMotifPos;
102 fIterator = right.fIterator;
109 //______________________________________________________________________________
110 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
112 /// Find the AliMpMotifType object associated with the triplet
113 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
114 /// place it in the private fMotifType member and return it.
116 if ( fCurrentIndex == fkSector->GetMotifMap()->GetNofMotifPositions() ) {
121 fMotifPos = fkSector->GetMotifMap()->GetMotifPosition(fCurrentIndex);
122 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
128 //______________________________________________________________________________
129 Bool_t AliMpSectorPadIterator::IsValid() const
131 /// Is the iterator in a valid position?
133 return (fkSector!=0) && (fMotifPos!=0);
140 //______________________________________________________________________________
141 void AliMpSectorPadIterator::First()
143 /// Reset the iterator, so that it points to the first available
144 /// pad in the sector
151 ResetToCurrentMotifPosition();
156 //______________________________________________________________________________
157 void AliMpSectorPadIterator::Next()
159 /// Move the iterator to the next valid pad.
161 if (!IsValid()) return;
165 if (!fIterator.IsDone()) return;
168 // Go to the next motif, in the current segment
170 if (ResetToCurrentMotifPosition()) return;
177 //______________________________________________________________________________
178 Bool_t AliMpSectorPadIterator::IsDone() const
180 /// Is the iterator in the end?
185 //______________________________________________________________________________
186 AliMpPad AliMpSectorPadIterator::CurrentItem () const
188 /// Return current pad.
191 return AliMpPad::Invalid();
194 // no more verification, since IsValid() is TRUE here.
195 return fIterator.CurrentItem();
198 //______________________________________________________________________________
199 void AliMpSectorPadIterator::Invalidate()
201 /// Let the iterator point to the invalid position
203 fIterator.Invalidate();