Double_t dphi = 15.; Double_t twist = 10; Double_t rmin = 0.; Double_t rmax = 1.; Double_t rtor = 5.; Double_t local[3] = {rtor, 0., 0.}; Bool_t composite = kFALSE; void spiral(Int_t nsegments=100) { TGeoManager *geom = new TGeoManager("test", "spiral made of toruses"); //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMaterial *matPoly = new TGeoMaterial("Poly",0,0,0); //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); TGeoMedium *Plexi = new TGeoMedium ("Plexiglass",3,matPoly); //--- make the top container volume TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 250, 250, 250); geom->SetTopVolume(top); TGeoTorus *tor = new TGeoTorus("tor",rtor,rmin,rmax,0,dphi);// The toroidal part TGeoVolume *guide; if (composite) { // Make a single composite shape TGeoUnion *bnode; TGeoShape *left, *right; TGeoMatrix *lmat, *rmat; left = tor; right = tor; lmat = gGeoIdentity; for (Int_t i=0; iSetLineColor(kRed); } else { // Make an assembly of segments TGeoVolumeAssembly *aguide = new TGeoVolumeAssembly("lguide2"); guide = aguide; TGeoVolume *vtor = new TGeoVolume("tor", tor, Plexi); vtor->SetLineColor(kRed); aguide->AddNode(vtor, 0); for (Int_t i=0; iAddNode(vtor, i+1, MakeMatrix(i)); } } top->AddNode(guide,1, new TGeoRotation("",0,0,0)); geom->CloseGeometry(); top->Draw("ogl"); } TGeoMatrix *MakeMatrix(Int_t i) { TGeoRotation rz; rz.RotateZ(dphi); TGeoRotation *ext = new TGeoRotation(); TGeoRotation xr; Double_t dummy1[3],dummy2[3],trans[3]; Double_t final[3]; rz.LocalToMaster(local, final); for (Int_t j=0; jRotateY(twist); ext->RotateZ(dphi); xr = *ext; xr.MultiplyBy(&rz); // X^j, X*Rz computed ext->LocalToMaster(local, dummy1); xr.LocalToMaster(local, dummy2); for (Int_t k=0; k<3; k++) { trans[k] = final[k] - dummy1[k]; final[k] = dummy2[k] + trans[k]; } } TGeoCombiTrans *matrix = new TGeoCombiTrans(Form("tr%d",i),trans[0],trans[1],trans[2], ext); matrix->RegisterYourself(); return matrix; }