1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSectorAreaVPadIterator.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $
20 // Class AliMpSectorAreaVPadIterator
21 // ---------------------------------
22 // Class, which defines an iterator over the pads
23 // inside a given area in a sector in vertical direction.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
27 #include "AliMpSectorAreaVPadIterator.h"
28 #include "AliMpSectorSegmentation.h"
29 #include "AliMpConstants.h"
31 #include <Riostream.h>
34 ClassImp(AliMpSectorAreaVPadIterator)
37 //______________________________________________________________________________
38 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
39 const AliMpSectorSegmentation* segmentation,
40 const AliMpArea& area)
41 : AliMpVPadIterator(),
42 fkSegmentation(segmentation),
44 fCurrentPad(AliMpPad::Invalid()),
45 fCurrentColumnPosition(0.)
47 /// Standard constructor, start in invalid position
50 //______________________________________________________________________________
51 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator(
52 const AliMpSectorAreaVPadIterator& right)
53 : AliMpVPadIterator(right)
55 /// Protected copy constructor (not provided)
57 Fatal("Copy constructor", "Not implemented");
60 //______________________________________________________________________________
61 AliMpSectorAreaVPadIterator::AliMpSectorAreaVPadIterator()
62 : AliMpVPadIterator(),
65 fCurrentPad(AliMpPad::Invalid()),
66 fCurrentColumnPosition(0.)
68 /// Default constructor.
71 //______________________________________________________________________________
72 AliMpSectorAreaVPadIterator::~AliMpSectorAreaVPadIterator()
81 //______________________________________________________________________________
82 AliMpSectorAreaVPadIterator&
83 AliMpSectorAreaVPadIterator::operator = (const AliMpSectorAreaVPadIterator& right)
85 /// Assignment operator
87 // check assignment to self
88 if (this == &right) return *this;
90 // base class assignment
91 AliMpVPadIterator::operator=(right);
93 fkSegmentation = right.fkSegmentation;
94 fkArea = right.fkArea;
95 fCurrentPad = right.fCurrentPad;
96 fCurrentColumnPosition = right.fCurrentColumnPosition;
105 //______________________________________________________________________________
106 Bool_t AliMpSectorAreaVPadIterator::IsValid() const
108 /// Is the iterator in a valid position?
110 return fCurrentPad.IsValid() ;
113 //______________________________________________________________________________
114 void AliMpSectorAreaVPadIterator::MoveRight()
116 /// Increase the current row position and searches the first valid pad.
118 Double_t step = 2.* fkSegmentation->GetMinPadDimensions().X();
120 while ( !fCurrentPad.IsValid() &&
121 fCurrentColumnPosition + step < fkArea.RightBorder())
123 fCurrentColumnPosition += step;
124 TVector2 position = TVector2(fCurrentColumnPosition, fkArea.DownBorder());
126 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
134 //______________________________________________________________________________
135 void AliMpSectorAreaVPadIterator::First()
137 /// Reset the iterator, so that it points to the first available
140 if (!fkSegmentation) {
141 Fatal("First", "Segmentation is not defined");
145 // Start position = left down corner of the area
147 fCurrentColumnPosition = fkArea.LeftBorder();
148 TVector2 position(fkArea.LeftDownCorner());
150 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
154 // Set the column position to the center of pad
156 if (fCurrentPad.IsValid()) fCurrentColumnPosition = fCurrentPad.Position().X();
159 //______________________________________________________________________________
160 void AliMpSectorAreaVPadIterator::Next()
162 /// Move the iterator to the next valid pad.
164 if (!IsValid()) return;
166 // Start position = up board of current pad + little step
169 = fCurrentPad.Position()
170 + TVector2(0., fCurrentPad.Dimensions().Y() + AliMpConstants::LengthStep());
172 fCurrentPad = fkSegmentation->PadByDirection(position, fkArea.UpBorder());
174 if (fCurrentPad.IsValid()) return;
179 //______________________________________________________________________________
180 Bool_t AliMpSectorAreaVPadIterator::IsDone() const
182 /// Is the iterator in the end ?
187 //______________________________________________________________________________
188 AliMpPad AliMpSectorAreaVPadIterator::CurrentItem () const
190 /// Return current pad.
194 //______________________________________________________________________________
195 void AliMpSectorAreaVPadIterator::Invalidate()
197 /// Let the iterator point to the invalid position
199 fCurrentPad = AliMpPad::Invalid();
200 fCurrentColumnPosition = 0;