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