Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
assembly.C File Reference

Detailed Description

Geometry detector assembly example.

Modified to save the assembly as shape-extract.

  1. Run root assembly.C This will produce assembly.root containing the extract.
  2. Display the assembly as: root show_extract.C("assembly.root")
void assembly()
{
//--- Definition of a simple geometry
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");
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++) {
yt = -yplate + (4*i+1)*ytooth;
tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
yt = -yplate + (4*i+3)*ytooth;
tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
}
rot1->RotateX(90);
// Make a hexagone cell out of 6 tooth plates. These can zip together
// without generating overlaps (they are self-contained)
for (i=0; i<6; i++) {
Double_t phi = 60.*i;
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");
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));
}
Int_t nrows = 5;
for (i=0; i<nrows; i++) {
Double_t xrow = 0.5*(2*i+1)*dxrow;
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();
}
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Class describing rotation + translation.
Definition TGeoMatrix.h:317
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
Base class describing materials.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
Class describing rotations.
Definition TGeoMatrix.h:168
Class describing translations.
Definition TGeoMatrix.h:116
Volume assemblies.
Definition TGeoVolume.h:316
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void Draw(Option_t *option="") override
draw top volume according to option
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:79
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:594
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:588
Double_t Tan(Double_t)
Returns the tangent of an angle of x radians.
Definition TMath.h:600
Author
Andrei Gheata

Definition in file assembly.C.