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