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 $
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>
38 //_____________________________________________________________________________
39 AliMpPadRow::AliMpPadRow(AliMpXDirection direction)
41 fDirection(direction),
46 /// Standard constructor
49 //_____________________________________________________________________________
50 AliMpPadRow::AliMpPadRow()
57 /// Default constructor
60 //_____________________________________________________________________________
61 AliMpPadRow::~AliMpPadRow()
65 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
73 //_____________________________________________________________________________
74 Double_t AliMpPadRow::CurrentBorderX() const
76 /// Return the left/right x border
77 /// (depending on the direction which the row segments are filled in).
79 if (GetNofPadRowSegments() == 0)
82 if (fDirection == kLeft)
83 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
85 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
92 //_____________________________________________________________________________
94 AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
97 /// Add a pad row segment.
99 AliMpVPadRowSegment* padRowSegment = 0;
101 if (fDirection == kLeft) {
103 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
107 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
110 // Set pad row segment offset
111 padRowSegment->SetOffsetX(CurrentBorderX());
113 // Adds the pad row segment
115 fSegments.push_back(padRowSegment);
119 fSegments.Add(padRowSegment);
122 return padRowSegment;
125 //_____________________________________________________________________________
126 AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
128 /// Find the row segment for the specified x position;
129 /// return 0 if no row segment is found.
131 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
132 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
133 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
140 //_____________________________________________________________________________
141 Double_t AliMpPadRow::HalfSizeY() const
143 /// Return the half size in y
145 return GetPadRowSegment(0)->HalfSizeY();
148 //_____________________________________________________________________________
149 void AliMpPadRow::SetID(Int_t id)
156 //_____________________________________________________________________________
157 void AliMpPadRow::SetOffsetX(Double_t offsetX)
159 /// Set the x offset.
164 //_____________________________________________________________________________
165 Int_t AliMpPadRow::GetID() const
167 /// Return the pad row ID.
172 //_____________________________________________________________________________
173 Int_t AliMpPadRow::GetNofPadRowSegments() const
175 /// Return the number of pad row segments.
178 return fSegments.size();
182 return fSegments.GetEntriesFast();
186 //_____________________________________________________________________________
187 AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
189 /// Return the pad row segment with the specified number.
191 if (i<0 || i>=GetNofPadRowSegments()) {
192 AliWarningStream() << "Index outside range" << endl;
201 return (AliMpVPadRowSegment*)fSegments[i];
205 //_____________________________________________________________________________
206 Int_t AliMpPadRow::GetNofPads() const
208 /// Return the number of pads in this pad row.
211 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
212 nofPads += GetPadRowSegment(i)->GetNofPads();