Get the branch name from the RunLoader
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifPositionPadIterator.cxx
CommitLineData
5f91c9e8 1// $Id$
2// Category: motif
3//
4// Class AliMpMotifPositionPadIterator
5// -----------------------------------
6// Class, which defines an iterator over the pads of a given motif type
7//
8// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
9
10#include "AliMpMotifPositionPadIterator.h"
11#include "AliMpMotifPosition.h"
12#include "AliMpMotifType.h"
13#include "AliMpConnection.h"
14
15ClassImp(AliMpMotifPositionPadIterator)
16
17//______________________________________________________________________________
18AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator():
19 AliMpVPadIterator(),
20 fMotifPos(0),
21 fIterator()
22{
23// default constructor, set the current position to "invalid"
24}
25
26//______________________________________________________________________________
27
28AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
29 const AliMpMotifPosition* motifPos)
30 : AliMpVPadIterator(),
31 fMotifPos(motifPos),
32 fIterator(motifPos->GetMotif()->GetMotifType())
33{
34// normal constructor, let *this to invalid position
35}
36
37//______________________________________________________________________________
38AliMpMotifPositionPadIterator::AliMpMotifPositionPadIterator(
39 const AliMpMotifPositionPadIterator& right)
40 : AliMpVPadIterator(right),
41 fMotifPos(right.fMotifPos),
42 fIterator(right.fIterator)
43
44{
45// copy constructor
46}
47
48//______________________________________________________________________________
49AliMpMotifPositionPadIterator::~AliMpMotifPositionPadIterator()
50{
51// destructor
52}
53
54// operators
55
56//______________________________________________________________________________
57AliMpMotifPositionPadIterator&
58AliMpMotifPositionPadIterator::operator = (const AliMpMotifPositionPadIterator& right)
59{
60// assignement operator
61// if the right hand iterator isn't of good type
62// the current operator is invalidated
63
64 // check assignement to self
65 if (this == &right) return *this;
66
67 // base class assignement
68 AliMpVPadIterator::operator=(right);
69
70 fMotifPos = right.fMotifPos;
71 fIterator = right.fIterator;
72
73 return *this;
74}
75
76//private methods
77
78
79//______________________________________________________________________________
80Bool_t AliMpMotifPositionPadIterator::IsValid() const
81{
82// Is the iterator in a valid position?
83
84 return (fMotifPos!=0) && (!fIterator.IsDone());
85}
86
87//public methods
88
89//______________________________________________________________________________
90void AliMpMotifPositionPadIterator::First()
91{
92// Reset the iterator, so that it points to the first available
93// pad in the motif type
94
95 if (!fMotifPos) {
96 Invalidate();
97 return ;
98 }
99
100 fIterator.First();
101 return;
102}
103
104//______________________________________________________________________________
105void AliMpMotifPositionPadIterator::Next()
106{
107// Move the iterator to the next valid pad.
108 fIterator.Next();
109}
110
111//______________________________________________________________________________
112Bool_t AliMpMotifPositionPadIterator::IsDone() const
113{
114//
115 return !IsValid();
116}
117
118//______________________________________________________________________________
119AliMpPad AliMpMotifPositionPadIterator::CurrentItem() const
120{
121// Returns current pad.
122
123 if (!fMotifPos)
124 return AliMpPad::Invalid();
125 else {
126 AliMpIntPair ind = fIterator.CurrentItem().GetIndices();
127 AliMpMotifType* mt = fMotifPos->GetMotif()->GetMotifType();
128 AliMpConnection* connect =
129 mt->FindConnectionByLocalIndices(ind);
130 return AliMpPad(AliMpIntPair(fMotifPos->GetID(),connect->GetGassiNum()),
131 fMotifPos->GlobalIndices(ind),
132 fMotifPos->Position()+fMotifPos->GetMotif()->PadPositionLocal(ind),
133 fMotifPos->GetMotif()->GetPadDimensions(ind));
134 }
135}
136
137//______________________________________________________________________________
138void AliMpMotifPositionPadIterator::Invalidate()
139{
140// Let the iterator points to the invalid position
141 fIterator.Invalidate();
142}
143