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 // Class AliMpSectorPadIterator
21 // ----------------------------
22 // Class, which defines an iterator over the pads of a sector
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpSectorPadIterator.h"
27 #include "AliMpIntPair.h"
28 #include "AliMpSector.h"
29 #include "AliMpMotifType.h"
32 #include "AliMpVRowSegment.h"
33 #include "AliMpMotifMap.h"
34 #include "AliMpMotifPosition.h"
37 ClassImp(AliMpSectorPadIterator)
40 //______________________________________________________________________________
41 AliMpSectorPadIterator::AliMpSectorPadIterator()
42 : AliMpVPadIterator(),
50 /// Default constructor, set the current position to "invalid"
53 //______________________________________________________________________________
54 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
55 : AliMpVPadIterator(),
63 /// Standard constructor, set *this to invalid position
66 //______________________________________________________________________________
67 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
68 : AliMpVPadIterator(right),
81 //______________________________________________________________________________
82 AliMpSectorPadIterator::~AliMpSectorPadIterator()
91 //______________________________________________________________________________
92 AliMpSectorPadIterator&
93 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
95 /// Assignment operator
97 // check assignment to self
98 if (this == &right) return *this;
100 // base class assignment
101 AliMpVPadIterator::operator=(right);
103 fkSector = right.fkSector;
104 fCurrentRow = right.fCurrentRow;
105 fCurrentSeg = right.fCurrentSeg;
106 fCurrentMotif = right.fCurrentMotif;
107 fIterator = right.fIterator;
114 //______________________________________________________________________________
115 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
117 /// Find the AliMpMotifType object associated with the triplet
118 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
119 /// place it in the private fMotifType member and return it.
125 if ((fCurrentRow >= 0) && (fCurrentRow < fkSector->GetNofRows())){
126 row= fkSector->GetRow(fCurrentRow);
128 AliMpVRowSegment* seg;
129 if (fCurrentSeg<row->GetNofRowSegments()){
130 seg = row->GetRowSegment(fCurrentSeg);
132 if (fCurrentMotif<seg->GetNofMotifs()){
134 fkSector->GetMotifMap()->FindMotifPosition(
135 seg->GetMotifPositionId(fCurrentMotif));
142 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
151 //______________________________________________________________________________
152 Bool_t AliMpSectorPadIterator::IsValid() const
154 /// Is the iterator in a valid position?
156 return (fkSector!=0) && (fMotifPos!=0);
163 //______________________________________________________________________________
164 void AliMpSectorPadIterator::First()
166 /// Reset the iterator, so that it points to the first available
167 /// pad in the sector
177 ResetToCurrentMotifPosition();
182 //______________________________________________________________________________
183 void AliMpSectorPadIterator::Next()
185 /// Move the iterator to the next valid pad.
187 //if (!IsValid()) return *this;
188 if (!IsValid()) return;
192 if (!fIterator.IsDone()) return;
195 // Go to ne next motif, in the current segment
197 if (ResetToCurrentMotifPosition()) return;
200 // if motif number is too big, set it to 0 and pass to the next row segment
203 if (ResetToCurrentMotifPosition()) return;
206 // if row segment number is too big, pass to the next row
209 if (ResetToCurrentMotifPosition()) return;
211 // if row number is too big, the invalidate the iterator (==End())
217 //______________________________________________________________________________
218 Bool_t AliMpSectorPadIterator::IsDone() const
220 /// Is the iterator in the end?
225 //______________________________________________________________________________
226 AliMpPad AliMpSectorPadIterator::CurrentItem () const
228 /// Return current pad.
231 return AliMpPad::Invalid();
234 // no more verification, since IsValid() is TRUE here.
236 return fIterator.CurrentItem();
239 //______________________________________________________________________________
240 void AliMpSectorPadIterator::Invalidate()
242 /// Let the iterator point to the invalid position
244 fIterator.Invalidate();