]>
Commit | Line | Data |
---|---|---|
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: AliMpRowSegmentRSpecial.cxx,v 1.7 2006/05/24 13:58:46 ivana Exp $ | |
18 | // Category: sector | |
19 | ||
20 | //----------------------------------------------------------------------------- | |
21 | // Class AliMpRowSegmentRSpecial | |
22 | // ----------------------------- | |
23 | // Class describing a special outer row segment composed of the | |
24 | // pad rows. | |
25 | // Included in AliRoot: 2003/05/02 | |
26 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
29 | #include "AliMpRowSegmentRSpecial.h" | |
30 | #include "AliMpRow.h" | |
31 | #include "AliMpPadRow.h" | |
32 | #include "AliMpVPadRowSegment.h" | |
33 | #include "AliMpMotif.h" | |
34 | #include "AliMpMotifType.h" | |
35 | #include "AliMpMotifMap.h" | |
36 | #include "AliMpMotifPosition.h" | |
37 | #include "AliMpConstants.h" | |
38 | ||
39 | #include "AliLog.h" | |
40 | ||
41 | #include <Riostream.h> | |
42 | #include <TMath.h> | |
43 | ||
44 | using std::endl; | |
45 | /// \cond CLASSIMP | |
46 | ClassImp(AliMpRowSegmentRSpecial) | |
47 | /// \endcond | |
48 | ||
49 | //______________________________________________________________________________ | |
50 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial(AliMpRow* row, Double_t offsetX) | |
51 | : AliMpVRowSegmentSpecial(row, offsetX) | |
52 | { | |
53 | /// Standard constructor | |
54 | } | |
55 | ||
56 | //______________________________________________________________________________ | |
57 | AliMpRowSegmentRSpecial::AliMpRowSegmentRSpecial() | |
58 | : AliMpVRowSegmentSpecial() | |
59 | { | |
60 | /// Default constructor | |
61 | } | |
62 | ||
63 | //______________________________________________________________________________ | |
64 | AliMpRowSegmentRSpecial::~AliMpRowSegmentRSpecial() | |
65 | { | |
66 | /// Destructor | |
67 | } | |
68 | ||
69 | // | |
70 | // private methods | |
71 | // | |
72 | ||
73 | //______________________________________________________________________________ | |
74 | AliMpVPadRowSegment* | |
75 | AliMpRowSegmentRSpecial::FindMostLeftPadRowSegment(Int_t motifPositionId) const | |
76 | { | |
77 | /// Find the most left pad row segment with this motifPositionId. | |
78 | ||
79 | AliMpVPadRowSegment* found = 0; | |
80 | ||
81 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
82 | AliMpPadRow* padRow = GetPadRow(i); | |
83 | ||
84 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
85 | AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j); | |
86 | ||
87 | if ( padRowSegment->GetMotifPositionId() == motifPositionId && | |
88 | (!found || padRowSegment->LeftBorderX() < found->LeftBorderX())) | |
89 | ||
90 | found = padRowSegment; | |
91 | } | |
92 | } | |
93 | ||
94 | return found; | |
95 | } | |
96 | ||
97 | //______________________________________________________________________________ | |
98 | void AliMpRowSegmentRSpecial::SetGlobalIndicesLow() | |
99 | { | |
100 | /// Set global low indices | |
101 | ||
102 | // Last normal row segment in the row | |
103 | // (preceding this special row segment) | |
104 | AliMpVRowSegment* rowSegment | |
105 | = GetRow()->GetRowSegment(GetRow()->GetNofRowSegments()-2); | |
106 | ||
107 | // Set low indices limit to continue indices of the | |
108 | // preceding row segment | |
109 | Int_t ix = rowSegment->GetHighLimitIx() + 1; | |
110 | Int_t iy = rowSegment->GetLowLimitIy(); | |
111 | ||
112 | SetLowIndicesLimit(ix, iy); | |
113 | } | |
114 | ||
115 | // | |
116 | // protected methods | |
117 | // | |
118 | ||
119 | //______________________________________________________________________________ | |
120 | void AliMpRowSegmentRSpecial::MotifCenterSlow(Int_t motifPositionId, | |
121 | Double_t& x, Double_t& y) const | |
122 | { | |
123 | /// Fill the coordinates of the motif specified with | |
124 | /// the given position identifier. \n | |
125 | /// !! Applicable only for motifs that have their most down pad in | |
126 | /// this row segment. | |
127 | ||
128 | // Find the first (left, down) pad row segment with this motifPositionId. | |
129 | AliMpVPadRowSegment* downPadRowSegment | |
130 | = FindPadRowSegment(motifPositionId); | |
131 | AliMpVPadRowSegment* leftPadRowSegment | |
132 | = FindMostLeftPadRowSegment(motifPositionId); | |
133 | ||
134 | // Check if the motifPositionId is present | |
135 | if (!downPadRowSegment || !leftPadRowSegment) { | |
136 | AliErrorStream() << "Outside row segment region" << endl; | |
137 | return; | |
138 | } | |
139 | ||
140 | // Check if both pad row segments have the same motif | |
141 | if (downPadRowSegment->GetMotif() != leftPadRowSegment->GetMotif()) { | |
142 | AliFatal("Outside row segment region"); | |
143 | return; | |
144 | } | |
145 | ||
146 | // Get position of found row segment | |
147 | x = leftPadRowSegment->LeftBorderX(); | |
148 | y = GetRow()->LowBorderY() ; | |
149 | ||
150 | for (Int_t i=0; i<downPadRowSegment->GetPadRow()->GetID(); i++) | |
151 | y += GetPadRow(i)->HalfSizeY()*2.; | |
152 | ||
153 | // Add motifs dimensions | |
154 | x += downPadRowSegment->GetMotif()->DimensionX(); | |
155 | y += downPadRowSegment->GetMotif()->DimensionY(); | |
156 | } | |
157 | ||
158 | // | |
159 | // public methods | |
160 | // | |
161 | ||
162 | //______________________________________________________________________________ | |
163 | Double_t AliMpRowSegmentRSpecial::LeftBorderX() const | |
164 | { | |
165 | /// Return the x coordinate of the left row segment border | |
166 | /// in the global coordinate system. | |
167 | ||
168 | // The right edge of the last normal segment | |
169 | Double_t sameBorder = GetOffsetX(); | |
170 | ||
171 | // Consistence check | |
172 | Double_t leftBorder = DBL_MAX; | |
173 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
174 | AliMpPadRow* padRow = GetPadRow(i); | |
175 | Double_t border = padRow->GetPadRowSegment(0)->LeftBorderX(); | |
176 | if (border < leftBorder) leftBorder = border; | |
177 | } | |
178 | ||
179 | if (TMath::Abs(sameBorder - leftBorder) > 1.e-04) { | |
180 | AliErrorStream() << "WrongBorder" << endl;; | |
181 | return sameBorder; | |
182 | } | |
183 | ||
184 | return leftBorder; | |
185 | ||
186 | } | |
187 | ||
188 | //______________________________________________________________________________ | |
189 | Double_t AliMpRowSegmentRSpecial::RightBorderX() const | |
190 | { | |
191 | /// Return the x coordinate of the right row segment border | |
192 | /// in the global coordinate system. | |
193 | ||
194 | Double_t rightBorder = -DBL_MAX; | |
195 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
196 | AliMpPadRow* padRow = GetPadRow(i); | |
197 | Double_t border | |
198 | = padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1) | |
199 | ->RightBorderX(); | |
200 | ||
201 | if (border > rightBorder) rightBorder = border; | |
202 | } | |
203 | ||
204 | return rightBorder; | |
205 | } | |
206 | ||
207 | //______________________________________________________________________________ | |
208 | Double_t AliMpRowSegmentRSpecial::GetPositionX() const | |
209 | { | |
210 | /// Return the x position of the row segment centre. | |
211 | /// The centre is defined as the centre of the rectangular | |
212 | /// row segment envelope. | |
213 | ||
214 | // The right edge of the last normal segment | |
215 | return GetOffsetX() + GetDimensionX(); | |
216 | } | |
217 | ||
218 | //______________________________________________________________________________ | |
219 | Double_t AliMpRowSegmentRSpecial::GetPositionY() const | |
220 | { | |
221 | /// Return the y position of the row segment centre. | |
222 | /// The centre is defined as the centre of the rectangular | |
223 | /// row segment envelope. | |
224 | ||
225 | // The right edge of the last normal segment | |
226 | return GetRow()->GetPositionY(); | |
227 | } | |
228 | ||
229 | //______________________________________________________________________________ | |
230 | Int_t AliMpRowSegmentRSpecial::SetIndicesToMotifPosition(Int_t i, MpPair_t indices) | |
231 | { | |
232 | /// Set global indices to i-th motif position and returns next index in x. | |
233 | ||
234 | // Update low indices limit for this row segment | |
235 | SetGlobalIndicesLow(); | |
236 | ||
237 | // Check for consistence | |
238 | if ( GetLowLimitIx() != AliMp::PairFirst(indices) ) | |
239 | AliFatal("Inconsistent indices"); | |
240 | ||
241 | // Get motif position | |
242 | AliMpMotifPosition* motifPosition | |
243 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i)); | |
244 | ||
245 | // Set limits only once | |
246 | if ( motifPosition->IsHighLimitValid() ) | |
247 | return AliMp::PairFirst(indices); | |
248 | ||
249 | // Low limit | |
250 | // | |
251 | Int_t ixl = GetLowLimitIx(); | |
252 | Int_t iyl = GetLowLimitIy(); | |
253 | ||
254 | // Find the most down pad row segment with this motifPositionId. | |
255 | AliMpVPadRowSegment* padRowSegment = FindPadRowSegment(GetMotifPositionId(i)); | |
256 | Int_t padRowID = padRowSegment->GetPadRow()->GetID(); | |
257 | iyl += padRowID; | |
258 | ||
259 | // Add pads offset of this motif position in the row segment | |
260 | for ( Int_t im=0; im<i; im++ ) { | |
261 | AliMpVPadRowSegment* rs = GetPadRow(padRowID)->GetPadRowSegment(im); | |
262 | if ( rs->GetMotifPositionId() == GetMotifPositionId(i) ) break; | |
263 | ixl += rs->GetNofPads(); | |
264 | } | |
265 | motifPosition->SetLowIndicesLimit(ixl, iyl); | |
266 | ||
267 | // High limit | |
268 | // | |
269 | AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType(); | |
270 | MpPair_t high | |
271 | = motifPosition->GetLowIndicesLimit() | |
272 | + AliMp::Pair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1); | |
273 | motifPosition->SetHighIndicesLimit(high); | |
274 | ||
275 | // No increment index needed (this is always the last element) | |
276 | return AliMp::PairFirst(indices); | |
277 | } | |
278 | ||
279 | //______________________________________________________________________________ | |
280 | void AliMpRowSegmentRSpecial::SetGlobalIndices(AliMpRow* rowBefore) | |
281 | { | |
282 | /// Set indices limits. | |
283 | /// The limits are defined as the limits of the smallest rectangle which | |
284 | /// includes all pads of this special row segment. | |
285 | ||
286 | // Get first motif position | |
287 | AliMpMotifPosition* firstMotifPosition | |
288 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(0)); | |
289 | ||
290 | // Low ix | |
291 | Int_t ixl = firstMotifPosition->GetLowLimitIx(); | |
292 | // We have to take the motif position limit | |
293 | // as it can overlap over more rows and the indices | |
294 | // of the right border of the precedent normal segment | |
295 | // differ from one row to another | |
296 | ||
297 | // High ix | |
298 | Int_t ixh = ixl + MaxNofPadsInRow() - 1; | |
299 | ||
300 | // Low iy | |
301 | Int_t iyl = AliMpConstants::StartPadIndex(); | |
302 | if (rowBefore) { | |
303 | //if (constPadSizeDirection == kY) { | |
304 | iyl = rowBefore->GetHighLimitIy()+1; | |
305 | //} | |
306 | /* | |
307 | else { | |
308 | AliMpVRowSegment* seg = rowBefore->FindRowSegment(ixl); | |
309 | AliMpMotifPosition* motPos = rowBefore->FindMotifPosition(seg, ixl); | |
310 | if (!motPos) | |
311 | Fatal("SetGlobalIndices", "Motif position in rowBefore not found."); | |
312 | iyl = motPos->GetHighLimitIy()+1; | |
313 | } | |
314 | */ | |
315 | } | |
316 | ||
317 | // High iy | |
318 | Int_t iyh = iyl + GetNofPadRows() - 1; | |
319 | ||
320 | SetLowIndicesLimit(ixl, iyl); | |
321 | SetHighIndicesLimit(ixh, iyh); | |
322 | } | |
323 | ||
324 |