]>
Commit | Line | Data |
---|---|---|
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 | 37 | ClassImp(AliMpPadRow) |
13985652 | 38 | /// \endcond |
5f91c9e8 | 39 | |
f0e4d56c | 40 | //_____________________________________________________________________________ |
cddd101e | 41 | AliMpPadRow::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 | //_____________________________________________________________________________ |
52 | AliMpPadRow::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 | 63 | AliMpPadRow::~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 | 76 | Double_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 | //_____________________________________________________________________________ | |
95 | AliMpVPadRowSegment* | |
96 | AliMpPadRow::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 | fSegments.Add(padRowSegment); |
f0e4d56c | 117 | |
118 | return padRowSegment; | |
5f91c9e8 | 119 | } |
120 | ||
121 | //_____________________________________________________________________________ | |
f0e4d56c | 122 | AliMpVPadRowSegment* AliMpPadRow::FindPadRowSegment(Double_t x) const |
5f91c9e8 | 123 | { |
dee1d5f1 | 124 | /// Find the row segment for the specified x position; |
125 | /// return 0 if no row segment is found. | |
5f91c9e8 | 126 | |
127 | for (Int_t i=0; i<GetNofPadRowSegments(); i++) { | |
f0e4d56c | 128 | AliMpVPadRowSegment* rs = GetPadRowSegment(i); |
5f91c9e8 | 129 | if (x >= rs->LeftBorderX() && x <= rs->RightBorderX()) |
130 | return rs; | |
131 | } | |
132 | ||
133 | return 0; | |
134 | } | |
135 | ||
136 | //_____________________________________________________________________________ | |
137 | Double_t AliMpPadRow::HalfSizeY() const | |
138 | { | |
dee1d5f1 | 139 | /// Return the half size in y |
140 | ||
5f91c9e8 | 141 | return GetPadRowSegment(0)->HalfSizeY(); |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | void AliMpPadRow::SetID(Int_t id) | |
146 | { | |
dee1d5f1 | 147 | /// Set the ID. |
5f91c9e8 | 148 | |
149 | fID = id; | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | void AliMpPadRow::SetOffsetX(Double_t offsetX) | |
154 | { | |
dee1d5f1 | 155 | /// Set the x offset. |
5f91c9e8 | 156 | |
157 | fOffsetX = offsetX; | |
158 | } | |
159 | ||
160 | //_____________________________________________________________________________ | |
161 | Int_t AliMpPadRow::GetID() const | |
162 | { | |
dee1d5f1 | 163 | /// Return the pad row ID. |
5f91c9e8 | 164 | |
165 | return fID; | |
166 | } | |
167 | ||
168 | //_____________________________________________________________________________ | |
169 | Int_t AliMpPadRow::GetNofPadRowSegments() const | |
170 | { | |
dee1d5f1 | 171 | /// Return the number of pad row segments. |
5f91c9e8 | 172 | |
f79c58a5 | 173 | return fSegments.GetEntriesFast(); |
5f91c9e8 | 174 | } |
175 | ||
176 | //_____________________________________________________________________________ | |
f0e4d56c | 177 | AliMpVPadRowSegment* AliMpPadRow::GetPadRowSegment(Int_t i) const |
5f91c9e8 | 178 | { |
dee1d5f1 | 179 | /// Return the pad row segment with the specified number. |
31e62cbe | 180 | |
5f91c9e8 | 181 | if (i<0 || i>=GetNofPadRowSegments()) { |
2c605e66 | 182 | AliWarningStream() << "Index outside range" << endl; |
5f91c9e8 | 183 | return 0; |
184 | } | |
185 | ||
f79c58a5 | 186 | return (AliMpVPadRowSegment*)fSegments[i]; |
5f91c9e8 | 187 | } |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | Int_t AliMpPadRow::GetNofPads() const | |
191 | { | |
dee1d5f1 | 192 | /// Return the number of pads in this pad row. |
5f91c9e8 | 193 | |
194 | Int_t nofPads=0; | |
195 | for (Int_t i=0; i<GetNofPadRowSegments(); i++) | |
196 | nofPads += GetPadRowSegment(i)->GetNofPads(); | |
197 | ||
198 | return nofPads; | |
199 | } | |
200 |