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: AliMpMotifTypePadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $
20 //-----------------------------------------------------------------------------
21 // Class AliMpMotifTypePadIterator
22 // -------------------------------
23 // Class, which defines an iterator over the pads of a given motif type
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
28 #include "AliMpMotifTypePadIterator.h"
29 #include "AliMpMotifType.h"
30 #include "AliMpEncodePair.h"
33 ClassImp(AliMpMotifTypePadIterator)
36 //______________________________________________________________________________
37 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator():
43 /// Default constructor, set the current position to "invalid"
46 //______________________________________________________________________________
47 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator(
48 const AliMpMotifType* motifType)
49 : AliMpVPadIterator(),
50 fkMotifType(motifType),
54 /// Standard constructor, let *this to invalid position
57 //______________________________________________________________________________
58 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator(
59 const AliMpMotifTypePadIterator& right)
60 : AliMpVPadIterator(right),
61 fkMotifType(right.fkMotifType),
62 fCurrentIx(right.fCurrentIx),
63 fCurrentIy(right.fCurrentIy)
69 //______________________________________________________________________________
70 AliMpMotifTypePadIterator::~AliMpMotifTypePadIterator()
77 //______________________________________________________________________________
78 AliMpMotifTypePadIterator&
79 AliMpMotifTypePadIterator::operator = (const AliMpMotifTypePadIterator& right)
81 /// Assignment operator. \n
82 /// If the right hand iterator isn't of good type
83 /// the current operator is invalidated
85 // check assignment to self
86 if (this == &right) return *this;
88 // base class assignment
89 AliMpVPadIterator::operator=(right);
91 fkMotifType = right.fkMotifType;
92 fCurrentIx = right.fCurrentIx;
93 fCurrentIy = right.fCurrentIy;
102 //______________________________________________________________________________
104 AliMpMotifTypePadIterator::FindFirstPadInLine(Int_t ix, Int_t iy,
105 Int_t& newIx, Int_t& newIy) const
107 /// Find the indices of the first pad in the same line
108 /// as the \a indices, and in column, at least equal, to the
109 /// one of \a indices
111 if ( ! fkMotifType ) {
117 while ( ix < fkMotifType->GetNofPadsX() ) {
118 if ( fkMotifType->HasPadByLocalIndices(ix, iy) ) {
131 //______________________________________________________________________________
132 Bool_t AliMpMotifTypePadIterator::IsValid() const
134 /// Is the iterator in a valid position?
136 return fkMotifType!=0 && fCurrentIx >=0 && fCurrentIy >=0;
143 //______________________________________________________________________________
144 void AliMpMotifTypePadIterator::First()
146 /// Reset the iterator, so that it points to the first available
147 /// pad in the motif type
149 if ( ! fkMotifType ) {
156 if ( fkMotifType->HasPadByLocalIndices(fCurrentIx, fCurrentIy) ) return;
159 // if (0,0) is not available
160 // place itself to the first avalable motif after (0,0) (if exists)
167 //______________________________________________________________________________
168 void AliMpMotifTypePadIterator::Next()
170 /// Move the iterator to the next valid pad.
172 if ( ! IsValid() ) return;
174 while ( fCurrentIy < fkMotifType->GetNofPadsY() ) {
175 Int_t nextTryIx, nextTryIy;
177 = FindFirstPadInLine(fCurrentIx+1, fCurrentIy, nextTryIx, nextTryIy);
180 fCurrentIx = nextTryIx;
181 fCurrentIy = nextTryIy;
188 // if the loop is finished, there's not available pads at all...
193 //______________________________________________________________________________
194 Bool_t AliMpMotifTypePadIterator::IsDone() const
196 /// Is the iterator in the end ?
201 //______________________________________________________________________________
202 AliMpPad AliMpMotifTypePadIterator::CurrentItem() const
204 /// Return current pad.
207 return AliMpPad::Invalid();
209 return AliMpPad(0, 0,
210 fCurrentIx, fCurrentIy,
214 //______________________________________________________________________________
215 void AliMpMotifTypePadIterator::Invalidate()
217 /// Let the iterator point to the invalid position