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.7 2006/03/17 11:38:43 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
26 #include "AliMpPadRow.h"
27 #include "AliMpPadRowLSegment.h"
28 #include "AliMpPadRowRSegment.h"
32 #include <Riostream.h>
36 //_____________________________________________________________________________
37 AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
39 fDirection(direction),
42 /// Standard constructor
45 //_____________________________________________________________________________
46 AliMpPadRow::AliMpPadRow()
51 /// Default constructor
54 //_____________________________________________________________________________
55 AliMpPadRow::~AliMpPadRow()
59 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
67 //_____________________________________________________________________________
68 Double_t AliMpPadRow::CurrentBorderX() const
70 /// Return the left/right x border
71 /// (depending on the direction which the row segments are filled in).
73 if (GetNofPadRowSegments() == 0)
76 if (fDirection == kLeft)
77 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
79 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
86 //_____________________________________________________________________________
88 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
91 /// Add a pad row segment.
93 AliMpVPadRowSegment* padRowSegment = 0;
95 if (fDirection == kLeft) {
97 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
101 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
104 // Set pad row segment offset
105 padRowSegment->SetOffsetX(CurrentBorderX());
107 // Adds the pad row segment
109 fSegments.push_back(padRowSegment);
113 fSegments.Add(padRowSegment);
116 return padRowSegment;
119 //_____________________________________________________________________________
120 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
122 /// Find the row segment for the specified x position;
123 /// return 0 if no row segment is found.
125 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
126 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
127 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
134 //_____________________________________________________________________________
135 Double_t AliMpPadRow::HalfSizeY() const
137 /// Return the half size in y
139 return GetPadRowSegment(0)->HalfSizeY();
142 //_____________________________________________________________________________
143 void AliMpPadRow::SetID(Int_t id)
150 //_____________________________________________________________________________
151 void AliMpPadRow::SetOffsetX(Double_t offsetX)
153 /// Set the x offset.
158 //_____________________________________________________________________________
159 Int_t AliMpPadRow::GetID() const
161 /// Return the pad row ID.
166 //_____________________________________________________________________________
167 Int_t AliMpPadRow::GetNofPadRowSegments() const
169 /// Return the number of pad row segments.
172 return fSegments.size();
176 return fSegments.GetEntriesFast();
180 //_____________________________________________________________________________
181 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
183 /// Return the pad row segment with the specified number.
185 if (i<0 || i>=GetNofPadRowSegments()) {
186 AliWarningStream() << "Index outside range" << endl;
195 return (AliMpVPadRowSegment*)fSegments[i];
199 //_____________________________________________________________________________
200 Int_t AliMpPadRow::GetNofPads() const
202 /// Return the number of pads in this pad row.
205 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
206 nofPads += GetPadRowSegment(i)->GetNofPads();