1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // $MpId: AliMpPadRow.cxx,v 1.6 2005/08/26 15:43:36 ivana Exp $
22 // Class describing a pad row composed of the pad row segments.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
28 #include "AliMpPadRow.h"
29 #include "AliMpPadRowLSegment.h"
30 #include "AliMpPadRowRSegment.h"
34 //_____________________________________________________________________________
35 AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
37 fDirection(direction),
40 /// Standard constructor
43 //_____________________________________________________________________________
44 AliMpPadRow::AliMpPadRow()
49 /// Default constructor
52 //_____________________________________________________________________________
53 AliMpPadRow::~AliMpPadRow()
57 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
65 //_____________________________________________________________________________
66 Double_t AliMpPadRow::CurrentBorderX() const
68 /// Return the left/right x border
69 /// (depending on the direction which the row segments are filled in).
71 if (GetNofPadRowSegments() == 0)
74 if (fDirection == kLeft)
75 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
77 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
84 //_____________________________________________________________________________
86 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
89 /// Add a pad row segment.
91 AliMpVPadRowSegment* padRowSegment = 0;
93 if (fDirection == kLeft) {
95 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
99 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
102 // Set pad row segment offset
103 padRowSegment->SetOffsetX(CurrentBorderX());
105 // Adds the pad row segment
107 fSegments.push_back(padRowSegment);
111 fSegments.Add(padRowSegment);
114 return padRowSegment;
117 //_____________________________________________________________________________
118 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
120 /// Find the row segment for the specified x position;
121 /// return 0 if no row segment is found.
123 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
124 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
125 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
132 //_____________________________________________________________________________
133 Double_t AliMpPadRow::HalfSizeY() const
135 /// Return the half size in y
137 return GetPadRowSegment(0)->HalfSizeY();
140 //_____________________________________________________________________________
141 void AliMpPadRow::SetID(Int_t id)
148 //_____________________________________________________________________________
149 void AliMpPadRow::SetOffsetX(Double_t offsetX)
151 /// Set the x offset.
156 //_____________________________________________________________________________
157 Int_t AliMpPadRow::GetID() const
159 /// Return the pad row ID.
164 //_____________________________________________________________________________
165 Int_t AliMpPadRow::GetNofPadRowSegments() const
167 /// Return the number of pad row segments.
170 return fSegments.size();
174 return fSegments.GetEntriesFast();
178 //_____________________________________________________________________________
179 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
181 /// Return the pad row segment with the specified number.
183 if (i<0 || i>=GetNofPadRowSegments()) {
184 Warning("GetRowSegment", "Index outside range");
193 return (AliMpVPadRowSegment*)fSegments[i];
197 //_____________________________________________________________________________
198 Int_t AliMpPadRow::GetNofPads() const
200 /// Return the number of pads in this pad row.
203 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
204 nofPads += GetPadRowSegment(i)->GetNofPads();