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