00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 void assembly()
00012 {
00013
00014 gSystem->Load("libGeom");
00015 TGeoManager *geom = new TGeoManager("Assemblies",
00016 "Geometry using assemblies");
00017 Int_t i;
00018
00019 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
00020 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
00021
00022 TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
00023 TGeoMedium *Al = new TGeoMedium("Aluminium",2, matAl);
00024
00025
00026 TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
00027 geom->SetTopVolume(top);
00028
00029
00030 TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");
00031
00032 Int_t ntooth = 5;
00033 Double_t xplate = 25;
00034 Double_t yplate = 50;
00035 Double_t xtooth = 10;
00036 Double_t ytooth = 0.5*yplate/ntooth;
00037 Double_t dshift = 2.*xplate + xtooth;
00038 Double_t xt,yt;
00039
00040 TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
00041 plate->SetLineColor(kBlue);
00042 TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
00043 tooth->SetLineColor(kBlue);
00044 tplate->AddNode(plate,1);
00045 for (i=0; i<ntooth; i++) {
00046 xt = xplate+xtooth;
00047 yt = -yplate + (4*i+1)*ytooth;
00048 tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
00049 xt = -xplate-xtooth;
00050 yt = -yplate + (4*i+3)*ytooth;
00051 tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
00052 }
00053
00054 TGeoRotation *rot1 = new TGeoRotation();
00055 rot1->RotateX(90);
00056 TGeoRotation *rot;
00057
00058
00059 TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
00060 for (i=0; i<6; i++) {
00061 Double_t phi = 60.*i;
00062 Double_t phirad = phi*TMath::DegToRad();
00063 Double_t xp = dshift*TMath::Sin(phirad);
00064 Double_t yp = -dshift*TMath::Cos(phirad);
00065 rot = new TGeoRotation(*rot1);
00066 rot->RotateZ(phi);
00067 cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
00068 }
00069
00070
00071
00072
00073 TGeoVolume *row = new TGeoVolumeAssembly("ROW");
00074 Int_t ncells = 5;
00075 for (i=0; i<ncells; i++) {
00076 Double_t ycell = (2*i+1)*(dshift+10);
00077 row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
00078 row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
00079 }
00080
00081 Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
00082 Double_t dyrow = dshift+10.;
00083 Int_t nrows = 5;
00084 for (i=0; i<nrows; i++) {
00085 Double_t xrow = 0.5*(2*i+1)*dxrow;
00086 Double_t yrow = 0.5*dyrow;
00087 if ((i%2)==0) yrow = -yrow;
00088 top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
00089 top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
00090 }
00091
00092
00093 geom->CloseGeometry();
00094
00095 TEveManager::Create();
00096
00097 TGeoNode* node = gGeoManager->GetTopNode();
00098 TEveGeoTopNode* en = new TEveGeoTopNode(gGeoManager, node);
00099 en->SetVisLevel(4);
00100 en->GetNode()->GetVolume()->SetVisibility(kFALSE);
00101
00102 gEve->AddGlobalElement(en);
00103
00104 gEve->Redraw3D(kTRUE);
00105
00106 en->ExpandIntoListTreesRecursively();
00107 en->Save("assembly.root", "Assembly");
00108 }