2 // --------------------------------------------------------
7 // Class describing a pad row composed of the pad row segments.
9 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
13 #include "AliMpPadRow.h"
14 #include "AliMpPadRowLSegment.h"
15 #include "AliMpPadRowRSegment.h"
19 //_____________________________________________________________________________
20 AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
22 fDirection(direction),
28 //_____________________________________________________________________________
29 AliMpPadRow::AliMpPadRow()
37 //_____________________________________________________________________________
38 AliMpPadRow::~AliMpPadRow() {
41 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
49 //_____________________________________________________________________________
50 Double_t AliMpPadRow::CurrentBorderX() const
52 // Returns the left/right x border
53 // (depending on the direction which the row segments are filled in).
56 if (GetNofPadRowSegments() == 0)
59 if (fDirection == kLeft)
60 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
62 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
69 //_____________________________________________________________________________
71 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
74 // Adds pad row segment.
77 AliMpVPadRowSegment* padRowSegment = 0;
79 if (fDirection == kLeft) {
81 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
85 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
88 // Set pad row segment offset
89 padRowSegment->SetOffsetX(CurrentBorderX());
91 // Adds the pad row segment
92 fSegments.push_back(padRowSegment);
97 //_____________________________________________________________________________
98 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
100 // Finds the row segment for the specified x position;
101 // returns 0 if no row segment is found.
104 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
105 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
106 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
113 //_____________________________________________________________________________
114 Double_t AliMpPadRow::HalfSizeY() const
116 return GetPadRowSegment(0)->HalfSizeY();
119 //_____________________________________________________________________________
120 void AliMpPadRow::SetID(Int_t id)
128 //_____________________________________________________________________________
129 void AliMpPadRow::SetOffsetX(Double_t offsetX)
131 // Sets the x offset.
137 //_____________________________________________________________________________
138 Int_t AliMpPadRow::GetID() const
140 // Returns the row ID.
146 //_____________________________________________________________________________
147 Int_t AliMpPadRow::GetNofPadRowSegments() const
149 // Returns number of row segments.
152 return fSegments.size();
155 //_____________________________________________________________________________
156 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
158 if (i<0 || i>=GetNofPadRowSegments()) {
159 Warning("GetRowSegment", "Index outside range");
166 //_____________________________________________________________________________
167 Int_t AliMpPadRow::GetNofPads() const
169 // Returns number of pads in this pad row.
173 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
174 nofPads += GetPadRowSegment(i)->GetNofPads();