]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpMotifTypePadIterator.cxx
Deleting this file since name is wrong (Christian)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifTypePadIterator.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: AliMpMotifTypePadIterator.cxx,v 1.6 2006/05/24 13:58:41 ivana Exp $
18 // Category: motif
19 //
20 // Class AliMpMotifTypePadIterator
21 // -------------------------------
22 // Class, which defines an iterator over the pads of a given motif type
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
25
26 #include "AliMpMotifTypePadIterator.h"
27 #include "AliMpMotifType.h"
28
29 /// \cond CLASSIMP
30 ClassImp(AliMpMotifTypePadIterator)
31 /// \endcond
32
33 //______________________________________________________________________________
34 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator():
35     AliMpVPadIterator(),
36     fMotifType(0),
37     fCurrentPosition(AliMpIntPair::Invalid())
38 {
39 /// Default constructor, set the current position to "invalid"
40 }
41
42 //______________________________________________________________________________
43 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator( 
44                                 const AliMpMotifType* motifType)
45   : AliMpVPadIterator(),
46     fMotifType(motifType),
47     fCurrentPosition(AliMpIntPair::Invalid())
48 {
49 /// Standard constructor, let *this to invalid position
50 }
51
52 //______________________________________________________________________________
53 AliMpMotifTypePadIterator::AliMpMotifTypePadIterator(
54                                 const AliMpMotifTypePadIterator& right)
55   : AliMpVPadIterator(right),
56     fMotifType(right.fMotifType),
57     fCurrentPosition(right.fCurrentPosition)
58     
59 {
60 /// Copy constructor
61 }
62
63 //______________________________________________________________________________
64 AliMpMotifTypePadIterator::~AliMpMotifTypePadIterator()
65 {
66 /// Destructor
67 }
68
69 // operators
70
71 //______________________________________________________________________________
72 AliMpMotifTypePadIterator& 
73 AliMpMotifTypePadIterator::operator = (const AliMpMotifTypePadIterator& right)
74 {
75 /// Assignment operator.                                                      \n
76 /// If the right hand iterator isn't of good type
77 /// the current operator is invalidated
78
79   // check assignment to self
80   if (this == &right) return *this;
81
82   // base class assignment
83   AliMpVPadIterator::operator=(right);
84
85   fMotifType = right.fMotifType;
86   fCurrentPosition = right.fCurrentPosition;
87
88   return *this;
89 }  
90
91 //
92 //private methods
93 //
94
95 //______________________________________________________________________________
96 AliMpIntPair 
97 AliMpMotifTypePadIterator::FindFirstPadInLine(AliMpIntPair indices) const
98 {
99 /// Find the indices of the first pad in the same line
100 /// as the \a indices, and in column, at least equal, to the
101 /// one of \a indices
102
103     if (!fMotifType) return AliMpIntPair::Invalid();
104
105     while (indices.GetFirst() < fMotifType->GetNofPadsX()) {
106         if (fMotifType->HasPad(indices)) return indices;
107         indices += AliMpIntPair(1,0);
108     }
109     return AliMpIntPair::Invalid();
110
111
112 //______________________________________________________________________________
113 Bool_t AliMpMotifTypePadIterator::IsValid() const
114 {
115 /// Is the iterator in a valid position?
116
117     return fMotifType!=0 && fCurrentPosition.IsValid();
118
119
120 //
121 //public methods
122 //
123
124 //______________________________________________________________________________
125 void AliMpMotifTypePadIterator::First()
126 {
127 /// Reset the iterator, so that it points to the first available
128 /// pad in the motif type
129
130     if (!fMotifType) {
131         Invalidate();
132         return ;
133     }
134     fCurrentPosition = AliMpIntPair(0,0);
135     if (fMotifType->HasPad(fCurrentPosition)) return;
136     
137     
138     // if (0,0) is not available
139     // place itself to the first avalable motif after (0,0) (if exists)
140     // ++(*this);
141     Next();
142     
143     return;
144 }
145
146 //______________________________________________________________________________
147 void AliMpMotifTypePadIterator::Next()
148 {
149 /// Move the iterator to the next valid pad.
150
151     //if (!IsValid()) return *this;
152     if (!IsValid()) return;
153
154     while (fCurrentPosition.GetSecond() < fMotifType->GetNofPadsY()){
155         AliMpIntPair nextTry 
156           = FindFirstPadInLine(fCurrentPosition + AliMpIntPair(1,0));
157         if (nextTry.IsValid()){
158             fCurrentPosition = nextTry;
159             return;
160         }
161         fCurrentPosition.SetFirst(-1);
162         fCurrentPosition.SetSecond(fCurrentPosition.GetSecond()+1);
163     }
164     
165     // if the loop is finished, there's not available pads at all...
166     Invalidate();
167     return;
168 }
169
170 //______________________________________________________________________________
171 Bool_t AliMpMotifTypePadIterator::IsDone() const
172 {
173 /// Is the iterator in the end ?
174  
175   return !IsValid();
176 }
177
178 //______________________________________________________________________________
179 AliMpPad AliMpMotifTypePadIterator::CurrentItem() const 
180 {
181 /// Return current pad.
182
183     if (!fMotifType)
184         return AliMpPad::Invalid();
185     else
186         return AliMpPad(AliMpIntPair::Invalid(),
187                         fCurrentPosition,TVector2(),TVector2());
188 }
189
190 //______________________________________________________________________________
191 void AliMpMotifTypePadIterator::Invalidate()
192 {
193 /// Let the iterator point to the invalid position
194
195     fCurrentPosition = AliMpIntPair::Invalid();
196
197
198