]>
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: AliMpRowSegment.cxx,v 1.10 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpRowSegment |
22 | // --------------------- | |
23 | // Class describing a row segment composed of the | |
24 | // the identic motifs. | |
dbe945cc | 25 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 26 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
5f91c9e8 | 28 | |
5f91c9e8 | 29 | #include "AliMpRowSegment.h" |
30 | #include "AliMpRow.h" | |
31 | #include "AliMpVMotif.h" | |
32 | #include "AliMpMotifType.h" | |
33 | #include "AliMpMotifTypePadIterator.h" | |
34 | #include "AliMpMotifMap.h" | |
35 | #include "AliMpMotifPosition.h" | |
580c28fd | 36 | #include "AliMpConstants.h" |
5f91c9e8 | 37 | |
97186a3f | 38 | #include "AliLog.h" |
39 | ||
2c605e66 | 40 | #include <TMath.h> |
41 | #include <Riostream.h> | |
42 | ||
13985652 | 43 | /// \cond CLASSIMP |
5f91c9e8 | 44 | ClassImp(AliMpRowSegment) |
13985652 | 45 | /// \endcond |
5f91c9e8 | 46 | |
47 | //_____________________________________________________________________________ | |
48 | AliMpRowSegment::AliMpRowSegment(AliMpRow* row, AliMpVMotif* motif, | |
49 | AliMpIntPair padOffset, | |
50 | Int_t nofMotifs, | |
51 | Int_t motifPositionId, Int_t motifPositionDId) | |
52 | : AliMpVRowSegment(), | |
53 | fNofMotifs(nofMotifs), | |
54 | fPadOffset(padOffset), | |
55 | fOffset(TVector2()), | |
56 | fRow(row), | |
57 | fMotif(motif), | |
58 | fMotifPositionId(motifPositionId), | |
59 | fMotifPositionDId(motifPositionDId) | |
60 | { | |
dee1d5f1 | 61 | /// Standard constructor |
62 | ||
5f91c9e8 | 63 | // Keep pad offset in the low indices limits |
64 | SetLowIndicesLimit(padOffset); | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliMpRowSegment::AliMpRowSegment() | |
69 | : AliMpVRowSegment(), | |
70 | fNofMotifs(0), | |
71 | fPadOffset(AliMpIntPair()), | |
72 | fOffset(TVector2()), | |
73 | fRow(0), | |
74 | fMotif(0), | |
75 | fMotifPositionId(0), | |
76 | fMotifPositionDId(0) | |
77 | { | |
dee1d5f1 | 78 | /// Default constructor |
5f91c9e8 | 79 | } |
80 | ||
81 | //_____________________________________________________________________________ | |
dee1d5f1 | 82 | AliMpRowSegment::~AliMpRowSegment() |
83 | { | |
84 | /// Destructor | |
5f91c9e8 | 85 | } |
86 | ||
87 | // | |
88 | // private methods | |
89 | // | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | Double_t AliMpRowSegment::FirstMotifCenterX() const | |
93 | { | |
dee1d5f1 | 94 | /// Return the x coordinate of the first motif center |
95 | /// in the global coordinate system. | |
5f91c9e8 | 96 | |
97 | return fOffset.X(); | |
98 | } | |
99 | ||
100 | //_____________________________________________________________________________ | |
101 | Double_t AliMpRowSegment::LastMotifCenterX() const | |
102 | { | |
dee1d5f1 | 103 | /// Return the x coordinate of the last motif center |
104 | /// in the global coordinate system. | |
5f91c9e8 | 105 | |
106 | return fOffset.X() + 2.*(fNofMotifs-1)*fMotif->Dimensions().X(); | |
107 | } | |
108 | ||
109 | //_____________________________________________________________________________ | |
110 | Double_t AliMpRowSegment::MotifCenterX(Int_t motifPositionId) const | |
111 | { | |
dee1d5f1 | 112 | /// Return the x coordinate of the motif specified with |
113 | /// the given position identifier. | |
5f91c9e8 | 114 | |
115 | // Check if x is in the row segment range | |
116 | if (! HasMotifPosition(motifPositionId)) { | |
2c605e66 | 117 | AliErrorStream() << "Outside row segment region" << endl; |
5f91c9e8 | 118 | return 0; |
119 | } | |
120 | ||
121 | // Find the position number in the segment | |
122 | Int_t num = (motifPositionId - fMotifPositionId) * fMotifPositionDId; | |
123 | ||
124 | return fOffset.X() + num*(fMotif->Dimensions().X() * 2.0); | |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | Double_t AliMpRowSegment::MotifCenterY(Int_t motifPositionId) const | |
129 | { | |
dee1d5f1 | 130 | /// Return the y coordinate of the motif specified with |
131 | /// the given position identifier. | |
5f91c9e8 | 132 | |
133 | // Check if x is in the row segment range | |
134 | if (! HasMotifPosition(motifPositionId)) { | |
2c605e66 | 135 | AliErrorStream() << "Outside row segment region" << endl; |
5f91c9e8 | 136 | return 0; |
137 | } | |
138 | ||
139 | return GetRow()->Position().Y() + fOffset.Y(); | |
140 | } | |
141 | ||
142 | //_____________________________________________________________________________ | |
143 | Bool_t AliMpRowSegment::IsInside(const TVector2& position, Bool_t warn) const | |
144 | { | |
dee1d5f1 | 145 | /// Check if the position is inside some motif of this row segment. |
5f91c9e8 | 146 | |
147 | Double_t minY = GetRow()->Position().Y() + fOffset.Y() - fMotif->Dimensions().Y(); | |
148 | Double_t maxY = GetRow()->Position().Y() + fOffset.Y() + fMotif->Dimensions().Y(); | |
149 | ||
150 | if ( position.X() < LeftBorderX() || position.X() > RightBorderX() || | |
151 | position.Y() < minY || position.Y() > maxY ) { | |
152 | ||
2c605e66 | 153 | if (warn) |
154 | AliWarningStream() << "Outside row segment region" << endl; | |
5f91c9e8 | 155 | return false; |
156 | } | |
157 | else | |
158 | return true; | |
159 | } | |
160 | ||
161 | // | |
162 | // public methods | |
163 | // | |
164 | ||
165 | //_____________________________________________________________________________ | |
166 | Double_t AliMpRowSegment::LeftBorderX() const | |
167 | { | |
dee1d5f1 | 168 | /// Return the x coordinate of the left row segment border |
169 | /// in the global coordinate system. | |
5f91c9e8 | 170 | |
171 | return FirstMotifCenterX() - fMotif->Dimensions().X(); | |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________ | |
175 | Double_t AliMpRowSegment::RightBorderX() const | |
176 | { | |
dee1d5f1 | 177 | /// Return the x coordinate of the right row segment border |
178 | /// in the global coordinate system. | |
5f91c9e8 | 179 | |
180 | return LastMotifCenterX() + fMotif->Dimensions().X(); | |
181 | } | |
182 | ||
183 | //_____________________________________________________________________________ | |
184 | Double_t AliMpRowSegment::HalfSizeY() const | |
185 | { | |
dee1d5f1 | 186 | /// Return the size in y of this row segment. |
5f91c9e8 | 187 | |
188 | return fMotif->Dimensions().Y() + fOffset.Y(); | |
189 | } | |
190 | ||
191 | //_____________________________________________________________________________ | |
192 | AliMpVMotif* AliMpRowSegment::FindMotif(const TVector2& position) const | |
193 | { | |
dee1d5f1 | 194 | /// Return the motif of this row; |
5f91c9e8 | 195 | |
196 | if (IsInside(position, false)) | |
197 | return fMotif; | |
198 | else | |
199 | return 0; | |
200 | } | |
201 | ||
202 | //_____________________________________________________________________________ | |
203 | Int_t AliMpRowSegment::FindMotifPositionId(const TVector2& position) const | |
204 | { | |
dee1d5f1 | 205 | /// Return the motif position identified for the given |
206 | /// geometric position. | |
5f91c9e8 | 207 | |
208 | if (!IsInside(position, false)) return 0; | |
209 | ||
210 | // Find the position number in the segment | |
211 | Int_t num | |
212 | = Int_t((position.X() - LeftBorderX()) / (fMotif->Dimensions().X() * 2.0)); | |
213 | ||
214 | // Calculate the position Id | |
215 | return fMotifPositionId + num*fMotifPositionDId; | |
216 | } | |
217 | ||
218 | //_____________________________________________________________________________ | |
219 | Bool_t AliMpRowSegment::HasMotifPosition(Int_t motifPositionId) const | |
220 | { | |
dee1d5f1 | 221 | /// Return true if the motif specified with the given position identifier |
222 | /// is in this segment. | |
5f91c9e8 | 223 | |
224 | Int_t minId = TMath::Min(fMotifPositionId, | |
225 | fMotifPositionId + (fNofMotifs-1)*fMotifPositionDId); | |
226 | Int_t maxId = TMath::Max(fMotifPositionId, | |
227 | fMotifPositionId + (fNofMotifs-1)*fMotifPositionDId); | |
228 | ||
229 | if (motifPositionId >= minId && motifPositionId <= maxId) { | |
230 | return true; | |
231 | } | |
232 | else | |
233 | return false; | |
234 | } | |
235 | ||
236 | //_____________________________________________________________________________ | |
237 | TVector2 AliMpRowSegment::MotifCenter(Int_t motifPositionId) const | |
238 | { | |
dee1d5f1 | 239 | /// Return the coordinates of the motif specified with |
240 | /// the given position identifier. | |
5f91c9e8 | 241 | |
242 | return TVector2(MotifCenterX(motifPositionId), MotifCenterY(motifPositionId)); | |
243 | } | |
244 | ||
245 | //_____________________________________________________________________________ | |
246 | TVector2 AliMpRowSegment::Position() const | |
247 | { | |
dee1d5f1 | 248 | /// Return the position of the row segment centre. |
5f91c9e8 | 249 | |
250 | Double_t x = (LeftBorderX() + RightBorderX())/2.; | |
251 | Double_t y = GetRow()->Position().Y(); | |
252 | ||
253 | return TVector2(x, y); | |
254 | } | |
255 | ||
256 | ||
257 | //_____________________________________________________________________________ | |
258 | TVector2 AliMpRowSegment::Dimensions() const | |
259 | { | |
dee1d5f1 | 260 | /// Return the halflengths of the row segment in x, y. |
5f91c9e8 | 261 | // --- |
262 | ||
263 | Double_t x = (RightBorderX() - LeftBorderX())/2.; | |
264 | Double_t y = GetRow()->Dimensions().Y(); | |
265 | ||
266 | return TVector2(x, y); | |
267 | } | |
268 | ||
269 | //_____________________________________________________________________________ | |
270 | void AliMpRowSegment::SetOffset(const TVector2& offset) | |
271 | { | |
dee1d5f1 | 272 | /// Calculate offset from given offset and |
273 | /// stored offset in pads. | |
5f91c9e8 | 274 | |
275 | AliMpMotifTypePadIterator iter(fMotif->GetMotifType()); | |
276 | iter.First(); | |
277 | AliMpIntPair localPos = iter.CurrentItem().GetIndices(); | |
278 | ||
279 | Double_t offsetX | |
280 | = offset.X() | |
281 | + 2.*fPadOffset.GetFirst() * fMotif->GetPadDimensions(localPos).X() | |
282 | + fMotif->Dimensions().X(); | |
283 | ||
284 | Double_t offsetY | |
285 | = offset.Y() | |
286 | + fPadOffset.GetSecond() * fMotif->GetPadDimensions(localPos).Y(); | |
287 | ||
288 | fOffset = TVector2(offsetX, offsetY); | |
289 | } | |
290 | ||
580c28fd | 291 | #include <Riostream.h> |
5f91c9e8 | 292 | //_____________________________________________________________________________ |
580c28fd | 293 | void AliMpRowSegment::SetGlobalIndices(AliMpRow* /*rowBefore*/) |
5f91c9e8 | 294 | { |
dee1d5f1 | 295 | /// Set global indices limits. |
5f91c9e8 | 296 | |
580c28fd | 297 | // The low/high indices limits has to be taken as the highest/lowest from all |
298 | // motif positions | |
299 | Int_t ixl = 9999; | |
300 | Int_t iyl = 9999; | |
301 | Int_t ixh = AliMpConstants::StartPadIndex(); | |
302 | Int_t iyh = AliMpConstants::StartPadIndex(); | |
303 | ||
304 | for (Int_t i=0; i<GetNofMotifs(); i++) { | |
305 | ||
306 | AliMpMotifPosition* mPos | |
307 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i)); | |
308 | ||
309 | // Check if the motif positions has the limits set | |
310 | if ( !mPos->HasValidIndices() ) | |
311 | Fatal("SetGlobalIndices", | |
312 | "Indices of motif positions have to be set first."); | |
5f91c9e8 | 313 | |
580c28fd | 314 | if ( mPos->GetLowIndicesLimit().GetFirst() < ixl ) |
315 | ixl = mPos->GetLowIndicesLimit().GetFirst(); | |
316 | ||
317 | if ( mPos->GetLowIndicesLimit().GetSecond() < iyl ) | |
318 | iyl = mPos->GetLowIndicesLimit().GetSecond(); | |
319 | ||
320 | if ( mPos->GetHighIndicesLimit().GetFirst() > ixh ) | |
321 | ixh = mPos->GetHighIndicesLimit().GetFirst(); | |
322 | ||
323 | if ( mPos->GetHighIndicesLimit().GetSecond() > iyh ) | |
324 | iyh = mPos->GetHighIndicesLimit().GetSecond(); | |
325 | } | |
326 | ||
327 | SetLowIndicesLimit(AliMpIntPair(ixl, iyl)); | |
328 | SetHighIndicesLimit(AliMpIntPair(ixh, iyh)); | |
5f91c9e8 | 329 | } |
330 | ||
331 | //_____________________________________________________________________________ | |
ffb47139 | 332 | Int_t AliMpRowSegment::SetIndicesToMotifPosition(Int_t i, |
333 | const AliMpIntPair& indices) | |
5f91c9e8 | 334 | { |
dee1d5f1 | 335 | /// Set global indices to i-th motif position and returns next index |
336 | /// in x. | |
5f91c9e8 | 337 | |
338 | // Get motif position | |
339 | AliMpMotifPosition* motifPosition | |
340 | = GetRow()->GetMotifMap()->FindMotifPosition(GetMotifPositionId(i)); | |
341 | ||
342 | // Low limit | |
343 | AliMpIntPair low = indices + AliMpIntPair(0, GetLowIndicesLimit().GetSecond()); | |
344 | motifPosition->SetLowIndicesLimit(low); | |
345 | ||
346 | // High limit | |
347 | AliMpMotifType* motifType = motifPosition->GetMotif()->GetMotifType(); | |
348 | AliMpIntPair high | |
349 | = motifPosition->GetLowIndicesLimit() | |
350 | + AliMpIntPair(motifType->GetNofPadsX()-1, motifType->GetNofPadsY()-1); | |
351 | motifPosition->SetHighIndicesLimit(high); | |
352 | ||
353 | // Return next index in x | |
354 | return high.GetFirst()+1; | |
355 | // return motifType->GetNofPadsX(); | |
356 | } | |
357 | ||
358 | ||
359 | //_____________________________________________________________________________ | |
360 | AliMpRow* AliMpRowSegment::GetRow() const | |
361 | { | |
dee1d5f1 | 362 | /// Return the row.which this row segment belongs to. |
5f91c9e8 | 363 | |
364 | return fRow; | |
365 | } | |
366 | ||
367 | //_____________________________________________________________________________ | |
368 | Int_t AliMpRowSegment::GetNofMotifs() const | |
369 | { | |
dee1d5f1 | 370 | /// Return number of motifs in this this row segment. |
5f91c9e8 | 371 | |
372 | return fNofMotifs; | |
373 | } | |
374 | ||
375 | //_____________________________________________________________________________ | |
376 | Int_t AliMpRowSegment::GetMotifPositionId(Int_t i) const | |
377 | { | |
dee1d5f1 | 378 | /// Return number of motifs in this this row segment. |
5f91c9e8 | 379 | |
380 | return fMotifPositionId + i*fMotifPositionDId; | |
381 | } | |
382 | ||
383 | //_____________________________________________________________________________ | |
ffb47139 | 384 | AliMpVMotif* AliMpRowSegment::GetMotif(Int_t /*i*/) const |
5f91c9e8 | 385 | { |
dee1d5f1 | 386 | /// Return the motif of this row segment. |
5f91c9e8 | 387 | |
388 | return fMotif; | |
389 | } |