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