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