Update for station2:
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.cxx
CommitLineData
5f91c9e8 1// $Id$
2// --------------------------------------------------------
3// Category: sector
4//
5// Class AliMpPadRow
6// -----------------
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"
14#include "AliMpPadRowSegment.h"
15
16ClassImp(AliMpPadRow)
17
18//_____________________________________________________________________________
19AliMpPadRow::AliMpPadRow()
20 : TObject(),
21 fID(0)
22{
23//
24}
25
26//_____________________________________________________________________________
27AliMpPadRow::~AliMpPadRow() {
28//
29
30 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
31 delete fSegments[i];
32}
33
34//
35// public methods
36//
37
38//_____________________________________________________________________________
39void AliMpPadRow::AddPadRowSegment(AliMpPadRowSegment* padRowSegment)
40{
41// Adds row segment.
42// ---
43
44 // Set pad row segment offset
45 if (GetNofPadRowSegments() == 0)
46 padRowSegment
47 ->SetOffsetX(fOffsetX);
48 else
49 padRowSegment
50 ->SetOffsetX(GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX());
51
52 // Adds the pad row segment
53 fSegments.push_back(padRowSegment);
54}
55
56//_____________________________________________________________________________
57AliMpPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
58{
59// Finds the row segment for the specified x position;
60// returns 0 if no row segment is found.
61// ---
62
63 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
64 AliMpPadRowSegment* rs = GetPadRowSegment(i);
65 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
66 return rs;
67 }
68
69 return 0;
70}
71
72//_____________________________________________________________________________
73Double_t AliMpPadRow::HalfSizeY() const
74{
75 return GetPadRowSegment(0)->HalfSizeY();
76}
77
78//_____________________________________________________________________________
79void AliMpPadRow::SetID(Int_t id)
80{
81// Sets the ID.
82// ---
83
84 fID = id;
85}
86
87//_____________________________________________________________________________
88void AliMpPadRow::SetOffsetX(Double_t offsetX)
89{
90// Sets the x offset.
91// ---
92
93 fOffsetX = offsetX;
94}
95
96//_____________________________________________________________________________
97Int_t AliMpPadRow::GetID() const
98{
99// Returns the row ID.
100// ---
101
102 return fID;
103}
104
105//_____________________________________________________________________________
106Int_t AliMpPadRow::GetNofPadRowSegments() const
107{
108// Returns number of row segments.
109// ---
110
111 return fSegments.size();
112}
113
114//_____________________________________________________________________________
115AliMpPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
116{
117 if (i<0 || i>=GetNofPadRowSegments()) {
118 Warning("GetRowSegment", "Index outside range");
119 return 0;
120 }
121
122 return fSegments[i];
123}
124
125//_____________________________________________________________________________
126Int_t AliMpPadRow::GetNofPads() const
127{
128// Returns number of pads in this pad row.
129// ---
130
131 Int_t nofPads=0;
132 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
133 nofPads += GetPadRowSegment(i)->GetNofPads();
134
135 return nofPads;
136}
137