4 // Class AliMpSectorAreaHPadIterator
5 // ---------------------------------
6 // Class, which defines an iterator over the pads
7 // inside a given area in a sector in horizontal direction.
8 // Included in AliRoot: 2003/05/02
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
11 #include <Riostream.h>
13 #include "AliMpSectorAreaHPadIterator.h"
14 #include "AliMpSectorSegmentation.h"
15 #include "AliMpConstants.h"
17 ClassImp(AliMpSectorAreaHPadIterator)
19 //______________________________________________________________________________
20 AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator(
21 const AliMpSectorSegmentation* segmentation,
22 const AliMpArea& area)
23 : AliMpVPadIterator(),
24 fkSegmentation(segmentation),
26 fCurrentPad(AliMpPad::Invalid()),
27 fCurrentRowPosition(0.)
29 // normal constructor, start in invalid position
32 //______________________________________________________________________________
33 AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator(
34 const AliMpSectorAreaHPadIterator& right)
35 : AliMpVPadIterator(right)
39 Fatal("Copy constructor", "Not implemented");
42 //______________________________________________________________________________
43 AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator()
44 : AliMpVPadIterator(),
47 fCurrentPad(AliMpPad::Invalid()),
48 fCurrentRowPosition(0.)
50 // Dummy default constructor.
53 //______________________________________________________________________________
54 AliMpSectorAreaHPadIterator::~AliMpSectorAreaHPadIterator()
63 //______________________________________________________________________________
64 AliMpSectorAreaHPadIterator&
65 AliMpSectorAreaHPadIterator::operator = (const AliMpSectorAreaHPadIterator& right)
67 // Assignement operator
69 // check assignement to self
70 if (this == &right) return *this;
72 // base class assignement
73 AliMpVPadIterator::operator=(right);
75 fkSegmentation = right.fkSegmentation;
76 fkArea = right.fkArea;
77 fCurrentPad = right.fCurrentPad;
78 fCurrentRowPosition = right.fCurrentRowPosition;
87 //______________________________________________________________________________
88 Bool_t AliMpSectorAreaHPadIterator::IsValid() const
90 // Is the iterator in a valid position?
93 return fCurrentPad.IsValid() ;
96 //______________________________________________________________________________
97 void AliMpSectorAreaHPadIterator::MoveUp()
99 // Increase the current row position and searches the first valid pad.
102 Double_t step = 2.* fkSegmentation->GetMinPadDimensions().Y();
104 while ( !fCurrentPad.IsValid() &&
105 fCurrentRowPosition + step < fkArea.UpBorder())
107 //cout << "######### Move up ##########" << endl;
109 fCurrentRowPosition += step;
110 TVector2 position = TVector2(fkArea.LeftBorder(), fCurrentRowPosition);
112 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.RightBorder());
120 //______________________________________________________________________________
121 void AliMpSectorAreaHPadIterator::First()
123 // Reset the iterator, so that it points to the first available
127 if (!fkSegmentation) {
128 Fatal("First", "Segmentation is not defined");
132 // Start position = left down corner of the area
134 fCurrentRowPosition = fkArea.DownBorder();
135 TVector2 position(fkArea.LeftDownCorner());
137 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.RightBorder());
141 // Set the row position to the center of pad
143 if (fCurrentPad.IsValid()) fCurrentRowPosition = fCurrentPad.Position().Y();
146 //______________________________________________________________________________
147 void AliMpSectorAreaHPadIterator::Next()
149 // Move the iterator to the next valid pad.
152 if (!IsValid()) return;
154 // Start position = right board of current pad + little step
157 = fCurrentPad.Position()
158 + TVector2(fCurrentPad.Dimensions().X() + AliMpConstants::LengthStep(), 0.);
160 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.RightBorder());
162 if (fCurrentPad.IsValid()) return;
167 //______________________________________________________________________________
168 Bool_t AliMpSectorAreaHPadIterator::IsDone() const
174 //______________________________________________________________________________
175 AliMpPad AliMpSectorAreaHPadIterator::CurrentItem () const
177 // Returns current pad.
182 //______________________________________________________________________________
183 void AliMpSectorAreaHPadIterator::Invalidate()
186 fCurrentPad = AliMpPad::Invalid();
187 fCurrentRowPosition = 0;