00001
00002
00003
00004 void assembly()
00005 {
00006
00007 gSystem->Load("libGeom");
00008 TGeoManager *geom = new TGeoManager("Assemblies",
00009 "Geometry using assemblies");
00010 Int_t i;
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("Aluminium",2, matAl);
00017
00018
00019 TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
00020 geom->SetTopVolume(top);
00021
00022
00023 TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");
00024
00025 Int_t ntooth = 5;
00026 Double_t xplate = 25;
00027 Double_t yplate = 50;
00028 Double_t xtooth = 10;
00029 Double_t ytooth = 0.5*yplate/ntooth;
00030 Double_t dshift = 2.*xplate + xtooth;
00031 Double_t xt,yt;
00032
00033 TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
00034 plate->SetLineColor(kBlue);
00035 TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
00036 tooth->SetLineColor(kBlue);
00037 tplate->AddNode(plate,1);
00038 for (i=0; i<ntooth; i++) {
00039 xt = xplate+xtooth;
00040 yt = -yplate + (4*i+1)*ytooth;
00041 tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
00042 xt = -xplate-xtooth;
00043 yt = -yplate + (4*i+3)*ytooth;
00044 tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
00045 }
00046
00047 TGeoRotation *rot1 = new TGeoRotation();
00048 rot1->RotateX(90);
00049 TGeoRotation *rot;
00050
00051
00052 TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
00053 for (i=0; i<6; i++) {
00054 Double_t phi = 60.*i;
00055 Double_t phirad = phi*TMath::DegToRad();
00056 Double_t xp = dshift*TMath::Sin(phirad);
00057 Double_t yp = -dshift*TMath::Cos(phirad);
00058 rot = new TGeoRotation(*rot1);
00059 rot->RotateZ(phi);
00060 cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
00061 }
00062
00063
00064
00065
00066 TGeoVolume *row = new TGeoVolumeAssembly("ROW");
00067 Int_t ncells = 5;
00068 for (i=0; i<ncells; i++) {
00069 Double_t ycell = (2*i+1)*(dshift+10);
00070 row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
00071 row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
00072 }
00073
00074 Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
00075 Double_t dyrow = dshift+10.;
00076 Int_t nrows = 5;
00077 for (i=0; i<nrows; i++) {
00078 Double_t xrow = 0.5*(2*i+1)*dxrow;
00079 Double_t yrow = 0.5*dyrow;
00080 if ((i%2)==0) yrow = -yrow;
00081 top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
00082 top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
00083 }
00084
00085
00086 geom->CloseGeometry();
00087
00088 geom->SetVisLevel(4);
00089 geom->SetVisOption(0);
00090 top->Draw();
00091 }
00092