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