]>
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: AliMpSectorAreaVPadIterator.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
19 | // | |
20 | // Class AliMpSectorAreaVPadIterator | |
21 | // --------------------------------- | |
22 | // Class, which defines an iterator over the pads | |
23 | // inside a given area in a sector in vertical direction. | |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
26 | ||
5f91c9e8 | 27 | #include "AliMpSectorAreaVPadIterator.h" |
28 | #include "AliMpSectorSegmentation.h" | |
29 | #include "AliMpConstants.h" | |
30 | ||
97186a3f | 31 | #include "AliLog.h" |
32 | ||
2c605e66 | 33 | #include <Riostream.h> |
34 | ||
13985652 | 35 | /// \cond CLASSIMP |
5f91c9e8 | 36 | ClassImp(AliMpSectorAreaVPadIterator) |
13985652 | 37 | /// \endcond |
5f91c9e8 | 38 | |
39 | //______________________________________________________________________________ | |
40 | AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator( | |
41 | const AliMpSectorSegmentation* segmentation, | |
42 | const AliMpArea& area) | |
43 | : AliMpVPadIterator(), | |
44 | fkSegmentation(segmentation), | |
45 | fkArea(area), | |
46 | fCurrentPad(AliMpPad::Invalid()), | |
47 | fCurrentColumnPosition(0.) | |
48 | { | |
dee1d5f1 | 49 | /// Standard constructor, start in invalid position |
5f91c9e8 | 50 | } |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator( | |
54 | const AliMpSectorAreaVPadIterator& right) | |
0471c97b | 55 | : AliMpVPadIterator(right), |
56 | fkSegmentation(0), | |
57 | fkArea(AliMpArea()), | |
58 | fCurrentPad(AliMpPad::Invalid()), | |
59 | fCurrentColumnPosition(0.) | |
5f91c9e8 | 60 | { |
0471c97b | 61 | /// Copy constructor |
5f91c9e8 | 62 | |
0471c97b | 63 | *this = right; |
5f91c9e8 | 64 | } |
65 | ||
66 | //______________________________________________________________________________ | |
67 | AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator() | |
68 | : AliMpVPadIterator(), | |
69 | fkSegmentation(0), | |
70 | fkArea(AliMpArea()), | |
71 | fCurrentPad(AliMpPad::Invalid()), | |
72 | fCurrentColumnPosition(0.) | |
73 | { | |
dee1d5f1 | 74 | /// Default constructor. |
5f91c9e8 | 75 | } |
76 | ||
77 | //______________________________________________________________________________ | |
78 | AliMpSectorAreaVPadIterator::~AliMpSectorAreaVPadIterator() | |
79 | { | |
dee1d5f1 | 80 | /// Destructor |
5f91c9e8 | 81 | } |
82 | ||
83 | // | |
84 | // operators | |
85 | // | |
86 | ||
87 | //______________________________________________________________________________ | |
88 | AliMpSectorAreaVPadIterator& | |
89 | AliMpSectorAreaVPadIterator::operator = (const AliMpSectorAreaVPadIterator& 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 | fCurrentColumnPosition = right.fCurrentColumnPosition; | |
103 | ||
104 | return *this; | |
105 | } | |
106 | ||
107 | // | |
108 | // private methods | |
109 | // | |
110 | ||
111 | //______________________________________________________________________________ | |
112 | Bool_t AliMpSectorAreaVPadIterator::IsValid() const | |
113 | { | |
dee1d5f1 | 114 | /// Is the iterator in a valid position? |
5f91c9e8 | 115 | |
116 | return fCurrentPad.IsValid() ; | |
117 | } | |
118 | ||
119 | //______________________________________________________________________________ | |
120 | void AliMpSectorAreaVPadIterator::MoveRight() | |
121 | { | |
dee1d5f1 | 122 | /// Increase the current row position and searches the first valid pad. |
5f91c9e8 | 123 | |
25a9f565 | 124 | Double_t dx = fkSegmentation->GetMinPadDimensions().X(); |
5f91c9e8 | 125 | |
126 | while ( !fCurrentPad.IsValid() && | |
25a9f565 | 127 | fCurrentColumnPosition + dx < fkArea.RightBorder()) |
5f91c9e8 | 128 | { |
25a9f565 | 129 | fCurrentColumnPosition += 2.*dx; |
5f91c9e8 | 130 | TVector2 position = TVector2(fCurrentColumnPosition, fkArea.DownBorder()); |
131 | ||
132 | fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder()); | |
133 | } | |
134 | } | |
135 | ||
136 | // | |
137 | // public methods | |
138 | // | |
139 | ||
140 | //______________________________________________________________________________ | |
141 | void AliMpSectorAreaVPadIterator::First() | |
142 | { | |
dee1d5f1 | 143 | /// Reset the iterator, so that it points to the first available |
144 | /// pad in the area | |
5f91c9e8 | 145 | |
146 | if (!fkSegmentation) { | |
0471c97b | 147 | AliFatal("Segmentation is not defined"); |
5f91c9e8 | 148 | return; |
149 | } | |
150 | ||
151 | // Start position = left down corner of the area | |
152 | // | |
bd7175ff | 153 | fCurrentColumnPosition = fkArea.LeftBorder(); |
5f91c9e8 | 154 | TVector2 position(fkArea.LeftDownCorner()); |
155 | ||
156 | fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder()); | |
157 | ||
158 | MoveRight(); | |
159 | ||
160 | // Set the column position to the center of pad | |
161 | // | |
162 | if (fCurrentPad.IsValid()) fCurrentColumnPosition = fCurrentPad.Position().X(); | |
163 | } | |
164 | ||
165 | //______________________________________________________________________________ | |
166 | void AliMpSectorAreaVPadIterator::Next() | |
167 | { | |
dee1d5f1 | 168 | /// Move the iterator to the next valid pad. |
5f91c9e8 | 169 | |
170 | if (!IsValid()) return; | |
171 | ||
172 | // Start position = up board of current pad + little step | |
173 | // | |
174 | TVector2 position | |
175 | = fCurrentPad.Position() | |
176 | + TVector2(0., fCurrentPad.Dimensions().Y() + AliMpConstants::LengthStep()); | |
177 | ||
178 | fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder()); | |
179 | ||
180 | if (fCurrentPad.IsValid()) return; | |
181 | ||
182 | MoveRight(); | |
183 | } | |
184 | ||
185 | //______________________________________________________________________________ | |
186 | Bool_t AliMpSectorAreaVPadIterator::IsDone() const | |
187 | { | |
dee1d5f1 | 188 | /// Is the iterator in the end ? |
189 | ||
5f91c9e8 | 190 | return !IsValid(); |
191 | } | |
192 | ||
193 | //______________________________________________________________________________ | |
194 | AliMpPad AliMpSectorAreaVPadIterator::CurrentItem () const | |
195 | { | |
dee1d5f1 | 196 | /// Return current pad. |
5f91c9e8 | 197 | |
198 | return fCurrentPad; | |
199 | } | |
200 | //______________________________________________________________________________ | |
201 | void AliMpSectorAreaVPadIterator::Invalidate() | |
202 | { | |
dee1d5f1 | 203 | /// Let the iterator point to the invalid position |
204 | ||
5f91c9e8 | 205 | fCurrentPad = AliMpPad::Invalid(); |
206 | fCurrentColumnPosition = 0; | |
207 | } | |
208 | ||
209 | ||
210 |