]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPadRow.cxx
Extendened class description to include at least 5 subsequent lines required by rule...
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.cxx
CommitLineData
5f91c9e8 1// $Id$
2// --------------------------------------------------------
3// Category: sector
4//
5// Class AliMpPadRow
f0e4d56c 6// ------------------
5f91c9e8 7// Class describing a pad row composed of the pad row segments.
dbe945cc 8// Included in AliRoot: 2003/05/02
5f91c9e8 9// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
10
11#include <TError.h>
12
13#include "AliMpPadRow.h"
f0e4d56c 14#include "AliMpPadRowLSegment.h"
15#include "AliMpPadRowRSegment.h"
5f91c9e8 16
17ClassImp(AliMpPadRow)
18
f0e4d56c 19//_____________________________________________________________________________
20AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
21 : TObject(),
22 fDirection(direction),
23 fID(0)
24{
25//
26}
27
5f91c9e8 28//_____________________________________________________________________________
29AliMpPadRow::AliMpPadRow()
30 : TObject(),
f0e4d56c 31 fDirection(kLeft),
32 fID(0)
5f91c9e8 33{
34//
35}
36
37//_____________________________________________________________________________
38AliMpPadRow::~AliMpPadRow() {
39//
40
41 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
42 delete fSegments[i];
43}
44
45//
f0e4d56c 46// private methods
5f91c9e8 47//
48
49//_____________________________________________________________________________
f0e4d56c 50Double_t AliMpPadRow::CurrentBorderX() const
5f91c9e8 51{
f0e4d56c 52// Returns the left/right x border
53// (depending on the direction which the row segments are filled in).
5f91c9e8 54// ---
55
5f91c9e8 56 if (GetNofPadRowSegments() == 0)
f0e4d56c 57 return fOffsetX;
5f91c9e8 58 else
f0e4d56c 59 if (fDirection == kLeft)
60 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
61 else
62 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
63}
64
65//
66// public methods
67//
68
69//_____________________________________________________________________________
70AliMpVPadRowSegment*
71AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
72 Int_t nofPads)
73{
74// Adds pad row segment.
75// ---
76
77 AliMpVPadRowSegment* padRowSegment = 0;
78
79 if (fDirection == kLeft) {
80 padRowSegment
81 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
82 }
83 else {
84 padRowSegment
85 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
86 }
87
88 // Set pad row segment offset
89 padRowSegment->SetOffsetX(CurrentBorderX());
5f91c9e8 90
91 // Adds the pad row segment
f79c58a5 92#ifdef WITH_STL
5f91c9e8 93 fSegments.push_back(padRowSegment);
f79c58a5 94#endif
95
96#ifdef WITH_ROOT
97 fSegments.Add(padRowSegment);
98#endif
f0e4d56c 99
100 return padRowSegment;
5f91c9e8 101}
102
103//_____________________________________________________________________________
f0e4d56c 104AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
5f91c9e8 105{
106// Finds the row segment for the specified x position;
107// returns 0 if no row segment is found.
108// ---
109
110 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
f0e4d56c 111 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
5f91c9e8 112 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
113 return rs;
114 }
115
116 return 0;
117}
118
119//_____________________________________________________________________________
120Double_t AliMpPadRow::HalfSizeY() const
121{
122 return GetPadRowSegment(0)->HalfSizeY();
123}
124
125//_____________________________________________________________________________
126void AliMpPadRow::SetID(Int_t id)
127{
128// Sets the ID.
129// ---
130
131 fID = id;
132}
133
134//_____________________________________________________________________________
135void AliMpPadRow::SetOffsetX(Double_t offsetX)
136{
137// Sets the x offset.
138// ---
139
140 fOffsetX = offsetX;
141}
142
143//_____________________________________________________________________________
144Int_t AliMpPadRow::GetID() const
145{
146// Returns the row ID.
147// ---
148
149 return fID;
150}
151
152//_____________________________________________________________________________
153Int_t AliMpPadRow::GetNofPadRowSegments() const
154{
155// Returns number of row segments.
156// ---
157
f79c58a5 158#ifdef WITH_STL
5f91c9e8 159 return fSegments.size();
f79c58a5 160#endif
161
162#ifdef WITH_ROOT
163 return fSegments.GetEntriesFast();
164#endif
5f91c9e8 165}
166
167//_____________________________________________________________________________
f0e4d56c 168AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
5f91c9e8 169{
31e62cbe 170// Returns pad row segment with specified number.
171// ---
172
5f91c9e8 173 if (i<0 || i>=GetNofPadRowSegments()) {
174 Warning("GetRowSegment", "Index outside range");
175 return 0;
176 }
177
f79c58a5 178#ifdef WITH_STL
5f91c9e8 179 return fSegments[i];
f79c58a5 180#endif
181
182#ifdef WITH_ROOT
183 return (AliMpVPadRowSegment*)fSegments[i];
184#endif
5f91c9e8 185}
186
187//_____________________________________________________________________________
188Int_t AliMpPadRow::GetNofPads() const
189{
190// Returns number of pads in this pad row.
191// ---
192
193 Int_t nofPads=0;
194 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
195 nofPads += GetPadRowSegment(i)->GetNofPads();
196
197 return nofPads;
198}
199