1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //____________________________________________________________________
20 // Forward Multiplicity Detector based on Silicon wafers.
22 // This class is a singleton that handles the geometry parameters of
25 // The actual code is done by various separate classes. Below is
26 // diagram showing the relationship between the various FMD classes
27 // that handles the geometry
32 // +----------------+<>--+ |
33 // | AliFMDGeometry | ^
34 // +----------------+<>--+ V 1..2
35 // 3 | +----------------+
36 // +-| AliFMDDetector |
40 // +-------------+-------------+
42 // +---------+ +---------+ +---------+
43 // | AliFMD1 | | AliFMD2 | | AliFMD3 |
44 // +---------+ +---------+ +---------+
48 // This class contains all stuff needed to do with a ring. It's
49 // used by the AliFMDDetector objects to instantise inner and
50 // outer rings. The AliFMDRing objects are shared by the
51 // AliFMDDetector objects, and owned by the AliFMDv1 object.
53 // * AliFMD1, AliFMD2, and AliFMD3
54 // These are specialisation of AliFMDDetector, that contains the
55 // particularities of each of the sub-detector system. It is
56 // envisioned that the classes should also define the support
57 // volumes and material for each of the detectors.
60 #include "AliFMDGeometry.h" // ALIFMDGEOMETRY_H
61 #include "AliFMDRing.h" // ALIFMDRING_H
62 #include "AliFMD1.h" // ALIFMD1_H
63 #include "AliFMD2.h" // ALIFMD2_H
64 #include "AliFMD3.h" // ALIFMD2_H
65 #include "AliRecPoint.h" // ALIRECPOINT_H
66 #include "AliLog.h" // ALIRECPOINT_H
67 #include <TVector3.h> // ROOT_TVector3
68 #include <TMatrix.h> // ROOT_TMatrix
69 #include <TParticle.h> // ROOT_TParticle
70 #include <Riostream.h>
72 #include "AliFMDGeometryBuilder.h"
74 #include <TGeoManager.h>
75 #include <TGeoVolume.h>
77 static Int_t FindNodeDepth(const char* name, const char* volname);
81 //====================================================================
82 ClassImp(AliFMDGeometry)
84 ; // This is here to keep Emacs for indenting the next line
87 //____________________________________________________________________
88 AliFMDGeometry* AliFMDGeometry::fgInstance = 0;
90 //____________________________________________________________________
92 AliFMDGeometry::Instance()
94 // Return (newly created) singleton instance
95 if (!fgInstance) fgInstance = new AliFMDGeometry;
99 //____________________________________________________________________
100 AliFMDGeometry::AliFMDGeometry()
101 : AliGeometry("FMD", "Forward multiplicity"),
105 // Default constructor
111 fUseAssembly = kTRUE;
113 fInner = new AliFMDRing('I');
114 fOuter = new AliFMDRing('O');
115 fFMD1 = new AliFMD1(fInner);
116 fFMD2 = new AliFMD2(fInner, fOuter);
117 fFMD3 = new AliFMD3(fInner, fOuter);
118 fIsInitialized = kFALSE;
125 //____________________________________________________________________
126 AliFMDGeometry::AliFMDGeometry(const AliFMDGeometry& other)
127 : AliGeometry(other),
128 fIsInitialized(other.fIsInitialized),
129 fInner(other.fInner),
130 fOuter(other.fOuter),
134 fUseFMD1(other.fUseFMD1),
135 fUseFMD2(other.fUseFMD2),
136 fUseFMD3(other.fUseFMD3)
138 , fActive(other.fActive),
139 fDetailed(other.fDetailed),
140 fUseAssembly(other.fUseAssembly)
149 //____________________________________________________________________
151 AliFMDGeometry::operator=(const AliFMDGeometry& other)
154 // Assignment operator
155 fUseFMD1 = other.fUseFMD1;
156 fUseFMD2 = other.fUseFMD2;
157 fUseFMD3 = other.fUseFMD3;
161 fInner = other.fInner;
162 fOuter = other.fOuter;
163 fIsInitialized = other.fIsInitialized;
167 //____________________________________________________________________
169 AliFMDGeometry::Init()
171 // Initialize the the singleton if not done so already
172 if (fIsInitialized) return;
181 //____________________________________________________________________
183 AliFMDGeometry::Build()
185 if (!fBuilder) fBuilder = new AliFMDGeometryBuilder(fDetailed);
186 fBuilder->SetDetailed(fDetailed);
187 fBuilder->UseAssembly(fUseAssembly);
191 //____________________________________________________________________
193 AliFMDGeometry::SetActive(Int_t* active, Int_t n)
196 for (Int_t i = 0; i < n; i++) fActive[i] = active[i];
199 //____________________________________________________________________
201 AliFMDGeometry::AddActive(Int_t active)
203 Int_t n = fActive.fN;
208 //____________________________________________________________________
210 AliFMDGeometry::IsActive(Int_t vol) const
212 for (Int_t i = 0; i < fActive.fN; i++)
213 if (fActive[i] == vol) return kTRUE;
219 //____________________________________________________________________
221 AliFMDGeometry::GetDetector(Int_t i) const
223 // Get the ith detector. i should be one of 1, 2, or 3. If an
224 // invalid value is passed, 0 (NULL) is returned.
226 case 1: return fUseFMD1 ? static_cast<AliFMDDetector*>(fFMD1) : 0;
227 case 2: return fUseFMD2 ? static_cast<AliFMDDetector*>(fFMD2) : 0;
228 case 3: return fUseFMD3 ? static_cast<AliFMDDetector*>(fFMD3) : 0;
233 //____________________________________________________________________
235 AliFMDGeometry::GetRing(Char_t i) const
237 // Get the ith ring. i should be one of 'I' or 'O' (case
238 // insensitive). If an invalid parameter is passed, 0 (NULL) is
242 case 'i': return fInner;
244 case 'o': return fOuter;
249 //____________________________________________________________________
251 AliFMDGeometry::Enable(Int_t i)
253 // Enable the ith detector. i should be one of 1, 2, or 3
255 case 1: fUseFMD1 = kTRUE; break;
256 case 2: fUseFMD2 = kTRUE; break;
257 case 3: fUseFMD3 = kTRUE; break;
261 //____________________________________________________________________
263 AliFMDGeometry::Disable(Int_t i)
265 // Disable the ith detector. i should be one of 1, 2, or 3
267 case 1: fUseFMD1 = kFALSE; break;
268 case 2: fUseFMD2 = kFALSE; break;
269 case 3: fUseFMD3 = kFALSE; break;
273 //____________________________________________________________________
275 AliFMDGeometry::Detector2XYZ(UShort_t detector,
283 // Translate detector coordinates (detector, ring, sector, strip) to
284 // spatial coordinates (x, y, z) in the master reference frame of
286 AliFMDDetector* det = GetDetector(detector);
288 det->Detector2XYZ(ring, sector, strip, x, y, z);
291 //____________________________________________________________________
293 AliFMDGeometry::XYZ2Detector(Double_t x,
299 UShort_t& strip) const
301 // Translate spatial coordinates (x,y,z) in the master reference frame of
302 // ALICE to the detector coordinates (detector, ring, sector,
303 // strip). Note, that if this method is to be used in
304 // reconstruction or the like, then the input z-coordinate should be
305 // corrected for the events interactions points z-coordinate, like
306 // geom->XYZ2Detector(x,y,z-ipz,d,r,s,t);
307 AliFMDDetector* det = 0;
309 for (int i = 1; i <= 3; i++) {
310 det = GetDetector(i);
312 if (det->XYZ2Detector(x, y, z, ring, sector, strip)) {
313 detector = det->GetId();
321 //____________________________________________________________________
323 AliFMDGeometry::GetGlobal(const AliRecPoint* p,
325 TMatrix& /* mat */) const
327 // Get the global coordinates cooresponding to the reconstructed
328 // point p. The coordiates is returned in the 3-vector pos passed
329 // to this member function. The matrix mat is used for rotations.
333 //____________________________________________________________________
335 AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const
337 // Get the global coordinates cooresponding to the reconstructed
338 // point p. The coordiates is returned in the 3-vector pos passed
339 // to this member function. Note, as AliRecPoint only has places for
340 // 3 indicies, it is assumed that the ring hit is an inner ring -
341 // which obviously needn't be the case. This makes the member
342 // function pretty darn useless.
343 // FIXME: Implement this function to work with outer rings too.
346 p->GetLocalPosition(local);
347 UShort_t detector = UShort_t(local.X());
348 UShort_t sector = UShort_t(local.Y());
349 UShort_t strip = UShort_t(local.Z());
350 Detector2XYZ(detector, 'I', sector, strip, x, y, z);
354 //____________________________________________________________________
356 AliFMDGeometry::Impact(const TParticle* /* particle */) const
358 // Return true, if the particle will hit the active detector
359 // elements, and false if not. Should be used for fast
360 // simulations. Note, that the function currently return false
362 // FIXME: Implement this function.
367 //____________________________________________________________________
369 AliFMDGeometry::ExtractGeomInfo()
371 // Check the volume depth of some nodes, get the active volume
372 // numbers, and so forth.
374 // TODO: Here, we should actually also get the parameters of the
375 // shapes, like the verticies of the polygon shape that makes up the
376 // silicon sensor, the strip pitch, the ring radii, the z-positions,
377 // and so on - that is, all the geometric information we need for
378 // futher processing, such as simulation, digitization,
379 // reconstruction, etc.
380 Int_t detectorDepth = FindNodeDepth("FMD1_1", "ALIC");
381 Int_t ringDepth = FindNodeDepth(Form("FMDI_%d", Int_t('I')), "ALIC");
382 Int_t moduleDepth = FindNodeDepth("FIFV_0", "ALIC");
383 Int_t sectorDepth = FindNodeDepth("FISE_1", "ALIC");
385 AliDebug(1, Form("Geometry depths:\n"
390 sectorDepth, moduleDepth, ringDepth, detectorDepth));
391 if (sectorDepth < 0 && moduleDepth < 0) {
396 fDetectorOff = (ringDepth - detectorDepth);
397 TGeoVolume* actiVol = gGeoManager->GetVolume("FIAC");
398 TGeoVolume* actoVol = gGeoManager->GetVolume("FOAC");
399 if (actiVol) AddActive(actiVol->GetNumber());
400 if (actiVol) AddActive(actoVol->GetNumber());
402 else if (sectorDepth < 0) {
406 fRingOff = (moduleDepth - ringDepth) + 1;
407 fDetectorOff = (moduleDepth - detectorDepth) + 1;
408 TGeoVolume* modiVol = gGeoManager->GetVolume("FIMO");
409 TGeoVolume* modoVol = gGeoManager->GetVolume("FOMO");
410 if (modiVol) AddActive(modiVol->GetNumber());
411 if (modoVol) AddActive(modoVol->GetNumber());
414 Int_t stripDepth = FindNodeDepth("FIST_1", "ALIC");
416 fSectorOff = (stripDepth - sectorDepth);
417 fModuleOff = (moduleDepth >= 0 ? (stripDepth - moduleDepth) : -1);
418 fRingOff = (stripDepth - ringDepth);
419 fDetectorOff = (stripDepth - detectorDepth );
420 TGeoVolume* striVol = gGeoManager->GetVolume("FIST");
421 TGeoVolume* stroVol = gGeoManager->GetVolume("FOST");
422 if (striVol) AddActive(striVol->GetNumber());
423 if (stroVol) AddActive(stroVol->GetNumber());
425 AliDebug(1, Form("Geometry offsets:\n"
430 fSectorOff, fModuleOff, fRingOff, fDetectorOff));
434 //____________________________________________________________________
436 CheckNodes(TGeoNode* node, const char* name, Int_t& lvl)
438 // If there's no node here.
439 if (!node) return -1;
440 // Check if it this one
442 if (sname == node->GetName()) return lvl;
444 // Check if the node is an immediate daugther
445 TObjArray* nodes = node->GetNodes();
446 if (!nodes) return -1;
447 // Increase the level, and search immediate sub nodes.
449 TGeoNode* found = static_cast<TGeoNode*>(nodes->FindObject(name));
450 if (found) return lvl;
452 // Check the sub node, if any of their sub-nodes match.
453 for (Int_t i = 0; i < nodes->GetEntries(); i++) {
454 TGeoNode* sub = static_cast<TGeoNode*>(nodes->At(i));
457 if (CheckNodes(sub, name, lvl) >= 0) return lvl;
459 // If not found, decrease the level
463 //____________________________________________________________________
465 FindNodeDepth(const char* name, const char* volname)
467 TGeoVolume* vol = gGeoManager->GetVolume(volname);
469 std::cerr << "No top volume defined" << std::endl;
472 TObjArray* nodes = vol->GetNodes();
474 std::cerr << "No nodes in top volume" << std::endl;
480 while ((node = static_cast<TGeoNode*>(next())))
481 if (CheckNodes(node, name, lvl) >= 0) return lvl;
486 //____________________________________________________________________