Added docs and fixed a bug
[u/mrichter/AliRoot.git] / FMD / AliFMDSubDetector.cxx
CommitLineData
4347b38f 1/**************************************************************************
0d0e6995 2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4347b38f 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// Utility class to help implement the FMD geometry. This provides
21// the interface for the concrete geometry implementations of the FMD
22// sub-detectors.
23//
24// The AliFMD object owns the AliFMDSubDetector objects
25//
26// Latest changes by Christian Holm Christensen
27//
28//////////////////////////////////////////////////////////////////////////////
29
e802be3e 30#include "AliFMDSubDetector.h" // ALIFMDSUBDETECTOR_H
31#include "AliFMDRing.h" // ALIFMDRING_H
56b1929b 32#include <AliLog.h> // ALILOG_H
33#include <TVirtualMC.h> // ROOT_TVirtualMC
34#include <TList.h> // ROOT_TList
35#include <TString.h> // ROOT_TString
4347b38f 36
7684b53c 37//____________________________________________________________________
4347b38f 38ClassImp(AliFMDSubDetector);
39
7684b53c 40//____________________________________________________________________
41const Char_t* AliFMDSubDetector::fgkHoneyTopFormat = "F%d%cH";
42const Char_t* AliFMDSubDetector::fgkHoneyBottomFormat = "F%d%cI";
43const Char_t* AliFMDSubDetector::fgkHoneyTopInnerFormat = "F%d%cJ";
44const Char_t* AliFMDSubDetector::fgkHoneyBottomInnerFormat = "F%d%cK";
45
4347b38f 46//____________________________________________________________________
47AliFMDSubDetector::AliFMDSubDetector(Int_t n)
48 : fId(n),
49 fInnerZ(0),
50 fOuterZ(0),
51 fInner(0),
52 fOuter(0)
7684b53c 53{
54 SetAlThickness();
55 SetHoneycombThickness();
56}
57
4347b38f 58
59//____________________________________________________________________
60void
61AliFMDSubDetector::Draw(Option_t* /* opt */) const
62{
63 // DebugGuard guard("AliFMDSubDetector::Draw");
64 AliDebug(10, "AliFMDSubDetector::Draw");
65}
66
67//____________________________________________________________________
68Bool_t
69AliFMDSubDetector::CheckHit(Char_t ring, Int_t module, Double_t x, Double_t y)
70{
71 // Check if a hit (x,y) in module module of ring ring is within the
72 // actual shape.
73 Bool_t ret = kFALSE;
74 switch (ring) {
75 case 'i':
76 case 'I':
77 if (!fInner) break;
78 ret = fInner->IsWithin(module, x, y);
79 break;
80 case 'o':
81 case 'O':
82 if (!fOuter) break;
83 ret = fOuter->IsWithin(module, x, y);
84 break;
85 }
86 return ret;
87}
88
89//____________________________________________________________________
90void
91AliFMDSubDetector::SimpleGeometry(TList* nodes,
92 TNode* mother,
93 Int_t colour,
94 Double_t zMother)
95{
96 // Make a simplified geometry for event display
97 //
98 // Parameters
99 //
100 // nodes List of nodes to register all create nodes in
101 // mother Mother node to put the ring in.
102 // colour Colour of the nodes
103 // zMother Z position of the node in the mother volume
104 //
105 for (int i = 0; i < 2; i++) {
106 AliFMDRing* r = 0;
107 Double_t z = 0;
108 switch (i) {
109 case 0:
110 r = fInner;
111 z = fInnerZ;
112 break;
113 case 1:
114 r = fOuter;
115 z = fOuterZ;
116 break;
117 }
118 if (!r) continue;
119
120 // Make the coordinates relative to the mother volume. If we're
121 // on the positive side, then we need to flip the z-coordinate, as
122 // we'll rotate the whole sub-detector afterwards.
123 z -= zMother;
124 if (zMother > 0) z *= -1;
125
126 r->SimpleGeometry(nodes, mother, colour, z, fId);
127 }
128}
129
130
131//____________________________________________________________________
132void
7684b53c 133AliFMDSubDetector::SetupGeometry(Int_t airId, Int_t alId, Int_t /* cId
134 */)
4347b38f 135{
136 // Set up the geometry of this particular detector.
137 //
138 // In this class, it defines the support honey comp calls and
139 // nothing else.
140 //
141 // Parameters
142 // airId Medium of inactive virtual volumes
7684b53c 143 // alId Medium of honeycomb
4347b38f 144 //
145 // DebugGuard guard("AliFMDSubDetector::SetupGeometry");
146 AliDebug(10, "AliFMDSubDetector::SetupGeometry");
147 TString name;
148 Double_t par[5];
149
150 for (int i = 0; i < 2; i++) {
151 AliFMDRing* r = 0;
152 char c = '\0';
153 switch (i) {
154 case 0:
155 r = fInner;
4347b38f 156 par[0] = fInnerHoneyLowR;
157 par[1] = fInnerHoneyHighR;
158 break;
159 case 1:
160 r = fOuter;
4347b38f 161 par[0] = fOuterHoneyLowR;
162 par[1] = fOuterHoneyHighR;
163 break;
164 }
165 if (!r) continue;
7684b53c 166 c = r->GetId();
167
4347b38f 168 // Top of honeycomb, inner ring
169 par[2] = fHoneycombThickness / 2;
170 par[3] = 0;
171 par[4] = 180;
7684b53c 172 name = Form(fgkHoneyTopFormat, fId, c);
173 gMC->Gsvolu(name.Data(), "TUBS", alId, par, 5);
4347b38f 174
175 // Bottom of honeycomb, inner ring
176 par[3] = 180;
177 par[4] = 360;
7684b53c 178 name = Form(fgkHoneyBottomFormat, fId, c);
179 gMC->Gsvolu(name.Data(), "TUBS", alId, par, 5);
4347b38f 180
181 // Air in top of honeycomb, inner ring
7684b53c 182 par[0] += fAlThickness;
183 par[1] -= fAlThickness;
184 par[2] -= fAlThickness;
4347b38f 185 par[3] = 0;
186 par[4] = 180;
7684b53c 187 name = Form(fgkHoneyTopInnerFormat, fId, c);
4347b38f 188 gMC->Gsvolu(name.Data(), "TUBS", airId, par, 5);
189
190 // Air in bottom of honeycomb, inner ring
191 par[3] = 180;
192 par[4] = 360;
7684b53c 193 name = Form(fgkHoneyBottomInnerFormat, fId, c);
4347b38f 194 gMC->Gsvolu(name.Data(), "TUBS", airId, par, 5);
195 }
196}
197
198//____________________________________________________________________
199void
200AliFMDSubDetector::Geometry(const char* mother, Int_t pbRotId, Int_t idRotId,
201 Double_t zMother)
202{
203 // Place the volume inside mother volume.
204 //
205 // Parameters
206 //
207 // mother Volume to position this detector in
208 // pbRotId Print board rotation matrix,
209 // idRotId Identity rotation matrix
210 // zMother The Z passed in, is the position of the middle
211 // point of the mother volume.
212 //
213 // In this base class, it asks the contained rings to position
214 // themselves in the mother volume, and positions the honey comb
215 // support in the mother volume
216 //
217 // DebugGuard guard("AliFMDSubDetector::Geometry");
218 AliDebug(10, "AliFMDSubDetector::Geometry");
219
220 Double_t ringW;
221 Double_t z = 0;
222 // Double_t* b = 0;
223 TString name;
224 TString name2;
225
226 for (int i = 0; i < 2; i++) {
227 AliFMDRing* r = 0;
228 char c = '\0';
229 switch (i) {
230 case 0:
231 r = fInner;
4347b38f 232 z = fInnerZ;
233 break;
234 case 1:
235 r = fOuter;
4347b38f 236 z = fOuterZ;
237 break;
238 }
239 if (!r) continue;
7684b53c 240 c = r->GetId();
4347b38f 241
242 // Make the coordinates relative to the mother volume. If we're
243 // on the positive side, then we need to flip the z-coordinate, as
244 // we'll rotate the whole sub-detector afterwards.
7684b53c 245 Double_t z2 = z;
246 z2 -= zMother;
247 if (zMother > 0) z2 *= -1;
248 AliDebug(10, Form("Putting ring %c in %s at z=%lf-%lf=%lf",
249 c, mother, z, zMother, z2));
250 r->Geometry(mother, fId, z2, pbRotId, idRotId);
4347b38f 251 ringW = r->GetRingDepth();
7684b53c 252 z2 -= ringW + fHoneycombThickness / 2;
4347b38f 253
254 // Top of honeycomb
7684b53c 255 name = Form(fgkHoneyTopFormat, fId, c);
256 gMC->Gspos(name.Data(), 1, mother, 0, 0, z2, idRotId);
4347b38f 257
258 // Air in top of honeycomb
259 name2 = name;
7684b53c 260 name = Form(fgkHoneyTopInnerFormat, fId, c);
261 gMC->Gspos(name.Data(), 1, name2.Data(),0,fAlThickness,0,idRotId);
4347b38f 262
263 // Bottom of honeycomb
7684b53c 264 name = Form(fgkHoneyBottomFormat, fId, c);
265 gMC->Gspos(name.Data(), 1, mother, 0, 0, z2, idRotId);
4347b38f 266
267 // Air in bottom of honeycomb
268 name2 = name;
7684b53c 269 name = Form(fgkHoneyBottomInnerFormat, fId, c);
270 gMC->Gspos(name.Data(),1,name2.Data(),0,-fAlThickness,0,idRotId);
4347b38f 271 }
272}
273
274//____________________________________________________________________
275void
276AliFMDSubDetector::Gsatt()
277{
278 // Set drawing attributes for the detector
279 //
280 // DebugGuard guard("AliFMDSubDetector::Gsatt");
281 AliDebug(10, "AliFMDSubDetector::Gsatt");
7684b53c 282 TString name;
283
284 name = Form("FMD%d", fId);
4347b38f 285 gMC->Gsatt(name.Data(), "SEEN", 0);
7684b53c 286
287 for (int i = 0; i < 2; i++) {
288 AliFMDRing* r = 0;
289 char c = '\0';
290 switch (i) {
291 case 0: r = fInner; break;
292 case 1: r = fOuter; break;
293 }
294 if (!r) continue;
295 c = r->GetId();
296
297 name = Form(fgkHoneyTopFormat, fId, c);
298 gMC->Gsatt(name.Data(), "SEEN", 1);
299
300 name = Form(fgkHoneyBottomFormat, fId, c);
301 gMC->Gsatt(name.Data(), "SEEN", 1);
302
303 name = Form(fgkHoneyTopInnerFormat, fId, c);
304 gMC->Gsatt(name.Data(), "SEEN", 0);
305
306 name = Form(fgkHoneyBottomInnerFormat, fId, c);
307 gMC->Gsatt(name.Data(), "SEEN", 0);
308 }
4347b38f 309}
310
311
312//____________________________________________________________________
313//
314// EOF
315//