ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cheongwadae.C
Go to the documentation of this file.
1 #include "TGeoManager.h"
2 
3 void cheongwadae()
4 {
5  // Drawing the Cheongwadae building which is the Presidential Residence of the Republic of Korea, using ROOT geometry class.
6  //
7  // Author: Hee Jun Shin (s-heejun@hanmail.net), Dept. of Physics, Univ. of Seoul
8  // Reviewed by Sunman Kim (sunman98@hanmail.net)
9  // Supervisor: Prof. Inkyu Park (icpark@physics.uos.ac.kr)
10  //
11  // How to run: .x cheongwadae.C in ROOT terminal, then use OpenGL
12  //
13  // This macro was created for the evaluation of Computational Physics course in 2006.
14  // We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
15  //
16 
17  TGeoManager *geom = new TGeoManager("geom","My first 3D geometry");
18 
19  //material
20  TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
21  TGeoMaterial *Fe = new TGeoMaterial("Fe",55.845,26,7.87);
22 
23  //creat media
24  TGeoMedium *Air = new TGeoMedium("Vacuum",0,vacuum);
25  TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe);
26 
27  //creat volume
28  TGeoVolume *top = geom->MakeBox("top",Air,300,300,300);
29  geom->SetTopVolume(top);
30  geom->SetTopVisible(0);
31  // If you want to see the boundary, please input the number, 1 instead of 0.
32  // Like this, geom->SetTopVisible(1);
33 
34 char nBlocks[100];
35 int N = 0;
36 int f=0;
37 int di[2]; di[0] = 0; di[1] = 30;
38 TGeoVolume *mBlock;
39 
40 
41  for(int k=0;k<7;k++){
42  for(int i=0;i<20;i++){
43  sprintf(nBlocks,"f%d_bg%d",f,N++);
44  mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
45  mBlock->SetLineColor(20);
46  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-10.6-(2.6*i),-17.8+(6*k),0));
47 
48  sprintf(nBlocks,"f%d_bg%d",f,N++);
49  mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
50  mBlock->SetLineColor(12);
51  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-11.9-(2.6*i),-17.8+(6*k),0));
52 
53  }
54  sprintf(nBlocks,"f%d_bg%d",f,N++);
55  mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
56  mBlock->SetLineColor(20);
57  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-14.8+(6*k),0));
58  }
59  sprintf(nBlocks,"f%d_bg%d",f,N++);
60  mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
61  mBlock->SetLineColor(20);
62  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-21.6,0));
63 
64 
65 
66  for(int k=0;k<7;k++){
67  for(int i=0;i<20;i++){
68  sprintf(nBlocks,"f%d_bg%d",f,N++);
69  mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
70  mBlock->SetLineColor(20);
71  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-10.6-(2.6*i),-17.8+(6*k),0));
72  sprintf(nBlocks,"f%d_bg%d",f,N++);
73  mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
74  mBlock->SetLineColor(12);
75  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-11.9-(2.6*i),-17.8+(6*k),0));
76 
77  }
78  sprintf(nBlocks,"f%d_bg%d",f,N++);
79  mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
80  mBlock->SetLineColor(20);
81  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-14.8+(6*k),0));
82  }
83 
84  sprintf(nBlocks,"f%d_bg%d",f,N++);
85  mBlock = geom->MakeBox(nBlocks, Iron, 10,22,58);
86  mBlock->SetLineColor(2);
87  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,0,0));
88 
89  sprintf(nBlocks,"f%d_bg%d",f,N++);
90  mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
91  mBlock->SetLineColor(13);
92  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(4,-14,60));
93 
94  sprintf(nBlocks,"f%d_bg%d",f,N++);
95  mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
96  mBlock->SetLineColor(13);
97  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-4,-14,60));
98 
99 
100 
101  sprintf(nBlocks,"f%d_bg%d",f,N++);
102  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
103  mBlock->SetLineColor(1);
104  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,20,60));
105 
106  sprintf(nBlocks,"f%d_bg%d",f,N++);
107  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
108  mBlock->SetLineColor(1);
109  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,17,60));
110 
111  sprintf(nBlocks,"f%d_bg%d",f,N++);
112  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
113  mBlock->SetLineColor(1);
114  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,14,60));
115 
116  sprintf(nBlocks,"f%d_bg%d",f,N++);
117  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
118  mBlock->SetLineColor(1);
119  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,11,60));
120 
121  sprintf(nBlocks,"f%d_bg%d",f,N++);
122  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
123  mBlock->SetLineColor(1);
124  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,8,60));
125 
126  sprintf(nBlocks,"f%d_bg%d",f,N++);
127  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
128  mBlock->SetLineColor(1);
129  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,5,60));
130 
131  sprintf(nBlocks,"f%d_bg%d",f,N++);
132  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
133  mBlock->SetLineColor(1);
134  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,2,60));
135 
136 
137 
138  for(int k=0;k<7;k++){
139  for(int i=0;i<20;i++){
140  sprintf(nBlocks,"f%d_bg%d",f,N++);
141  mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
142  mBlock->SetLineColor(20);
143  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(10.6+(2.6*i),-17.8+(6*k),0));
144  sprintf(nBlocks,"f%d_bg%d",f,N++);
145  mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
146  mBlock->SetLineColor(12);
147  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(11.9+(2.6*i),-17.8+(6*k),0));
148 
149  }
150  sprintf(nBlocks,"f%d_bg%d",f,N++);
151  mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
152  mBlock->SetLineColor(20);
153  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(36,-14.8+(6*k),0));
154  }
155  sprintf(nBlocks,"f%d_bg%d",f,N++);
156  mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
157  mBlock->SetLineColor(20);
158  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(36,-21.6,0));
159 
160 
161  sprintf(nBlocks,"f%d_bg%d",f,N++);
162  mBlock = geom->MakeBox(nBlocks, Iron, 82,2,82);
163  mBlock->SetLineColor(18);
164  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,24,0));
165 
166  sprintf(nBlocks,"f%d_bg%d",f,N++);
167  mBlock = geom->MakeBox(nBlocks, Iron, 85,0.5,85);
168  mBlock->SetLineColor(18);
169  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,26,0));
170 
171  sprintf(nBlocks,"f%d_bg%d",f,N++);
172  mBlock = geom->MakeBox(nBlocks, Iron, 88,2,88);
173  mBlock->SetLineColor(18);
174  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,0));
175 
176 
177  sprintf(nBlocks,"f%d_bg%d",f,N++);
178  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 30, 0, 180, 0, 180);
179  mBlock->SetLineColor(32);
180  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,24,0));
181 
182  sprintf(nBlocks,"ab%d",N++);
183  mBlock = geom->MakeBox(nBlocks,Iron, 0.1,30,0.1);
184  mBlock->SetLineColor(10);
185  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,40,0));
186 
187  sprintf(nBlocks,"ab%d",N++);
188  mBlock = geom->MakeTubs(nBlocks,Iron, 0,30,4,360,360);
189  mBlock->SetLineColor(10);
190  top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(0,27,0, new TGeoRotation("r1",0,90,0)));
191 
192 
193  for(int i=0;i<8;i++){
194  sprintf(nBlocks,"ab%d",N++);
195  mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
196  mBlock->SetLineColor(18);
197  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70+(20*i),0,80));
198  }
199 
200  for(int i=0;i<8;i++){
201  sprintf(nBlocks,"ab%d",N++);
202  mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
203  mBlock->SetLineColor(18);
204  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70+(20*i),0,-80));
205  }
206 
207  for(int i=0;i<7;i++){
208  sprintf(nBlocks,"ab%d",N++);
209  mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
210  mBlock->SetLineColor(18);
211  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70,0,-80+(23*i)));
212  }
213 
214  for(int i=0;i<7;i++){
215  sprintf(nBlocks,"ab%d",N++);
216  mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
217  mBlock->SetLineColor(18);
218  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(70,0,-80+(23*i)));
219  }
220  sprintf(nBlocks,"f%d_bg%d",f,N++);
221  mBlock = geom->MakeBox(nBlocks, Iron, 100,0.5,160);
222  mBlock->SetLineColor(41);
223  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-26,40));
224 
225 
226 
227  sprintf(nBlocks,"f%d_bg%d",f,N++);
228  mBlock = geom->MakeBox(nBlocks, Iron, 10,0.01,160);
229  mBlock->SetLineColor(19);
230  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-25,40));
231 
232 
233  sprintf(nBlocks,"f%d_bg%d",f,N++);
234  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
235  mBlock->SetLineColor(8);
236  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,170));
237 
238  sprintf(nBlocks,"f%d_bg%d",f,N++);
239  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
240  mBlock->SetLineColor(8);
241  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,170));
242 
243 
244  sprintf(nBlocks,"f%d_bg%d",f,N++);
245  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
246  mBlock->SetLineColor(8);
247  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,150));
248 
249  sprintf(nBlocks,"f%d_bg%d",f,N++);
250  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
251  mBlock->SetLineColor(8);
252  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,150));
253 
254 
255  sprintf(nBlocks,"f%d_bg%d",f,N++);
256  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
257  mBlock->SetLineColor(8);
258  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,130));
259 
260  sprintf(nBlocks,"f%d_bg%d",f,N++);
261  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
262  mBlock->SetLineColor(8);
263  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,130));
264 
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,110));
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,110));
275 
276 
277 
278 
279 
280  sprintf(nBlocks,"f%d_bg%d",f,N++);
281  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
282  mBlock->SetLineColor(8);
283  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,170));
284 
285  sprintf(nBlocks,"f%d_bg%d",f,N++);
286  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
287  mBlock->SetLineColor(8);
288  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,170));
289 
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,-22,150));
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,-25,150));
300 
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);
305  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,130));
306 
307  sprintf(nBlocks,"f%d_bg%d",f,N++);
308  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
309  mBlock->SetLineColor(8);
310  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,130));
311 
312 
313  sprintf(nBlocks,"f%d_bg%d",f,N++);
314  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
315  mBlock->SetLineColor(8);
316  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,110));
317 
318  sprintf(nBlocks,"f%d_bg%d",f,N++);
319  mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
320  mBlock->SetLineColor(8);
321  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,110));
322 
323 
324 
325 
326 
327 
328 
329 
330 
331  sprintf(nBlocks,"ab%d",N++);
332  mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
333  mBlock->SetLineColor(12);
334  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(20,-15,110));
335 
336  sprintf(nBlocks,"ab%d",N++);
337  mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
338  mBlock->SetLineColor(10);
339  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(25,-8,110));
340 
341  sprintf(nBlocks,"ab%d",N++);
342  mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
343  mBlock->SetLineColor(12);
344  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-20,-15,110));
345 
346  sprintf(nBlocks,"ab%d",N++);
347  mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
348  mBlock->SetLineColor(10);
349  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-8,110));
350 
351 
352  sprintf(nBlocks,"f%d_bg%d",f,N++);
353  mBlock = geom->MakeBox(nBlocks, Iron, 7,1.5,5);
354  mBlock->SetLineColor(18);
355  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,88));
356 
357  sprintf(nBlocks,"f%d_bg%d",f,N++);
358  mBlock = geom->MakeBox(nBlocks, Iron, 7,1,5);
359  mBlock->SetLineColor(18);
360  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,92));
361 
362  sprintf(nBlocks,"f%d_bg%d",f,N++);
363  mBlock = geom->MakeBox(nBlocks, Iron, 7,0.5,5);
364  mBlock->SetLineColor(18);
365  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,96));
366 
367  sprintf(nBlocks,"f%d_bg%d",f,N++);
368  mBlock = geom->MakeBox(nBlocks, Iron, 7,0.1,5);
369  mBlock->SetLineColor(18);
370  top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,100));
371 
372  geom->CloseGeometry();
373  top->SetVisibility(0);
374 
375  top->Draw("ogl");
376 }
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
virtual void Draw(Option_t *option="")
draw top volume according to option
#define N
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
TFile * f
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.
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.
void cheongwadae()
Definition: cheongwadae.C:3
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
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.
virtual void SetVisibility(Bool_t vis=kTRUE)
set visibility of this volume
virtual void SetLineColor(Color_t lcolor)
Set the line color.