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