Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
cheongwadae.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Drawing the Cheongwadae building which is the Presidential Residence of the Republic of Korea, using ROOT geometry
4/// class.
5///
6/// Reviewed by Sunman Kim (sunman98@hanmail.net)
7/// Supervisor: Prof. Inkyu Park (icpark@physics.uos.ac.kr)
8///
9/// How to run: `.x cheongwadae.C` in ROOT terminal, then use OpenGL
10///
11/// This macro was created for the evaluation of Computational Physics course in 2006.
12/// We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
13///
14/// \image html geom_cheongwadae.png width=800px
15/// \macro_code
16///
17/// \author Hee Jun Shin (s-heejun@hanmail.net), Dept. of Physics, Univ. of Seoul
18
19#include "TGeoManager.h"
20
21void cheongwadae()
22{
23 TGeoManager *geom = new TGeoManager("geom", "My first 3D geometry");
24
25 // material
26 TGeoMaterial *vacuum = new TGeoMaterial("vacuum", 0, 0, 0);
27 TGeoMaterial *Fe = new TGeoMaterial("Fe", 55.845, 26, 7.87);
28
29 // creat media
30 TGeoMedium *Air = new TGeoMedium("Vacuum", 0, vacuum);
31 TGeoMedium *Iron = new TGeoMedium("Iron", 1, Fe);
32
33 // creat volume
34 TGeoVolume *top = geom->MakeBox("top", Air, 300, 300, 300);
35 geom->SetTopVolume(top);
36 geom->SetTopVisible(false);
37 // If you want to see the boundary, please input the number, 1 instead of 0.
38 // Like this, geom->SetTopVisible(1);
39
40 char nBlocks[100];
41 int N = 0;
42 int f = 0;
43 int di[2];
44 di[0] = 0;
45 di[1] = 30;
46 TGeoVolume *mBlock;
47
48 for (int k = 0; k < 7; k++) {
49 for (int i = 0; i < 20; i++) {
50 sprintf(nBlocks, "f%d_bg%d", f, N++);
51 mBlock = geom->MakeBox(nBlocks, Iron, 0.6, 1.8, 63);
52 mBlock->SetLineColor(20);
53 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-10.6 - (2.6 * i), -17.8 + (6 * k), 0));
54
55 sprintf(nBlocks, "f%d_bg%d", f, N++);
56 mBlock = geom->MakeBox(nBlocks, Iron, 0.7, 1.8, 58);
57 mBlock->SetLineColor(12);
58 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-11.9 - (2.6 * i), -17.8 + (6 * k), 0));
59 }
60 sprintf(nBlocks, "f%d_bg%d", f, N++);
61 mBlock = geom->MakeBox(nBlocks, Iron, 26, 1.2, 63);
62 mBlock->SetLineColor(20);
63 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-36, -14.8 + (6 * k), 0));
64 }
65 sprintf(nBlocks, "f%d_bg%d", f, N++);
66 mBlock = geom->MakeBox(nBlocks, Iron, 26, 2, 63);
67 mBlock->SetLineColor(20);
68 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-36, -21.6, 0));
69
70 for (int k = 0; k < 7; k++) {
71 for (int i = 0; i < 20; i++) {
72 sprintf(nBlocks, "f%d_bg%d", f, N++);
73 mBlock = geom->MakeBox(nBlocks, Iron, 0.6, 1.8, 63);
74 mBlock->SetLineColor(20);
75 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-10.6 - (2.6 * i), -17.8 + (6 * k), 0));
76 sprintf(nBlocks, "f%d_bg%d", f, N++);
77 mBlock = geom->MakeBox(nBlocks, Iron, 0.7, 1.8, 58);
78 mBlock->SetLineColor(12);
79 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-11.9 - (2.6 * i), -17.8 + (6 * k), 0));
80 }
81 sprintf(nBlocks, "f%d_bg%d", f, N++);
82 mBlock = geom->MakeBox(nBlocks, Iron, 26, 1.2, 63);
83 mBlock->SetLineColor(20);
84 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-36, -14.8 + (6 * k), 0));
85 }
86
87 sprintf(nBlocks, "f%d_bg%d", f, N++);
88 mBlock = geom->MakeBox(nBlocks, Iron, 10, 22, 58);
89 mBlock->SetLineColor(2);
90 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 0, 0));
91
92 sprintf(nBlocks, "f%d_bg%d", f, N++);
93 mBlock = geom->MakeBox(nBlocks, Iron, 3.5, 8, 0.1);
94 mBlock->SetLineColor(13);
95 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(4, -14, 60));
96
97 sprintf(nBlocks, "f%d_bg%d", f, N++);
98 mBlock = geom->MakeBox(nBlocks, Iron, 3.5, 8, 0.1);
99 mBlock->SetLineColor(13);
100 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-4, -14, 60));
101
102 sprintf(nBlocks, "f%d_bg%d", f, N++);
103 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
104 mBlock->SetLineColor(1);
105 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 20, 60));
106
107 sprintf(nBlocks, "f%d_bg%d", f, N++);
108 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
109 mBlock->SetLineColor(1);
110 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 17, 60));
111
112 sprintf(nBlocks, "f%d_bg%d", f, N++);
113 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
114 mBlock->SetLineColor(1);
115 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 14, 60));
116
117 sprintf(nBlocks, "f%d_bg%d", f, N++);
118 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
119 mBlock->SetLineColor(1);
120 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 11, 60));
121
122 sprintf(nBlocks, "f%d_bg%d", f, N++);
123 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
124 mBlock->SetLineColor(1);
125 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 8, 60));
126
127 sprintf(nBlocks, "f%d_bg%d", f, N++);
128 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
129 mBlock->SetLineColor(1);
130 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 5, 60));
131
132 sprintf(nBlocks, "f%d_bg%d", f, N++);
133 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.2, 0.1);
134 mBlock->SetLineColor(1);
135 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 2, 60));
136
137 for (int k = 0; k < 7; k++) {
138 for (int i = 0; i < 20; i++) {
139 sprintf(nBlocks, "f%d_bg%d", f, N++);
140 mBlock = geom->MakeBox(nBlocks, Iron, 0.6, 1.8, 63);
141 mBlock->SetLineColor(20);
142 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(10.6 + (2.6 * i), -17.8 + (6 * k), 0));
143 sprintf(nBlocks, "f%d_bg%d", f, N++);
144 mBlock = geom->MakeBox(nBlocks, Iron, 0.7, 1.8, 58);
145 mBlock->SetLineColor(12);
146 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(11.9 + (2.6 * i), -17.8 + (6 * k), 0));
147 }
148 sprintf(nBlocks, "f%d_bg%d", f, N++);
149 mBlock = geom->MakeBox(nBlocks, Iron, 26, 1.2, 63);
150 mBlock->SetLineColor(20);
151 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(36, -14.8 + (6 * k), 0));
152 }
153 sprintf(nBlocks, "f%d_bg%d", f, N++);
154 mBlock = geom->MakeBox(nBlocks, Iron, 26, 2, 63);
155 mBlock->SetLineColor(20);
156 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(36, -21.6, 0));
157
158 sprintf(nBlocks, "f%d_bg%d", f, N++);
159 mBlock = geom->MakeBox(nBlocks, Iron, 82, 2, 82);
160 mBlock->SetLineColor(18);
161 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 24, 0));
162
163 sprintf(nBlocks, "f%d_bg%d", f, N++);
164 mBlock = geom->MakeBox(nBlocks, Iron, 85, 0.5, 85);
165 mBlock->SetLineColor(18);
166 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 26, 0));
167
168 sprintf(nBlocks, "f%d_bg%d", f, N++);
169 mBlock = geom->MakeBox(nBlocks, Iron, 88, 2, 88);
170 mBlock->SetLineColor(18);
171 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -24, 0));
172
173 sprintf(nBlocks, "f%d_bg%d", f, N++);
174 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 30, 0, 180, 0, 180);
175 mBlock->SetLineColor(32);
176 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 24, 0));
177
178 sprintf(nBlocks, "ab%d", N++);
179 mBlock = geom->MakeBox(nBlocks, Iron, 0.1, 30, 0.1);
180 mBlock->SetLineColor(10);
181 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, 40, 0));
182
183 sprintf(nBlocks, "ab%d", N++);
184 mBlock = geom->MakeTubs(nBlocks, Iron, 0, 30, 4, 360, 360);
185 mBlock->SetLineColor(10);
186 top->AddNodeOverlap(mBlock, 1, new TGeoCombiTrans(0, 27, 0, new TGeoRotation("r1", 0, 90, 0)));
187
188 for (int i = 0; i < 8; i++) {
189 sprintf(nBlocks, "ab%d", N++);
190 mBlock = geom->MakeBox(nBlocks, Iron, 2, 22, 2);
191 mBlock->SetLineColor(18);
192 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-70 + (20 * i), 0, 80));
193 }
194
195 for (int i = 0; i < 8; i++) {
196 sprintf(nBlocks, "ab%d", N++);
197 mBlock = geom->MakeBox(nBlocks, Iron, 2, 22, 2);
198 mBlock->SetLineColor(18);
199 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-70 + (20 * i), 0, -80));
200 }
201
202 for (int i = 0; i < 7; i++) {
203 sprintf(nBlocks, "ab%d", N++);
204 mBlock = geom->MakeBox(nBlocks, Iron, 2, 22, 2);
205 mBlock->SetLineColor(18);
206 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-70, 0, -80 + (23 * i)));
207 }
208
209 for (int i = 0; i < 7; i++) {
210 sprintf(nBlocks, "ab%d", N++);
211 mBlock = geom->MakeBox(nBlocks, Iron, 2, 22, 2);
212 mBlock->SetLineColor(18);
213 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(70, 0, -80 + (23 * i)));
214 }
215
216 sprintf(nBlocks, "f%d_bg%d", f, N++);
217 mBlock = geom->MakeBox(nBlocks, Iron, 100, 0.5, 160);
218 mBlock->SetLineColor(41);
219 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -26, 40));
220
221 sprintf(nBlocks, "f%d_bg%d", f, N++);
222 mBlock = geom->MakeBox(nBlocks, Iron, 10, 0.01, 160);
223 mBlock->SetLineColor(19);
224 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -25, 40));
225
226 sprintf(nBlocks, "f%d_bg%d", f, N++);
227 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
228 mBlock->SetLineColor(8);
229 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -22, 170));
230
231 sprintf(nBlocks, "f%d_bg%d", f, N++);
232 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
233 mBlock->SetLineColor(8);
234 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -25, 170));
235
236 sprintf(nBlocks, "f%d_bg%d", f, N++);
237 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
238 mBlock->SetLineColor(8);
239 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -22, 150));
240
241 sprintf(nBlocks, "f%d_bg%d", f, N++);
242 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
243 mBlock->SetLineColor(8);
244 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -25, 150));
245
246 sprintf(nBlocks, "f%d_bg%d", f, N++);
247 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
248 mBlock->SetLineColor(8);
249 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -22, 130));
250
251 sprintf(nBlocks, "f%d_bg%d", f, N++);
252 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
253 mBlock->SetLineColor(8);
254 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -25, 130));
255
256 sprintf(nBlocks, "f%d_bg%d", f, N++);
257 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
258 mBlock->SetLineColor(8);
259 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -22, 110));
260
261 sprintf(nBlocks, "f%d_bg%d", f, N++);
262 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
263 mBlock->SetLineColor(8);
264 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(15, -25, 110));
265
266 sprintf(nBlocks, "f%d_bg%d", f, N++);
267 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
268 mBlock->SetLineColor(8);
269 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -22, 170));
270
271 sprintf(nBlocks, "f%d_bg%d", f, N++);
272 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
273 mBlock->SetLineColor(8);
274 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -25, 170));
275
276 sprintf(nBlocks, "f%d_bg%d", f, N++);
277 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
278 mBlock->SetLineColor(8);
279 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -22, 150));
280
281 sprintf(nBlocks, "f%d_bg%d", f, N++);
282 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
283 mBlock->SetLineColor(8);
284 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -25, 150));
285
286 sprintf(nBlocks, "f%d_bg%d", f, N++);
287 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
288 mBlock->SetLineColor(8);
289 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -22, 130));
290
291 sprintf(nBlocks, "f%d_bg%d", f, N++);
292 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
293 mBlock->SetLineColor(8);
294 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -25, 130));
295
296 sprintf(nBlocks, "f%d_bg%d", f, N++);
297 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
298 mBlock->SetLineColor(8);
299 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -22, 110));
300
301 sprintf(nBlocks, "f%d_bg%d", f, N++);
302 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
303 mBlock->SetLineColor(8);
304 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -25, 110));
305
306 sprintf(nBlocks, "ab%d", N++);
307 mBlock = geom->MakeBox(nBlocks, Iron, 0.1, 10, 0.1);
308 mBlock->SetLineColor(12);
309 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(20, -15, 110));
310
311 sprintf(nBlocks, "ab%d", N++);
312 mBlock = geom->MakeBox(nBlocks, Iron, 5, 3, 0.1);
313 mBlock->SetLineColor(10);
314 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(25, -8, 110));
315
316 sprintf(nBlocks, "ab%d", N++);
317 mBlock = geom->MakeBox(nBlocks, Iron, 0.1, 10, 0.1);
318 mBlock->SetLineColor(12);
319 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-20, -15, 110));
320
321 sprintf(nBlocks, "ab%d", N++);
322 mBlock = geom->MakeBox(nBlocks, Iron, 5, 3, 0.1);
323 mBlock->SetLineColor(10);
324 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(-15, -8, 110));
325
326 sprintf(nBlocks, "f%d_bg%d", f, N++);
327 mBlock = geom->MakeBox(nBlocks, Iron, 7, 1.5, 5);
328 mBlock->SetLineColor(18);
329 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -24, 88));
330
331 sprintf(nBlocks, "f%d_bg%d", f, N++);
332 mBlock = geom->MakeBox(nBlocks, Iron, 7, 1, 5);
333 mBlock->SetLineColor(18);
334 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -24, 92));
335
336 sprintf(nBlocks, "f%d_bg%d", f, N++);
337 mBlock = geom->MakeBox(nBlocks, Iron, 7, 0.5, 5);
338 mBlock->SetLineColor(18);
339 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -24, 96));
340
341 sprintf(nBlocks, "f%d_bg%d", f, N++);
342 mBlock = geom->MakeBox(nBlocks, Iron, 7, 0.1, 5);
343 mBlock->SetLineColor(18);
344 top->AddNodeOverlap(mBlock, 1, new TGeoTranslation(0, -24, 100));
345
346 geom->CloseGeometry();
347 top->SetVisibility(false);
348
349 top->Draw("ogl");
350}
#define f(i)
Definition RSha256.hxx:104
#define N
Class describing rotation + translation.
Definition TGeoMatrix.h:317
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
Class describing rotations.
Definition TGeoMatrix.h:168
Class describing translations.
Definition TGeoMatrix.h:116
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void Draw(Option_t *option="") override
draw top volume according to option
virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void SetLineColor(Color_t lcolor) override
Set the line color.