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