]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/MUONmapping/AliMpMotifTypePadIterator.cxx
Fixes for object target dependencies
[u/mrichter/AliRoot.git] / MUON / MUONmapping / AliMpMotifTypePadIterator.cxx
CommitLineData
dee1d5f1 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
5f91c9e8 16// $Id$
13985652 17// $MpId: AliMpMotifTypePadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $
5f91c9e8 18// Category: motif
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 21// Class AliMpMotifTypePadIterator
22// -------------------------------
23// Class, which defines an iterator over the pads of a given motif type
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 26//-----------------------------------------------------------------------------
5f91c9e8 27
28#include "AliMpMotifTypePadIterator.h"
29#include "AliMpMotifType.h"
168e9c4d 30#include "AliMpEncodePair.h"
5f91c9e8 31
13985652 32/// \cond CLASSIMP
5f91c9e8 33ClassImp(AliMpMotifTypePadIterator)
13985652 34/// \endcond
5f91c9e8 35
36//______________________________________________________________________________
37AliMpMotifTypePadIterator::AliMpMotifTypePadIterator():
38 AliMpVPadIterator(),
7d5d0cc5 39 fkMotifType(0),
168e9c4d 40 fCurrentIx(-1),
41 fCurrentIy(-1)
5f91c9e8 42{
dee1d5f1 43/// Default constructor, set the current position to "invalid"
5f91c9e8 44}
45
46//______________________________________________________________________________
47AliMpMotifTypePadIterator::AliMpMotifTypePadIterator(
48 const AliMpMotifType* motifType)
49 : AliMpVPadIterator(),
7d5d0cc5 50 fkMotifType(motifType),
168e9c4d 51 fCurrentIx(-1),
52 fCurrentIy(-1)
5f91c9e8 53{
dee1d5f1 54/// Standard constructor, let *this to invalid position
5f91c9e8 55}
56
57//______________________________________________________________________________
58AliMpMotifTypePadIterator::AliMpMotifTypePadIterator(
59 const AliMpMotifTypePadIterator& right)
60 : AliMpVPadIterator(right),
7d5d0cc5 61 fkMotifType(right.fkMotifType),
168e9c4d 62 fCurrentIx(right.fCurrentIx),
63 fCurrentIy(right.fCurrentIy)
5f91c9e8 64
65{
dee1d5f1 66/// Copy constructor
5f91c9e8 67}
68
69//______________________________________________________________________________
70AliMpMotifTypePadIterator::~AliMpMotifTypePadIterator()
71{
dee1d5f1 72/// Destructor
5f91c9e8 73}
74
75// operators
76
77//______________________________________________________________________________
78AliMpMotifTypePadIterator&
79AliMpMotifTypePadIterator::operator = (const AliMpMotifTypePadIterator& right)
80{
dee1d5f1 81/// Assignment operator. \n
82/// If the right hand iterator isn't of good type
83/// the current operator is invalidated
5f91c9e8 84
dee1d5f1 85 // check assignment to self
5f91c9e8 86 if (this == &right) return *this;
87
dee1d5f1 88 // base class assignment
5f91c9e8 89 AliMpVPadIterator::operator=(right);
90
7d5d0cc5 91 fkMotifType = right.fkMotifType;
168e9c4d 92 fCurrentIx = right.fCurrentIx;
93 fCurrentIy = right.fCurrentIy;
5f91c9e8 94
95 return *this;
96}
97
98//
99//private methods
100//
101
102//______________________________________________________________________________
168e9c4d 103Bool_t
104AliMpMotifTypePadIterator::FindFirstPadInLine(Int_t ix, Int_t iy,
105 Int_t& newIx, Int_t& newIy) const
5f91c9e8 106{
dee1d5f1 107/// Find the indices of the first pad in the same line
13985652 108/// as the \a indices, and in column, at least equal, to the
109/// one of \a indices
5f91c9e8 110
168e9c4d 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++;
5f91c9e8 124 }
168e9c4d 125
126 newIx = -1;
127 newIy = -1;
128 return false;
5f91c9e8 129}
130
131//______________________________________________________________________________
132Bool_t AliMpMotifTypePadIterator::IsValid() const
133{
dee1d5f1 134/// Is the iterator in a valid position?
5f91c9e8 135
168e9c4d 136 return fkMotifType!=0 && fCurrentIx >=0 && fCurrentIy >=0;
5f91c9e8 137}
138
139//
140//public methods
141//
142
143//______________________________________________________________________________
144void AliMpMotifTypePadIterator::First()
145{
dee1d5f1 146/// Reset the iterator, so that it points to the first available
147/// pad in the motif type
5f91c9e8 148
168e9c4d 149 if ( ! fkMotifType ) {
150 Invalidate();
151 return ;
5f91c9e8 152 }
168e9c4d 153
154 fCurrentIx = 0;
155 fCurrentIy = 0;
156 if ( fkMotifType->HasPadByLocalIndices(fCurrentIx, fCurrentIy) ) return;
5f91c9e8 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//______________________________________________________________________________
168void AliMpMotifTypePadIterator::Next()
169{
dee1d5f1 170/// Move the iterator to the next valid pad.
5f91c9e8 171
168e9c4d 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++;
5f91c9e8 186 }
187
188 // if the loop is finished, there's not available pads at all...
189 Invalidate();
190 return;
191}
192
193//______________________________________________________________________________
194Bool_t AliMpMotifTypePadIterator::IsDone() const
195{
dee1d5f1 196/// Is the iterator in the end ?
197
168e9c4d 198 return ! IsValid();
5f91c9e8 199}
200
201//______________________________________________________________________________
202AliMpPad AliMpMotifTypePadIterator::CurrentItem() const
203{
dee1d5f1 204/// Return current pad.
5f91c9e8 205
168e9c4d 206 if ( ! fkMotifType )
207 return AliMpPad::Invalid();
5f91c9e8 208 else
168e9c4d 209 return AliMpPad(0, 0,
210 fCurrentIx, fCurrentIy,
6e97fbb8 211 0., 0.,0., 0.);
5f91c9e8 212}
213
214//______________________________________________________________________________
215void AliMpMotifTypePadIterator::Invalidate()
216{
dee1d5f1 217/// Let the iterator point to the invalid position
218
168e9c4d 219 fCurrentIx = -1;
220 fCurrentIy = -1;
5f91c9e8 221}
222