]>
Commit | Line | Data |
---|---|---|
1a1fdef7 | 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 | **************************************************************************/ | |
1a1fdef7 | 15 | /* $Id$ */ |
09b6c804 | 16 | /** |
17 | * @file AliFMDGeometry.cxx | |
18 | * @author Christian Holm Christensen <cholm@nbi.dk> | |
19 | * @date Mon Mar 27 12:40:37 2006 | |
20 | * @brief Geometry mananger for the FMD | |
21 | */ | |
1a1fdef7 | 22 | //____________________________________________________________________ |
23 | // | |
24 | // Forward Multiplicity Detector based on Silicon wafers. | |
25 | // | |
26 | // This class is a singleton that handles the geometry parameters of | |
27 | // the FMD detectors. | |
28 | // | |
29 | // The actual code is done by various separate classes. Below is | |
30 | // diagram showing the relationship between the various FMD classes | |
31 | // that handles the geometry | |
32 | // | |
33 | // +------------+ | |
34 | // +- | AliFMDRing | | |
35 | // 2 | +------------+ | |
36 | // +----------------+<>--+ | | |
37 | // | AliFMDGeometry | ^ | |
38 | // +----------------+<>--+ V 1..2 | |
39 | // 3 | +----------------+ | |
40 | // +-| AliFMDDetector | | |
41 | // +----------------+ | |
42 | // ^ | |
43 | // | | |
44 | // +-------------+-------------+ | |
45 | // | | | | |
46 | // +---------+ +---------+ +---------+ | |
47 | // | AliFMD1 | | AliFMD2 | | AliFMD3 | | |
48 | // +---------+ +---------+ +---------+ | |
49 | // | |
50 | // | |
51 | // * AliFMDRing | |
52 | // This class contains all stuff needed to do with a ring. It's | |
53 | // used by the AliFMDDetector objects to instantise inner and | |
54 | // outer rings. The AliFMDRing objects are shared by the | |
55 | // AliFMDDetector objects, and owned by the AliFMDv1 object. | |
56 | // | |
57 | // * AliFMD1, AliFMD2, and AliFMD3 | |
58 | // These are specialisation of AliFMDDetector, that contains the | |
59 | // particularities of each of the sub-detector system. It is | |
60 | // envisioned that the classes should also define the support | |
61 | // volumes and material for each of the detectors. | |
62 | // | |
63 | // | |
64 | #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H | |
65 | #include "AliFMDRing.h" // ALIFMDRING_H | |
66 | #include "AliFMD1.h" // ALIFMD1_H | |
67 | #include "AliFMD2.h" // ALIFMD2_H | |
68 | #include "AliFMD3.h" // ALIFMD2_H | |
69 | #include "AliRecPoint.h" // ALIRECPOINT_H | |
f95a63c4 | 70 | #include "AliFMDDebug.h" // ALILOG_H |
1a1fdef7 | 71 | #include <TVector3.h> // ROOT_TVector3 |
02a27b50 | 72 | // #include <TMatrix.h> // ROOT_TMatrix |
73 | // #include <TParticle.h> // ROOT_TParticle | |
1a1fdef7 | 74 | #include <Riostream.h> |
54e415a8 | 75 | #include "AliFMDGeometryBuilder.h" |
02a27b50 | 76 | // #include <TArrayI.h> |
54e415a8 | 77 | #include <TGeoManager.h> |
78 | #include <TGeoVolume.h> | |
79 | #include <TGeoNode.h> | |
75609cab | 80 | #include <TMath.h> |
54e415a8 | 81 | static Int_t FindNodeDepth(const char* name, const char* volname); |
54e415a8 | 82 | |
1a1fdef7 | 83 | |
84 | //==================================================================== | |
85 | ClassImp(AliFMDGeometry) | |
86 | #if 0 | |
87 | ; // This is here to keep Emacs for indenting the next line | |
88 | #endif | |
89 | ||
90 | //____________________________________________________________________ | |
91 | AliFMDGeometry* AliFMDGeometry::fgInstance = 0; | |
92 | ||
93 | //____________________________________________________________________ | |
94 | AliFMDGeometry* | |
95 | AliFMDGeometry::Instance() | |
96 | { | |
09b6c804 | 97 | // |
98 | // singleton access | |
99 | // | |
100 | // Return: | |
101 | // Singleton | |
102 | // | |
103 | if (!fgInstance) fgInstance = new AliFMDGeometry("FMD"); | |
1a1fdef7 | 104 | return fgInstance; |
105 | } | |
106 | ||
107 | //____________________________________________________________________ | |
108 | AliFMDGeometry::AliFMDGeometry() | |
09b6c804 | 109 | : AliGeometry(), |
110 | fIsInitialized(kFALSE), | |
111 | fInner(0), | |
112 | fOuter(0), | |
113 | fFMD1(0), | |
114 | fFMD2(0), | |
115 | fFMD3(0), | |
116 | fUseFMD1(kTRUE), | |
117 | fUseFMD2(kTRUE), | |
118 | fUseFMD3(kTRUE), | |
119 | fIsInitTrans(kFALSE), | |
120 | fBuilder(0), | |
121 | fDetectorOff(0), | |
122 | fModuleOff(0), | |
123 | fRingOff(0), | |
124 | fSectorOff(0), | |
125 | fActive(2), | |
126 | fDetailed(kTRUE), | |
127 | fUseAssembly(kTRUE) | |
128 | { | |
129 | // PROTECTED | |
130 | // | |
131 | // CTOR | |
132 | // | |
133 | } | |
134 | ||
135 | //____________________________________________________________________ | |
136 | AliFMDGeometry::AliFMDGeometry(const char* ) | |
a1f80595 | 137 | : AliGeometry("FMD", "Forward multiplicity"), |
b5ee4425 | 138 | fIsInitialized(kFALSE), |
139 | fInner(0), | |
140 | fOuter(0), | |
141 | fFMD1(0), | |
142 | fFMD2(0), | |
143 | fFMD3(0), | |
09b6c804 | 144 | fUseFMD1(kTRUE), |
145 | fUseFMD2(kTRUE), | |
146 | fUseFMD3(kTRUE), | |
352482dc | 147 | fIsInitTrans(kFALSE), |
b5ee4425 | 148 | fBuilder(0), |
149 | fDetectorOff(0), | |
150 | fModuleOff(0), | |
151 | fRingOff(0), | |
152 | fSectorOff(0), | |
153 | fActive(2), | |
09b6c804 | 154 | fDetailed(kTRUE), |
155 | fUseAssembly(kTRUE) | |
1a1fdef7 | 156 | { |
69b696b9 | 157 | // PROTECTED |
09b6c804 | 158 | // |
159 | // CTOR | |
160 | // | |
161 | // Parameters: | |
162 | // name Not used | |
163 | // | |
064fa304 | 164 | fInner = new AliFMDRing('I'); |
165 | fOuter = new AliFMDRing('O'); | |
166 | fFMD1 = new AliFMD1(fInner); | |
167 | fFMD2 = new AliFMD2(fInner, fOuter); | |
168 | fFMD3 = new AliFMD3(fInner, fOuter); | |
169 | fIsInitialized = kFALSE; | |
170 | fActive.Reset(-1); | |
1a1fdef7 | 171 | } |
172 | ||
69b696b9 | 173 | //____________________________________________________________________ |
174 | AliFMDGeometry::AliFMDGeometry(const AliFMDGeometry& other) | |
175 | : AliGeometry(other), | |
176 | fIsInitialized(other.fIsInitialized), | |
177 | fInner(other.fInner), | |
178 | fOuter(other.fOuter), | |
179 | fFMD1(other.fFMD1), | |
180 | fFMD2(other.fFMD2), | |
181 | fFMD3(other.fFMD3), | |
182 | fUseFMD1(other.fUseFMD1), | |
183 | fUseFMD2(other.fUseFMD2), | |
bf000c32 | 184 | fUseFMD3(other.fUseFMD3), |
352482dc | 185 | fIsInitTrans(other.fIsInitTrans), |
b5ee4425 | 186 | fBuilder(other.fBuilder), |
187 | fDetectorOff(other.fDetectorOff), | |
188 | fModuleOff(other.fModuleOff), | |
189 | fRingOff(other.fRingOff), | |
190 | fSectorOff(other.fSectorOff), | |
bf000c32 | 191 | fActive(other.fActive), |
54e415a8 | 192 | fDetailed(other.fDetailed), |
193 | fUseAssembly(other.fUseAssembly) | |
69b696b9 | 194 | { |
195 | // PROTECTED | |
09b6c804 | 196 | // |
197 | // Copy CTOR | |
198 | // | |
199 | // Parameters: | |
200 | // other To copy from | |
201 | // | |
69b696b9 | 202 | } |
203 | ||
204 | ||
205 | ||
206 | //____________________________________________________________________ | |
207 | AliFMDGeometry& | |
208 | AliFMDGeometry::operator=(const AliFMDGeometry& other) | |
209 | { | |
210 | // PROTECTED | |
09b6c804 | 211 | // |
69b696b9 | 212 | // Assignment operator |
09b6c804 | 213 | // |
214 | // Parameters: | |
215 | // other To assig from | |
216 | // Return: | |
217 | // reference to this. | |
218 | // | |
69b696b9 | 219 | fUseFMD1 = other.fUseFMD1; |
220 | fUseFMD2 = other.fUseFMD2; | |
221 | fUseFMD3 = other.fUseFMD3; | |
222 | fFMD1 = other.fFMD1; | |
223 | fFMD2 = other.fFMD2; | |
224 | fFMD3 = other.fFMD3; | |
225 | fInner = other.fInner; | |
226 | fOuter = other.fOuter; | |
227 | fIsInitialized = other.fIsInitialized; | |
228 | return *this; | |
229 | } | |
230 | ||
1a1fdef7 | 231 | //____________________________________________________________________ |
232 | void | |
233 | AliFMDGeometry::Init() | |
234 | { | |
09b6c804 | 235 | // |
69b696b9 | 236 | // Initialize the the singleton if not done so already |
09b6c804 | 237 | // |
1a1fdef7 | 238 | if (fIsInitialized) return; |
239 | fInner->Init(); | |
240 | fOuter->Init(); | |
241 | fFMD1->Init(); | |
242 | fFMD2->Init(); | |
243 | fFMD3->Init(); | |
244 | } | |
245 | ||
bf000c32 | 246 | //____________________________________________________________________ |
247 | void | |
352482dc | 248 | AliFMDGeometry::InitTransformations(Bool_t force) |
bf000c32 | 249 | { |
09b6c804 | 250 | // |
02a27b50 | 251 | // Find all local <-> global transforms |
09b6c804 | 252 | // |
352482dc | 253 | if (force) fIsInitTrans = kFALSE; |
254 | if (fIsInitTrans) return; | |
bf000c32 | 255 | if (!gGeoManager) { |
256 | AliError("No TGeoManager defined"); | |
257 | return; | |
258 | } | |
352482dc | 259 | AliFMDDebug(1, ("Initialising transforms for FMD geometry")); |
bf000c32 | 260 | if (fFMD1) fFMD1->InitTransformations(); |
261 | if (fFMD2) fFMD2->InitTransformations(); | |
262 | if (fFMD3) fFMD3->InitTransformations(); | |
352482dc | 263 | fIsInitTrans = kTRUE; |
bf000c32 | 264 | } |
265 | ||
54e415a8 | 266 | //____________________________________________________________________ |
267 | void | |
268 | AliFMDGeometry::Build() | |
269 | { | |
09b6c804 | 270 | // |
271 | // Make the geometry. This delegates to AliFMDGeometryBuilder | |
272 | // | |
54e415a8 | 273 | if (!fBuilder) fBuilder = new AliFMDGeometryBuilder(fDetailed); |
274 | fBuilder->SetDetailed(fDetailed); | |
275 | fBuilder->UseAssembly(fUseAssembly); | |
276 | fBuilder->Exec(); | |
277 | } | |
278 | ||
279 | //____________________________________________________________________ | |
280 | void | |
281 | AliFMDGeometry::SetActive(Int_t* active, Int_t n) | |
282 | { | |
09b6c804 | 283 | // |
02a27b50 | 284 | // Set active volumes |
09b6c804 | 285 | // |
286 | // Parameters: | |
287 | // active Active volume id array | |
288 | // n elements of @a active | |
289 | // | |
54e415a8 | 290 | fActive.Set(n); |
088f8e79 | 291 | for (Int_t i = 0; i < n; i++) { |
f95a63c4 | 292 | AliFMDDebug(1, ("Active vol id # %d: %d", i, active[i])); |
088f8e79 | 293 | fActive[i] = active[i]; |
294 | } | |
54e415a8 | 295 | } |
296 | ||
297 | //____________________________________________________________________ | |
298 | void | |
299 | AliFMDGeometry::AddActive(Int_t active) | |
300 | { | |
09b6c804 | 301 | // |
02a27b50 | 302 | // Add an active volume |
09b6c804 | 303 | // |
304 | // Parameters: | |
305 | // id Register volume @a id to be active | |
306 | // | |
307 | // | |
54e415a8 | 308 | Int_t n = fActive.fN; |
309 | fActive.Set(n+1); | |
310 | fActive[n] = active; | |
311 | } | |
312 | ||
313 | //____________________________________________________________________ | |
314 | Bool_t | |
315 | AliFMDGeometry::IsActive(Int_t vol) const | |
316 | { | |
09b6c804 | 317 | // |
318 | // Check if volume @a vol is marked as active | |
319 | // | |
320 | // Parameters: | |
321 | // vol Volume ID | |
322 | // Return: | |
323 | // @c true if @a vol is declared active | |
324 | // | |
54e415a8 | 325 | for (Int_t i = 0; i < fActive.fN; i++) |
326 | if (fActive[i] == vol) return kTRUE; | |
327 | return kFALSE; | |
328 | } | |
54e415a8 | 329 | |
1a1fdef7 | 330 | //____________________________________________________________________ |
331 | AliFMDDetector* | |
332 | AliFMDGeometry::GetDetector(Int_t i) const | |
333 | { | |
09b6c804 | 334 | // |
335 | // Get description of a sub-detector | |
336 | // | |
337 | // Parameters: | |
338 | // i Sub-detector # | |
339 | // Return: | |
340 | // Description of sub-detector, or 0 | |
341 | // | |
1a1fdef7 | 342 | switch (i) { |
343 | case 1: return fUseFMD1 ? static_cast<AliFMDDetector*>(fFMD1) : 0; | |
344 | case 2: return fUseFMD2 ? static_cast<AliFMDDetector*>(fFMD2) : 0; | |
345 | case 3: return fUseFMD3 ? static_cast<AliFMDDetector*>(fFMD3) : 0; | |
346 | } | |
347 | return 0; | |
348 | } | |
349 | ||
350 | //____________________________________________________________________ | |
351 | AliFMDRing* | |
352 | AliFMDGeometry::GetRing(Char_t i) const | |
353 | { | |
09b6c804 | 354 | // |
355 | // Get description of a ring, i should be one of 'I' or 'O' (case | |
69b696b9 | 356 | // insensitive). If an invalid parameter is passed, 0 (NULL) is |
09b6c804 | 357 | // returned. |
358 | // | |
359 | // Parameters: | |
360 | // i Ring id | |
361 | // Return: | |
362 | // Description of ring, or 0 | |
363 | // | |
1a1fdef7 | 364 | switch (i) { |
365 | case 'I': | |
366 | case 'i': return fInner; | |
367 | case 'O': | |
368 | case 'o': return fOuter; | |
369 | } | |
370 | return 0; | |
371 | } | |
372 | ||
373 | //____________________________________________________________________ | |
374 | void | |
375 | AliFMDGeometry::Enable(Int_t i) | |
376 | { | |
09b6c804 | 377 | // |
378 | // Enable the ith detector | |
379 | // | |
380 | // Parameters: | |
381 | // i IF true, enable sub-detector @a i | |
382 | // | |
1a1fdef7 | 383 | switch (i) { |
384 | case 1: fUseFMD1 = kTRUE; break; | |
385 | case 2: fUseFMD2 = kTRUE; break; | |
386 | case 3: fUseFMD3 = kTRUE; break; | |
387 | } | |
388 | } | |
389 | ||
390 | //____________________________________________________________________ | |
391 | void | |
392 | AliFMDGeometry::Disable(Int_t i) | |
393 | { | |
09b6c804 | 394 | // |
395 | // Disable the ith detector | |
396 | // | |
397 | // Parameters: | |
398 | // i IF true, disable sub-detector @a i | |
399 | // | |
1a1fdef7 | 400 | switch (i) { |
401 | case 1: fUseFMD1 = kFALSE; break; | |
402 | case 2: fUseFMD2 = kFALSE; break; | |
403 | case 3: fUseFMD3 = kFALSE; break; | |
404 | } | |
405 | } | |
406 | ||
407 | //____________________________________________________________________ | |
408 | void | |
409 | AliFMDGeometry::Detector2XYZ(UShort_t detector, | |
69b696b9 | 410 | Char_t ring, |
411 | UShort_t sector, | |
412 | UShort_t strip, | |
413 | Double_t& x, | |
414 | Double_t& y, | |
415 | Double_t& z) const | |
1a1fdef7 | 416 | { |
09b6c804 | 417 | // |
418 | // Translate detector coordinates (detector, ring, sector, strip) | |
419 | // to spatial coordinates (x, y, z) in the master reference frame | |
420 | // of ALICE. The member function uses the transformations | |
421 | // previously obtained from the TGeoManager. | |
422 | // | |
423 | // Parameters: | |
424 | // detector Detector number | |
425 | // ring Ring id | |
426 | // sector Sector number | |
427 | // strip Strip number | |
428 | // x On return, X coordinate | |
429 | // y On return, Y coordinate | |
430 | // z On return, Z coordinate | |
431 | // | |
1a1fdef7 | 432 | AliFMDDetector* det = GetDetector(detector); |
bf000c32 | 433 | if (!det) { |
434 | AliWarning(Form("Unknown detector %d", detector)); | |
435 | return; | |
436 | } | |
1a1fdef7 | 437 | det->Detector2XYZ(ring, sector, strip, x, y, z); |
438 | } | |
439 | ||
54e415a8 | 440 | //____________________________________________________________________ |
441 | Bool_t | |
442 | AliFMDGeometry::XYZ2Detector(Double_t x, | |
443 | Double_t y, | |
444 | Double_t z, | |
445 | UShort_t& detector, | |
446 | Char_t& ring, | |
447 | UShort_t& sector, | |
448 | UShort_t& strip) const | |
449 | { | |
09b6c804 | 450 | // |
451 | // Translate spatial coordinates (x,y,z) in the master reference | |
452 | // frame of ALICE to the detector coordinates (detector, ring, | |
453 | // sector, strip). Note, that if this method is to be used in | |
454 | // reconstruction or the like, then the input z-coordinate should | |
455 | // be corrected for the events interactions points z-coordinate, | |
456 | // like | |
457 | // @code | |
54e415a8 | 458 | // geom->XYZ2Detector(x,y,z-ipz,d,r,s,t); |
09b6c804 | 459 | // @endcode |
460 | // | |
461 | // Parameters: | |
462 | // x X coordinate | |
463 | // y Y coordinate | |
464 | // z Z coordinate | |
465 | // detector On return, Detector number | |
466 | // ring On return, Ring id | |
467 | // sector On return, Sector number | |
468 | // strip On return, Strip number | |
469 | // Return: | |
470 | // @c false of (@a x, @a y, @a z) is not within this | |
471 | // detector. | |
472 | // | |
54e415a8 | 473 | AliFMDDetector* det = 0; |
474 | detector = 0; | |
475 | for (int i = 1; i <= 3; i++) { | |
476 | det = GetDetector(i); | |
477 | if (!det) continue; | |
478 | if (det->XYZ2Detector(x, y, z, ring, sector, strip)) { | |
479 | detector = det->GetId(); | |
480 | return kTRUE; | |
481 | } | |
482 | } | |
483 | return kFALSE; | |
484 | } | |
485 | ||
75609cab | 486 | //____________________________________________________________________ |
487 | Bool_t | |
488 | AliFMDGeometry::XYZ2REtaPhiTheta(Double_t x, Double_t y, | |
489 | Double_t z, | |
490 | Double_t& r, Double_t& eta, | |
491 | Double_t& phi, Double_t& theta) | |
492 | { | |
493 | ||
75609cab | 494 | // |
09b6c804 | 495 | // Service function to convert Cartisean XYZ to r, eta, phi, and theta. |
496 | // | |
75609cab | 497 | // Note, that the z input should be corrected for the vertex location |
498 | // if needed. | |
75609cab | 499 | // |
09b6c804 | 500 | // Parameters: |
501 | // x Cartisean X coordinate | |
502 | // y Cartisean Y coordinate | |
503 | // z Cartisean Z coordinate | |
504 | // r On return, the radius | |
505 | // eta On return, the pseudo-rapidity | |
506 | // phi On return, the azimuthal angle | |
507 | // theta On return, the polar angle; | |
508 | // | |
75609cab | 509 | // Return: |
09b6c804 | 510 | // kTRUE on success, kFALSE in case of problems |
511 | // | |
75609cab | 512 | if (x == 0 && y == 0 && z == 0) return kFALSE; |
513 | ||
514 | // Correct for vertex offset. | |
515 | phi = TMath::ATan2(y, x); | |
516 | r = TMath::Sqrt(y * y + x * x); | |
517 | theta = TMath::ATan2(r, z); | |
518 | eta = -TMath::Log(TMath::Tan(theta / 2)); | |
519 | ||
520 | return kTRUE; | |
521 | } | |
522 | ||
1a1fdef7 | 523 | |
524 | //____________________________________________________________________ | |
525 | void | |
526 | AliFMDGeometry::GetGlobal(const AliRecPoint* p, | |
527 | TVector3& pos, | |
e8d02863 | 528 | TMatrixF& /* mat */) const |
1a1fdef7 | 529 | { |
09b6c804 | 530 | // |
531 | // Get global coordinates cooresponding to a rec point. | |
532 | // | |
533 | // Parameters: | |
534 | // p Reconstructed point. | |
535 | // pos On return, the position | |
536 | // mat On return, the material at @a post | |
537 | // | |
1a1fdef7 | 538 | GetGlobal(p, pos); |
539 | } | |
540 | ||
541 | //____________________________________________________________________ | |
542 | void | |
543 | AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const | |
544 | { | |
09b6c804 | 545 | // |
546 | // Get global coordinates cooresponding to a rec point. | |
547 | // | |
548 | // Parameters: | |
549 | // p Reconstructed point. | |
550 | // pos On return, the position | |
551 | // | |
69b696b9 | 552 | // FIXME: Implement this function to work with outer rings too. |
1a1fdef7 | 553 | Double_t x, y, z; |
554 | TVector3 local; | |
555 | p->GetLocalPosition(local); | |
556 | UShort_t detector = UShort_t(local.X()); | |
557 | UShort_t sector = UShort_t(local.Y()); | |
558 | UShort_t strip = UShort_t(local.Z()); | |
559 | Detector2XYZ(detector, 'I', sector, strip, x, y, z); | |
560 | pos.SetXYZ(x, y, z); | |
561 | } | |
562 | ||
563 | //____________________________________________________________________ | |
564 | Bool_t | |
565 | AliFMDGeometry::Impact(const TParticle* /* particle */) const | |
566 | { | |
09b6c804 | 567 | // |
568 | // Check if particle will hit an active detector element. | |
569 | // | |
570 | // @todo implement this function | |
571 | // | |
572 | // Parameters: | |
573 | // particle Track | |
574 | // Return: | |
575 | // @c true if @a particle will hit this detector | |
576 | // | |
1a1fdef7 | 577 | return kFALSE; |
578 | } | |
579 | ||
9de78b35 | 580 | //____________________________________________________________________ |
581 | void | |
582 | AliFMDGeometry::SetAlignableVolumes() const | |
583 | { | |
09b6c804 | 584 | // |
585 | // Declare alignable volumes | |
586 | // | |
9de78b35 | 587 | for (Int_t d = 1; d <= 3; d++) |
588 | if (GetDetector(d)) GetDetector(d)->SetAlignableVolumes(); | |
589 | } | |
590 | ||
591 | ||
54e415a8 | 592 | //____________________________________________________________________ |
593 | void | |
594 | AliFMDGeometry::ExtractGeomInfo() | |
595 | { | |
596 | // Check the volume depth of some nodes, get the active volume | |
597 | // numbers, and so forth. | |
598 | // | |
599 | // TODO: Here, we should actually also get the parameters of the | |
600 | // shapes, like the verticies of the polygon shape that makes up the | |
601 | // silicon sensor, the strip pitch, the ring radii, the z-positions, | |
602 | // and so on - that is, all the geometric information we need for | |
603 | // futher processing, such as simulation, digitization, | |
604 | // reconstruction, etc. | |
53a1201d | 605 | Int_t detectorDepth = FindNodeDepth("F1MT_1", "ALIC"); |
606 | Int_t ringDepth = FindNodeDepth(Form("FITV_%d", int('I')), "ALIC"); | |
607 | Int_t moduleDepth = FindNodeDepth("FIBH_0", "ALIC"); | |
608 | Int_t sectorDepth = FindNodeDepth("FISC_1", "ALIC"); | |
609 | fActive.Set(0); | |
54e415a8 | 610 | fActive.Reset(-1); |
f95a63c4 | 611 | AliFMDDebug(1, ("Geometry depths:\n" |
54e415a8 | 612 | " Sector: %d\n" |
613 | " Module: %d\n" | |
614 | " Ring: %d\n" | |
615 | " Detector: %d", | |
616 | sectorDepth, moduleDepth, ringDepth, detectorDepth)); | |
617 | if (sectorDepth < 0 && moduleDepth < 0) { | |
618 | fDetailed = kFALSE; | |
619 | fSectorOff = -1; | |
620 | fModuleOff = -1; | |
621 | fRingOff = 0; | |
622 | fDetectorOff = (ringDepth - detectorDepth); | |
623 | TGeoVolume* actiVol = gGeoManager->GetVolume("FIAC"); | |
624 | TGeoVolume* actoVol = gGeoManager->GetVolume("FOAC"); | |
625 | if (actiVol) AddActive(actiVol->GetNumber()); | |
626 | if (actiVol) AddActive(actoVol->GetNumber()); | |
627 | } | |
628 | else if (sectorDepth < 0) { | |
629 | fDetailed = kFALSE; | |
630 | fSectorOff = -1; | |
631 | fModuleOff = 1; | |
632 | fRingOff = (moduleDepth - ringDepth) + 1; | |
633 | fDetectorOff = (moduleDepth - detectorDepth) + 1; | |
634 | TGeoVolume* modiVol = gGeoManager->GetVolume("FIMO"); | |
635 | TGeoVolume* modoVol = gGeoManager->GetVolume("FOMO"); | |
636 | if (modiVol) AddActive(modiVol->GetNumber()); | |
637 | if (modoVol) AddActive(modoVol->GetNumber()); | |
638 | } | |
639 | else { | |
640 | Int_t stripDepth = FindNodeDepth("FIST_1", "ALIC"); | |
641 | fDetailed = kTRUE; | |
642 | fSectorOff = (stripDepth - sectorDepth); | |
643 | fModuleOff = (moduleDepth >= 0 ? (stripDepth - moduleDepth) : -1); | |
644 | fRingOff = (stripDepth - ringDepth); | |
645 | fDetectorOff = (stripDepth - detectorDepth ); | |
646 | TGeoVolume* striVol = gGeoManager->GetVolume("FIST"); | |
647 | TGeoVolume* stroVol = gGeoManager->GetVolume("FOST"); | |
648 | if (striVol) AddActive(striVol->GetNumber()); | |
649 | if (stroVol) AddActive(stroVol->GetNumber()); | |
650 | } | |
f95a63c4 | 651 | AliFMDDebug(1, ("Geometry offsets:\n" |
54e415a8 | 652 | " Sector: %d\n" |
653 | " Module: %d\n" | |
654 | " Ring: %d\n" | |
655 | " Detector: %d", | |
656 | fSectorOff, fModuleOff, fRingOff, fDetectorOff)); | |
657 | } | |
658 | ||
659 | ||
660 | //____________________________________________________________________ | |
661 | static Int_t | |
662 | CheckNodes(TGeoNode* node, const char* name, Int_t& lvl) | |
663 | { | |
664 | // If there's no node here. | |
665 | if (!node) return -1; | |
666 | // Check if it this one | |
667 | TString sname(name); | |
668 | if (sname == node->GetName()) return lvl; | |
669 | ||
670 | // Check if the node is an immediate daugther | |
671 | TObjArray* nodes = node->GetNodes(); | |
672 | if (!nodes) return -1; | |
673 | // Increase the level, and search immediate sub nodes. | |
674 | lvl++; | |
675 | TGeoNode* found = static_cast<TGeoNode*>(nodes->FindObject(name)); | |
676 | if (found) return lvl; | |
677 | ||
678 | // Check the sub node, if any of their sub-nodes match. | |
679 | for (Int_t i = 0; i < nodes->GetEntries(); i++) { | |
680 | TGeoNode* sub = static_cast<TGeoNode*>(nodes->At(i)); | |
681 | if (!sub) continue; | |
682 | // Recurive check | |
683 | if (CheckNodes(sub, name, lvl) >= 0) return lvl; | |
684 | } | |
685 | // If not found, decrease the level | |
686 | lvl--; | |
687 | return -1; | |
688 | } | |
689 | //____________________________________________________________________ | |
690 | Int_t | |
691 | FindNodeDepth(const char* name, const char* volname) | |
692 | { | |
02a27b50 | 693 | // Find the depth of a node |
54e415a8 | 694 | TGeoVolume* vol = gGeoManager->GetVolume(volname); |
695 | if (!vol) { | |
696 | std::cerr << "No top volume defined" << std::endl; | |
697 | return -1; | |
698 | } | |
53a1201d | 699 | |
700 | TGeoIterator next(vol); | |
701 | TGeoNode* node = 0; | |
702 | TString sName(name); | |
703 | while ((node = next())) { | |
53a1201d | 704 | if (sName == node->GetName()) { |
2af4b50b | 705 | //std::cout << "Found node " << node->GetName() << " at level " |
706 | // << next.GetLevel() << std::endl; | |
53a1201d | 707 | return next.GetLevel(); |
708 | } | |
709 | } | |
710 | return -1; | |
711 | #if 0 | |
54e415a8 | 712 | TObjArray* nodes = vol->GetNodes(); |
713 | if (!nodes) { | |
714 | std::cerr << "No nodes in top volume" << std::endl; | |
715 | return -1; | |
716 | } | |
717 | TIter next(nodes); | |
718 | TGeoNode* node = 0; | |
719 | Int_t lvl = 0; | |
720 | while ((node = static_cast<TGeoNode*>(next()))) | |
721 | if (CheckNodes(node, name, lvl) >= 0) return lvl; | |
722 | return -1; | |
53a1201d | 723 | #endif |
54e415a8 | 724 | } |
54e415a8 | 725 | |
1a1fdef7 | 726 | //____________________________________________________________________ |
727 | // | |
728 | // EOF | |
729 | // |