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