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.8 2006/05/24 13:58:46 ivana Exp $
20 //-----------------------------------------------------------------------------
23 // Class describing a pad row composed of the pad row segments.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
28 #include "AliMpPadRow.h"
29 #include "AliMpPadRowLSegment.h"
30 #include "AliMpPadRowRSegment.h"
34 #include <Riostream.h>
40 //_____________________________________________________________________________
41 AliMpPadRow::AliMpPadRow(AliMp::XDirection direction)
43 fDirection(direction),
48 /// Standard constructor
51 //_____________________________________________________________________________
52 AliMpPadRow::AliMpPadRow()
54 fDirection(AliMp::kLeft),
59 /// Default constructor
62 //_____________________________________________________________________________
63 AliMpPadRow::~AliMpPadRow()
67 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
75 //_____________________________________________________________________________
76 Double_t AliMpPadRow::CurrentBorderX() const
78 /// Return the left/right x border
79 /// (depending on the direction which the row segments are filled in).
81 if (GetNofPadRowSegments() == 0)
84 if (fDirection == AliMp::kLeft)
85 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
87 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
94 //_____________________________________________________________________________
96 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
99 /// Add a pad row segment.
101 AliMpVPadRowSegment* padRowSegment = 0;
103 if (fDirection == AliMp::kLeft) {
105 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
109 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
112 // Set pad row segment offset
113 padRowSegment->SetOffsetX(CurrentBorderX());
115 // Adds the pad row segment
117 fSegments.push_back(padRowSegment);
121 fSegments.Add(padRowSegment);
124 return padRowSegment;
127 //_____________________________________________________________________________
128 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
130 /// Find the row segment for the specified x position;
131 /// return 0 if no row segment is found.
133 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
134 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
135 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
142 //_____________________________________________________________________________
143 Double_t AliMpPadRow::HalfSizeY() const
145 /// Return the half size in y
147 return GetPadRowSegment(0)->HalfSizeY();
150 //_____________________________________________________________________________
151 void AliMpPadRow::SetID(Int_t id)
158 //_____________________________________________________________________________
159 void AliMpPadRow::SetOffsetX(Double_t offsetX)
161 /// Set the x offset.
166 //_____________________________________________________________________________
167 Int_t AliMpPadRow::GetID() const
169 /// Return the pad row ID.
174 //_____________________________________________________________________________
175 Int_t AliMpPadRow::GetNofPadRowSegments() const
177 /// Return the number of pad row segments.
180 return fSegments.size();
184 return fSegments.GetEntriesFast();
188 //_____________________________________________________________________________
189 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
191 /// Return the pad row segment with the specified number.
193 if (i<0 || i>=GetNofPadRowSegments()) {
194 AliWarningStream() << "Index outside range" << endl;
203 return (AliMpVPadRowSegment*)fSegments[i];
207 //_____________________________________________________________________________
208 Int_t AliMpPadRow::GetNofPads() const
210 /// Return the number of pads in this pad row.
213 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
214 nofPads += GetPadRowSegment(i)->GetNofPads();