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