]>
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: AliMpVRowSegmentSpecial.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $ |
ea4cae7a | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
ea4cae7a | 21 | // Class AliMpVRowSegmentSpecial |
22 | // ---------------------------- | |
23 | // Class describing a special row segment composed of the | |
24 | // pad rows. | |
dbe945cc | 25 | // Included in AliRoot: 2003/05/02 |
ea4cae7a | 26 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 27 | //----------------------------------------------------------------------------- |
ea4cae7a | 28 | |
ea4cae7a | 29 | #include "AliMpVRowSegmentSpecial.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 | ||
63ed9c6b | 39 | #include <Riostream.h> |
ea4cae7a | 40 | |
13985652 | 41 | /// \cond CLASSIMP |
42 | ClassImp(AliMpVRowSegmentSpecial) | |
43 | /// \endcond | |
44 | ||
f79c58a5 | 45 | #ifdef WITH_ROOT |
46 | const Int_t AliMpVRowSegmentSpecial::fgkMaxNofMotifPositionIds = 20; | |
47 | #endif | |
48 | ||
ea4cae7a | 49 | //______________________________________________________________________________ |
50 | AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial(AliMpRow* row, Double_t offsetX) | |
51 | : AliMpVRowSegment(), | |
52 | fRow(row), | |
53 | fOffsetX(offsetX), | |
54 | fPadRows(), | |
55 | fMotifs(), | |
56 | fMotifPositionIds() | |
f79c58a5 | 57 | #ifdef WITH_ROOT |
58 | ,fNofMotifPositionIds(0) | |
59 | #endif | |
ea4cae7a | 60 | { |
dee1d5f1 | 61 | /// Standard constructor |
ea4cae7a | 62 | } |
63 | ||
64 | //______________________________________________________________________________ | |
65 | AliMpVRowSegmentSpecial::AliMpVRowSegmentSpecial() | |
66 | : AliMpVRowSegment(), | |
67 | fRow(0), | |
68 | fOffsetX(0.), | |
69 | fPadRows(), | |
70 | fMotifs(), | |
71 | fMotifPositionIds() | |
f79c58a5 | 72 | #ifdef WITH_ROOT |
73 | ,fNofMotifPositionIds(0) | |
74 | #endif | |
ea4cae7a | 75 | { |
dee1d5f1 | 76 | /// Default constructor |
77 | ||
f79c58a5 | 78 | #ifdef WITH_ROOT |
79 | fMotifPositionIds.Set(fgkMaxNofMotifPositionIds); | |
80 | #endif | |
ea4cae7a | 81 | } |
82 | ||
83 | //______________________________________________________________________________ | |
84 | AliMpVRowSegmentSpecial::~AliMpVRowSegmentSpecial() | |
85 | { | |
dee1d5f1 | 86 | /// Destructor |
87 | ||
ea4cae7a | 88 | for (Int_t i=0; i<GetNofPadRows(); i++) |
89 | delete fPadRows[i]; | |
90 | } | |
91 | ||
92 | // | |
93 | // protected methods | |
94 | // | |
95 | ||
96 | //______________________________________________________________________________ | |
97 | AliMpPadRow* AliMpVRowSegmentSpecial::FindPadRow(Double_t y) const | |
98 | { | |
dee1d5f1 | 99 | /// Find the pad row in the given y coordinate. |
ea4cae7a | 100 | |
101 | Double_t lowBorder = fRow->LowBorderY(); | |
102 | Double_t highBorder = fRow->LowBorderY(); | |
103 | ||
104 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
105 | ||
106 | AliMpPadRow* padRow = GetPadRow(i); | |
107 | highBorder += 2.*padRow->HalfSizeY(); | |
108 | ||
109 | if ( y >= lowBorder && y <= highBorder) | |
110 | return padRow; | |
111 | ||
112 | lowBorder = highBorder; | |
113 | } | |
114 | ||
115 | return 0; | |
116 | } | |
117 | ||
118 | //______________________________________________________________________________ | |
119 | AliMpVPadRowSegment* | |
120 | AliMpVRowSegmentSpecial::FindPadRowSegment(Int_t motifPositionId) const | |
121 | { | |
dee1d5f1 | 122 | /// Find the most down pad row segment with this motifPositionId. |
ea4cae7a | 123 | |
124 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
125 | AliMpPadRow* padRow = GetPadRow(i); | |
126 | ||
127 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
128 | AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j); | |
129 | ||
130 | if (padRowSegment->GetMotifPositionId() == motifPositionId) | |
131 | return padRowSegment; | |
132 | } | |
133 | } | |
134 | return 0; | |
135 | } | |
136 | ||
137 | //______________________________________________________________________________ | |
138 | AliMpIntPair | |
139 | AliMpVRowSegmentSpecial::FindRelativeLowIndicesOf(Int_t motifPositionId) const | |
140 | { | |
dee1d5f1 | 141 | /// Return the lowest pad indices where the motif of the given position ID |
142 | /// exist in this segment. | |
ea4cae7a | 143 | |
144 | AliMpIntPair ans(0,1000); | |
145 | AliMpIntPair ans0 = ans; | |
146 | Int_t maxNofPadsX=0; | |
147 | ||
148 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
149 | AliMpPadRow* padRow = GetPadRow(i); | |
150 | ||
151 | Int_t nofPadsX=0; | |
152 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
153 | AliMpVPadRowSegment* padRowSegment = padRow->GetPadRowSegment(j); | |
154 | nofPadsX += padRowSegment->GetNofPads(); | |
155 | if (padRowSegment->GetMotifPositionId() == motifPositionId) { | |
156 | if (ans.GetFirst() < nofPadsX) ans.SetFirst(nofPadsX); | |
157 | if (ans.GetSecond()>i) ans.SetSecond(i); | |
158 | // ans.First = max (nof pads of this pos ID) | |
159 | // ans.Second = min of pad row number | |
160 | } | |
161 | } | |
162 | if (nofPadsX > maxNofPadsX) maxNofPadsX = nofPadsX; | |
163 | } | |
164 | if (ans == ans0) return AliMpIntPair::Invalid(); | |
165 | ||
166 | return AliMpIntPair(maxNofPadsX-ans.GetFirst(), ans.GetSecond()); | |
167 | } | |
168 | ||
169 | //______________________________________________________________________________ | |
170 | Int_t AliMpVRowSegmentSpecial::MaxNofPadsInRow() const | |
171 | { | |
dee1d5f1 | 172 | /// Return the maximum number of pads in this row segment along the X direction |
ea4cae7a | 173 | |
174 | Int_t maxNofPads = 0; | |
175 | ||
176 | for (Int_t i=0; i<GetNofPadRows(); i++){ | |
177 | Int_t nofPads = GetPadRow(i)->GetNofPads(); | |
178 | ||
179 | // Find maximum | |
180 | if (nofPads > maxNofPads) maxNofPads = nofPads; | |
181 | } | |
182 | ||
183 | return maxNofPads; | |
184 | } | |
185 | ||
186 | //______________________________________________________________________________ | |
187 | Bool_t AliMpVRowSegmentSpecial::HasMotif(const AliMpVMotif* motif) const | |
188 | { | |
dee1d5f1 | 189 | /// Return true if the specified motif is already in fMotifs vector, |
190 | /// returns false otherwise. | |
ea4cae7a | 191 | |
f79c58a5 | 192 | #ifdef WITH_STL |
ea4cae7a | 193 | for (UInt_t i=0; i<fMotifs.size(); i++) |
194 | if (fMotifs[i] == motif) return true; | |
f79c58a5 | 195 | #endif |
196 | ||
197 | #ifdef WITH_ROOT | |
198 | for (Int_t i=0; i<fMotifs.GetEntriesFast(); i++) | |
b166d013 | 199 | if (fMotifs[i] == (const TObject*)motif) return true; |
f79c58a5 | 200 | #endif |
ea4cae7a | 201 | |
202 | return false; | |
203 | } | |
204 | ||
205 | //______________________________________________________________________________ | |
206 | Int_t AliMpVRowSegmentSpecial::GetNofPadRows() const | |
207 | { | |
dee1d5f1 | 208 | /// Return number of pad rows. |
ea4cae7a | 209 | |
f79c58a5 | 210 | #ifdef WITH_STL |
ea4cae7a | 211 | return fPadRows.size(); |
f79c58a5 | 212 | #endif |
213 | ||
214 | #ifdef WITH_ROOT | |
215 | return fPadRows.GetEntriesFast(); | |
216 | #endif | |
ea4cae7a | 217 | } |
218 | ||
219 | //______________________________________________________________________________ | |
220 | AliMpPadRow* AliMpVRowSegmentSpecial::GetPadRow(Int_t i) const | |
221 | { | |
dee1d5f1 | 222 | /// Return number of pad rows. |
ea4cae7a | 223 | |
f79c58a5 | 224 | #ifdef WITH_STL |
ea4cae7a | 225 | return fPadRows[i]; |
f79c58a5 | 226 | #endif |
227 | ||
228 | #ifdef WITH_ROOT | |
229 | return (AliMpPadRow*)fPadRows[i]; | |
230 | #endif | |
ea4cae7a | 231 | } |
232 | ||
233 | // | |
234 | // public methods | |
235 | // | |
236 | ||
237 | //______________________________________________________________________________ | |
238 | void AliMpVRowSegmentSpecial::AddPadRow(AliMpPadRow* padRow) | |
239 | { | |
dee1d5f1 | 240 | /// Add a pad row. |
ea4cae7a | 241 | |
242 | padRow->SetOffsetX(fOffsetX); | |
243 | padRow->SetID(GetNofPadRows()); | |
f79c58a5 | 244 | |
245 | #ifdef WITH_STL | |
ea4cae7a | 246 | fPadRows.push_back(padRow); |
f79c58a5 | 247 | #endif |
248 | ||
249 | #ifdef WITH_ROOT | |
250 | fPadRows.Add(padRow); | |
251 | #endif | |
ea4cae7a | 252 | } |
253 | ||
254 | //______________________________________________________________________________ | |
255 | void AliMpVRowSegmentSpecial::UpdateMotifVector() | |
256 | { | |
dee1d5f1 | 257 | /// Add motifs associated with the pad row segments in the specified |
258 | /// pad row in the fMotifs vector. | |
ea4cae7a | 259 | |
260 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
261 | AliMpPadRow* padRow = GetPadRow(i); | |
262 | ||
263 | for (Int_t j=0; j<padRow->GetNofPadRowSegments(); j++) { | |
264 | AliMpVMotif* motif = padRow->GetPadRowSegment(j)->GetMotif(); | |
265 | ||
266 | if (!HasMotif(motif)) { | |
f79c58a5 | 267 | #ifdef WITH_STL |
ea4cae7a | 268 | fMotifs.push_back(motif); |
269 | fMotifPositionIds.push_back( | |
270 | padRow->GetPadRowSegment(j)->GetMotifPositionId()); | |
f79c58a5 | 271 | #endif |
272 | #ifdef WITH_ROOT | |
273 | fMotifs.Add(motif); | |
274 | ||
275 | // resize array if needed | |
276 | if (fNofMotifPositionIds<fgkMaxNofMotifPositionIds) | |
277 | fMotifPositionIds.Set(fMotifPositionIds.GetSize()+ | |
278 | fgkMaxNofMotifPositionIds); | |
279 | fMotifPositionIds.AddAt( | |
280 | padRow->GetPadRowSegment(j)->GetMotifPositionId(), | |
281 | fNofMotifPositionIds++); | |
282 | #endif | |
ea4cae7a | 283 | } |
284 | } | |
285 | } | |
286 | } | |
287 | ||
288 | //______________________________________________________________________________ | |
289 | Double_t AliMpVRowSegmentSpecial::HalfSizeY() const | |
290 | { | |
dee1d5f1 | 291 | /// Return the size in y of this row segment. |
ea4cae7a | 292 | |
293 | Double_t halfSizeY = 0.; | |
294 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
295 | halfSizeY += GetPadRow(i)->HalfSizeY(); | |
296 | } | |
297 | ||
298 | return halfSizeY; | |
299 | } | |
300 | ||
301 | //______________________________________________________________________________ | |
302 | AliMpVMotif* AliMpVRowSegmentSpecial::FindMotif(const TVector2& position) const | |
303 | { | |
dee1d5f1 | 304 | /// Return the motif of this row; |
ea4cae7a | 305 | |
306 | AliMpPadRow* padRow | |
307 | = FindPadRow(position.Y()); | |
308 | ||
309 | if (!padRow) return 0; | |
310 | ||
311 | AliMpVPadRowSegment* padRowSegment | |
312 | = padRow->FindPadRowSegment(position.X()); | |
313 | ||
314 | if (!padRowSegment) return 0; | |
315 | ||
316 | return padRowSegment->GetMotif(); | |
317 | } | |
318 | ||
319 | //______________________________________________________________________________ | |
320 | Int_t AliMpVRowSegmentSpecial::FindMotifPositionId(const TVector2& position) const | |
321 | { | |
dee1d5f1 | 322 | /// Return the motif position identified for the given |
323 | /// geometric position. | |
ea4cae7a | 324 | |
325 | AliMpPadRow* padRow | |
326 | = FindPadRow(position.Y()); | |
327 | ||
328 | if (!padRow) return 0; | |
329 | ||
330 | AliMpVPadRowSegment* padRowSegment | |
331 | = padRow->FindPadRowSegment(position.X()); | |
332 | ||
333 | if (!padRowSegment) return 0; | |
334 | ||
335 | return padRowSegment->GetMotifPositionId(); | |
336 | } | |
337 | ||
338 | //______________________________________________________________________________ | |
339 | Bool_t AliMpVRowSegmentSpecial::HasMotifPosition(Int_t motifPositionId) const | |
340 | { | |
dee1d5f1 | 341 | /// Return true if the motif specified with the given position identifier |
342 | /// is in this segment. | |
ea4cae7a | 343 | |
344 | if (FindPadRowSegment(motifPositionId)) | |
345 | return true; | |
346 | else | |
347 | return false; | |
348 | } | |
349 | ||
350 | //______________________________________________________________________________ | |
351 | TVector2 AliMpVRowSegmentSpecial::MotifCenter(Int_t motifPositionId) const | |
352 | { | |
dee1d5f1 | 353 | /// Return the coordinates of the motif specified with |
354 | /// the given position identifier. | |
ea4cae7a | 355 | |
356 | // Try to get the motif position from the motif map first | |
357 | AliMpMotifPosition* motifPosition | |
358 | = GetRow()->GetMotifMap()->FindMotifPosition(motifPositionId); | |
359 | if (motifPosition) return motifPosition->Position(); | |
360 | ||
361 | // Use slow method otherwise | |
362 | return MotifCenterSlow(motifPositionId); | |
363 | } | |
364 | ||
365 | //______________________________________________________________________________ | |
366 | TVector2 AliMpVRowSegmentSpecial::Dimensions() const | |
367 | { | |
dee1d5f1 | 368 | /// Return the halflengths in x, y of the row segment rectangular envelope. |
ea4cae7a | 369 | |
370 | Double_t x = 0.; | |
371 | Double_t y = 0.; | |
372 | for (Int_t i=0; i<GetNofPadRows(); i++) { | |
373 | AliMpPadRow* padRow = GetPadRow(i); | |
374 | ||
375 | // Add all pad rows y halfsizes | |
376 | y += padRow->HalfSizeY(); | |
377 | ||
378 | // Find the biggest pad rows x halfsize | |
379 | Double_t xx | |
380 | = (padRow->GetPadRowSegment(0)->RightBorderX() - | |
381 | padRow->GetPadRowSegment(padRow->GetNofPadRowSegments()-1)->LeftBorderX())/2.; | |
382 | if (xx > x) x = xx; | |
383 | } | |
384 | ||
385 | return TVector2(x, y); | |
386 | } | |
387 | ||
ea4cae7a | 388 | //______________________________________________________________________________ |
389 | AliMpRow* AliMpVRowSegmentSpecial::GetRow() const | |
390 | { | |
dee1d5f1 | 391 | /// Return the row.which this row segment belongs to. |
ea4cae7a | 392 | |
393 | return fRow; | |
394 | } | |
395 | ||
396 | //______________________________________________________________________________ | |
397 | Int_t AliMpVRowSegmentSpecial::GetNofMotifs() const | |
398 | { | |
dee1d5f1 | 399 | /// Return the number of different motifs present in this row segment. |
ea4cae7a | 400 | |
f79c58a5 | 401 | #ifdef WITH_STL |
ea4cae7a | 402 | return fMotifs.size(); |
f79c58a5 | 403 | #endif |
404 | #ifdef WITH_ROOT | |
405 | return fMotifs.GetEntriesFast(); | |
406 | #endif | |
ea4cae7a | 407 | } |
408 | ||
409 | //______________________________________________________________________________ | |
410 | AliMpVMotif* AliMpVRowSegmentSpecial::GetMotif(Int_t i) const | |
411 | { | |
dee1d5f1 | 412 | /// Return the i-th motif present in this row segment. |
ea4cae7a | 413 | |
f79c58a5 | 414 | #ifdef WITH_STL |
ea4cae7a | 415 | return fMotifs[i]; |
f79c58a5 | 416 | #endif |
417 | #ifdef WITH_ROOT | |
418 | return (AliMpVMotif*)fMotifs[i]; | |
419 | #endif | |
ea4cae7a | 420 | } |
421 | ||
422 | //______________________________________________________________________________ | |
423 | Int_t AliMpVRowSegmentSpecial::GetMotifPositionId(Int_t i) const | |
424 | { | |
dee1d5f1 | 425 | /// Return the i-th motif position Id present in this row segment. |
ea4cae7a | 426 | |
427 | return fMotifPositionIds[i]; | |
428 | } | |
429 |