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.5 2005/08/26 15:43:36 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"
36 ClassImp(AliMpSectorPadIterator)
38 //______________________________________________________________________________
39 AliMpSectorPadIterator::AliMpSectorPadIterator()
40 : AliMpVPadIterator(),
48 /// Default constructor, set the current position to "invalid"
51 //______________________________________________________________________________
52 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
53 : AliMpVPadIterator(),
61 /// Standard constructor, set *this to invalid position
64 //______________________________________________________________________________
65 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
66 : AliMpVPadIterator(right)
73 //______________________________________________________________________________
74 AliMpSectorPadIterator::~AliMpSectorPadIterator()
83 //______________________________________________________________________________
84 AliMpSectorPadIterator&
85 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
87 /// Assignment operator
89 // check assignment to self
90 if (this == &right) return *this;
92 // base class assignment
93 AliMpVPadIterator::operator=(right);
95 fkSector = right.fkSector;
96 fCurrentRow = right.fCurrentRow;
97 fCurrentSeg = right.fCurrentSeg;
98 fCurrentMotif = right.fCurrentMotif;
99 fIterator = right.fIterator;
106 //______________________________________________________________________________
107 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
109 /// Find the AliMpMotifType object associated with the triplet
110 /// (fCurrentRow, fCurrentSeg, fCurrentMotif),
111 /// place it in the private fMotifType member and return it.
117 if ((fCurrentRow >= 0) && (fCurrentRow < fkSector->GetNofRows())){
118 row= fkSector->GetRow(fCurrentRow);
120 AliMpVRowSegment* seg;
121 if (fCurrentSeg<row->GetNofRowSegments()){
122 seg = row->GetRowSegment(fCurrentSeg);
124 if (fCurrentMotif<seg->GetNofMotifs()){
126 fkSector->GetMotifMap()->FindMotifPosition(
127 seg->GetMotifPositionId(fCurrentMotif));
134 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
143 //______________________________________________________________________________
144 Bool_t AliMpSectorPadIterator::IsValid() const
146 /// Is the iterator in a valid position?
148 return (fkSector!=0) && (fMotifPos!=0);
155 //______________________________________________________________________________
156 void AliMpSectorPadIterator::First()
158 /// Reset the iterator, so that it points to the first available
159 /// pad in the sector
169 ResetToCurrentMotifPosition();
174 //______________________________________________________________________________
175 void AliMpSectorPadIterator::Next()
177 /// Move the iterator to the next valid pad.
179 //if (!IsValid()) return *this;
180 if (!IsValid()) return;
184 if (!fIterator.IsDone()) return;
187 // Go to ne next motif, in the current segment
189 if (ResetToCurrentMotifPosition()) return;
192 // if motif number is too big, set it to 0 and pass to the next row segment
195 if (ResetToCurrentMotifPosition()) return;
198 // if row segment number is too big, pass to the next row
201 if (ResetToCurrentMotifPosition()) return;
203 // if row number is too big, the invalidate the iterator (==End())
209 //______________________________________________________________________________
210 Bool_t AliMpSectorPadIterator::IsDone() const
212 /// Is the iterator in the end?
217 //______________________________________________________________________________
218 AliMpPad AliMpSectorPadIterator::CurrentItem () const
220 /// Return current pad.
223 return AliMpPad::Invalid();
226 // no more verification, since IsValid() is TRUE here.
228 return fIterator.CurrentItem();
231 //______________________________________________________________________________
232 void AliMpSectorPadIterator::Invalidate()
234 /// Let the iterator point to the invalid position
236 fIterator.Invalidate();