]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMD3Support.cxx
Bugfix.
[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   if (outerZh - fZ < p[24]) 
146     Warning("SetupGeometry", "Outer ring back is at %f (%f), "
147             "but support ends %f", outerZh, outerZl,
148             p[24] + fZ);
149   
150   // ------------- Support Structures --------------------------------
151   fRotations.Set(fNBeam + fNFlange);
152   Double_t par[3];
153   
154   // The nose 
155   par[0]  = fNoseLowR;
156   par[1]  = fNoseHighR;
157   par[2]  = fNoseLength / 2;
158   fNoseId = gMC->Gsvolu(fgkNoseName, "TUBE", cId, par, 3);
159
160   // The Back 
161   par[0]  = fBackLowR;
162   par[1]  = fBackHighR;
163   par[2]  = fBackLength / 2;
164   fBackId = gMC->Gsvolu(fgkBackName, "TUBE", cId, par, 3);
165
166   // The Beams 
167   par[0]  = fBeamThickness  / 2;
168   par[1]  = fBeamWidth / 2;
169   par[2]  = beaml / 2;
170   fBeamId = gMC->Gsvolu(fgkBeamName, "BOX", cId, par, 3);
171   for (Int_t i = 0; i < fNBeam; i++) {
172     // cout << "Making beam # " << i << endl;
173     Double_t phi = 360. / fNBeam * i;
174     Int_t    id;
175     gMC->Matrix(id, 180 - theta, phi, 90, 90 + phi, theta, phi);
176     fRotations[i] = id;
177   }
178
179   // The Flanges 
180   par[0]    = (fFlangeR - fBackHighR) / 2;
181   par[1]    = fBeamWidth / 2;
182   par[2]    = fBackLength  / 2;
183   fFlangeId = gMC->Gsvolu(fgkFlangeName, "BOX", cId, par, 3);
184   for (Int_t i = 0; i < fNFlange; i++) {
185     Double_t phi = 360. / fNFlange * i + 180. / fNFlange;
186     Int_t id;
187     gMC->Matrix(id, 90, phi, 90, 90+phi, 0, 0);
188     fRotations[fNBeam + i] = id;
189   }
190 }
191
192 //____________________________________________________________________
193 void 
194 AliFMD3Support::Geometry(const char* mother, Int_t idRotId, Double_t zTop) 
195 {
196   // Position the FMD3 sub-detector volume 
197   // 
198   // Parameters 
199   //
200   //     mother     name of the mother volume 
201   //     idRotId    Identity rotation matrix ID 
202   //     z          Z position
203   //
204
205   // Common parameters 
206   Double_t zdist = fConeLength - fBackLength - fNoseLength;
207   Double_t tdist = fBackHighR - fNoseHighR;
208   const Char_t* name = "FMD3";
209   Double_t z = zTop;
210   
211   // Placing mother volume 
212   AliDebug(10, Form("\tPutting %s in %s at z=%lf", name, mother, zTop));
213   gMC->Gspos(name, 1, mother, 0, 0, zTop, idRotId, "ONLY");
214
215   // Placing the nose 
216   z       = fNoseZ - fNoseLength / 2 - fZ;
217   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf/2-%lf=%lf", 
218                     fgkNoseName, name, fNoseZ, fNoseLength, fZ, z));
219   gMC->Gspos(fgkNoseName, 1, name, 0., 0., z, idRotId, "");
220
221   // Placing  the back 
222   z       = fNoseZ - fNoseLength - zdist - fBackLength / 2 - fZ;
223   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf-%lf-%lf/2-%lf=%lf", 
224                     fgkBackName, name, fNoseZ, fNoseLength, zdist, 
225                     fBackLength, fZ, z));
226   gMC->Gspos(fgkBackName, 1, name, 0., 0., z, idRotId, "");
227
228   // Placing the beams 
229   z          = fNoseZ - fNoseLength - zdist / 2 - fZ;
230   Double_t r = fNoseHighR + tdist / 2;
231   AliDebug(10, Form("\tPutting %s's in %s at z=%lf-%lf-%lf/2-%lf=%lf", 
232                     fgkBeamName, name, fNoseZ, fNoseLength, zdist, fZ, z));
233   for (Int_t i = 0; i < fNBeam; i++) {
234     // cout << "Making beam # " << i << endl;
235     Double_t phi = 360. / fNBeam * i;
236     gMC->Gspos(fgkBeamName, i, name, 
237                r * TMath::Cos(TMath::Pi() / 180 * phi), 
238                r * TMath::Sin(TMath::Pi() / 180 * phi), 
239                z, fRotations[i], "");
240   }
241
242   // Placing the flanges 
243   r         = fBackHighR + (fFlangeR - fBackHighR) / 2;
244   z         = fNoseZ - fNoseLength - zdist - fBackLength / 2 - fZ;
245   AliDebug(10, Form("\tPutting %s in %s at z=%lf-%lf-%lf-%lf/2-%lf=%lf", 
246                     fgkFlangeName, name, fNoseZ, fNoseLength, zdist, 
247                     fBackLength, fZ, z));
248   for (Int_t i = 0; i < fNFlange; i++) {
249     Double_t phi = 360. / fNFlange * i + 180. / fNFlange;
250     gMC->Gspos(fgkFlangeName, i, name, 
251                r * TMath::Cos(TMath::Pi() / 180 * phi), 
252                r * TMath::Sin(TMath::Pi() / 180 * phi), 
253                z, fRotations[fNBeam + i], "");
254   }
255
256 }
257
258 //____________________________________________________________________
259 Double_t
260 AliFMD3Support::ConeR(Double_t z, Option_t* opt) const
261 {
262   // Calculate the cone radius at Z 
263   if (fAlpha < 0) {
264     Warning("ConeR", "alpha not set: %lf", fAlpha);
265     return -1;
266   }
267   if (z > fNoseZ) { 
268     Warning("ConeR", "z=%lf is before start of cone %lf", z, fNoseZ);
269     return -1;
270   }
271   Double_t e = fBeamThickness / TMath::Cos(TMath::ATan(fAlpha));
272   if (opt[0] == 'I' || opt[1] == 'i') e *= -1;
273   if (z > fNoseZ - fNoseLength) return fNoseHighR + e; 
274   if (z < fNoseZ - fConeLength + fBackLength) return fBackHighR + e; 
275   Double_t r = fNoseHighR + fAlpha * TMath::Abs(z - fNoseZ + fNoseLength) + e;
276   return r;
277 }
278
279 //____________________________________________________________________
280 void 
281 AliFMD3Support::Gsatt() const
282 {
283   // Set drawing attributes for the FMD3 Support 
284   gMC->Gsatt(fgkNoseName, "SEEN", 1);
285   gMC->Gsatt(fgkBeamName, "SEEN", 1);
286   gMC->Gsatt(fgkBackName, "SEEN", 1);
287   gMC->Gsatt(fgkFlangeName, "SEEN", 1);
288 }
289
290
291 //____________________________________________________________________
292 //
293 // EOF
294 //