]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpSectorAreaHPadIterator.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpSectorAreaHPadIterator |
22 | // --------------------------------- | |
23 | // Class, which defines an iterator over the pads | |
24 | // inside a given area in a sector in horizontal direction. | |
dbe945cc | 25 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 26 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
5f91c9e8 | 28 | |
5f91c9e8 | 29 | #include "AliMpSectorAreaHPadIterator.h" |
30 | #include "AliMpSectorSegmentation.h" | |
31 | #include "AliMpConstants.h" | |
32 | ||
2c605e66 | 33 | #include <Riostream.h> |
34 | ||
13985652 | 35 | /// \cond CLASSIMP |
5f91c9e8 | 36 | ClassImp(AliMpSectorAreaHPadIterator) |
13985652 | 37 | /// \endcond |
5f91c9e8 | 38 | |
39 | //______________________________________________________________________________ | |
40 | AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator( | |
41 | const AliMpSectorSegmentation* segmentation, | |
42 | const AliMpArea& area) | |
43 | : AliMpVPadIterator(), | |
44 | fkSegmentation(segmentation), | |
45 | fkArea(area), | |
46 | fCurrentPad(AliMpPad::Invalid()), | |
47 | fCurrentRowPosition(0.) | |
48 | { | |
dee1d5f1 | 49 | /// Standard constructor, start in invalid position |
5f91c9e8 | 50 | } |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator( | |
54 | const AliMpSectorAreaHPadIterator& right) | |
0471c97b | 55 | : AliMpVPadIterator(right), |
56 | fkSegmentation(0), | |
57 | fkArea(AliMpArea()), | |
58 | fCurrentPad(AliMpPad::Invalid()), | |
59 | fCurrentRowPosition(0.) | |
5f91c9e8 | 60 | { |
0471c97b | 61 | /// Copy constructor |
5f91c9e8 | 62 | |
0471c97b | 63 | *this = right; |
5f91c9e8 | 64 | } |
65 | ||
66 | //______________________________________________________________________________ | |
67 | AliMpSectorAreaHPadIterator::AliMpSectorAreaHPadIterator() | |
68 | : AliMpVPadIterator(), | |
69 | fkSegmentation(0), | |
70 | fkArea(AliMpArea()), | |
71 | fCurrentPad(AliMpPad::Invalid()), | |
72 | fCurrentRowPosition(0.) | |
73 | { | |
dee1d5f1 | 74 | /// Default constructor. |
5f91c9e8 | 75 | } |
76 | ||
77 | //______________________________________________________________________________ | |
78 | AliMpSectorAreaHPadIterator::~AliMpSectorAreaHPadIterator() | |
79 | { | |
dee1d5f1 | 80 | /// Destructor |
5f91c9e8 | 81 | } |
82 | ||
83 | // | |
84 | // operators | |
85 | // | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | AliMpSectorAreaHPadIterator& | |
89 | AliMpSectorAreaHPadIterator::operator = (const AliMpSectorAreaHPadIterator& right) | |
90 | { | |
dee1d5f1 | 91 | /// Assignment operator |
5f91c9e8 | 92 | |
dee1d5f1 | 93 | // check assignment to self |
5f91c9e8 | 94 | if (this == &right) return *this; |
95 | ||
dee1d5f1 | 96 | // base class assignment |
5f91c9e8 | 97 | AliMpVPadIterator::operator=(right); |
98 | ||
99 | fkSegmentation = right.fkSegmentation; | |
100 | fkArea = right.fkArea; | |
101 | fCurrentPad = right.fCurrentPad; | |
102 | fCurrentRowPosition = right.fCurrentRowPosition; | |
103 | ||
104 | return *this; | |
105 | } | |
106 | ||
107 | // | |
108 | // private methods | |
109 | // | |
110 | ||
111 | //______________________________________________________________________________ | |
112 | Bool_t AliMpSectorAreaHPadIterator::IsValid() const | |
113 | { | |
dee1d5f1 | 114 | /// Is the iterator in a valid position? |
5f91c9e8 | 115 | |
116 | return fCurrentPad.IsValid() ; | |
117 | } | |
118 | ||
119 | //______________________________________________________________________________ | |
120 | void AliMpSectorAreaHPadIterator::MoveUp() | |
121 | { | |
dee1d5f1 | 122 | /// Increase the current row position and searches the first valid pad. |
5f91c9e8 | 123 | |
6e97fbb8 | 124 | Double_t dy = fkSegmentation->GetMinPadDimensionY(); |
5f91c9e8 | 125 | |
6e97fbb8 | 126 | while ( ! fCurrentPad.IsValid() && |
127 | fCurrentRowPosition + dy < fkArea.UpBorder() ) | |
5f91c9e8 | 128 | { |
ae676989 | 129 | fCurrentRowPosition += 2.*dy; |
5f91c9e8 | 130 | |
6e97fbb8 | 131 | fCurrentPad |
132 | = fkSegmentation->PadByDirection(fkArea.LeftBorder(), fCurrentRowPosition, | |
133 | fkArea.RightBorder()); | |
5f91c9e8 | 134 | } |
135 | } | |
136 | ||
137 | // | |
138 | // public methods | |
139 | // | |
140 | ||
141 | //______________________________________________________________________________ | |
142 | void AliMpSectorAreaHPadIterator::First() | |
143 | { | |
dee1d5f1 | 144 | /// Reset the iterator, so that it points to the first available |
145 | /// pad in the area | |
5f91c9e8 | 146 | |
6e97fbb8 | 147 | if ( ! fkSegmentation ) { |
5f91c9e8 | 148 | Fatal("First", "Segmentation is not defined"); |
149 | return; | |
150 | } | |
151 | ||
152 | // Start position = left down corner of the area | |
153 | // | |
6e97fbb8 | 154 | |
5f91c9e8 | 155 | fCurrentRowPosition = fkArea.DownBorder(); |
6e97fbb8 | 156 | |
157 | Double_t posx, posy; | |
158 | fkArea.LeftDownCorner(posx, posy); | |
ae676989 | 159 | |
6e97fbb8 | 160 | fCurrentPad = fkSegmentation->PadByDirection(posx, posy, fkArea.RightBorder()); |
5f91c9e8 | 161 | |
162 | MoveUp(); | |
163 | ||
164 | // Set the row position to the center of pad | |
165 | // | |
6e97fbb8 | 166 | if (fCurrentPad.IsValid()) fCurrentRowPosition = fCurrentPad.GetPositionY(); |
5f91c9e8 | 167 | } |
168 | ||
169 | //______________________________________________________________________________ | |
170 | void AliMpSectorAreaHPadIterator::Next() | |
171 | { | |
dee1d5f1 | 172 | /// Move the iterator to the next valid pad. |
5f91c9e8 | 173 | |
6e97fbb8 | 174 | if ( ! IsValid() ) return; |
5f91c9e8 | 175 | |
176 | // Start position = right board of current pad + little step | |
5f91c9e8 | 177 | |
6e97fbb8 | 178 | fCurrentPad |
179 | = fkSegmentation->PadByDirection( | |
180 | fCurrentPad.GetPositionX() + fCurrentPad.GetDimensionX() + | |
181 | AliMpConstants::LengthStep(), | |
182 | fCurrentPad.GetPositionY(), | |
183 | fkArea.RightBorder()); | |
5f91c9e8 | 184 | |
6e97fbb8 | 185 | if ( fCurrentPad.IsValid() ) return; |
5f91c9e8 | 186 | |
187 | MoveUp(); | |
188 | } | |
189 | ||
190 | //______________________________________________________________________________ | |
191 | Bool_t AliMpSectorAreaHPadIterator::IsDone() const | |
192 | { | |
dee1d5f1 | 193 | /// Is the iterator in the end ? |
194 | ||
5f91c9e8 | 195 | return !IsValid(); |
196 | } | |
197 | ||
198 | //______________________________________________________________________________ | |
199 | AliMpPad AliMpSectorAreaHPadIterator::CurrentItem () const | |
200 | { | |
dee1d5f1 | 201 | /// Return current pad. |
5f91c9e8 | 202 | |
203 | return fCurrentPad; | |
204 | } | |
205 | //______________________________________________________________________________ | |
206 | void AliMpSectorAreaHPadIterator::Invalidate() | |
207 | { | |
dee1d5f1 | 208 | /// Let the iterator point to the invalid position |
209 | ||
5f91c9e8 | 210 | fCurrentPad = AliMpPad::Invalid(); |
211 | fCurrentRowPosition = 0; | |
212 | } | |
213 | ||
214 | ||
215 |