4 // Class AliMpSectorPadIterator
5 // ----------------------------
6 // Class, which defines an iterator over the pads of a sector
7 // Included in AliRoot: 2003/05/02
8 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10 #include "AliMpSectorPadIterator.h"
11 #include "AliMpIntPair.h"
12 #include "AliMpSector.h"
13 #include "AliMpMotifType.h"
16 #include "AliMpVRowSegment.h"
17 #include "AliMpMotifMap.h"
18 #include "AliMpMotifPosition.h"
20 ClassImp(AliMpSectorPadIterator)
22 //______________________________________________________________________________
23 AliMpSectorPadIterator::AliMpSectorPadIterator()
24 : AliMpVPadIterator(),
32 // default constructor, set the current position to "invalid"
35 //______________________________________________________________________________
36 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSector* const sector)
37 : AliMpVPadIterator(),
45 // normal constructor, set *this to invalid position
48 //______________________________________________________________________________
49 AliMpSectorPadIterator::AliMpSectorPadIterator(const AliMpSectorPadIterator& right)
50 : AliMpVPadIterator(right)
57 //______________________________________________________________________________
58 AliMpSectorPadIterator::~AliMpSectorPadIterator()
65 //______________________________________________________________________________
66 AliMpSectorPadIterator&
67 AliMpSectorPadIterator::operator = (const AliMpSectorPadIterator& right)
69 // assignement operator
71 // check assignement to self
72 if (this == &right) return *this;
74 // base class assignement
75 AliMpVPadIterator::operator=(right);
77 fkSector = right.fkSector;
78 fCurrentRow = right.fCurrentRow;
79 fCurrentSeg = right.fCurrentSeg;
80 fCurrentMotif = right.fCurrentMotif;
81 fIterator = right.fIterator;
88 //______________________________________________________________________________
89 AliMpMotifPosition* AliMpSectorPadIterator::ResetToCurrentMotifPosition()
91 // Find the AliMpMotifType object associated with the triplet
92 // (fCurrentRow, fCurrentSeg, fCurrentMotif)
93 // place it in the private fMotifType member and returns it.
99 if ((fCurrentRow >= 0) && (fCurrentRow < fkSector->GetNofRows())){
100 row= fkSector->GetRow(fCurrentRow);
102 AliMpVRowSegment* seg;
103 if (fCurrentSeg<row->GetNofRowSegments()){
104 seg = row->GetRowSegment(fCurrentSeg);
106 if (fCurrentMotif<seg->GetNofMotifs()){
108 fkSector->GetMotifMap()->FindMotifPosition(
109 seg->GetMotifPositionId(fCurrentMotif));
116 fIterator = AliMpMotifPositionPadIterator(fMotifPos);
125 //______________________________________________________________________________
126 Bool_t AliMpSectorPadIterator::IsValid() const
128 // Is the iterator in a valid position?
129 return (fkSector!=0) && (fMotifPos!=0);
134 //______________________________________________________________________________
135 void AliMpSectorPadIterator::First()
137 // Reset the iterator, so that it points to the first available
148 ResetToCurrentMotifPosition();
153 //______________________________________________________________________________
154 void AliMpSectorPadIterator::Next()
156 // Move the iterator to the next valid pad.
159 //if (!IsValid()) return *this;
160 if (!IsValid()) return;
164 if (!fIterator.IsDone()) return;
167 // Go to ne next motif, in the current segment
169 if (ResetToCurrentMotifPosition()) return;
172 // if motif number is too big, set it to 0 and pass to the next row segment
175 if (ResetToCurrentMotifPosition()) return;
178 // if row segment number is too big, pass to the next row
181 if (ResetToCurrentMotifPosition()) return;
183 // if row number is too big, the invalidate the iterator (==End())
189 //______________________________________________________________________________
190 Bool_t AliMpSectorPadIterator::IsDone() const
196 //______________________________________________________________________________
197 AliMpPad AliMpSectorPadIterator::CurrentItem () const
199 // Returns current pad.
202 return AliMpPad::Invalid();
205 // no more verification, since IsValid() is TRUE here.
207 return fIterator.CurrentItem();
210 //______________________________________________________________________________
211 void AliMpSectorPadIterator::Invalidate()
213 // Let the iterator points to the invalid position
215 fIterator.Invalidate();