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