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