Migrated to a geometry implemented via AliFMDGeometry (derives from
[u/mrichter/AliRoot.git] / FMD / AliFMDGeometry.cxx
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
18 //____________________________________________________________________
19 //                                                                          
20 // Forward Multiplicity Detector based on Silicon wafers. 
21 //
22 // This class is a singleton that handles the geometry parameters of
23 // the FMD detectors.  
24 //                                                       
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 
28 //
29 //                               +------------+ 
30 //                            +- | AliFMDRing |
31 //                         2  |  +------------+
32 //      +----------------+<>--+        |                                
33 //      | AliFMDGeometry |             ^                        
34 //      +----------------+<>--+        V 1..2                           
35 //                         3  | +----------------+              
36 //                            +-| AliFMDDetector |              
37 //                              +----------------+              
38 //                                     ^
39 //                                     |
40 //                       +-------------+-------------+
41 //                       |             |             |        
42 //                  +---------+   +---------+   +---------+
43 //                  | AliFMD1 |   | AliFMD2 |   | AliFMD3 |
44 //                  +---------+   +---------+   +---------+
45 //      
46 //
47 // *  AliFMDRing 
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. 
52 //
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.                          
58 //                                                                          
59 //
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>
71
72 //====================================================================
73 ClassImp(AliFMDGeometry)
74 #if 0
75   ; // This is here to keep Emacs for indenting the next line
76 #endif
77
78 //____________________________________________________________________
79 AliFMDGeometry* AliFMDGeometry::fgInstance = 0;
80
81 //____________________________________________________________________
82 AliFMDGeometry* 
83 AliFMDGeometry::Instance() 
84 {
85   if (!fgInstance) fgInstance = new AliFMDGeometry;
86   return fgInstance;
87 }
88
89 //____________________________________________________________________
90 AliFMDGeometry::AliFMDGeometry() 
91   : AliGeometry("FMD", "Forward multiplicity")
92 {
93   fUseFMD1 = kTRUE;
94   fUseFMD2 = kTRUE;
95   fUseFMD3 = kTRUE;  
96   fInner = new AliFMDRing('I');
97   fOuter = new AliFMDRing('O');
98   fFMD1  = new AliFMD1(fInner);
99   fFMD2  = new AliFMD2(fInner, fOuter);
100   fFMD3  = new AliFMD3(fInner, fOuter);
101   fIsInitialized = kFALSE;
102 }
103
104 //____________________________________________________________________
105 void
106 AliFMDGeometry::Init()
107 {
108   if (fIsInitialized) return;
109   fInner->Init();
110   fOuter->Init();
111   fFMD1->Init();
112   fFMD2->Init();
113   fFMD3->Init();
114 }
115
116 //____________________________________________________________________
117 AliFMDDetector*
118 AliFMDGeometry::GetDetector(Int_t i) const
119 {
120   switch (i) {
121   case 1: return fUseFMD1 ? static_cast<AliFMDDetector*>(fFMD1) : 0;
122   case 2: return fUseFMD2 ? static_cast<AliFMDDetector*>(fFMD2) : 0;
123   case 3: return fUseFMD3 ? static_cast<AliFMDDetector*>(fFMD3) : 0;
124   }
125   return 0;
126 }
127
128 //____________________________________________________________________
129 AliFMDRing*
130 AliFMDGeometry::GetRing(Char_t i) const
131 {
132   switch (i) {
133   case 'I':
134   case 'i': return fInner;
135   case 'O':
136   case 'o': return fOuter;
137   }
138   return 0;
139 }
140
141 //____________________________________________________________________
142 void
143 AliFMDGeometry::Enable(Int_t i)
144 {
145   switch (i) {
146   case 1: fUseFMD1 = kTRUE; break;
147   case 2: fUseFMD2 = kTRUE; break;
148   case 3: fUseFMD3 = kTRUE; break;
149   }
150 }
151
152 //____________________________________________________________________
153 void
154 AliFMDGeometry::Disable(Int_t i)
155 {
156   switch (i) {
157   case 1: fUseFMD1 = kFALSE; break;
158   case 2: fUseFMD2 = kFALSE; break;
159   case 3: fUseFMD3 = kFALSE; break;
160   }
161 }
162
163 //____________________________________________________________________
164 void
165 AliFMDGeometry::Detector2XYZ(UShort_t  detector, 
166                      Char_t    ring, 
167                      UShort_t  sector, 
168                      UShort_t  strip, 
169                      Double_t& x, 
170                      Double_t& y, 
171                      Double_t& z) const
172 {
173   AliFMDDetector* det = GetDetector(detector);
174   if (!det) return;
175   det->Detector2XYZ(ring, sector, strip, x, y, z);
176 }
177
178
179 //____________________________________________________________________
180 void
181 AliFMDGeometry::GetGlobal(const AliRecPoint* p, 
182                           TVector3& pos, 
183                           TMatrix& /* mat */) const 
184 {
185   GetGlobal(p, pos);
186 }
187
188 //____________________________________________________________________
189 void
190 AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const 
191 {
192   Double_t x, y, z;
193   TVector3 local;
194   p->GetLocalPosition(local);
195   UShort_t detector = UShort_t(local.X());
196   UShort_t sector   = UShort_t(local.Y());
197   UShort_t strip    = UShort_t(local.Z());
198   Detector2XYZ(detector, 'I', sector, strip, x, y, z);
199   pos.SetXYZ(x, y, z);
200 }
201
202 //____________________________________________________________________
203 Bool_t
204 AliFMDGeometry::Impact(const TParticle* /* particle */) const 
205
206   return kFALSE; 
207 }
208
209 //____________________________________________________________________
210 //
211 // EOF
212 //