]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD3Support.cxx
587eb3172b222b76eea05d8e60777911248350a3
[u/mrichter/AliRoot.git] / FMD / AliFMD3Support.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 // Concrete implementation of AliFMDSubDetector 
21 //
22 // This implements the geometry for FMD3
23 //
24 #include "TVirtualMC.h"         // ROOT_TVirtualMC
25 #include "AliFMD3Support.h"     // ALIFMD3SUPPORT_H 
26 #include "AliLog.h"             // ALILOG_H
27 #include <Riostream.h>          // ROOT_Riostream
28
29 //____________________________________________________________________
30 ClassImp(AliFMD3Support);
31
32 //____________________________________________________________________
33 const Char_t* AliFMD3Support::fgkNoseName   = "F3SN";
34 const Char_t* AliFMD3Support::fgkBackName   = "F3SB";
35 const Char_t* AliFMD3Support::fgkBeamName   = "F3SL";
36 const Char_t* AliFMD3Support::fgkFlangeName = "F3SF";
37
38 //____________________________________________________________________
39 AliFMD3Support::AliFMD3Support() 
40   : fZ(0),
41     fAlpha(-1),
42     fNoseId(-1),
43     fBeamId(-1),
44     fBackId(-1), 
45     fFlangeId(-1)
46 {
47   // Default constructor for the support of FMD3 sub-detector 
48   SetNoseZ();
49   SetNoseLowR();
50   SetNoseHighR();
51   SetNoseLength();
52   SetBackLowR();
53   SetBackHighR();
54   SetBackLength();
55   SetBeamThickness();
56   SetBeamWidth();
57   SetConeLength();
58   SetFlangeR();
59   SetNBeam();
60   SetNFlange();
61 }
62
63
64 //____________________________________________________________________
65 AliFMD3Support::~AliFMD3Support() 
66 {
67   // Destructor - does nothing 
68 }
69
70
71 //____________________________________________________________________
72 void 
73 AliFMD3Support::SetupGeometry(Int_t    airId, 
74                               Int_t    cId, 
75                               Double_t innerZl, 
76                               Double_t innerZh, 
77                               Double_t innerRl, 
78                               Double_t /* outerZl */, 
79                               Double_t outerZh, 
80                               Double_t outerRl)
81 {
82   // Setup the FMD3 sub-detector geometry 
83   // 
84   // Parameters:
85   // 
86   //     airId         Id # of the Air medium 
87   //     cId           Id # of the Carbon fibre medium 
88   // 
89
90   // Global stuff we need 
91   Double_t zdist = fConeLength - fBackLength - fNoseLength;
92   Double_t tdist = fBackHighR - fNoseHighR;
93   Double_t beaml = TMath::Sqrt(zdist * zdist + tdist * tdist);
94   Double_t theta = -180. * TMath::ATan2(tdist, zdist) / TMath::Pi();
95   Double_t minZ  = TMath::Min(fNoseZ - fConeLength, outerZh);
96   fAlpha         = tdist / zdist;
97   fZ             = fNoseZ + (minZ - fNoseZ) / 2;
98   AliDebug(30, Form("\tTheta = %lf", theta));
99   
100   const Char_t* mother = "FMD3";
101   Double_t p[3 + 9 * 3];
102   Double_t eps = 0;
103   // ------------- Mother volume -------------------------------------
104   // The planes should be defined with increasing Z, as it will become
105   // invalid if not 
106   // Global parameters 
107   p[0]  = 0;
108   p[1]  = 360;
109   p[2]  = 8;
110   // First plane (at back of back or outer ring)
111   p[3]  = minZ - fZ - eps;
112   p[4]  = outerRl - eps;                                   
113   p[5]  = fFlangeR + eps;
114   // Second plane (at front of back, at end of flanges)
115   p[6]  = fNoseZ - zdist - fNoseLength  - fZ  + eps;
116   p[7]  = p[4];
117   p[8]  = p[5];      
118   // Third plane (at front of back)
119   p[9]  = p[6] - eps/2; 
120   p[10] = p[7];
121   p[11] = ConeR(p[9] + fZ)  + eps;                 
122   // Fourth plane (at back of inner ring) 
123   p[12] = innerZh - fZ - eps;     
124   p[13] = outerRl - eps;          
125   p[14] = ConeR(p[12] + fZ) + eps;
126   // Fifth plane (at back of inner ring) 
127   p[15] = p[12] - eps/2;          
128   p[16] = innerRl - eps;         
129   p[17] = ConeR(p[15] + fZ) + eps;
130   // Sixth plane  (at front of inner ring)
131   p[18] = innerZl - fZ + eps;    
132   p[19] = p[16];                  
133   p[20] = ConeR(p[18] + fZ) + eps;
134   // Seventh plane (at end of nose)
135   p[21] = fNoseZ - fNoseLength  - fZ - eps;     
136   p[22] = fNoseLowR - eps;                      
137   p[23] = ConeR(p[21] + fZ) + eps; // fNoseHighR;
138   // Eight (and final) plane (at start of nose)
139   p[24] = fNoseZ  - fZ + eps;
140   p[25] = p[22];
141   p[26] = fNoseHighR + eps;  
142
143   // The volume 
144   gMC->Gsvolu(mother, "PCON", airId, p, 27);
145   
146   // ------------- Support Structures --------------------------------
147   fRotations.Set(fNBeam + fNFlange);
148   Double_t par[3];
149   
150   // The nose 
151   par[0]  = fNoseLowR;
152   par[1]  = fNoseHighR;
153   par[2]  = fNoseLength / 2;
154   fNoseId = gMC->Gsvolu(fgkNoseName, "TUBE", cId, par, 3);
155
156   // The Back 
157   par[0]  = fBackLowR;
158   par[1]  = fBackHighR;
159   par[2]  = fBackLength / 2;
160   fBackId = gMC->Gsvolu(fgkBackName, "TUBE", cId, par, 3);
161
162   // The Beams 
163   par[0]  = fBeamThickness  / 2;
164   par[1]  = fBeamWidth / 2;
165   par[2]  = beaml / 2;
166   fBeamId = gMC->Gsvolu(fgkBeamName, "BOX", cId, par, 3);
167   for (Int_t i = 0; i < fNBeam; i++) {
168     // cout << "Making beam # " << i << endl;
169     Double_t phi = 360. / fNBeam * i;
170     Int_t    id;
171     gMC->Matrix(id, 180 - theta, phi, 90, 90 + phi, theta, phi);
172     fRotations[i] = id;
173   }
174
175   // The Flanges 
176   par[0]    = (fFlangeR - fBackHighR) / 2;
177   par[1]    = fBeamWidth / 2;
178   par[2]    = fBackLength  / 2;
179   fFlangeId = gMC->Gsvolu(fgkFlangeName, "BOX", cId, par, 3);
180   for (Int_t i = 0; i < fNFlange; i++) {
181     Double_t phi = 360. / fNFlange * i + 180. / fNFlange;
182     Int_t id;
183     gMC->Matrix(id, 90, phi, 90, 90+phi, 0, 0);
184     fRotations[fNBeam + i] = id;
185   }
186 }
187
188 //____________________________________________________________________
189 void 
190 AliFMD3Support::Geometry(const char* mother, Int_t idRotId, Double_t zTop) 
191 {
192   // Position the FMD3 sub-detector volume 
193   // 
194   // Parameters 
195   //
196   //     mother     name of the mother volume 
197   //     idRotId    Identity rotation matrix ID 
198   //     z          Z position
199   //
200
201   // Common parameters 
202   Double_t zdist = fConeLength - fBackLength - fNoseLength;
203   Double_t tdist = fBackHighR - fNoseHighR;
204   const Char_t* name = "FMD3";
205   Double_t z = zTop;
206   
207   // Placing mother volume 
208   AliDebug(10, Form("\tPutting %s in %s at z=%lf", name, mother, zTop));
209   gMC->Gspos(name, 1, mother, 0, 0, zTop, idRotId, "ONLY");
210
211   // Placing the nose 
212   z       = fNoseZ - fNoseLength / 2 - fZ;
213   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf/2-%lf=%lf", 
214                     fgkNoseName, name, fNoseZ, fNoseLength, fZ, z));
215   gMC->Gspos(fgkNoseName, 1, name, 0., 0., z, idRotId, "");
216
217   // Placing  the back 
218   z       = fNoseZ - fNoseLength - zdist - fBackLength / 2 - fZ;
219   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf-%lf-%lf/2-%lf=%lf", 
220                     fgkBackName, name, fNoseZ, fNoseLength, zdist, 
221                     fBackLength, fZ, z));
222   gMC->Gspos(fgkBackName, 1, name, 0., 0., z, idRotId, "");
223
224   // Placing the beams 
225   z          = fNoseZ - fNoseLength - zdist / 2 - fZ;
226   Double_t r = fNoseHighR + tdist / 2;
227   AliDebug(10, Form("\tPutting %s's in %s at z=%lf-%lf-%lf/2-%lf=%lf", 
228                     fgkBeamName, name, fNoseZ, fNoseLength, zdist, fZ, z));
229   for (Int_t i = 0; i < fNBeam; i++) {
230     // cout << "Making beam # " << i << endl;
231     Double_t phi = 360. / fNBeam * i;
232     gMC->Gspos(fgkBeamName, i, name, 
233                r * TMath::Cos(TMath::Pi() / 180 * phi), 
234                r * TMath::Sin(TMath::Pi() / 180 * phi), 
235                z, fRotations[i], "");
236   }
237
238   // Placing the flanges 
239   r         = fBackHighR + (fFlangeR - fBackHighR) / 2;
240   z         = fNoseZ - fNoseLength - zdist - fBackLength / 2 - fZ;
241   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf-%lf-%lf/2-%lf=%lf", 
242                     fgkFlangeName, name, fNoseZ, fNoseLength, zdist, 
243                     fBackLength, fZ, z));
244   for (Int_t i = 0; i < fNFlange; i++) {
245     Double_t phi = 360. / fNFlange * i + 180. / fNFlange;
246     gMC->Gspos(fgkFlangeName, i, name, 
247                r * TMath::Cos(TMath::Pi() / 180 * phi), 
248                r * TMath::Sin(TMath::Pi() / 180 * phi), 
249                z, fRotations[fNBeam + i], "");
250   }
251
252 }
253
254 //____________________________________________________________________
255 Double_t
256 AliFMD3Support::ConeR(Double_t z, Option_t* opt) const
257 {
258   // Calculate the cone radius at Z 
259   if (fAlpha < 0) {
260     Warning("ConeR", "alpha not set: %lf", fAlpha);
261     return -1;
262   }
263   if (z > fNoseZ) { 
264     Warning("ConeR", "z=%lf is before start of cone %lf", z, fNoseZ);
265     return -1;
266   }
267   Double_t e = fBeamThickness / TMath::Cos(TMath::ATan(fAlpha));
268   if (opt[0] == 'I' || opt[1] == 'i') e *= -1;
269   if (z > fNoseZ - fNoseLength) return fNoseHighR + e; 
270   if (z < fNoseZ - fConeLength + fBackLength) return fBackHighR + e; 
271   Double_t r = fNoseHighR + fAlpha * TMath::Abs(z - fNoseZ + fNoseLength) + e;
272   return r;
273 }
274
275 //____________________________________________________________________
276 void 
277 AliFMD3Support::Gsatt() const
278 {
279   // Set drawing attributes for the FMD3 Support 
280   gMC->Gsatt(fgkNoseName, "SEEN", 1);
281   gMC->Gsatt(fgkBeamName, "SEEN", 1);
282   gMC->Gsatt(fgkBackName, "SEEN", 1);
283   gMC->Gsatt(fgkFlangeName, "SEEN", 1);
284 }
285
286
287 //____________________________________________________________________
288 //
289 // EOF
290 //