AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpMotifTypePadIterator.cxx
Go to the documentation of this file.
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 
16 // $Id$
17 // $MpId: AliMpMotifTypePadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $
18 // Category: motif
19 
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 //-----------------------------------------------------------------------------
27 
29 #include "AliMpMotifType.h"
30 #include "AliMpEncodePair.h"
31 
35 
36 //______________________________________________________________________________
39  fkMotifType(0),
40  fCurrentIx(-1),
41  fCurrentIy(-1)
42 {
44 }
45 
46 //______________________________________________________________________________
48  const AliMpMotifType* motifType)
50  fkMotifType(motifType),
51  fCurrentIx(-1),
52  fCurrentIy(-1)
53 {
55 }
56 
57 //______________________________________________________________________________
59  const AliMpMotifTypePadIterator& right)
60  : AliMpVPadIterator(right),
61  fkMotifType(right.fkMotifType),
62  fCurrentIx(right.fCurrentIx),
63  fCurrentIy(right.fCurrentIy)
64 
65 {
67 }
68 
69 //______________________________________________________________________________
71 {
73 }
74 
75 // operators
76 
77 //______________________________________________________________________________
80 {
84 
85  // check assignment to self
86  if (this == &right) return *this;
87 
88  // base class assignment
90 
91  fkMotifType = right.fkMotifType;
92  fCurrentIx = right.fCurrentIx;
93  fCurrentIy = right.fCurrentIy;
94 
95  return *this;
96 }
97 
98 //
99 //private methods
100 //
101 
102 //______________________________________________________________________________
103 Bool_t
105  Int_t& newIx, Int_t& newIy) const
106 {
110 
111  if ( ! fkMotifType ) {
112  newIx = -1;
113  newIy = -1;
114  return false;
115  }
116 
117  while ( ix < fkMotifType->GetNofPadsX() ) {
118  if ( fkMotifType->HasPadByLocalIndices(ix, iy) ) {
119  newIx = ix;
120  newIy = iy;
121  return true;
122  }
123  ix++;
124  }
125 
126  newIx = -1;
127  newIy = -1;
128  return false;
129 }
130 
131 //______________________________________________________________________________
133 {
135 
136  return fkMotifType!=0 && fCurrentIx >=0 && fCurrentIy >=0;
137 }
138 
139 //
140 //public methods
141 //
142 
143 //______________________________________________________________________________
145 {
148 
149  if ( ! fkMotifType ) {
150  Invalidate();
151  return ;
152  }
153 
154  fCurrentIx = 0;
155  fCurrentIy = 0;
157 
158 
159  // if (0,0) is not available
160  // place itself to the first avalable motif after (0,0) (if exists)
161  // ++(*this);
162  Next();
163 
164  return;
165 }
166 
167 //______________________________________________________________________________
169 {
171 
172  if ( ! IsValid() ) return;
173 
174  while ( fCurrentIy < fkMotifType->GetNofPadsY() ) {
175  Int_t nextTryIx, nextTryIy;
176  Bool_t result
177  = FindFirstPadInLine(fCurrentIx+1, fCurrentIy, nextTryIx, nextTryIy);
178 
179  if ( result ){
180  fCurrentIx = nextTryIx;
181  fCurrentIy = nextTryIy;
182  return;
183  }
184  fCurrentIx = -1;
185  fCurrentIy++;
186  }
187 
188  // if the loop is finished, there's not available pads at all...
189  Invalidate();
190  return;
191 }
192 
193 //______________________________________________________________________________
195 {
197 
198  return ! IsValid();
199 }
200 
201 //______________________________________________________________________________
203 {
205 
206  if ( ! fkMotifType )
207  return AliMpPad::Invalid();
208  else
209  return AliMpPad(0, 0,
211  0., 0.,0., 0.);
212 }
213 
214 //______________________________________________________________________________
216 {
218 
219  fCurrentIx = -1;
220  fCurrentIy = -1;
221 }
222 
virtual void Next()
Set iterator to the next pad.
virtual Bool_t IsDone() const
Is iterator done.
An iterator over the pads of a given motif type.
virtual void First()
Set iterator to the first pad.
static AliMpPad Invalid()
Return invalid pad.
Definition: AliMpPad.h:57
Int_t fCurrentIy
the current iy position inside the motif type
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t fCurrentIx
the current ix position inside the motif type
virtual AliMpPad CurrentItem() const
Return current pad.
const AliMpMotifType * fkMotifType
the motif type over which iterate
Bool_t HasPadByLocalIndices(MpPair_t localIndices) const
An interface for an iterator over pads.
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
virtual void Invalidate()
Invalidate iterator (.
AliMpVPadIterator & operator=(const AliMpVPadIterator &right)
AliMpMotifTypePadIterator & operator=(const AliMpMotifTypePadIterator &right)
Class that defines the motif properties.
Bool_t FindFirstPadInLine(Int_t ix, Int_t iy, Int_t &newIx, Int_t &newIy) const