2 // --------------------------------------------------------
7 // Class describing a pad row composed of the pad row segments.
8 // Included in AliRoot: 2003/05/02
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
93 fSegments.push_back(padRowSegment);
97 fSegments.Add(padRowSegment);
100 return padRowSegment;
103 //_____________________________________________________________________________
104 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
106 // Finds the row segment for the specified x position;
107 // returns 0 if no row segment is found.
110 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
111 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
112 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
119 //_____________________________________________________________________________
120 Double_t AliMpPadRow::HalfSizeY() const
122 return GetPadRowSegment(0)->HalfSizeY();
125 //_____________________________________________________________________________
126 void AliMpPadRow::SetID(Int_t id)
134 //_____________________________________________________________________________
135 void AliMpPadRow::SetOffsetX(Double_t offsetX)
137 // Sets the x offset.
143 //_____________________________________________________________________________
144 Int_t AliMpPadRow::GetID() const
146 // Returns the row ID.
152 //_____________________________________________________________________________
153 Int_t AliMpPadRow::GetNofPadRowSegments() const
155 // Returns number of row segments.
159 return fSegments.size();
163 return fSegments.GetEntriesFast();
167 //_____________________________________________________________________________
168 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
170 // Returns pad row segment with specified number.
173 if (i<0 || i>=GetNofPadRowSegments()) {
174 Warning("GetRowSegment", "Index outside range");
183 return (AliMpVPadRowSegment*)fSegments[i];
187 //_____________________________________________________________________________
188 Int_t AliMpPadRow::GetNofPads() const
190 // Returns number of pads in this pad row.
194 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
195 nofPads += GetPadRowSegment(i)->GetNofPads();