]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpPlaneAreaPadIterator.cxx
new class AliMUONLoader
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPlaneAreaPadIterator.cxx
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
19 ClassImp(AliMpPlaneAreaPadIterator)
20
21 //______________________________________________________________________________
22 AliMpPlaneAreaPadIterator::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 //______________________________________________________________________________
38 AliMpPlaneAreaPadIterator::AliMpPlaneAreaPadIterator(
39                                 const AliMpPlaneAreaPadIterator& right)
40   : AliMpVPadIterator(right)
41 {
42 // copy constructor
43  
44   Fatal("Copy constructor", "Not implemented");
45 }
46
47 //______________________________________________________________________________
48 AliMpPlaneAreaPadIterator::AliMpPlaneAreaPadIterator()
49  : AliMpVPadIterator(),
50    fkPlaneSegmentation(0),
51    fkArea(AliMpArea()),
52    fPadIterators()
53 {
54 // Dummy default constructor.
55 }
56
57 //______________________________________________________________________________
58 AliMpPlaneAreaPadIterator::~AliMpPlaneAreaPadIterator()
59 {
60 // destructor
61
62   // delete created iterators here
63 }
64
65 //
66 // operators
67 //
68
69 //______________________________________________________________________________
70 AliMpPlaneAreaPadIterator& 
71 AliMpPlaneAreaPadIterator::operator = (const AliMpPlaneAreaPadIterator& right)
72 {
73 // Assignement operator
74
75   Fatal("operator =", "Not implemented.");
76   return *this;
77
78
79 //
80 // private methods
81 //
82
83 //______________________________________________________________________________
84 void AliMpPlaneAreaPadIterator::DecomposeArea()
85 {
86 // Decompose the area into areas belonging to the quadrants.
87 // --
88
89   for (Int_t i=0; i<fkPlaneSegmentation->GetNofTransformers(); i++) {
90   
91     AliMpTransformer* transformer = fkPlaneSegmentation->GetTransformer(i);
92     AliMpArea area = transformer->CutArea(fkArea);
93
94     if (area.IsValid()) {
95     
96       AliMpSectorSegmentation* segmentation 
97         = fkPlaneSegmentation->GetSectorSegmentation(transformer->GetScale());
98           
99       AliMpVPadIterator* sectorIt 
100         = segmentation->CreateIterator(area);
101             
102       fPadIterators.push_back(
103         new AliMpTransformPadIterator(sectorIt, transformer));
104     }   
105   }
106 }
107
108 //
109 // public methods
110 //
111
112 //______________________________________________________________________________
113 void AliMpPlaneAreaPadIterator::First()
114 {
115 // Reset the iterator, so that it points to the first available
116 // pad in the area
117 // ---
118   if (fPadIterators.size()==0) return;
119
120   fCurrentIterator = fPadIterators.begin();
121   (*fCurrentIterator)->First();
122
123   while ( fCurrentIterator != fPadIterators.end() &&
124           (*fCurrentIterator)->IsDone()) {
125          
126     fCurrentIterator++;
127     if (fCurrentIterator != fPadIterators.end()) {
128       (*fCurrentIterator)->First();
129     }    
130   }
131 }
132
133 //______________________________________________________________________________
134 void AliMpPlaneAreaPadIterator::Next()
135 {
136 // Move the iterator to the next valid pad.
137 // ---
138
139   (*fCurrentIterator)->Next();
140   
141   while ( fCurrentIterator != fPadIterators.end() &&
142           (*fCurrentIterator)->IsDone()) {
143          
144     fCurrentIterator++;
145     if (fCurrentIterator != fPadIterators.end()) {
146       (*fCurrentIterator)->First();
147     }    
148   }
149 }
150
151 //______________________________________________________________________________
152 Bool_t AliMpPlaneAreaPadIterator::IsDone() const
153 {
154 // 
155   return  fCurrentIterator == fPadIterators.end();
156 }
157
158 //______________________________________________________________________________
159 AliMpPad AliMpPlaneAreaPadIterator::CurrentItem() const 
160 {
161 // Returns the current pad.
162 // ---
163
164   if (fCurrentIterator != fPadIterators.end())
165     return (*fCurrentIterator)->CurrentItem();
166   else
167     return AliMpPad::Invalid();  
168 }
169
170 //______________________________________________________________________________
171 void AliMpPlaneAreaPadIterator::Invalidate()
172 {
173 // Invalidates all sector iterators and sets the current
174 // iterator to invalid position.
175 // ---
176  
177   PadIteratorVectorIterator it;
178   for (it=fPadIterators.begin(); it !=fPadIterators.end(); it++) {
179     (*it)->Invalidate(); 
180   }
181   
182   fCurrentIterator = fPadIterators.end();
183 }
184