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