]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/mapping/AliMpPadRow.cxx
In SetNofManusPerModule(): return false if no action
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPadRow.cxx
... / ...
CommitLineData
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
16// $Id$
17// $MpId: AliMpPadRow.cxx,v 1.8 2006/05/24 13:58:46 ivana Exp $
18// Category: sector
19//
20// Class AliMpPadRow
21// ------------------
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
25
26#include "AliMpPadRow.h"
27#include "AliMpPadRowLSegment.h"
28#include "AliMpPadRowRSegment.h"
29
30#include "AliLog.h"
31
32#include <Riostream.h>
33
34/// \cond CLASSIMP
35ClassImp(AliMpPadRow)
36/// \endcond
37
38//_____________________________________________________________________________
39AliMpPadRow::AliMpPadRow(AliMp::XDirection direction)
40 : TObject(),
41 fDirection(direction),
42 fID(0),
43 fOffsetX(0),
44 fSegments()
45{
46/// Standard constructor
47}
48
49//_____________________________________________________________________________
50AliMpPadRow::AliMpPadRow()
51 : TObject(),
52 fDirection(AliMp::kLeft),
53 fID(0),
54 fOffsetX(0),
55 fSegments()
56{
57/// Default constructor
58}
59
60//_____________________________________________________________________________
61AliMpPadRow::~AliMpPadRow()
62{
63/// Destructor
64
65 for (Int_t i=0; i<GetNofPadRowSegments() ; i++)
66 delete fSegments[i];
67}
68
69//
70// private methods
71//
72
73//_____________________________________________________________________________
74Double_t AliMpPadRow::CurrentBorderX() const
75{
76/// Return the left/right x border
77/// (depending on the direction which the row segments are filled in).
78
79 if (GetNofPadRowSegments() == 0)
80 return fOffsetX;
81 else
82 if (fDirection == AliMp::kLeft)
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{
97/// Add a pad row segment.
98
99 AliMpVPadRowSegment* padRowSegment = 0;
100
101 if (fDirection == AliMp::kLeft) {
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());
112
113 // Adds the pad row segment
114#ifdef WITH_STL
115 fSegments.push_back(padRowSegment);
116#endif
117
118#ifdef WITH_ROOT
119 fSegments.Add(padRowSegment);
120#endif
121
122 return padRowSegment;
123}
124
125//_____________________________________________________________________________
126AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const
127{
128/// Find the row segment for the specified x position;
129/// return 0 if no row segment is found.
130
131 for (Int_t i=0; i<GetNofPadRowSegments(); i++) {
132 AliMpVPadRowSegment* rs = GetPadRowSegment(i);
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{
143/// Return the half size in y
144
145 return GetPadRowSegment(0)->HalfSizeY();
146}
147
148//_____________________________________________________________________________
149void AliMpPadRow::SetID(Int_t id)
150{
151/// Set the ID.
152
153 fID = id;
154}
155
156//_____________________________________________________________________________
157void AliMpPadRow::SetOffsetX(Double_t offsetX)
158{
159/// Set the x offset.
160
161 fOffsetX = offsetX;
162}
163
164//_____________________________________________________________________________
165Int_t AliMpPadRow::GetID() const
166{
167/// Return the pad row ID.
168
169 return fID;
170}
171
172//_____________________________________________________________________________
173Int_t AliMpPadRow::GetNofPadRowSegments() const
174{
175/// Return the number of pad row segments.
176
177#ifdef WITH_STL
178 return fSegments.size();
179#endif
180
181#ifdef WITH_ROOT
182 return fSegments.GetEntriesFast();
183#endif
184}
185
186//_____________________________________________________________________________
187AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const
188{
189/// Return the pad row segment with the specified number.
190
191 if (i<0 || i>=GetNofPadRowSegments()) {
192 AliWarningStream() << "Index outside range" << endl;
193 return 0;
194 }
195
196#ifdef WITH_STL
197 return fSegments[i];
198#endif
199
200#ifdef WITH_ROOT
201 return (AliMpVPadRowSegment*)fSegments[i];
202#endif
203}
204
205//_____________________________________________________________________________
206Int_t AliMpPadRow::GetNofPads() const
207{
208/// Return the number of pads in this pad row.
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