]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/scripts/SimpleGeometry.C
Added AliMpStringObjMap, AliMpDEIterator, AliMpDEManager, AliMpSegFactory
[u/mrichter/AliRoot.git] / FMD / scripts / SimpleGeometry.C
CommitLineData
d389af40 1//____________________________________________________________________
2//
a1f80595 3//
4// $Id$
5//
d389af40 6// Script I used for rapid prototyping of the FMD3 geometry - in
7// particular the support cone
8//
9//____________________________________________________________________
10TObjArray*
11waferParameters(double dl, double dh, double theta, double r,
12 Bool_t verbose=kFALSE)
13{
14 double tan_theta = tan(theta * TMath::Pi() / 180.);
15 double tan_theta2 = pow(tan_theta,2);
16 double r2 = pow(r,2);
17 double y_A = tan_theta * dl;
18 double x_D = dl + sqrt(r2 - tan_theta2 * pow(dl,2));
19 double x_D_2 = dl - sqrt(r2 - tan_theta2 * pow(dl,2));
20
21 double y_B = sqrt(r2 - pow(dh,2) + 2 * dh * x_D - pow(x_D,2));
22 double x_C = (x_D + sqrt(-tan_theta2 * pow(x_D,2) + r2
23 + r2 * tan_theta2)) / (1 + tan_theta2);
24 double y_C = tan_theta * x_C;
25
26 if (verbose) {
27 cout << "A: (" << dl << "," << y_A << ")" << endl;
28 cout << "B: (" << dh << "," << y_B << ")" << endl;
29 cout << "C: (" << x_C << "," << y_C << ")" << endl;
30 cout << "D: (" << x_D << ",0)" << endl;
31
32 cout << "Recentred at D:" << endl;
33 cout << "A: (" << dl - x_D << "," << y_A << ")" << endl;
34 cout << "B: (" << dh - x_D << "," << y_B << ")" << endl;
35 cout << "C: (" << x_C - x_D << "," << y_C << ")" << endl;
36 }
37
38 TObjArray* verticies = new TObjArray(6);
39 verticies->AddAt(new TVector2(dl, y_A), 0);
40 verticies->AddAt(new TVector2(x_C, y_C), 1);
41 verticies->AddAt(new TVector2(dh, y_B), 2);
42 verticies->AddAt(new TVector2(dh, -y_B), 3);
43 verticies->AddAt(new TVector2(x_C, -y_C), 4);
44 verticies->AddAt(new TVector2(dl, -y_A), 5);
45
46 return verticies;
47}
48
49//____________________________________________________________________
50TShape*
51createModuleShape(const Char_t* name, double rl, double rh, double th,
52 double r, double dz)
53{
54 std::cout << "Creating Module shape for " << name << std::flush;
55 // TShape* virtualShape = new TTUBS(Form("%sVirtual", name),
56 // Form("Virtual %s", name),
57 // "", rl, rh, 1, -th, th);
58
59 TObjArray* v = waferParameters(rl, rh, th, r);
60 TXTRU* moduleShape = new TXTRU(Form("%sModule", name),
61 Form("Module %s", name),
62 "", 6, 2);
63 for (Int_t i = 0; i < 6; i++) {
64 std::cout << "." << std::flush;
65 TVector2* vv = static_cast<TVector2*>(v->At(i));
66 moduleShape->DefineVertex(i, vv->X(), vv->Y());
67 }
68 moduleShape->DefineSection(0, -dz, 1, 0, 0);
69 moduleShape->DefineSection(1, dz, 1, 0, 0);
70 std::cout << std::endl;
71
72 return (TShape*)moduleShape;
73}
74
75//____________________________________________________________________
76TNode*
77createRing(const char* name, double rl, double rh, double th,
78 double siThick, double waferR, double staggering, double z)
79{
80 std::cout << "Creating Ring node for " << name << std::flush;
81 TShape* ringShape = new TTUBE(Form("%sShape", name), "Ring Shape",
82 "", rl, rh, staggering + siThick);
83 TNode* ringNode = new TNode(Form("%sNode", name), "Ring Node",
84 ringShape, 0, 0, z, 0);
85 TShape* moduleShape = createModuleShape(name, rl, rh, th, waferR, siThick);
86 Int_t n = 360 / 2 / th;
87 for (Int_t i = 0; i < n; i++) {
88 std::cout << "." << std::flush;
89 ringNode->cd();
90 Double_t theta = 2 * th * i;
91 Double_t z = (i % 2 ? 0 : staggering);
92 TRotMatrix* rot = new TRotMatrix(Form("%sRotation%02d", name, i),
93 "Rotation", 90, theta, 90,
94 fmod(90 + theta, 360), 0, 0);
95 TNode* moduleNode = new TNode(Form("%sModule%02d", name, i),
96 "Module", moduleShape, 0, 0, z,
97 rot);
98 moduleNode->SetFillColor(5);
99 moduleNode->SetLineColor(5);
100 moduleNode->SetLineWidth(2);
101 }
102 std::cout << std::endl;
103 ringNode->SetVisibility(0);
104 return ringNode;
105}
106
107//____________________________________________________________________
108TNode*
109createSupport(double noseRl, double noseRh, double noseDz, double noseZ,
110 double backRl, double backRh, double backDz, double coneL,
111 double beamW, double beamDz, double flangeR)
112{
113 TShape* noseShape = new TTUBE("noseShape", "Nose Shape", "",
114 noseRl, noseRh, noseDz);
115 TNode* noseNode = new TNode("noseNode", "noseNode", noseShape,
116 0, 0, noseZ - noseDz, 0);
117 noseNode->SetLineColor(0);
118
119 Double_t zdist = coneL - 2 * backDz - 2 * noseDz;
120 Double_t tdist = backRh - noseRh;
121 Double_t beamL = TMath::Sqrt(zdist * zdist + tdist * tdist);
122 Double_t theta = -TMath::ATan2(tdist, zdist);
123
124
125 TShape* backShape = new TTUBE("backShape", "Back Shape", "",
126 backRl, backRh, backDz);
127 TNode* backNode = new TNode("backNode", "backNode", backShape,
128 0, 0, noseZ - 2 * noseDz - zdist - backDz, 0);
129 backNode->SetLineColor(0);
130
131
132 TShape* beamShape = new TBRIK("beamShape", "beamShape", "",
133 beamDz, beamW / 2 , beamL / 2);
134 Int_t n = 8;
135 Double_t r = noseRl + tdist / 2;
136 for (Int_t i = 0; i < n; i++) {
137 Double_t phi = 360. / n * i;
138 Double_t t = 180. * theta / TMath::Pi();
139 TRotMatrix* beamRotation = new TRotMatrix(Form("beamRotation%d", i),
140 Form("beamRotation%d", i),
141 180-t, phi, 90, 90+phi,
142 t, phi);
143 TNode* beamNode = new TNode(Form("beamNode%d", i),
144 Form("beamNode%d", i), beamShape,
145 r * TMath::Cos(phi / 180 * TMath::Pi()),
146 r * TMath::Sin(phi / 180 * TMath::Pi()),
147 noseZ - 2 * noseDz - zdist / 2, beamRotation);
148 beamNode->SetLineColor(0);
149 }
150
151 Double_t flangel = (flangeR - backRh) / 2;
152 TShape* flangeShape = new TBRIK("flangeShape", "FlangeShape", "",
153 flangel, beamW / 2, backDz);
154 n = 4;
155 r = backRh + flangel;
156 for (Int_t i = 0; i < n; i++) {
157 Double_t phi = 360. / n * i + 180. / n;
158 TRotMatrix* flangeRotation = new TRotMatrix(Form("flangeRotation%d", i),
159 Form("Flange Rotation %d", i),
160 90, phi, 90, 90+phi, 0, 0);
161 TNode* flangeNode = new TNode(Form("flangeNode%d", i),
162 Form("flangeNode%d", i),
163 flangeShape,
164 r * TMath::Cos(phi / 180 * TMath::Pi()),
165 r * TMath::Sin(phi / 180 * TMath::Pi()),
166 noseZ - 2 * noseDz - zdist - backDz,
167 flangeRotation);
168 flangeNode->SetLineColor(0);
169
170 }
171 return 0;
172}
173
174
175
176
177//____________________________________________________________________
178void
179SimpleGeometry()
180{
181 TGeometry* geometry = new TGeometry("geometry","geometry");
182 TShape* topShape = new TBRIK("topShape", "topShape", "", 40, 40, 150);
183 TNode* topNode = new TNode("topNode", "topNode", topShape, 0, 0, 0, 0);
184 topNode->SetVisibility(0);
185 topNode->cd();
186
187 Double_t waferR = 13.4 / 2;
188 Double_t siThick = .03;
189 Double_t staggering = 1;
190 Double_t innerRh = 17.2;
191 Double_t innerRl = 4.3;
192 Double_t innerTh = 18;
193 Double_t innerZ = -62.8;
194 Double_t outerRh = 28;
195 Double_t outerRl = 15.6;
196 Double_t outerTh = 9;
197 Double_t outerZ = -75.2;
198 Double_t noseRl = 5.5;
199 Double_t noseRh = 6.7;
200 Double_t noseDz = 2.8 / 2;
201 Double_t noseZ = -46;
202 Double_t coneL = 30.9;
203 Double_t backRl = 61 / 2;
204 Double_t backRh = 66.8 /2;
205 Double_t backDz = 1.4 / 2;
206 Double_t beamDz = .5 / 2;
207 Double_t beamW = 6;
208 Double_t flangeR = 49.25;
209
210 Double_t zdist = coneL - 2 * backDz - 2 * noseDz;
211 Double_t tdist = backRh - noseRh;
212 Double_t alpha = tdist / zdist;
213
214 Double_t x, rl, rh, z;
215 z = noseZ - coneL / 2;
216 TPCON* fmd3Shape = new TPCON("fmd3Shape", "FMD 3 Shape", "", 0, 360, 7);
217
218 x = noseZ;
219 rl = noseRl;
220 rh = noseRh;
221 fmd3Shape->DefineSection(0, x - z, rl, rh);
222
223 x = noseZ-2*noseDz;
224 fmd3Shape->DefineSection(1, x - z, rl, rh);
225
226 x = innerZ - staggering - siThick;
227 rl = innerRl;
228 rh = noseRh + alpha * TMath::Abs(x-noseZ + 2 * noseDz);
229 fmd3Shape->DefineSection(2, x - z, rl, rh);
230
231 x = outerZ;
232 rl = outerRl;
233 rh = backRh;
234 fmd3Shape->DefineSection(3, x - z, rl, rh);
235
236 x = noseZ - zdist - 2 * noseDz;
237 rl = outerRl;
238 rh = backRh;
239 fmd3Shape->DefineSection(4, x - z, rl, rh);
240
241 x = noseZ - zdist - 2 * noseDz;
242 rl = outerRl;
243 rh = flangeR;
244 fmd3Shape->DefineSection(5, x - z, rl, rh);
245
246 x = noseZ - coneL;
247 rl = outerRl;
248 rh = flangeR;
249 fmd3Shape->DefineSection(6, x - z, rl, rh);
250
251 TNode* fmd3Node = new TNode("fmd3Node", "FMD3 Node", fmd3Shape,
252 0, 0, z, 0);
253 fmd3Node->SetLineColor(3);
254 fmd3Node->SetVisibility(1);
255
256 fmd3Node->cd();
257 TNode* innerNode = createRing("inner", innerRl, innerRh, innerTh,
258 siThick, waferR, staggering, innerZ-z);
259
260
261 fmd3Node->cd();
262 TNode* outerNode = createRing("outer", outerRl, outerRh, outerTh,
263 siThick, waferR, staggering, outerZ-z);
264
265
266 fmd3Node->cd();
267 TNode* supportNode = createSupport(noseRl, noseRh, noseDz, noseZ-z,
268 backRl, backRh, backDz, coneL,
269 beamW, beamDz, flangeR);
270
271 TCanvas* c = new TCanvas("c", "c", 800, 800);
272 c->SetFillColor(1);
273 geometry->Draw();
274 // c->x3d("ogl");
275}
a1f80595 276//____________________________________________________________________
277//
278// EOF
279//