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: AliMpSectorAreaVPadIterator.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $
20 // Class AliMpSectorAreaVPadIterator
21 // ---------------------------------
22 // Class, which defines an iterator over the pads
23 // inside a given area in a sector in vertical direction.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 #include "AliMpSectorAreaVPadIterator.h"
28 #include "AliMpSectorSegmentation.h"
29 #include "AliMpConstants.h"
31 #include <Riostream.h>
34 ClassImp(AliMpSectorAreaVPadIterator)
37 //______________________________________________________________________________
38 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
39 const AliMpSectorSegmentation* segmentation,
40 const AliMpArea& area)
41 : AliMpVPadIterator(),
42 fkSegmentation(segmentation),
44 fCurrentPad(AliMpPad::Invalid()),
45 fCurrentColumnPosition(0.)
47 /// Standard constructor, start in invalid position
50 //______________________________________________________________________________
51 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
52 const AliMpSectorAreaVPadIterator& right)
53 : AliMpVPadIterator(right),
56 fCurrentPad(AliMpPad::Invalid()),
57 fCurrentColumnPosition(0.)
64 //______________________________________________________________________________
65 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator()
66 : AliMpVPadIterator(),
69 fCurrentPad(AliMpPad::Invalid()),
70 fCurrentColumnPosition(0.)
72 /// Default constructor.
75 //______________________________________________________________________________
76 AliMpSectorAreaVPadIterator::~AliMpSectorAreaVPadIterator()
85 //______________________________________________________________________________
86 AliMpSectorAreaVPadIterator&
87 AliMpSectorAreaVPadIterator::operator = (const AliMpSectorAreaVPadIterator& right)
89 /// Assignment operator
91 // check assignment to self
92 if (this == &right) return *this;
94 // base class assignment
95 AliMpVPadIterator::operator=(right);
97 fkSegmentation = right.fkSegmentation;
98 fkArea = right.fkArea;
99 fCurrentPad = right.fCurrentPad;
100 fCurrentColumnPosition = right.fCurrentColumnPosition;
109 //______________________________________________________________________________
110 Bool_t AliMpSectorAreaVPadIterator::IsValid() const
112 /// Is the iterator in a valid position?
114 return fCurrentPad.IsValid() ;
117 //______________________________________________________________________________
118 void AliMpSectorAreaVPadIterator::MoveRight()
120 /// Increase the current row position and searches the first valid pad.
122 Double_t step = 2.* fkSegmentation->GetMinPadDimensions().X();
124 while ( !fCurrentPad.IsValid() &&
125 fCurrentColumnPosition + step < fkArea.RightBorder())
127 fCurrentColumnPosition += step;
128 TVector2 position = TVector2(fCurrentColumnPosition, fkArea.DownBorder());
130 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
138 //______________________________________________________________________________
139 void AliMpSectorAreaVPadIterator::First()
141 /// Reset the iterator, so that it points to the first available
144 if (!fkSegmentation) {
145 AliFatal("Segmentation is not defined");
149 // Start position = left down corner of the area
151 fCurrentColumnPosition = fkArea.LeftBorder();
152 TVector2 position(fkArea.LeftDownCorner());
154 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
158 // Set the column position to the center of pad
160 if (fCurrentPad.IsValid()) fCurrentColumnPosition = fCurrentPad.Position().X();
163 //______________________________________________________________________________
164 void AliMpSectorAreaVPadIterator::Next()
166 /// Move the iterator to the next valid pad.
168 if (!IsValid()) return;
170 // Start position = up board of current pad + little step
173 = fCurrentPad.Position()
174 + TVector2(0., fCurrentPad.Dimensions().Y() + AliMpConstants::LengthStep());
176 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
178 if (fCurrentPad.IsValid()) return;
183 //______________________________________________________________________________
184 Bool_t AliMpSectorAreaVPadIterator::IsDone() const
186 /// Is the iterator in the end ?
191 //______________________________________________________________________________
192 AliMpPad AliMpSectorAreaVPadIterator::CurrentItem () const
194 /// Return current pad.
198 //______________________________________________________________________________
199 void AliMpSectorAreaVPadIterator::Invalidate()
201 /// Let the iterator point to the invalid position
203 fCurrentPad = AliMpPad::Invalid();
204 fCurrentColumnPosition = 0;