ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
assembly.C
Go to the documentation of this file.
1 //Geometry detector assembly example
2 //Author: Andrei Gheata
3 
4 void assembly()
5 {
6 //--- Definition of a simple geometry
7  gSystem->Load("libGeom");
8  TGeoManager *geom = new TGeoManager("Assemblies",
9  "Geometry using assemblies");
10  Int_t i;
11  //--- define some materials
12  TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
13  TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
14 // //--- define some media
15  TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
16  TGeoMedium *Al = new TGeoMedium("Aluminium",2, matAl);
17 
18  //--- make the top container volume
19  TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
20  geom->SetTopVolume(top);
21 
22  // Make the elementary assembly of the whole structure
23  TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");
24 
25  Int_t ntooth = 5;
26  Double_t xplate = 25;
27  Double_t yplate = 50;
28  Double_t xtooth = 10;
29  Double_t ytooth = 0.5*yplate/ntooth;
30  Double_t dshift = 2.*xplate + xtooth;
31  Double_t xt,yt;
32 
33  TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
34  plate->SetLineColor(kBlue);
35  TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
36  tooth->SetLineColor(kBlue);
37  tplate->AddNode(plate,1);
38  for (i=0; i<ntooth; i++) {
39  xt = xplate+xtooth;
40  yt = -yplate + (4*i+1)*ytooth;
41  tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
42  xt = -xplate-xtooth;
43  yt = -yplate + (4*i+3)*ytooth;
44  tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
45  }
46 
47  TGeoRotation *rot1 = new TGeoRotation();
48  rot1->RotateX(90);
49  TGeoRotation *rot;
50  // Make a hexagone cell out of 6 toothplates. These can zip togeather
51  // without generating overlaps (they are self-contained)
52  TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
53  for (i=0; i<6; i++) {
54  Double_t phi = 60.*i;
55  Double_t phirad = phi*TMath::DegToRad();
56  Double_t xp = dshift*TMath::Sin(phirad);
57  Double_t yp = -dshift*TMath::Cos(phirad);
58  rot = new TGeoRotation(*rot1);
59  rot->RotateZ(phi);
60  cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
61  }
62 
63  // Make a row as an assembly of cells, then combine rows in a honeycomb
64  // structure. This again works without any need to define rows as
65  // "overlapping"
66  TGeoVolume *row = new TGeoVolumeAssembly("ROW");
67  Int_t ncells = 5;
68  for (i=0; i<ncells; i++) {
69  Double_t ycell = (2*i+1)*(dshift+10);
70  row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
71  row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
72  }
73 
74  Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
75  Double_t dyrow = dshift+10.;
76  Int_t nrows = 5;
77  for (i=0; i<nrows; i++) {
78  Double_t xrow = 0.5*(2*i+1)*dxrow;
79  Double_t yrow = 0.5*dyrow;
80  if ((i%2)==0) yrow = -yrow;
81  top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
82  top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
83  }
84 
85  //--- close the geometry
86  geom->CloseGeometry();
87 
88  geom->SetVisLevel(4);
89  geom->SetVisOption(0);
90  top->Draw();
91 }
92 
tuple row
Definition: mrt.py:26
Double_t DegToRad()
Definition: TMath.h:50
virtual void RotateX(Double_t angle)
Rotate about X axis of the master frame with angle expressed in degrees.
Definition: TGeoMatrix.cxx:993
virtual void Draw(Option_t *option="")
draw top volume according to option
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition: TSystem.cxx:1766
int Int_t
Definition: RtypesCore.h:41
void assembly()
Definition: assembly.C:4
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition: TGeoVolume.cxx:948
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
virtual void RotateZ(Double_t angle)
Rotate about Z axis of the master frame with angle expressed in degrees.
Double_t Cos(Double_t)
Definition: TMath.h:424
Float_t phi
Definition: shapesAnim.C:6
double Double_t
Definition: RtypesCore.h:55
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
Double_t Sin(Double_t)
Definition: TMath.h:421
Definition: Rtypes.h:61
void SetVisOption(Int_t option=0)
set drawing mode : option=0 (default) all nodes drawn down to vislevel option=1 leaves and nodes at v...
Double_t Tan(Double_t)
Definition: TMath.h:427