00001 void rootgeom_coin()
00002 {
00003
00004 gSystem->Load("libGeom");
00005 gSystem->Load("libRQTGL");
00006 gSystem->Load("libRQIVTGL");
00007 TCanvas *cc = new TCanvas("rootgeom");
00008 cc->SetFillColor(kBlack);
00009 TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");
00010
00011
00012 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
00013 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
00014
00015 TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
00016 TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
00017
00018
00019 TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.);
00020 TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.);
00021 TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.);
00022 TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.);
00023 TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.);
00024 TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.);
00025 TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.);
00026 TGeoRotation *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.);
00027 TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1);
00028 TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.);
00029 TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.);
00030 TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.);
00031 TGeoTranslationC *tr11 = new TGeoTranslationC(35., 0., 0.);
00032 TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.);
00033 TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.);
00034
00035 TGeoTranslation *tr14 = new TGeoTranslation(0,0,-100);
00036 TGeoCombiTrans *combi2 = new TGeoCombiTrans(0,0,100,
00037 new TGeoRotation("rot2",90,180,90,90,180,0));
00038 TGeoCombiTrans *combi3 = new TGeoCombiTrans(100,0,0,
00039 new TGeoRotation("rot3",90,270,0,0,90,180));
00040 TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100,0,0,
00041 new TGeoRotation("rot4",90,90,0,0,90,0));
00042 TGeoCombiTrans *combi5 = new TGeoCombiTrans(0,100,0,
00043 new TGeoRotation("rot5",0,0,90,180,90,270));
00044 TGeoCombiTrans *combi6 = new TGeoCombiTrans(0,-100,0,
00045 new TGeoRotation("rot6",180,0,90,180,90,90));
00046
00047
00048 Double_t worldx = 110.;
00049 Double_t worldy = 50.;
00050 Double_t worldz = 5.;
00051 TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.);
00052 geom->SetTopVolume(top);
00053 TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum,120,120,120);
00054 replica->SetVisibility(kFALSE);
00055 TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.);
00056 rootbox->SetVisibility(kFALSE);
00057
00058
00059 TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.);
00060 R->SetVisibility(kFALSE);
00061 TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.);
00062 bar1->SetLineColor(kRed);
00063 R->AddNode(bar1, 1, tr1);
00064 TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.);
00065 bar2->SetLineColor(kRed);
00066 R->AddNode(bar2, 1, tr2);
00067 R->AddNode(bar2, 2, tr3);
00068 TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.);
00069 tub1->SetLineColor(kRed);
00070 R->AddNode(tub1, 1, tr4);
00071 TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.);
00072 bar3->SetLineColor(kRed);
00073 TGeoArb8 *arb = (TGeoArb8*)bar3->GetShape();
00074 arb->SetVertex(0, 15., -5.);
00075 arb->SetVertex(1, 0., -25.);
00076 arb->SetVertex(2, -10., -25.);
00077 arb->SetVertex(3, 5., -5.);
00078 arb->SetVertex(4, 15., -5.);
00079 arb->SetVertex(5, 0., -25.);
00080 arb->SetVertex(6, -10., -25.);
00081 arb->SetVertex(7, 5., -5.);
00082 R->AddNode(bar3, 1, gGeoIdentity);
00083
00084
00085 TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.);
00086 O->SetVisibility(kFALSE);
00087 TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.);
00088 bar4->SetLineColor(kYellow);
00089 O->AddNode(bar4, 1, tr5);
00090 O->AddNode(bar4, 2, tr6);
00091 TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.);
00092 tub2->SetLineColor(kYellow);
00093 O->AddNode(tub2, 1, tr7);
00094 O->AddNode(tub2, 2, combi1);
00095
00096
00097 TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.);
00098 T->SetVisibility(kFALSE);
00099 TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.);
00100 bar5->SetLineColor(kBlue);
00101 T->AddNode(bar5, 1, tr8);
00102 TGeoVolume *bar6 = geom->MakeBox("bar6", Al, 17.5, 5., 5.);
00103 bar6->SetLineColor(kBlue);
00104 T->AddNode(bar6, 1, tr9);
00105
00106
00107
00108 rootbox->AddNode(R, 1, tr10);
00109 rootbox->AddNode(O, 1, tr11);
00110 rootbox->AddNode(O, 2, tr12);
00111 rootbox->AddNode(T, 1, tr13);
00112
00113 replica->AddNode(rootbox, 1, tr14);
00114 replica->AddNode(rootbox, 2, combi2);
00115 replica->AddNode(rootbox, 3, combi3);
00116 replica->AddNode(rootbox, 4, combi4);
00117 replica->AddNode(rootbox, 5, combi5);
00118 replica->AddNode(rootbox, 6, combi6);
00119
00120 TGeoTranslationC *replica1 =new TGeoTranslationC(-150, -150, 0);
00121 TGeoTranslation *replica2 =new TGeoTranslation ( 150, -150, 0);
00122 TGeoTranslationC *replica3 =new TGeoTranslationC( 150, 150, 0);
00123 TGeoTranslation *replica4 =new TGeoTranslation (-150, 150, 0);
00124
00125 tr11->SetFileName("replica3.iv");
00126 replica1->SetFileName("replica1.iv");
00127 replica3->SetFileName("replica3.iv");
00128
00129 top->AddNode(replica, 1, replica1);
00130 top->AddNode(replica, 2, replica2);
00131 top->AddNode(replica, 3, replica3);
00132 top->AddNode(replica, 4, replica4);
00133
00134
00135 geom->CloseGeometry();
00136
00137
00138
00139
00140
00141
00142
00143 geom->SetVisLevel(4);
00144 gGeoManager->GetTopVolume()->Draw("oiv");
00145 printf("\n\n-----------------------------------------\n");
00146 printf(" With your left mouse button, select menu: \n");
00147 printf(" \"View\" -> \"View3D with\" -> \"Coin3D view\" \n");
00148 printf("-----------------------------------------\n");
00149 }
00150