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 //-----------------------------------------------------------------------------
21 // Class AliMpSectorAreaVPadIterator
22 // ---------------------------------
23 // Class, which defines an iterator over the pads
24 // inside a given area in a sector in vertical direction.
25 // Included in AliRoot: 2003/05/02
26 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 //-----------------------------------------------------------------------------
29 #include "AliMpSectorAreaVPadIterator.h"
30 #include "AliMpSectorSegmentation.h"
31 #include "AliMpConstants.h"
35 #include <Riostream.h>
38 ClassImp(AliMpSectorAreaVPadIterator)
41 //______________________________________________________________________________
42 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
43 const AliMpSectorSegmentation* segmentation,
44 const AliMpArea& area)
45 : AliMpVPadIterator(),
46 fkSegmentation(segmentation),
48 fCurrentPad(AliMpPad::Invalid()),
49 fCurrentColumnPosition(0.)
51 /// Standard constructor, start in invalid position
54 //______________________________________________________________________________
55 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
56 const AliMpSectorAreaVPadIterator& right)
57 : AliMpVPadIterator(right),
60 fCurrentPad(AliMpPad::Invalid()),
61 fCurrentColumnPosition(0.)
68 //______________________________________________________________________________
69 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator()
70 : AliMpVPadIterator(),
73 fCurrentPad(AliMpPad::Invalid()),
74 fCurrentColumnPosition(0.)
76 /// Default constructor.
79 //______________________________________________________________________________
80 AliMpSectorAreaVPadIterator::~AliMpSectorAreaVPadIterator()
89 //______________________________________________________________________________
90 AliMpSectorAreaVPadIterator&
91 AliMpSectorAreaVPadIterator::operator = (const AliMpSectorAreaVPadIterator& right)
93 /// Assignment operator
95 // check assignment to self
96 if (this == &right) return *this;
98 // base class assignment
99 AliMpVPadIterator::operator=(right);
101 fkSegmentation = right.fkSegmentation;
102 fkArea = right.fkArea;
103 fCurrentPad = right.fCurrentPad;
104 fCurrentColumnPosition = right.fCurrentColumnPosition;
113 //______________________________________________________________________________
114 Bool_t AliMpSectorAreaVPadIterator::IsValid() const
116 /// Is the iterator in a valid position?
118 return fCurrentPad.IsValid() ;
121 //______________________________________________________________________________
122 void AliMpSectorAreaVPadIterator::MoveRight()
124 /// Increase the current row position and searches the first valid pad.
126 Double_t dx = fkSegmentation->GetMinPadDimensions().X();
128 while ( !fCurrentPad.IsValid() &&
129 fCurrentColumnPosition + dx < fkArea.RightBorder())
131 fCurrentColumnPosition += 2.*dx;
132 TVector2 position = TVector2(fCurrentColumnPosition, fkArea.DownBorder());
134 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
142 //______________________________________________________________________________
143 void AliMpSectorAreaVPadIterator::First()
145 /// Reset the iterator, so that it points to the first available
148 if (!fkSegmentation) {
149 AliFatal("Segmentation is not defined");
153 // Start position = left down corner of the area
155 fCurrentColumnPosition = fkArea.LeftBorder();
156 TVector2 position(fkArea.LeftDownCorner());
158 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
162 // Set the column position to the center of pad
164 if (fCurrentPad.IsValid()) fCurrentColumnPosition = fCurrentPad.Position().X();
167 //______________________________________________________________________________
168 void AliMpSectorAreaVPadIterator::Next()
170 /// Move the iterator to the next valid pad.
172 if (!IsValid()) return;
174 // Start position = up board of current pad + little step
177 = fCurrentPad.Position()
178 + TVector2(0., fCurrentPad.Dimensions().Y() + AliMpConstants::LengthStep());
180 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
182 if (fCurrentPad.IsValid()) return;
187 //______________________________________________________________________________
188 Bool_t AliMpSectorAreaVPadIterator::IsDone() const
190 /// Is the iterator in the end ?
195 //______________________________________________________________________________
196 AliMpPad AliMpSectorAreaVPadIterator::CurrentItem () const
198 /// Return current pad.
202 //______________________________________________________________________________
203 void AliMpSectorAreaVPadIterator::Invalidate()
205 /// Let the iterator point to the invalid position
207 fCurrentPad = AliMpPad::Invalid();
208 fCurrentColumnPosition = 0;