]>
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: AliMpSector.cxx,v 1.14 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
19 | // | |
20 | // Class AliMpSector | |
21 | // ----------------- | |
22 | // Class describing the sector of the MUON chamber of station 1. | |
dbe945cc | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
25 | ||
5f91c9e8 | 26 | #include "AliMpSector.h" |
27 | #include "AliMpSectorPadIterator.h" | |
28 | #include "AliMpZone.h" | |
29 | #include "AliMpRow.h" | |
30 | #include "AliMpVRowSegment.h" | |
31 | #include "AliMpVMotif.h" | |
32 | #include "AliMpMotifMap.h" | |
33 | #include "AliMpIntPair.h" | |
34 | #include "AliMpConstants.h" | |
35 | ||
2c605e66 | 36 | #include <Riostream.h> |
37 | ||
13985652 | 38 | /// \cond CLASSIMP |
5f91c9e8 | 39 | ClassImp(AliMpSector) |
13985652 | 40 | /// \endcond |
5f91c9e8 | 41 | |
42 | //_____________________________________________________________________________ | |
d1d8330f | 43 | AliMpSector::AliMpSector(const TString& id, Int_t nofZones, Int_t nofRows, |
14b7b896 | 44 | AliMpDirection direction, const TVector2& offset) |
5006ec94 | 45 | : TNamed("Sector", ""), |
5f91c9e8 | 46 | fID(id), |
14b7b896 | 47 | fOffset(offset), |
5f91c9e8 | 48 | fZones(), |
49 | fRows(), | |
13e7956b | 50 | fMotifMap(0), |
5f91c9e8 | 51 | fDirection(direction), |
f9a3ff6a | 52 | fMinPadDimensions(TVector2(1.e6, 1.e6)), |
53 | fMaxPadIndices(AliMpIntPair::Invalid()), | |
54 | fNofPads(0) | |
5f91c9e8 | 55 | { |
dee1d5f1 | 56 | /// Standard constructor |
57 | ||
642b74ab | 58 | AliDebugStream(1) << "this = " << this << endl; |
59 | ||
5006ec94 | 60 | fMotifMap = new AliMpMotifMap(true); |
61 | //fMotifMap = new AliMpMotifMap(); | |
5f91c9e8 | 62 | |
f79c58a5 | 63 | #ifdef WITH_STL |
5f91c9e8 | 64 | for (Int_t izone = 0; izone<nofZones; izone++) |
65 | fZones.push_back(new AliMpZone(izone+1)); | |
66 | ||
67 | for (Int_t irow = 0; irow<nofRows; irow++) | |
68 | fRows.push_back(new AliMpRow(irow, fMotifMap)); | |
f79c58a5 | 69 | #endif |
70 | ||
71 | #ifdef WITH_ROOT | |
72 | for (Int_t izone = 0; izone<nofZones; izone++) | |
73 | fZones.Add(new AliMpZone(izone+1)); | |
74 | ||
75 | for (Int_t irow = 0; irow<nofRows; irow++) | |
76 | fRows.Add(new AliMpRow(irow, fMotifMap)); | |
77 | #endif | |
5f91c9e8 | 78 | } |
79 | ||
80 | //_____________________________________________________________________________ | |
81 | AliMpSector::AliMpSector() | |
5006ec94 | 82 | : TNamed(), |
5f91c9e8 | 83 | fID(""), |
84 | fOffset(TVector2(0., 0.)), | |
85 | fZones(), | |
86 | fRows(), | |
87 | fMotifMap(0), | |
88 | fDirection(kX), | |
f9a3ff6a | 89 | fMinPadDimensions(TVector2(0., 0.)), |
90 | fMaxPadIndices(AliMpIntPair::Invalid()), | |
91 | fNofPads(0) | |
5f91c9e8 | 92 | { |
dee1d5f1 | 93 | /// Default constructor |
642b74ab | 94 | |
95 | AliDebugStream(1) << "this = " << this << endl; | |
5f91c9e8 | 96 | } |
97 | ||
98 | //_____________________________________________________________________________ | |
dee1d5f1 | 99 | AliMpSector::~AliMpSector() |
100 | { | |
101 | /// Destructor | |
102 | ||
642b74ab | 103 | AliDebugStream(1) << "this = " << this << endl; |
104 | ||
5f91c9e8 | 105 | // deletes |
106 | for (Int_t izone = 0; izone<GetNofZones(); izone++) | |
107 | delete fZones[izone]; | |
108 | ||
109 | for (Int_t irow = 0; irow<GetNofRows(); irow++) | |
110 | delete fRows[irow]; | |
111 | ||
112 | delete fMotifMap; | |
113 | } | |
114 | ||
115 | // | |
116 | // private methods | |
117 | // | |
118 | ||
119 | //_____________________________________________________________________________ | |
120 | AliMpVPadIterator* AliMpSector::CreateIterator() const | |
121 | { | |
dee1d5f1 | 122 | /// Create sector pad iterator |
123 | ||
5f91c9e8 | 124 | return new AliMpSectorPadIterator(this); |
125 | } | |
126 | ||
127 | ||
128 | //_____________________________________________________________________________ | |
129 | AliMpVRowSegment* AliMpSector::FindRowSegment(const TVector2& position) const | |
130 | { | |
dee1d5f1 | 131 | /// Find the row segment in the specified position. \n |
132 | /// Return if no motif is found. | |
5f91c9e8 | 133 | |
134 | // Find row | |
135 | AliMpRow* row = FindRow(position); | |
136 | ||
137 | if (!row) return 0; | |
138 | ||
139 | // Find the row segment and return its motif | |
140 | AliMpVRowSegment* rowSegment = row->FindRowSegment(position.X()); | |
141 | ||
142 | return rowSegment; | |
143 | } | |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | void AliMpSector::SetRowOffsets() | |
147 | { | |
dee1d5f1 | 148 | /// For each row check consitency of the row segments |
149 | /// and calculate the row offset. | |
5f91c9e8 | 150 | |
151 | Double_t offset = fOffset.Y(); | |
152 | ||
f79c58a5 | 153 | for (Int_t irow=0; irow<GetNofRows(); irow++) |
5f91c9e8 | 154 | offset = GetRow(irow)->SetOffsetY(offset); |
155 | } | |
156 | ||
157 | //_____________________________________________________________________________ | |
158 | void AliMpSector::SetMotifPositions() | |
159 | { | |
dee1d5f1 | 160 | /// Create motif positions objects and fills them in the motif map. |
5f91c9e8 | 161 | |
f79c58a5 | 162 | for (Int_t i=0; i<GetNofRows(); i++) |
5f91c9e8 | 163 | GetRow(i)->SetMotifPositions(); |
164 | } | |
165 | ||
166 | //_____________________________________________________________________________ | |
167 | void AliMpSector::SetGlobalIndices() | |
168 | { | |
dee1d5f1 | 169 | /// Set the indices limits to all indexed elements |
170 | /// (row, row segment, motif positions). | |
5f91c9e8 | 171 | |
172 | AliMpIntPair indices(0,0); | |
173 | AliMpRow* rowBefore=0; | |
f79c58a5 | 174 | for (Int_t i=0; i<GetNofRows(); i++) { |
5f91c9e8 | 175 | GetRow(i)->SetGlobalIndices(fDirection, rowBefore); |
176 | rowBefore = GetRow(i); | |
177 | } | |
178 | } | |
179 | ||
180 | //_____________________________________________________________________________ | |
181 | void AliMpSector::SetMinPadDimensions() | |
182 | { | |
dee1d5f1 | 183 | /// Set the minimal pad dimensions. |
5f91c9e8 | 184 | |
185 | for (Int_t i=1; i<GetNofZones()+1; i++) { | |
186 | TVector2 padDimensions = GetZone(i)->GetPadDimensions(); | |
187 | ||
188 | if ( fDirection == kX && | |
189 | padDimensions.Y() > 0. && padDimensions.Y() < fMinPadDimensions.Y() || | |
190 | fDirection == kY && | |
191 | padDimensions.X() > 0. && padDimensions.X() < fMinPadDimensions.X()) | |
192 | ||
193 | fMinPadDimensions = padDimensions; | |
194 | } | |
195 | } | |
196 | ||
f9a3ff6a | 197 | //_____________________________________________________________________________ |
198 | void AliMpSector::SetMaxPadIndices() | |
199 | { | |
200 | /// Set maximum pad indices in x, y | |
201 | ||
202 | if ( fMaxPadIndices != AliMpIntPair::Invalid() ) return; | |
203 | ||
204 | Int_t maxIndexInX = 0; | |
205 | Int_t maxIndexInY = 0; | |
206 | for (Int_t i=0; i<GetNofRows(); i++) { | |
207 | ||
208 | Int_t ixh = GetRow(i)->GetHighIndicesLimit().GetFirst(); | |
209 | if ( ixh > maxIndexInX ) maxIndexInX = ixh; | |
210 | ||
211 | Int_t iyh = GetRow(i)->GetHighIndicesLimit().GetSecond(); | |
212 | if ( iyh > maxIndexInY ) maxIndexInY = iyh; | |
213 | } | |
214 | ||
215 | fMaxPadIndices = AliMpIntPair(maxIndexInX, maxIndexInY); | |
216 | } | |
217 | ||
218 | ||
219 | //_____________________________________________________________________________ | |
220 | void AliMpSector::SetNofPads() | |
221 | { | |
222 | /// Set the total number of pads | |
223 | ||
224 | fNofPads = fMotifMap->CalculateNofPads(); | |
225 | } | |
226 | ||
5f91c9e8 | 227 | // |
228 | // public methods | |
229 | // | |
230 | ||
231 | //_____________________________________________________________________________ | |
232 | void AliMpSector::SetRowSegmentOffsets() | |
233 | { | |
dee1d5f1 | 234 | /// For all rows set the offset to all row segments. |
5f91c9e8 | 235 | |
f79c58a5 | 236 | for (Int_t irow=0; irow<GetNofRows(); irow++) |
5f91c9e8 | 237 | GetRow(irow)->SetRowSegmentOffsets(fOffset); |
238 | } | |
239 | ||
240 | //_____________________________________________________________________________ | |
241 | void AliMpSector::Initialize() | |
242 | { | |
dee1d5f1 | 243 | /// Make needed settings after sector is read from |
244 | /// data files. | |
5f91c9e8 | 245 | |
246 | SetRowOffsets(); | |
247 | SetMotifPositions(); | |
248 | SetGlobalIndices(); | |
249 | SetMinPadDimensions(); | |
f9a3ff6a | 250 | SetMaxPadIndices(); |
251 | SetNofPads(); | |
5f91c9e8 | 252 | } |
253 | ||
254 | //_____________________________________________________________________________ | |
255 | void AliMpSector::PrintGeometry() const | |
256 | { | |
dee1d5f1 | 257 | /// Print the positions of rows, rows segments |
5f91c9e8 | 258 | |
259 | for (Int_t i=0; i<GetNofRows(); i++) { | |
260 | AliMpRow* row = GetRow(i); | |
261 | ||
262 | cout << "ROW " << row->GetID() | |
263 | << " center Y " << row->Position().Y() << endl; | |
264 | ||
265 | for (Int_t j=0; j<row->GetNofRowSegments(); j++) { | |
266 | AliMpVRowSegment* rowSegment = row->GetRowSegment(j); | |
267 | ||
268 | cout << " ROW Segment " << j | |
269 | << " borders " | |
270 | << rowSegment->LeftBorderX() << " " | |
271 | << rowSegment->RightBorderX() | |
272 | << " x-size " | |
273 | << 2*rowSegment->Dimensions().X() << " " | |
274 | << endl; | |
275 | } | |
276 | } | |
277 | } | |
278 | ||
279 | ||
280 | //_____________________________________________________________________________ | |
281 | AliMpRow* AliMpSector::FindRow(const TVector2& position) const | |
282 | { | |
dee1d5f1 | 283 | /// Find the row for the specified y position. \n |
284 | /// If y is on border the lowest row is returned. | |
5f91c9e8 | 285 | |
286 | Double_t y = position.Y(); | |
287 | ||
f79c58a5 | 288 | #ifdef WITH_STL |
289 | for (Int_t i=0; i<GetNofRows(); i++) { | |
5f91c9e8 | 290 | if ( y >= fRows[i]->LowBorderY() && y <= fRows[i]->UpperBorderY()) |
291 | return fRows[i]; | |
292 | } | |
f79c58a5 | 293 | #endif |
294 | ||
295 | #ifdef WITH_ROOT | |
296 | for (Int_t i=0; i<GetNofRows(); i++) { | |
297 | if ( y >= ((AliMpRow*)fRows[i])->LowBorderY() && | |
298 | y <= ((AliMpRow*)fRows[i])->UpperBorderY()) | |
299 | return (AliMpRow*)fRows[i]; | |
300 | } | |
301 | #endif | |
5f91c9e8 | 302 | |
303 | return 0; | |
304 | } | |
305 | ||
306 | //_____________________________________________________________________________ | |
307 | AliMpVMotif* AliMpSector::FindMotif(const TVector2& position) const | |
308 | { | |
dee1d5f1 | 309 | /// Find the motif in the specified position. \n |
310 | /// Return 0 if no motif is found. | |
5f91c9e8 | 311 | |
312 | // Find the row segment | |
313 | AliMpVRowSegment* rowSegment = FindRowSegment(position); | |
314 | ||
315 | if (!rowSegment) return 0; | |
316 | ||
317 | // Find motif | |
318 | return rowSegment->FindMotif(position); | |
319 | } | |
5f91c9e8 | 320 | //_____________________________________________________________________________ |
321 | Int_t AliMpSector::FindMotifPositionId(const TVector2& position) const | |
322 | { | |
dee1d5f1 | 323 | /// Find the motif position ID in the specified position. \n |
324 | /// Return 0 if no motif is found. | |
325 | ||
5f91c9e8 | 326 | // Find the row segment |
327 | AliMpVRowSegment* rowSegment = FindRowSegment(position); | |
328 | ||
329 | if (!rowSegment) return 0; | |
330 | ||
331 | // Find motif position ID | |
332 | return rowSegment->FindMotifPositionId(position); | |
333 | } | |
334 | ||
335 | //_____________________________________________________________________________ | |
336 | AliMpRow* AliMpSector::FindRow(Int_t motifPositionId) const | |
337 | { | |
dee1d5f1 | 338 | /// Find the row with the the specified motif position. \n |
339 | /// Return 0 if no row is found. | |
5f91c9e8 | 340 | |
341 | AliMpVRowSegment* segment = FindRowSegment(motifPositionId); | |
342 | ||
343 | if (segment) return segment->GetRow(); | |
344 | ||
345 | return 0; | |
346 | } | |
347 | ||
348 | //_____________________________________________________________________________ | |
349 | AliMpVRowSegment* AliMpSector::FindRowSegment(Int_t motifPositionId) const | |
350 | { | |
dee1d5f1 | 351 | /// Find the row segment with the the specified motif position. \n |
352 | /// Return 0 if no row segment is found. | |
5f91c9e8 | 353 | |
f79c58a5 | 354 | for (Int_t irow=0; irow<GetNofRows(); irow++) { |
355 | ||
356 | #ifdef WITH_STL | |
5f91c9e8 | 357 | AliMpRow* row = fRows[irow]; |
f79c58a5 | 358 | #endif |
359 | #ifdef WITH_ROOT | |
360 | AliMpRow* row = (AliMpRow*)fRows[irow]; | |
361 | #endif | |
5f91c9e8 | 362 | |
363 | for (Int_t iseg=0; iseg<row->GetNofRowSegments(); iseg++) { | |
364 | AliMpVRowSegment* segment = row->GetRowSegment(iseg); | |
365 | if (segment->HasMotifPosition(motifPositionId)) return segment; | |
366 | } | |
367 | } | |
368 | ||
369 | return 0; | |
370 | } | |
371 | ||
372 | //_____________________________________________________________________________ | |
373 | TVector2 AliMpSector::FindPosition(Int_t motifPositionId) const | |
374 | { | |
dee1d5f1 | 375 | /// Find the position of the motif specified by its position Id. \n |
376 | /// Return 0 if no row segment is found. | |
5f91c9e8 | 377 | |
378 | AliMpVRowSegment* segment = FindRowSegment(motifPositionId); | |
379 | ||
380 | if (!segment) { | |
2c605e66 | 381 | AliWarningStream() << "Given motifPositionId not found." << endl; |
5f91c9e8 | 382 | return TVector2(); |
383 | } | |
384 | ||
385 | return segment->MotifCenter(motifPositionId); | |
386 | } | |
387 | ||
388 | //_____________________________________________________________________________ | |
389 | AliMpZone* AliMpSector::FindZone(const TVector2& padDimensions) const | |
390 | { | |
dee1d5f1 | 391 | /// Find the zone with specified padDimensions. |
5f91c9e8 | 392 | |
393 | for (Int_t i=0; i<GetNofZones(); i++) { | |
394 | AliMpZone* zone = GetZone(i+1); | |
395 | if (AliMpConstants::IsEqual(padDimensions, zone->GetPadDimensions())) | |
396 | return zone; | |
397 | } | |
398 | ||
399 | // Return 0 if not found | |
400 | return 0; | |
401 | } | |
402 | ||
403 | //_____________________________________________________________________________ | |
404 | TVector2 AliMpSector::Position() const | |
405 | { | |
dee1d5f1 | 406 | /// Return the sector offset. |
5f91c9e8 | 407 | |
408 | return fOffset; | |
409 | } | |
410 | ||
411 | ||
412 | //_____________________________________________________________________________ | |
413 | TVector2 AliMpSector::Dimensions() const | |
414 | { | |
dee1d5f1 | 415 | /// Return the maximum halflengths in x, y. |
5f91c9e8 | 416 | |
417 | Double_t x = 0.; | |
418 | Double_t y = 0.; | |
419 | for (Int_t i=0; i<GetNofRows(); i++) { | |
420 | ||
f79c58a5 | 421 | #ifdef WITH_STL |
5f91c9e8 | 422 | // take the largest x row dimension |
423 | if (fRows[i]->Dimensions().X() > x) | |
424 | x = fRows[i]->Dimensions().X(); | |
425 | ||
426 | // add all rows y dimensions | |
427 | y += fRows[i]->Dimensions().Y(); | |
f79c58a5 | 428 | #endif |
429 | ||
430 | #ifdef WITH_ROOT | |
431 | // take the largest x row dimension | |
432 | if ( ((AliMpRow*)fRows[i])->Dimensions().X() > x) | |
433 | x = ((AliMpRow*)fRows[i])->Dimensions().X(); | |
434 | ||
435 | // add all rows y dimensions | |
436 | y += ((AliMpRow*)fRows[i])->Dimensions().Y(); | |
437 | #endif | |
5f91c9e8 | 438 | } |
439 | ||
440 | return TVector2(x, y); | |
441 | } | |
442 | ||
443 | //_____________________________________________________________________________ | |
444 | Int_t AliMpSector::GetNofZones() const | |
445 | { | |
dee1d5f1 | 446 | /// Return the number of zones. |
5f91c9e8 | 447 | |
f79c58a5 | 448 | #ifdef WITH_STL |
5f91c9e8 | 449 | return fZones.size(); |
f79c58a5 | 450 | #endif |
451 | ||
452 | #ifdef WITH_ROOT | |
453 | return fZones.GetEntriesFast(); | |
454 | #endif | |
5f91c9e8 | 455 | } |
456 | ||
457 | //_____________________________________________________________________________ | |
458 | AliMpZone* AliMpSector::GetZone(Int_t zoneID) const | |
459 | { | |
dee1d5f1 | 460 | /// Return zone with specified ID. |
5f91c9e8 | 461 | |
462 | if (zoneID < 1 || zoneID > GetNofZones()) { | |
2c605e66 | 463 | AliWarningStream() << "Index outside range" << endl; |
5f91c9e8 | 464 | return 0; |
465 | } | |
466 | ||
f79c58a5 | 467 | #ifdef WITH_STL |
5f91c9e8 | 468 | return fZones[zoneID-1]; |
f79c58a5 | 469 | #endif |
470 | ||
471 | #ifdef WITH_ROOT | |
472 | return (AliMpZone*)fZones[zoneID-1]; | |
473 | #endif | |
5f91c9e8 | 474 | } |
475 | ||
476 | //_____________________________________________________________________________ | |
477 | Int_t AliMpSector::GetNofRows() const | |
478 | { | |
dee1d5f1 | 479 | /// Return the number of rows. |
5f91c9e8 | 480 | |
f79c58a5 | 481 | #ifdef WITH_STL |
5f91c9e8 | 482 | return fRows.size(); |
f79c58a5 | 483 | #endif |
484 | ||
485 | #ifdef WITH_ROOT | |
486 | return fRows.GetEntriesFast(); | |
487 | #endif | |
5f91c9e8 | 488 | } |
489 | ||
490 | //_____________________________________________________________________________ | |
491 | AliMpRow* AliMpSector::GetRow(Int_t rowID) const | |
492 | { | |
dee1d5f1 | 493 | /// Return row with specified ID. |
5f91c9e8 | 494 | |
495 | if (rowID < 0 || rowID >= GetNofRows()) { | |
2c605e66 | 496 | AliWarningStream() << "Index outside range" << endl; |
5f91c9e8 | 497 | return 0; |
498 | } | |
499 | ||
f79c58a5 | 500 | #ifdef WITH_STL |
5f91c9e8 | 501 | return fRows[rowID]; |
f79c58a5 | 502 | #endif |
503 | ||
504 | #ifdef WITH_ROOT | |
505 | return (AliMpRow*)fRows[rowID]; | |
506 | #endif | |
5f91c9e8 | 507 | } |
c9da0af9 | 508 | |
f9a3ff6a | 509 | //_____________________________________________________________________________ |
510 | AliMpPlaneType | |
511 | AliMpSector::GetPlaneType() const | |
512 | { | |
513 | /// Return the plane type | |
514 | ||
515 | return GetDirection()==kY ? kBendingPlane : kNonBendingPlane; | |
516 | } | |
517 | ||
518 | //_____________________________________________________________________________ | |
519 | void | |
520 | AliMpSector::GetAllMotifPositionsIDs(TArrayI& ecn) const | |
521 | { | |
522 | /// Return the array of all motif positions IDs | |
523 | ||
524 | fMotifMap->GetAllMotifPositionsIDs(ecn); | |
525 | } | |
526 | ||
c9da0af9 | 527 | //_____________________________________________________________________________ |
528 | void | |
529 | AliMpSector::Print(Option_t* opt) const | |
530 | { | |
f9a3ff6a | 531 | /// Print the map of motifs |
532 | ||
533 | cout << "Sector," << PlaneTypeName(GetPlaneType()) << endl; | |
c9da0af9 | 534 | fMotifMap->Print(opt); |
535 | } |