ROOT   Reference Guide
Searching...
No Matches
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 class.
4///
5/// Reviewed by Sunman Kim (sunman98@hanmail.net)
6/// Supervisor: Prof. Inkyu Park (icpark@physics.uos.ac.kr)
7///
8/// How to run: .x cheongwadae.C in ROOT terminal, then use OpenGL
9///
10/// This macro was created for the evaluation of Computational Physics course in 2006.
11/// We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
12///
14/// \macro_code
15///
16/// \author Hee Jun Shin (s-heejun@hanmail.net), Dept. of Physics, Univ. of Seoul
17
18#include "TGeoManager.h"
19
21{
22 TGeoManager *geom = new TGeoManager("geom","My first 3D geometry");
23
24 //material
25 TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
26 TGeoMaterial *Fe = new TGeoMaterial("Fe",55.845,26,7.87);
27
28 //creat media
29 TGeoMedium *Air = new TGeoMedium("Vacuum",0,vacuum);
30 TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe);
31
32 //creat volume
33 TGeoVolume *top = geom->MakeBox("top",Air,300,300,300);
34 geom->SetTopVolume(top);
35 geom->SetTopVisible(0);
36 // If you want to see the boundary, please input the number, 1 instead of 0.
37 // Like this, geom->SetTopVisible(1);
38
39char nBlocks[100];
40int N = 0;
41int f=0;
42int di[2]; di[0] = 0; di[1] = 30;
43TGeoVolume *mBlock;
44
45 for(int k=0;k<7;k++){
46 for(int i=0;i<20;i++){
47 sprintf(nBlocks,"f%d_bg%d",f,N++);
48 mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
49 mBlock->SetLineColor(20);
51
52 sprintf(nBlocks,"f%d_bg%d",f,N++);
53 mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
54 mBlock->SetLineColor(12);
56 }
57 sprintf(nBlocks,"f%d_bg%d",f,N++);
58 mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
59 mBlock->SetLineColor(20);
61 }
62 sprintf(nBlocks,"f%d_bg%d",f,N++);
63 mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
64 mBlock->SetLineColor(20);
66
67 for(int k=0;k<7;k++){
68 for(int i=0;i<20;i++){
69 sprintf(nBlocks,"f%d_bg%d",f,N++);
70 mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
71 mBlock->SetLineColor(20);
73 sprintf(nBlocks,"f%d_bg%d",f,N++);
74 mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
75 mBlock->SetLineColor(12);
77
78 }
79 sprintf(nBlocks,"f%d_bg%d",f,N++);
80 mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
81 mBlock->SetLineColor(20);
83 }
84
85 sprintf(nBlocks,"f%d_bg%d",f,N++);
86 mBlock = geom->MakeBox(nBlocks, Iron, 10,22,58);
87 mBlock->SetLineColor(2);
89
90 sprintf(nBlocks,"f%d_bg%d",f,N++);
91 mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
92 mBlock->SetLineColor(13);
94
95 sprintf(nBlocks,"f%d_bg%d",f,N++);
96 mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
97 mBlock->SetLineColor(13);
99
100 sprintf(nBlocks,"f%d_bg%d",f,N++);
101 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
102 mBlock->SetLineColor(1);
104
105 sprintf(nBlocks,"f%d_bg%d",f,N++);
106 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
107 mBlock->SetLineColor(1);
109
110 sprintf(nBlocks,"f%d_bg%d",f,N++);
111 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
112 mBlock->SetLineColor(1);
114
115 sprintf(nBlocks,"f%d_bg%d",f,N++);
116 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
117 mBlock->SetLineColor(1);
119
120 sprintf(nBlocks,"f%d_bg%d",f,N++);
121 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
122 mBlock->SetLineColor(1);
124
125 sprintf(nBlocks,"f%d_bg%d",f,N++);
126 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
127 mBlock->SetLineColor(1);
129
130 sprintf(nBlocks,"f%d_bg%d",f,N++);
131 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
132 mBlock->SetLineColor(1);
134
135 for(int k=0;k<7;k++){
136 for(int i=0;i<20;i++){
137 sprintf(nBlocks,"f%d_bg%d",f,N++);
138 mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
139 mBlock->SetLineColor(20);
141 sprintf(nBlocks,"f%d_bg%d",f,N++);
142 mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
143 mBlock->SetLineColor(12);
145
146 }
147 sprintf(nBlocks,"f%d_bg%d",f,N++);
148 mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
149 mBlock->SetLineColor(20);
151 }
152 sprintf(nBlocks,"f%d_bg%d",f,N++);
153 mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
154 mBlock->SetLineColor(20);
156
157
158 sprintf(nBlocks,"f%d_bg%d",f,N++);
159 mBlock = geom->MakeBox(nBlocks, Iron, 82,2,82);
160 mBlock->SetLineColor(18);
162
163 sprintf(nBlocks,"f%d_bg%d",f,N++);
164 mBlock = geom->MakeBox(nBlocks, Iron, 85,0.5,85);
165 mBlock->SetLineColor(18);
167
168 sprintf(nBlocks,"f%d_bg%d",f,N++);
169 mBlock = geom->MakeBox(nBlocks, Iron, 88,2,88);
170 mBlock->SetLineColor(18);
172
173
174 sprintf(nBlocks,"f%d_bg%d",f,N++);
175 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 30, 0, 180, 0, 180);
176 mBlock->SetLineColor(32);
178
179 sprintf(nBlocks,"ab%d",N++);
180 mBlock = geom->MakeBox(nBlocks,Iron, 0.1,30,0.1);
181 mBlock->SetLineColor(10);
183
184 sprintf(nBlocks,"ab%d",N++);
185 mBlock = geom->MakeTubs(nBlocks,Iron, 0,30,4,360,360);
186 mBlock->SetLineColor(10);
188
189 for(int i=0;i<8;i++){
190 sprintf(nBlocks,"ab%d",N++);
191 mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
192 mBlock->SetLineColor(18);
194 }
195
196 for(int i=0;i<8;i++){
197 sprintf(nBlocks,"ab%d",N++);
198 mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
199 mBlock->SetLineColor(18);
201 }
202
203 for(int i=0;i<7;i++){
204 sprintf(nBlocks,"ab%d",N++);
205 mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
206 mBlock->SetLineColor(18);
208 }
209
210 for(int i=0;i<7;i++){
211 sprintf(nBlocks,"ab%d",N++);
212 mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
213 mBlock->SetLineColor(18);
215 }
216
217 sprintf(nBlocks,"f%d_bg%d",f,N++);
218 mBlock = geom->MakeBox(nBlocks, Iron, 100,0.5,160);
219 mBlock->SetLineColor(41);
221
222 sprintf(nBlocks,"f%d_bg%d",f,N++);
223 mBlock = geom->MakeBox(nBlocks, Iron, 10,0.01,160);
224 mBlock->SetLineColor(19);
226
227 sprintf(nBlocks,"f%d_bg%d",f,N++);
228 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
229 mBlock->SetLineColor(8);
231
232 sprintf(nBlocks,"f%d_bg%d",f,N++);
233 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
234 mBlock->SetLineColor(8);
236
237 sprintf(nBlocks,"f%d_bg%d",f,N++);
238 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
239 mBlock->SetLineColor(8);
241
242 sprintf(nBlocks,"f%d_bg%d",f,N++);
243 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
244 mBlock->SetLineColor(8);
246
247 sprintf(nBlocks,"f%d_bg%d",f,N++);
248 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
249 mBlock->SetLineColor(8);
251
252 sprintf(nBlocks,"f%d_bg%d",f,N++);
253 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
254 mBlock->SetLineColor(8);
256
257 sprintf(nBlocks,"f%d_bg%d",f,N++);
258 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
259 mBlock->SetLineColor(8);
261
262 sprintf(nBlocks,"f%d_bg%d",f,N++);
263 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
264 mBlock->SetLineColor(8);
266
267 sprintf(nBlocks,"f%d_bg%d",f,N++);
268 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
269 mBlock->SetLineColor(8);
271
272 sprintf(nBlocks,"f%d_bg%d",f,N++);
273 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
274 mBlock->SetLineColor(8);
276
277 sprintf(nBlocks,"f%d_bg%d",f,N++);
278 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
279 mBlock->SetLineColor(8);
281
282 sprintf(nBlocks,"f%d_bg%d",f,N++);
283 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
284 mBlock->SetLineColor(8);
286
287 sprintf(nBlocks,"f%d_bg%d",f,N++);
288 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
289 mBlock->SetLineColor(8);
291
292 sprintf(nBlocks,"f%d_bg%d",f,N++);
293 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
294 mBlock->SetLineColor(8);
296
297 sprintf(nBlocks,"f%d_bg%d",f,N++);
298 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
299 mBlock->SetLineColor(8);
301
302 sprintf(nBlocks,"f%d_bg%d",f,N++);
303 mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
304 mBlock->SetLineColor(8);
306
307 sprintf(nBlocks,"ab%d",N++);
308 mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
309 mBlock->SetLineColor(12);
311
312 sprintf(nBlocks,"ab%d",N++);
313 mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
314 mBlock->SetLineColor(10);
316
317 sprintf(nBlocks,"ab%d",N++);
318 mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
319 mBlock->SetLineColor(12);
321
322 sprintf(nBlocks,"ab%d",N++);
323 mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
324 mBlock->SetLineColor(10);
326
327 sprintf(nBlocks,"f%d_bg%d",f,N++);
328 mBlock = geom->MakeBox(nBlocks, Iron, 7,1.5,5);
329 mBlock->SetLineColor(18);
331
332 sprintf(nBlocks,"f%d_bg%d",f,N++);
333 mBlock = geom->MakeBox(nBlocks, Iron, 7,1,5);
334 mBlock->SetLineColor(18);
336
337 sprintf(nBlocks,"f%d_bg%d",f,N++);
338 mBlock = geom->MakeBox(nBlocks, Iron, 7,0.5,5);
339 mBlock->SetLineColor(18);
341
342 sprintf(nBlocks,"f%d_bg%d",f,N++);
343 mBlock = geom->MakeBox(nBlocks, Iron, 7,0.1,5);
344 mBlock->SetLineColor(18);
346
347 geom->CloseGeometry();
348 top->SetVisibility(0);
349
350 top->Draw("ogl");
351}
#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.