From $ROOTSYS/tutorials/geom/assembly.C

//Geometry detector assembly example
//Author: Andrei Gheata

void assembly()
{
//--- Definition of a simple geometry
   gSystem->Load("libGeom");
   TGeoManager *geom = new TGeoManager("Assemblies",
      "Geometry using assemblies");
   Int_t i;
   //--- define some materials
   TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
   TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
//   //--- define some media
   TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
   TGeoMedium *Al = new TGeoMedium("Aluminium",2, matAl);

   //--- make the top container volume
   TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
   geom->SetTopVolume(top);

   // Make the elementary assembly of the whole structure
   TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");

   Int_t ntooth = 5;
   Double_t xplate = 25;
   Double_t yplate = 50;
   Double_t xtooth = 10;
   Double_t ytooth = 0.5*yplate/ntooth;
   Double_t dshift = 2.*xplate + xtooth;
   Double_t xt,yt;

   TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
   plate->SetLineColor(kBlue);
   TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
   tooth->SetLineColor(kBlue);
   tplate->AddNode(plate,1);
   for (i=0; i<ntooth; i++) {
      xt = xplate+xtooth;
      yt = -yplate + (4*i+1)*ytooth;
      tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
      xt = -xplate-xtooth;
      yt = -yplate + (4*i+3)*ytooth;
      tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
   }

   TGeoRotation *rot1 = new TGeoRotation();
   rot1->RotateX(90);
   TGeoRotation *rot;
   // Make a hexagone cell out of 6 toothplates. These can zip togeather
   // without generating overlaps (they are self-contained)
   TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
   for (i=0; i<6; i++) {
      Double_t phi =  60.*i;
      Double_t phirad = phi*TMath::DegToRad();
      Double_t xp = dshift*TMath::Sin(phirad);
      Double_t yp = -dshift*TMath::Cos(phirad);
      rot = new TGeoRotation(*rot1);
      rot->RotateZ(phi);
      cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
   }

   // Make a row as an assembly of cells, then combine rows in a honeycomb
   // structure. This again works without any need to define rows as
   // "overlapping"
   TGeoVolume *row = new TGeoVolumeAssembly("ROW");
   Int_t ncells = 5;
   for (i=0; i<ncells; i++) {
      Double_t ycell = (2*i+1)*(dshift+10);
      row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
      row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
   }

   Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
   Double_t dyrow = dshift+10.;
   Int_t nrows = 5;
   for (i=0; i<nrows; i++) {
      Double_t xrow = 0.5*(2*i+1)*dxrow;
      Double_t yrow = 0.5*dyrow;
      if ((i%2)==0) yrow = -yrow;
      top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
      top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
   }

   //--- close the geometry
   geom->CloseGeometry();

   geom->SetVisLevel(4);
   geom->SetVisOption(0);
   top->Draw();
}

 assembly.C:1
 assembly.C:2
 assembly.C:3
 assembly.C:4
 assembly.C:5
 assembly.C:6
 assembly.C:7
 assembly.C:8
 assembly.C:9
 assembly.C:10
 assembly.C:11
 assembly.C:12
 assembly.C:13
 assembly.C:14
 assembly.C:15
 assembly.C:16
 assembly.C:17
 assembly.C:18
 assembly.C:19
 assembly.C:20
 assembly.C:21
 assembly.C:22
 assembly.C:23
 assembly.C:24
 assembly.C:25
 assembly.C:26
 assembly.C:27
 assembly.C:28
 assembly.C:29
 assembly.C:30
 assembly.C:31
 assembly.C:32
 assembly.C:33
 assembly.C:34
 assembly.C:35
 assembly.C:36
 assembly.C:37
 assembly.C:38
 assembly.C:39
 assembly.C:40
 assembly.C:41
 assembly.C:42
 assembly.C:43
 assembly.C:44
 assembly.C:45
 assembly.C:46
 assembly.C:47
 assembly.C:48
 assembly.C:49
 assembly.C:50
 assembly.C:51
 assembly.C:52
 assembly.C:53
 assembly.C:54
 assembly.C:55
 assembly.C:56
 assembly.C:57
 assembly.C:58
 assembly.C:59
 assembly.C:60
 assembly.C:61
 assembly.C:62
 assembly.C:63
 assembly.C:64
 assembly.C:65
 assembly.C:66
 assembly.C:67
 assembly.C:68
 assembly.C:69
 assembly.C:70
 assembly.C:71
 assembly.C:72
 assembly.C:73
 assembly.C:74
 assembly.C:75
 assembly.C:76
 assembly.C:77
 assembly.C:78
 assembly.C:79
 assembly.C:80
 assembly.C:81
 assembly.C:82
 assembly.C:83
 assembly.C:84
 assembly.C:85
 assembly.C:86
 assembly.C:87
 assembly.C:88
 assembly.C:89
 assembly.C:90
 assembly.C:91
 assembly.C:92
 assembly.C:93