]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpPadRow.cxx
Coding conventions
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.cxx
CommitLineData
dee1d5f1 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
5f91c9e8 16// $Id$
13985652 17// $MpId: AliMpPadRow.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $
5f91c9e8 18// Category: sector
3d1463c8 19
20//-----------------------------------------------------------------------------
5f91c9e8 21// Class AliMpPadRow
f0e4d56c 22// ------------------
5f91c9e8 23// Class describing a pad row composed of the pad row segments.
dbe945cc 24// Included in AliRoot: 2003/05/02
5f91c9e8 25// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
3d1463c8 26//-----------------------------------------------------------------------------
5f91c9e8 27
5f91c9e8 28#include "AliMpPadRow.h"
f0e4d56c 29#include "AliMpPadRowLSegment.h"
30#include "AliMpPadRowRSegment.h"
5f91c9e8 31
2c605e66 32#include "AliLog.h"
33
34#include <Riostream.h>
35
13985652 36/// \cond CLASSIMP
5f91c9e8 37ClassImp(AliMpPadRow)
13985652 38/// \endcond
5f91c9e8 39
f0e4d56c 40//_____________________________________________________________________________
cddd101e 41AliMpPadRow::AliMpPadRow(AliMp::XDirection direction)
f0e4d56c 42 : TObject(),
43 fDirection(direction),
0471c97b 44 fID(0),
45 fOffsetX(0),
46 fSegments()
f0e4d56c 47{
dee1d5f1 48/// Standard constructor
f0e4d56c 49}
50
5f91c9e8 51//_____________________________________________________________________________
52AliMpPadRow::AliMpPadRow()
53 : TObject(),
cddd101e 54 fDirection(AliMp::kLeft),
0471c97b 55 fID(0),
56 fOffsetX(0),
57 fSegments()
5f91c9e8 58{
dee1d5f1 59/// Default constructor
5f91c9e8 60}
61
62//_____________________________________________________________________________
dee1d5f1 63AliMpPadRow::~AliMpPadRow()
64{
65/// Destructor
5f91c9e8 66
67 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
68 delete fSegments[i];
69}
70
71//
f0e4d56c 72// private methods
5f91c9e8 73//
74
75//_____________________________________________________________________________
f0e4d56c 76Double_t AliMpPadRow::CurrentBorderX() const
5f91c9e8 77{
dee1d5f1 78/// Return the left/right x border
79/// (depending on the direction which the row segments are filled in).
5f91c9e8 80
5f91c9e8 81 if (GetNofPadRowSegments() == 0)
f0e4d56c 82 return fOffsetX;
5f91c9e8 83 else
cddd101e 84 if (fDirection == AliMp::kLeft)
f0e4d56c 85 return GetPadRowSegment(GetNofPadRowSegments()-1)->LeftBorderX();
86 else
87 return GetPadRowSegment(GetNofPadRowSegments()-1)->RightBorderX();
88}
89
90//
91// public methods
92//
93
94//_____________________________________________________________________________
95AliMpVPadRowSegment*
96AliMpPadRow::AddPadRowSegment(AliMpMotif* motif, Int_t motifPositionId,
97 Int_t nofPads)
98{
dee1d5f1 99/// Add a pad row segment.
f0e4d56c 100
101 AliMpVPadRowSegment* padRowSegment = 0;
102
cddd101e 103 if (fDirection == AliMp::kLeft) {
f0e4d56c 104 padRowSegment
105 = new AliMpPadRowLSegment(this, motif, motifPositionId, nofPads);
106 }
107 else {
108 padRowSegment
109 = new AliMpPadRowRSegment(this, motif, motifPositionId, nofPads);
110 }
111
112 // Set pad row segment offset
113 padRowSegment->SetOffsetX(CurrentBorderX());
5f91c9e8 114
115 // Adds the pad row segment
f79c58a5 116#ifdef WITH_STL
5f91c9e8 117 fSegments.push_back(padRowSegment);
f79c58a5 118#endif
119
120#ifdef WITH_ROOT
121 fSegments.Add(padRowSegment);
122#endif
f0e4d56c 123
124 return padRowSegment;
5f91c9e8 125}
126
127//_____________________________________________________________________________
f0e4d56c 128AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
5f91c9e8 129{
dee1d5f1 130/// Find the row segment for the specified x position;
131/// return 0 if no row segment is found.
5f91c9e8 132
133 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
f0e4d56c 134 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
5f91c9e8 135 if (x >= rs->LeftBorderX() && x <= rs->RightBorderX())
136 return rs;
137 }
138
139 return 0;
140}
141
142//_____________________________________________________________________________
143Double_t AliMpPadRow::HalfSizeY() const
144{
dee1d5f1 145/// Return the half size in y
146
5f91c9e8 147 return GetPadRowSegment(0)->HalfSizeY();
148}
149
150//_____________________________________________________________________________
151void AliMpPadRow::SetID(Int_t id)
152{
dee1d5f1 153/// Set the ID.
5f91c9e8 154
155 fID = id;
156}
157
158//_____________________________________________________________________________
159void AliMpPadRow::SetOffsetX(Double_t offsetX)
160{
dee1d5f1 161/// Set the x offset.
5f91c9e8 162
163 fOffsetX = offsetX;
164}
165
166//_____________________________________________________________________________
167Int_t AliMpPadRow::GetID() const
168{
dee1d5f1 169/// Return the pad row ID.
5f91c9e8 170
171 return fID;
172}
173
174//_____________________________________________________________________________
175Int_t AliMpPadRow::GetNofPadRowSegments() const
176{
dee1d5f1 177/// Return the number of pad row segments.
5f91c9e8 178
f79c58a5 179#ifdef WITH_STL
5f91c9e8 180 return fSegments.size();
f79c58a5 181#endif
182
183#ifdef WITH_ROOT
184 return fSegments.GetEntriesFast();
185#endif
5f91c9e8 186}
187
188//_____________________________________________________________________________
f0e4d56c 189AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
5f91c9e8 190{
dee1d5f1 191/// Return the pad row segment with the specified number.
31e62cbe 192
5f91c9e8 193 if (i<0 || i>=GetNofPadRowSegments()) {
2c605e66 194 AliWarningStream() << "Index outside range" << endl;
5f91c9e8 195 return 0;
196 }
197
f79c58a5 198#ifdef WITH_STL
5f91c9e8 199 return fSegments[i];
f79c58a5 200#endif
201
202#ifdef WITH_ROOT
203 return (AliMpVPadRowSegment*)fSegments[i];
204#endif
5f91c9e8 205}
206
207//_____________________________________________________________________________
208Int_t AliMpPadRow::GetNofPads() const
209{
dee1d5f1 210/// Return the number of pads in this pad row.
5f91c9e8 211
212 Int_t nofPads=0;
213 for (Int_t i=0; i<GetNofPadRowSegments(); i++)
214 nofPads += GetPadRowSegment(i)->GetNofPads();
215
216 return nofPads;
217}
218