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