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