cheongwadae.C

Go to the documentation of this file.
00001 #include "TGeoManager.h"
00002    
00003 void cheongwadae() 
00004 {
00005   // Drawing the Cheongwadae building which is the Presidential Residence of the Republic of Korea, using ROOT geometry class.
00006   //
00007   // Author: Hee Jun Shin (s-heejun@hanmail.net), Dept. of Physics, Univ. of Seoul
00008   // Reviewed by Sunman Kim (sunman98@hanmail.net)
00009   // Supervisor: Prof. Inkyu Park (icpark@physics.uos.ac.kr)
00010   // 
00011   // How to run: .x cheongwadae.C in ROOT terminal, then use OpenGL
00012   //
00013   // This macro was created for the evaluation of Computational Physics course in 2006.
00014   // We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team
00015   //
00016    
00017    TGeoManager *geom = new TGeoManager("geom","My first 3D geometry");
00018 
00019    //material
00020    TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
00021    TGeoMaterial *Fe = new TGeoMaterial("Fe",55.845,26,7.87);
00022 
00023    //creat media
00024    TGeoMedium *Air = new TGeoMedium("Vacuum",0,vacuum);
00025    TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe);
00026 
00027    //creat volume
00028    TGeoVolume *top = geom->MakeBox("top",Air,300,300,300);
00029    geom->SetTopVolume(top);
00030    geom->SetTopVisible(0);
00031    // If you want to see the boundary, please input the number, 1 instead of 0.
00032    // Like this, geom->SetTopVisible(1); 
00033 
00034 char nBlocks[100];
00035 int N = 0;
00036 int f=0;
00037 int di[2]; di[0] = 0; di[1] = 30;
00038 TGeoVolume *mBlock;
00039    
00040 
00041    for(int k=0;k<7;k++){
00042    for(int i=0;i<20;i++){
00043       sprintf(nBlocks,"f%d_bg%d",f,N++);
00044       mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
00045       mBlock->SetLineColor(20);
00046       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-10.6-(2.6*i),-17.8+(6*k),0));
00047 
00048       sprintf(nBlocks,"f%d_bg%d",f,N++);
00049       mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
00050       mBlock->SetLineColor(12);
00051       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-11.9-(2.6*i),-17.8+(6*k),0));
00052 
00053    }
00054       sprintf(nBlocks,"f%d_bg%d",f,N++);
00055       mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
00056       mBlock->SetLineColor(20);
00057       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-14.8+(6*k),0));
00058    }
00059       sprintf(nBlocks,"f%d_bg%d",f,N++);
00060       mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
00061       mBlock->SetLineColor(20);
00062       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-21.6,0));
00063 
00064 
00065 
00066    for(int k=0;k<7;k++){
00067    for(int i=0;i<20;i++){
00068       sprintf(nBlocks,"f%d_bg%d",f,N++);
00069       mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
00070       mBlock->SetLineColor(20);
00071       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-10.6-(2.6*i),-17.8+(6*k),0));
00072       sprintf(nBlocks,"f%d_bg%d",f,N++);
00073       mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
00074       mBlock->SetLineColor(12);
00075       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-11.9-(2.6*i),-17.8+(6*k),0));
00076 
00077    }
00078       sprintf(nBlocks,"f%d_bg%d",f,N++);
00079       mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
00080       mBlock->SetLineColor(20);
00081       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-36,-14.8+(6*k),0));
00082    }
00083 
00084       sprintf(nBlocks,"f%d_bg%d",f,N++);
00085       mBlock = geom->MakeBox(nBlocks, Iron, 10,22,58);
00086       mBlock->SetLineColor(2);
00087       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,0,0));
00088 
00089       sprintf(nBlocks,"f%d_bg%d",f,N++);
00090       mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
00091       mBlock->SetLineColor(13);
00092       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(4,-14,60));
00093 
00094       sprintf(nBlocks,"f%d_bg%d",f,N++);
00095       mBlock = geom->MakeBox(nBlocks, Iron, 3.5,8,0.1);
00096       mBlock->SetLineColor(13);
00097       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-4,-14,60));
00098 
00099 
00100 
00101       sprintf(nBlocks,"f%d_bg%d",f,N++);
00102       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00103       mBlock->SetLineColor(1);
00104       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,20,60));
00105 
00106       sprintf(nBlocks,"f%d_bg%d",f,N++);
00107       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00108       mBlock->SetLineColor(1);
00109       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,17,60));
00110 
00111       sprintf(nBlocks,"f%d_bg%d",f,N++);
00112       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00113       mBlock->SetLineColor(1);
00114       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,14,60));
00115 
00116       sprintf(nBlocks,"f%d_bg%d",f,N++);
00117       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00118       mBlock->SetLineColor(1);
00119       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,11,60));
00120 
00121       sprintf(nBlocks,"f%d_bg%d",f,N++);
00122       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00123       mBlock->SetLineColor(1);
00124       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,8,60));
00125 
00126       sprintf(nBlocks,"f%d_bg%d",f,N++);
00127       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00128       mBlock->SetLineColor(1);
00129       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,5,60));
00130 
00131       sprintf(nBlocks,"f%d_bg%d",f,N++);
00132       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.2,0.1);
00133       mBlock->SetLineColor(1);
00134       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,2,60));
00135 
00136 
00137 
00138    for(int k=0;k<7;k++){
00139    for(int i=0;i<20;i++){
00140       sprintf(nBlocks,"f%d_bg%d",f,N++);
00141       mBlock = geom->MakeBox(nBlocks, Iron, 0.6,1.8,63);
00142       mBlock->SetLineColor(20);
00143       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(10.6+(2.6*i),-17.8+(6*k),0));
00144       sprintf(nBlocks,"f%d_bg%d",f,N++);
00145       mBlock = geom->MakeBox(nBlocks, Iron, 0.7,1.8,58);
00146       mBlock->SetLineColor(12);
00147       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(11.9+(2.6*i),-17.8+(6*k),0));
00148 
00149    }
00150       sprintf(nBlocks,"f%d_bg%d",f,N++);
00151       mBlock = geom->MakeBox(nBlocks, Iron, 26,1.2,63);
00152       mBlock->SetLineColor(20);
00153       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(36,-14.8+(6*k),0));
00154    }
00155       sprintf(nBlocks,"f%d_bg%d",f,N++);
00156       mBlock = geom->MakeBox(nBlocks, Iron, 26,2,63);
00157       mBlock->SetLineColor(20);
00158       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(36,-21.6,0));
00159 
00160 
00161       sprintf(nBlocks,"f%d_bg%d",f,N++);
00162       mBlock = geom->MakeBox(nBlocks, Iron, 82,2,82);
00163       mBlock->SetLineColor(18);
00164       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,24,0));
00165 
00166       sprintf(nBlocks,"f%d_bg%d",f,N++);
00167       mBlock = geom->MakeBox(nBlocks, Iron, 85,0.5,85);
00168       mBlock->SetLineColor(18);
00169       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,26,0));
00170 
00171       sprintf(nBlocks,"f%d_bg%d",f,N++);
00172       mBlock = geom->MakeBox(nBlocks, Iron, 88,2,88);
00173       mBlock->SetLineColor(18);
00174       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,0));
00175 
00176 
00177       sprintf(nBlocks,"f%d_bg%d",f,N++);
00178       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 30, 0, 180, 0, 180);
00179       mBlock->SetLineColor(32);
00180       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,24,0));
00181    
00182       sprintf(nBlocks,"ab%d",N++);
00183       mBlock = geom->MakeBox(nBlocks,Iron, 0.1,30,0.1);
00184       mBlock->SetLineColor(10);   
00185       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,40,0));
00186 
00187       sprintf(nBlocks,"ab%d",N++);
00188       mBlock = geom->MakeTubs(nBlocks,Iron, 0,30,4,360,360);
00189       mBlock->SetLineColor(10);   
00190       top->AddNodeOverlap(mBlock,1,new TGeoCombiTrans(0,27,0, new TGeoRotation("r1",0,90,0)));
00191 
00192 
00193    for(int i=0;i<8;i++){
00194       sprintf(nBlocks,"ab%d",N++);
00195       mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
00196       mBlock->SetLineColor(18);   
00197       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70+(20*i),0,80));
00198    }
00199 
00200    for(int i=0;i<8;i++){
00201       sprintf(nBlocks,"ab%d",N++);
00202       mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
00203       mBlock->SetLineColor(18);   
00204       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70+(20*i),0,-80));
00205    }
00206 
00207    for(int i=0;i<7;i++){
00208       sprintf(nBlocks,"ab%d",N++);
00209       mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
00210       mBlock->SetLineColor(18);   
00211       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-70,0,-80+(23*i)));
00212    }
00213 
00214    for(int i=0;i<7;i++){
00215       sprintf(nBlocks,"ab%d",N++);
00216       mBlock = geom->MakeBox(nBlocks,Iron, 2,22,2);
00217       mBlock->SetLineColor(18);   
00218       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(70,0,-80+(23*i)));
00219    }
00220       sprintf(nBlocks,"f%d_bg%d",f,N++);
00221       mBlock = geom->MakeBox(nBlocks, Iron, 100,0.5,160);
00222       mBlock->SetLineColor(41);
00223       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-26,40));
00224 
00225 
00226 
00227       sprintf(nBlocks,"f%d_bg%d",f,N++);
00228       mBlock = geom->MakeBox(nBlocks, Iron, 10,0.01,160);
00229       mBlock->SetLineColor(19);
00230       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-25,40));
00231 
00232 
00233       sprintf(nBlocks,"f%d_bg%d",f,N++);
00234       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00235       mBlock->SetLineColor(8);
00236       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,170));
00237 
00238       sprintf(nBlocks,"f%d_bg%d",f,N++);
00239       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00240       mBlock->SetLineColor(8);
00241       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,170));
00242 
00243 
00244       sprintf(nBlocks,"f%d_bg%d",f,N++);
00245       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00246       mBlock->SetLineColor(8);
00247       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,150));
00248 
00249       sprintf(nBlocks,"f%d_bg%d",f,N++);
00250       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00251       mBlock->SetLineColor(8);
00252       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,150));
00253 
00254 
00255       sprintf(nBlocks,"f%d_bg%d",f,N++);
00256       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00257       mBlock->SetLineColor(8);
00258       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,130));
00259 
00260       sprintf(nBlocks,"f%d_bg%d",f,N++);
00261       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00262       mBlock->SetLineColor(8);
00263       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,130));
00264 
00265 
00266       sprintf(nBlocks,"f%d_bg%d",f,N++);
00267       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00268       mBlock->SetLineColor(8);
00269       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-22,110));
00270 
00271       sprintf(nBlocks,"f%d_bg%d",f,N++);
00272       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00273       mBlock->SetLineColor(8);
00274       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(15,-25,110));
00275 
00276 
00277 
00278 
00279 
00280       sprintf(nBlocks,"f%d_bg%d",f,N++);
00281       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00282       mBlock->SetLineColor(8);
00283       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,170));
00284 
00285       sprintf(nBlocks,"f%d_bg%d",f,N++);
00286       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00287       mBlock->SetLineColor(8);
00288       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,170));
00289 
00290 
00291       sprintf(nBlocks,"f%d_bg%d",f,N++);
00292       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00293       mBlock->SetLineColor(8);
00294       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,150));
00295 
00296       sprintf(nBlocks,"f%d_bg%d",f,N++);
00297       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00298       mBlock->SetLineColor(8);
00299       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,150));
00300 
00301 
00302       sprintf(nBlocks,"f%d_bg%d",f,N++);
00303       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00304       mBlock->SetLineColor(8);
00305       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,130));
00306 
00307       sprintf(nBlocks,"f%d_bg%d",f,N++);
00308       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00309       mBlock->SetLineColor(8);
00310       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,130));
00311 
00312 
00313       sprintf(nBlocks,"f%d_bg%d",f,N++);
00314       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00315       mBlock->SetLineColor(8);
00316       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-22,110));
00317 
00318       sprintf(nBlocks,"f%d_bg%d",f,N++);
00319       mBlock = geom->MakeSphere(nBlocks, Iron, 0, 5, 0, 180, 0, 180);
00320       mBlock->SetLineColor(8);
00321       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-25,110));
00322 
00323 
00324 
00325    
00326 
00327 
00328 
00329 
00330 
00331       sprintf(nBlocks,"ab%d",N++);
00332       mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
00333       mBlock->SetLineColor(12);   
00334       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(20,-15,110));
00335 
00336       sprintf(nBlocks,"ab%d",N++);
00337       mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
00338       mBlock->SetLineColor(10);   
00339       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(25,-8,110));
00340 
00341       sprintf(nBlocks,"ab%d",N++);
00342       mBlock = geom->MakeBox(nBlocks,Iron, 0.1,10,0.1);
00343       mBlock->SetLineColor(12);   
00344       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-20,-15,110));
00345 
00346       sprintf(nBlocks,"ab%d",N++);
00347       mBlock = geom->MakeBox(nBlocks,Iron, 5,3,0.1);
00348       mBlock->SetLineColor(10);   
00349       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-15,-8,110));
00350 
00351 
00352       sprintf(nBlocks,"f%d_bg%d",f,N++);
00353       mBlock = geom->MakeBox(nBlocks, Iron, 7,1.5,5);
00354       mBlock->SetLineColor(18);
00355       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,88));
00356 
00357       sprintf(nBlocks,"f%d_bg%d",f,N++);
00358       mBlock = geom->MakeBox(nBlocks, Iron, 7,1,5);
00359       mBlock->SetLineColor(18);
00360       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,92));
00361 
00362       sprintf(nBlocks,"f%d_bg%d",f,N++);
00363       mBlock = geom->MakeBox(nBlocks, Iron, 7,0.5,5);
00364       mBlock->SetLineColor(18);
00365       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,96));
00366 
00367       sprintf(nBlocks,"f%d_bg%d",f,N++);
00368       mBlock = geom->MakeBox(nBlocks, Iron, 7,0.1,5);
00369       mBlock->SetLineColor(18);
00370       top->AddNodeOverlap(mBlock,1,new TGeoTranslation(0,-24,100));
00371 
00372    geom->CloseGeometry();
00373    top->SetVisibility(0);
00374 
00375    top->Draw("ogl");
00376 }

Generated on Tue Jul 5 15:44:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1