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