]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPadRow.cxx
gAlice->Particle(lab) removed. TParticle obj. accessed via AliMC
[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.
8//
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
92 fSegments.push_back(padRowSegment);
f0e4d56c 93
94 return padRowSegment;
5f91c9e8 95}
96
97//_____________________________________________________________________________
f0e4d56c 98AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
5f91c9e8 99{
100// Finds the row segment for the specified x position;
101// returns 0 if no row segment is found.
102// ---
103
104 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
f0e4d56c 105 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
5f91c9e8 106 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
107 return rs;
108 }
109
110 return 0;
111}
112
113//_____________________________________________________________________________
114Double_t AliMpPadRow::HalfSizeY() const
115{
116 return GetPadRowSegment(0)->HalfSizeY();
117}
118
119//_____________________________________________________________________________
120void AliMpPadRow::SetID(Int_t id)
121{
122// Sets the ID.
123// ---
124
125 fID = id;
126}
127
128//_____________________________________________________________________________
129void AliMpPadRow::SetOffsetX(Double_t offsetX)
130{
131// Sets the x offset.
132// ---
133
134 fOffsetX = offsetX;
135}
136
137//_____________________________________________________________________________
138Int_t AliMpPadRow::GetID() const
139{
140// Returns the row ID.
141// ---
142
143 return fID;
144}
145
146//_____________________________________________________________________________
147Int_t AliMpPadRow::GetNofPadRowSegments() const
148{
149// Returns number of row segments.
150// ---
151
152 return fSegments.size();
153}
154
155//_____________________________________________________________________________
f0e4d56c 156AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
5f91c9e8 157{
158 if (i<0 || i>=GetNofPadRowSegments()) {
159 Warning("GetRowSegment", "Index outside range");
160 return 0;
161 }
162
163 return fSegments[i];
164}
165
166//_____________________________________________________________________________
167Int_t AliMpPadRow::GetNofPads() const
168{
169// Returns number of pads in this pad row.
170// ---
171
172 Int_t nofPads=0;
173 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
174 nofPads += GetPadRowSegment(i)->GetNofPads();
175
176 return nofPads;
177}
178