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