]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPlaneAreaPadIterator.cxx
Corrected assignment operator
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPlaneAreaPadIterator.cxx
CommitLineData
5f91c9e8 1// $Id$
2// Category: plane
3//
4// Class AliMpPlaneAreaPadIterator
5// -------------------------------
6// Class, which defines an iterator over the pads
7// inside a given area in a plane in horizontal direction.
8//
9// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10
11#include <Riostream.h>
12#include <TVector2.h>
13
14#include "AliMpPlaneAreaPadIterator.h"
15#include "AliMpTransformPadIterator.h"
16#include "AliMpPlaneSegmentation.h"
17#include "AliMpSectorSegmentation.h"
18
19ClassImp(AliMpPlaneAreaPadIterator)
20
21//______________________________________________________________________________
22AliMpPlaneAreaPadIterator::AliMpPlaneAreaPadIterator(
23 const AliMpPlaneSegmentation* segmentation,
24 const AliMpArea& area)
25 : AliMpVPadIterator(),
26 fkPlaneSegmentation(segmentation),
27 fkArea(area),
28 fPadIterators()
29{
30// Normal constructor, start in invalid position
31
32 DecomposeArea();
33
34 fCurrentIterator = fPadIterators.end();
35}
36
37//______________________________________________________________________________
38AliMpPlaneAreaPadIterator::AliMpPlaneAreaPadIterator(
39 const AliMpPlaneAreaPadIterator& right)
40 : AliMpVPadIterator(right)
41{
435d6612 42// Copy constructor
5f91c9e8 43
44 Fatal("Copy constructor", "Not implemented");
45}
46
47//______________________________________________________________________________
48AliMpPlaneAreaPadIterator::AliMpPlaneAreaPadIterator()
49 : AliMpVPadIterator(),
50 fkPlaneSegmentation(0),
51 fkArea(AliMpArea()),
52 fPadIterators()
53{
54// Dummy default constructor.
55}
56
57//______________________________________________________________________________
58AliMpPlaneAreaPadIterator::~AliMpPlaneAreaPadIterator()
59{
435d6612 60// Destructor
5f91c9e8 61
62 // delete created iterators here
63}
64
65//
66// operators
67//
68
69//______________________________________________________________________________
70AliMpPlaneAreaPadIterator&
71AliMpPlaneAreaPadIterator::operator = (const AliMpPlaneAreaPadIterator& right)
72{
73// Assignement operator
74
435d6612 75 // check assignement to self
76 if (this == &right) return *this;
77
78 Fatal("operator =", "Assignement operator not provided.");
79
5f91c9e8 80 return *this;
81}
82
83//
84// private methods
85//
86
87//______________________________________________________________________________
88void AliMpPlaneAreaPadIterator::DecomposeArea()
89{
90// Decompose the area into areas belonging to the quadrants.
91// --
92
93 for (Int_t i=0; i<fkPlaneSegmentation->GetNofTransformers(); i++) {
94
95 AliMpTransformer* transformer = fkPlaneSegmentation->GetTransformer(i);
96 AliMpArea area = transformer->CutArea(fkArea);
97
98 if (area.IsValid()) {
99
100 AliMpSectorSegmentation* segmentation
101 = fkPlaneSegmentation->GetSectorSegmentation(transformer->GetScale());
102
103 AliMpVPadIterator* sectorIt
104 = segmentation->CreateIterator(area);
105
106 fPadIterators.push_back(
107 new AliMpTransformPadIterator(sectorIt, transformer));
108 }
109 }
110}
111
112//
113// public methods
114//
115
116//______________________________________________________________________________
117void AliMpPlaneAreaPadIterator::First()
118{
119// Reset the iterator, so that it points to the first available
120// pad in the area
121// ---
122 if (fPadIterators.size()==0) return;
123
124 fCurrentIterator = fPadIterators.begin();
125 (*fCurrentIterator)->First();
126
127 while ( fCurrentIterator != fPadIterators.end() &&
128 (*fCurrentIterator)->IsDone()) {
129
130 fCurrentIterator++;
131 if (fCurrentIterator != fPadIterators.end()) {
132 (*fCurrentIterator)->First();
133 }
134 }
135}
136
137//______________________________________________________________________________
138void AliMpPlaneAreaPadIterator::Next()
139{
140// Move the iterator to the next valid pad.
141// ---
142
143 (*fCurrentIterator)->Next();
144
145 while ( fCurrentIterator != fPadIterators.end() &&
146 (*fCurrentIterator)->IsDone()) {
147
148 fCurrentIterator++;
149 if (fCurrentIterator != fPadIterators.end()) {
150 (*fCurrentIterator)->First();
151 }
152 }
153}
154
155//______________________________________________________________________________
156Bool_t AliMpPlaneAreaPadIterator::IsDone() const
157{
158//
159 return fCurrentIterator == fPadIterators.end();
160}
161
162//______________________________________________________________________________
163AliMpPad AliMpPlaneAreaPadIterator::CurrentItem() const
164{
165// Returns the current pad.
166// ---
167
168 if (fCurrentIterator != fPadIterators.end())
169 return (*fCurrentIterator)->CurrentItem();
170 else
171 return AliMpPad::Invalid();
172}
173
174//______________________________________________________________________________
175void AliMpPlaneAreaPadIterator::Invalidate()
176{
177// Invalidates all sector iterators and sets the current
178// iterator to invalid position.
179// ---
180
181 PadIteratorVectorIterator it;
182 for (it=fPadIterators.begin(); it !=fPadIterators.end(); it++) {
183 (*it)->Invalidate();
184 }
185
186 fCurrentIterator = fPadIterators.end();
187}
188