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