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