1 //____________________________________________________________________
6 // Script I used for rapid prototyping of the FMD3 geometry - in
7 // particular the support cone
9 /** @defgroup node_geom Simple geometry
12 #include <TGeometry.h>
25 //____________________________________________________________________
31 point_t(double x=0, double y=0) : first(x), second(y) {}
36 //____________________________________________________________________
37 /** @brief Shape of a ring
42 // typedef std::pair<double,double> point_t;
43 typedef std::vector<point_t> points_t;
45 @param rL Lower radius
46 @param rH Higer radius
47 @param theta Opening angle
48 @param waferR Wafer radius
49 @param siThick Silicon thickness
50 @param staggering Staggering of modules */
51 Ring(double rL, double rH, double theta, double waferR,
52 double siThick, double staggering)
53 : fStaggering(staggering),
61 double tan_theta = tan(fAngle * TMath::Pi() / 180.);
62 double tan_theta2 = pow(tan_theta,2);
63 double r2 = pow(fRadius,2);
64 double ir2 = pow(fInnerRadius,2);
65 double or2 = pow(fOuterRadius,2);
66 double y_A = tan_theta * fInnerRadius;
67 double x_D = fInnerRadius + sqrt(r2 - tan_theta2 * ir2);
68 double x_D2 = pow(x_D,2);
69 double y_B = sqrt(r2 - or2 + 2 * fOuterRadius * x_D - x_D2);
70 double x_C = ((x_D + sqrt(-tan_theta2 * x_D2
71 + r2 * (1 + tan_theta2)))
73 double y_C = tan_theta * x_C;
75 fVerticies[0] = point_t(fInnerRadius, y_A);
76 fVerticies[1] = point_t(x_C, y_C);
77 fVerticies[2] = point_t(fOuterRadius, y_B);
78 fVerticies[3] = point_t(fOuterRadius, -y_B);
79 fVerticies[4] = point_t(x_C, -y_C);
80 fVerticies[5] = point_t(fInnerRadius, -y_A);
88 @return pointer to new shape */
91 std::cout << "Creating Module shape" << std::flush;
92 TXTRU* moduleShape = new TXTRU("Module","Module", "", 6, 2);
93 for (Int_t i = 0; i < 6; i++) {
94 std::cout << "." << std::flush;
95 point_t& p = fVerticies[i];
96 moduleShape->DefineVertex(i, p.first, p.second);
98 moduleShape->DefineSection(0, -fThickness/2, 1, 0, 0);
99 moduleShape->DefineSection(1, fThickness/2, 1, 0, 0);
100 std::cout << std::endl;
101 return (TShape*)moduleShape;
103 /** Create a node that represents a ring.
105 TNode* CreateRing(const char* name, double z)
107 std::cout << "Creating Ring node for " << name << std::flush;
108 double bredth = fStaggering + fThickness;
109 TShape* ringShape = new TTUBE(Form("%sShape", name), "Ring Shape",
111 fOuterRadius,bredth/2);
112 TNode* ringNode = new TNode(Form("%sNode", name), "Ring Node",
113 ringShape, 0, 0, z+bredth/2, 0);
114 TShape* moduleShape = CreateShape();
115 Int_t n = Int_t(360 / 2 / fAngle);
116 for (Int_t i = 0; i < n; i++) {
117 std::cout << "." << std::flush;
119 Double_t theta = 2 * fAngle * i;
120 Double_t z = -(bredth+fThickness)/2+(i%2?0:fStaggering);
121 TRotMatrix* rot = new TRotMatrix(Form("%sRotation%02d", name, i),
122 "Rotation", 90, theta, 90,
123 fmod(90 + theta, 360), 0, 0);
124 TNode* moduleNode = new TNode(Form("%sModule%02d", name, i),
125 "Module", moduleShape, 0, 0, z,
127 moduleNode->SetFillColor(2);
128 moduleNode->SetLineColor(2);
129 moduleNode->SetLineWidth(2);
131 std::cout << std::endl;
132 ringNode->SetVisibility(0);
140 /** Opening angle (in degrees) */
142 /** Radius (in centimeters) */
146 /** List of verticies */
150 //____________________________________________________________________
151 /** @brief Shape of a detector
160 Detector(Ring* inner, double iZ, Ring* outer=0, double oZ=0)
161 : fInner(inner), fInnerZ(iZ), fOuter(outer), fOuterZ(oZ)
164 virtual ~Detector() {}
166 virtual void CreateRings()
168 if (fInner) fInner->CreateRing("inner", fInnerZ);
169 if (fOuter) fOuter->CreateRing("outer", fOuterZ);
171 /** Create a node that represents the support */
172 virtual void CreateSupport(double) { }
173 /** Pointer to inner ring */
175 /** Position in z of inner ring */
177 /** Pointer to outer ring */
179 /** Position in z of inner ring */
183 //____________________________________________________________________
184 /** @brief FMD3 simple node geometry
187 struct FMD3 : public Detector
190 @param inner Inner ring representation
191 @param outer Outer ring representation */
192 FMD3(Ring* inner, Ring* outer)
193 : Detector(inner, -62.8,outer, -75.2)
210 double zdist = fConeL - 2 * fBackDz - 2 * fNoseDz;
211 double tdist = fBackRh - fNoseRh;
212 double alpha = tdist / zdist;
214 z = fNoseZ - fConeL / 2;
215 TPCON* fmd3Shape = new TPCON("fmd3Shape", "FMD 3 Shape", "", 0, 360, 7);
219 fmd3Shape->DefineSection(0, x - z, rl, rh);
220 x = fNoseZ-2*fNoseDz;
221 fmd3Shape->DefineSection(1, x - z, rl, rh);
222 x = fInnerZ - fInner->fStaggering - fInner->fThickness;
223 rl = fInner->fInnerRadius;
224 rh = fNoseRh + alpha * TMath::Abs(x-fNoseZ + 2 * fNoseDz);
225 fmd3Shape->DefineSection(2, x - z, rl, rh);
227 rl = fOuter->fInnerRadius;
229 fmd3Shape->DefineSection(3, x - z, rl, rh);
230 x = fNoseZ - zdist - 2 * fNoseDz;
231 rl = fOuter->fInnerRadius;
233 fmd3Shape->DefineSection(4, x - z, rl, rh);
234 x = fNoseZ - zdist - 2 * fNoseDz;
235 rl = fOuter->fInnerRadius;
237 fmd3Shape->DefineSection(5, x - z, rl, rh);
239 rl = fOuter->fInnerRadius;
241 fmd3Shape->DefineSection(6, x - z, rl, rh);
243 TNode* fmd3Node = new TNode("fmd3Node", "FMD3 Node", fmd3Shape,0,0,z,0);
244 fmd3Node->SetLineColor(11);
245 fmd3Node->SetFillColor(11);
246 fmd3Node->SetVisibility(1);
248 if (fInner) fInner->CreateRing("inner", fInnerZ-z);
250 if (fOuter) fOuter->CreateRing("outer", fOuterZ-z);
252 CreateSupport(fNoseZ - z);
255 /** Create support volumes */
256 void CreateSupport(double noseZ)
258 TShape* noseShape = new TTUBE("noseShape", "Nose Shape", "",
259 fNoseRl, fNoseRh, fNoseDz);
260 TNode* noseNode = new TNode("noseNode", "noseNode", noseShape,
261 0, 0, noseZ - fNoseDz, 0);
262 noseNode->SetLineColor(0);
263 double zdist = fConeL - 2 * fBackDz - 2 * fNoseDz;
264 double tdist = fBackRh - fNoseRh;
265 double beamL = TMath::Sqrt(zdist * zdist + tdist * tdist);
266 double theta = -TMath::ATan2(tdist, zdist);
267 TShape* backShape = new TTUBE("backShape", "Back Shape", "",
268 fBackRl, fBackRh, fBackDz);
269 TNode* backNode = new TNode("backNode", "backNode", backShape,
270 0, 0, noseZ-2*fNoseDz-zdist-fBackDz, 0);
271 backNode->SetLineColor(0);
272 TShape* beamShape = new TBRIK("beamShape", "beamShape", "",
273 fBeamDz, fBeamW / 2 , beamL / 2);
275 Double_t r = fNoseRl + tdist / 2;
276 for (Int_t i = 0; i < n; i++) {
277 Double_t phi = 360. / n * i;
278 Double_t t = 180. * theta / TMath::Pi();
279 TRotMatrix* beamRotation = new TRotMatrix(Form("beamRotation%d", i),
280 Form("beamRotation%d", i),
281 180-t,phi,90,90+phi,t,phi);
282 TNode* beamNode = new TNode(Form("beamNode%d", i),
283 Form("beamNode%d", i), beamShape,
284 r * TMath::Cos(phi / 180 * TMath::Pi()),
285 r * TMath::Sin(phi / 180 * TMath::Pi()),
286 noseZ-2*fNoseDz-zdist/2, beamRotation);
287 beamNode->SetLineColor(0);
289 Double_t flangel = (fFlangeR - fBackRh) / 2;
290 TShape* flangeShape = new TBRIK("flangeShape", "FlangeShape", "",
291 flangel, fBeamW / 2, fBackDz);
293 r = fBackRh + flangel;
294 for (Int_t i = 0; i < n; i++) {
295 Double_t phi = 360. / n * i + 180. / n;
296 TRotMatrix* flangeRotation = new TRotMatrix(Form("flangeRotation%d", i),
297 Form("Flange Rotation %d",i),
298 90,phi,90,90+phi,0,0);
299 TNode* flangeNode = new TNode(Form("flangeNode%d", i),
300 Form("flangeNode%d", i),
302 r * TMath::Cos(phi / 180 * TMath::Pi()),
303 r * TMath::Sin(phi / 180 * TMath::Pi()),
304 noseZ-2*fNoseDz-zdist-fBackDz,
306 flangeNode->SetLineColor(0);
310 /** Nose inner radius */
312 /** Nose outer radius */
316 /** Nose start position */
318 /** Length of whole support structure */
320 /** Inner radius of back ring */
322 /** Outer radius of back ring */
324 /** Thickness of back ring */
326 /** Thickness of beams */
328 /** Width of beams */
330 /** Ending radius of flanges */
334 //____________________________________________________________________
335 /** @brief Create a node geometry
344 TGeometry* geometry = new TGeometry("geometry","geometry");
345 TShape* topShape = new TBRIK("topShape", "topShape", "", 40, 40, 150);
346 TNode* topNode = new TNode("topNode", "topNode", topShape, 0, 0, 0, 0);
347 topNode->SetVisibility(0);
350 Ring inner( 4.3, 17.2, 18, 13.4 / 2, .03, 1);
351 Ring outer(15.6, 28.0, 9, 13.4 / 2, .03, 1);
352 FMD3 fmd3(&inner, &outer);
355 TCanvas* c = new TCanvas("c", "c", 800, 800);
360 //____________________________________________________________________