]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpSectorPadIterator.cxx
Updated comments for Doxygen - corrected warnings
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSectorPadIterator.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: AliMpSectorPadIterator.cxx,v 1.6 2006/05/24 13:58:46 ivana Exp $
5f91c9e8 18// Category: sector
19//
20// Class AliMpSectorPadIterator
21// ----------------------------
22// Class, which defines an iterator over the pads of a sector
dbe945cc 23// Included in AliRoot: 2003/05/02
5f91c9e8 24// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
25
26#include "AliMpSectorPadIterator.h"
27#include "AliMpIntPair.h"
28#include "AliMpSector.h"
29#include "AliMpMotifType.h"
30
31#include "AliMpRow.h"
32#include "AliMpVRowSegment.h"
33#include "AliMpMotifMap.h"
34#include "AliMpMotifPosition.h"
35
13985652 36/// \cond CLASSIMP
5f91c9e8 37ClassImp(AliMpSectorPadIterator)
13985652 38/// \endcond
5f91c9e8 39
40//______________________________________________________________________________
41AliMpSectorPadIterator::AliMpSectorPadIterator()
42 : AliMpVPadIterator(),
43 fkSector(0),
44 fCurrentRow(0),
45 fCurrentSeg(0),
46 fCurrentMotif(0),
47 fMotifPos(0),
48 fIterator()
49{
dee1d5f1 50/// Default constructor, set the current position to "invalid"
5f91c9e8 51}
52
53//______________________________________________________________________________
dee1d5f1 54AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
5f91c9e8 55 : AliMpVPadIterator(),
56 fkSector(sector),
57 fCurrentRow(0),
58 fCurrentSeg(0),
59 fCurrentMotif(0),
60 fMotifPos(0),
61 fIterator()
62{
dee1d5f1 63/// Standard constructor, set *this to invalid position
5f91c9e8 64}
65
66//______________________________________________________________________________
67AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
68 : AliMpVPadIterator(right)
69{
dee1d5f1 70/// Copy constructor
5f91c9e8 71
72 *this = right;
73}
74
75//______________________________________________________________________________
76AliMpSectorPadIterator::~AliMpSectorPadIterator()
77{
dee1d5f1 78/// Destructor
5f91c9e8 79}
80
dee1d5f1 81//
5f91c9e8 82// operators
dee1d5f1 83//
5f91c9e8 84
85//______________________________________________________________________________
86AliMpSectorPadIterator&
87AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
88{
dee1d5f1 89/// Assignment operator
5f91c9e8 90
dee1d5f1 91 // check assignment to self
5f91c9e8 92 if (this == &right) return *this;
93
dee1d5f1 94 // base class assignment
5f91c9e8 95 AliMpVPadIterator::operator=(right);
96
97 fkSector = right.fkSector;
98 fCurrentRow = right.fCurrentRow;
99 fCurrentSeg = right.fCurrentSeg;
100 fCurrentMotif = right.fCurrentMotif;
101 fIterator = right.fIterator;
102
103 return *this;
104}
105
106//private methods
107
108//______________________________________________________________________________
109AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
110{
dee1d5f1 111/// Find the AliMpMotifType object associated with the triplet
112/// (fCurrentRow, fCurrentSeg, fCurrentMotif),
113/// place it in the private fMotifType member and return it.
5f91c9e8 114
115 fMotifPos =0;
116
117 if (fkSector){
118 AliMpRow* row;
119 if ((fCurrentRow >= 0) && (fCurrentRow < fkSector->GetNofRows())){
120 row= fkSector->GetRow(fCurrentRow);
121
122 AliMpVRowSegment* seg;
123 if (fCurrentSeg<row->GetNofRowSegments()){
124 seg = row->GetRowSegment(fCurrentSeg);
125
126 if (fCurrentMotif<seg->GetNofMotifs()){
127 fMotifPos =
128 fkSector->GetMotifMap()->FindMotifPosition(
129 seg->GetMotifPositionId(fCurrentMotif));
130 }
131 }
132 }
133 }
134
135 if (fMotifPos) {
136 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
137 fIterator.First();
138 }
139 else
140 Invalidate();
141
142 return fMotifPos;
143}
144
145//______________________________________________________________________________
146Bool_t AliMpSectorPadIterator::IsValid() const
147{
dee1d5f1 148/// Is the iterator in a valid position?
149
5f91c9e8 150 return (fkSector!=0) && (fMotifPos!=0);
151}
152
dee1d5f1 153//
5f91c9e8 154//public methods
dee1d5f1 155//
5f91c9e8 156
157//______________________________________________________________________________
158void AliMpSectorPadIterator::First()
159{
dee1d5f1 160/// Reset the iterator, so that it points to the first available
161/// pad in the sector
5f91c9e8 162
163 if (!fkSector) {
164 Invalidate();
165 return;
166 }
167 fCurrentRow =0;
168 fCurrentSeg=0;
169 fCurrentMotif=0;
170
171 ResetToCurrentMotifPosition();
172
173 return;
174}
175
176//______________________________________________________________________________
177void AliMpSectorPadIterator::Next()
178{
dee1d5f1 179/// Move the iterator to the next valid pad.
5f91c9e8 180
181 //if (!IsValid()) return *this;
182 if (!IsValid()) return;
183
184 fIterator.Next();
185
186 if (!fIterator.IsDone()) return;
187
188
189 // Go to ne next motif, in the current segment
190 ++fCurrentMotif;
191 if (ResetToCurrentMotifPosition()) return;
192
193
194 // if motif number is too big, set it to 0 and pass to the next row segment
195 fCurrentMotif=0;
196 ++fCurrentSeg;
197 if (ResetToCurrentMotifPosition()) return;
198
199
200 // if row segment number is too big, pass to the next row
201 fCurrentSeg=0;
202 ++fCurrentRow;
203 if (ResetToCurrentMotifPosition()) return;
204
205 // if row number is too big, the invalidate the iterator (==End())
206 Invalidate();
207 return;
208
209}
210
211//______________________________________________________________________________
212Bool_t AliMpSectorPadIterator::IsDone() const
213{
dee1d5f1 214/// Is the iterator in the end?
215
5f91c9e8 216 return !IsValid();
217}
218
219//______________________________________________________________________________
220AliMpPad AliMpSectorPadIterator::CurrentItem () const
221{
dee1d5f1 222/// Return current pad.
5f91c9e8 223
224 if (!IsValid())
225 return AliMpPad::Invalid();
226
227
228 // no more verification, since IsValid() is TRUE here.
229
230 return fIterator.CurrentItem();
231}
232
233//______________________________________________________________________________
234void AliMpSectorPadIterator::Invalidate()
235{
dee1d5f1 236/// Let the iterator point to the invalid position
5f91c9e8 237 fMotifPos = 0;
238 fIterator.Invalidate();
239}
240