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