warning about AddDigit(Int_t*, Int_t*) fixed as Federico asked
[u/mrichter/AliRoot.git] / FMD / AliFMDGeometry.cxx
CommitLineData
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 **************************************************************************/
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//====================================================================
73ClassImp(AliFMDGeometry)
74#if 0
75 ; // This is here to keep Emacs for indenting the next line
76#endif
77
78//____________________________________________________________________
79AliFMDGeometry* AliFMDGeometry::fgInstance = 0;
80
81//____________________________________________________________________
82AliFMDGeometry*
83AliFMDGeometry::Instance()
84{
69b696b9 85 // Return (newly created) singleton instance
1a1fdef7 86 if (!fgInstance) fgInstance = new AliFMDGeometry;
87 return fgInstance;
88}
89
90//____________________________________________________________________
91AliFMDGeometry::AliFMDGeometry()
92 : AliGeometry("FMD", "Forward multiplicity")
93{
69b696b9 94 // PROTECTED
95 // Default constructor
1a1fdef7 96 fUseFMD1 = kTRUE;
97 fUseFMD2 = kTRUE;
98 fUseFMD3 = kTRUE;
99 fInner = new AliFMDRing('I');
100 fOuter = new AliFMDRing('O');
101 fFMD1 = new AliFMD1(fInner);
102 fFMD2 = new AliFMD2(fInner, fOuter);
103 fFMD3 = new AliFMD3(fInner, fOuter);
104 fIsInitialized = kFALSE;
105}
106
107//____________________________________________________________________
69b696b9 108AliFMDGeometry::AliFMDGeometry(const AliFMDGeometry& other)
109 : AliGeometry(other),
110 fIsInitialized(other.fIsInitialized),
111 fInner(other.fInner),
112 fOuter(other.fOuter),
113 fFMD1(other.fFMD1),
114 fFMD2(other.fFMD2),
115 fFMD3(other.fFMD3),
116 fUseFMD1(other.fUseFMD1),
117 fUseFMD2(other.fUseFMD2),
118 fUseFMD3(other.fUseFMD3)
119{
120 // PROTECTED
121 // Copy constructor
122}
123
124
125
126//____________________________________________________________________
127AliFMDGeometry&
128AliFMDGeometry::operator=(const AliFMDGeometry& other)
129{
130 // PROTECTED
131 // Assignment operator
132 fUseFMD1 = other.fUseFMD1;
133 fUseFMD2 = other.fUseFMD2;
134 fUseFMD3 = other.fUseFMD3;
135 fFMD1 = other.fFMD1;
136 fFMD2 = other.fFMD2;
137 fFMD3 = other.fFMD3;
138 fInner = other.fInner;
139 fOuter = other.fOuter;
140 fIsInitialized = other.fIsInitialized;
141 return *this;
142}
143
144//____________________________________________________________________
1a1fdef7 145void
146AliFMDGeometry::Init()
147{
69b696b9 148 // Initialize the the singleton if not done so already
1a1fdef7 149 if (fIsInitialized) return;
150 fInner->Init();
151 fOuter->Init();
152 fFMD1->Init();
153 fFMD2->Init();
154 fFMD3->Init();
155}
156
157//____________________________________________________________________
158AliFMDDetector*
159AliFMDGeometry::GetDetector(Int_t i) const
160{
69b696b9 161 // Get the ith detector. i should be one of 1, 2, or 3. If an
162 // invalid value is passed, 0 (NULL) is returned.
1a1fdef7 163 switch (i) {
164 case 1: return fUseFMD1 ? static_cast<AliFMDDetector*>(fFMD1) : 0;
165 case 2: return fUseFMD2 ? static_cast<AliFMDDetector*>(fFMD2) : 0;
166 case 3: return fUseFMD3 ? static_cast<AliFMDDetector*>(fFMD3) : 0;
167 }
168 return 0;
169}
170
171//____________________________________________________________________
172AliFMDRing*
173AliFMDGeometry::GetRing(Char_t i) const
174{
69b696b9 175 // Get the ith ring. i should be one of 'I' or 'O' (case
176 // insensitive). If an invalid parameter is passed, 0 (NULL) is
177 // returned.
1a1fdef7 178 switch (i) {
179 case 'I':
180 case 'i': return fInner;
181 case 'O':
182 case 'o': return fOuter;
183 }
184 return 0;
185}
186
187//____________________________________________________________________
188void
189AliFMDGeometry::Enable(Int_t i)
190{
69b696b9 191 // Enable the ith detector. i should be one of 1, 2, or 3
1a1fdef7 192 switch (i) {
193 case 1: fUseFMD1 = kTRUE; break;
194 case 2: fUseFMD2 = kTRUE; break;
195 case 3: fUseFMD3 = kTRUE; break;
196 }
197}
198
199//____________________________________________________________________
200void
201AliFMDGeometry::Disable(Int_t i)
202{
69b696b9 203 // Disable the ith detector. i should be one of 1, 2, or 3
1a1fdef7 204 switch (i) {
205 case 1: fUseFMD1 = kFALSE; break;
206 case 2: fUseFMD2 = kFALSE; break;
207 case 3: fUseFMD3 = kFALSE; break;
208 }
209}
210
211//____________________________________________________________________
212void
213AliFMDGeometry::Detector2XYZ(UShort_t detector,
69b696b9 214 Char_t ring,
215 UShort_t sector,
216 UShort_t strip,
217 Double_t& x,
218 Double_t& y,
219 Double_t& z) const
1a1fdef7 220{
69b696b9 221 // Translate detector coordinates (detector, ring, sector, strip) to
222 // spatial coordinates (x, y, z) in the master reference frame of
223 // ALICE.
1a1fdef7 224 AliFMDDetector* det = GetDetector(detector);
225 if (!det) return;
226 det->Detector2XYZ(ring, sector, strip, x, y, z);
227}
228
229
230//____________________________________________________________________
231void
232AliFMDGeometry::GetGlobal(const AliRecPoint* p,
233 TVector3& pos,
234 TMatrix& /* mat */) const
235{
69b696b9 236 // Get the global coordinates cooresponding to the reconstructed
237 // point p. The coordiates is returned in the 3-vector pos passed
238 // to this member function. The matrix mat is used for rotations.
1a1fdef7 239 GetGlobal(p, pos);
240}
241
242//____________________________________________________________________
243void
244AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const
245{
69b696b9 246 // Get the global coordinates cooresponding to the reconstructed
247 // point p. The coordiates is returned in the 3-vector pos passed
248 // to this member function. Note, as AliRecPoint only has places for
249 // 3 indicies, it is assumed that the ring hit is an inner ring -
250 // which obviously needn't be the case. This makes the member
251 // function pretty darn useless.
252 // FIXME: Implement this function to work with outer rings too.
1a1fdef7 253 Double_t x, y, z;
254 TVector3 local;
255 p->GetLocalPosition(local);
256 UShort_t detector = UShort_t(local.X());
257 UShort_t sector = UShort_t(local.Y());
258 UShort_t strip = UShort_t(local.Z());
259 Detector2XYZ(detector, 'I', sector, strip, x, y, z);
260 pos.SetXYZ(x, y, z);
261}
262
263//____________________________________________________________________
264Bool_t
265AliFMDGeometry::Impact(const TParticle* /* particle */) const
266{
69b696b9 267 // Return true, if the particle will hit the active detector
268 // elements, and false if not. Should be used for fast
269 // simulations. Note, that the function currently return false
270 // always.
271 // FIXME: Implement this function.
1a1fdef7 272 return kFALSE;
273}
274
275//____________________________________________________________________
276//
277// EOF
278//