ROOT
master
Reference Guide
Loading...
Searching...
No Matches
rootgeom.C File Reference
Tutorials
»
Geometry tutorials
Detailed Description
Definition of a simple geometry (the 4
ROOT
characters)
U
void
rootgeom
(
bool
vis =
true
)
{
// gStyle->SetCanvasPreferGL(true);
TGeoManager
*geom =
new
TGeoManager
(
"simple1"
,
"Simple geometry"
);
//--- 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
(
"Root Material"
,2, matAl);
//--- define the transformations
TGeoTranslation
*tr1 =
new
TGeoTranslation
(20., 0, 0.);
TGeoTranslation
*tr2 =
new
TGeoTranslation
(10., 0., 0.);
TGeoTranslation
*tr3 =
new
TGeoTranslation
(10., 20., 0.);
TGeoTranslation
*tr4 =
new
TGeoTranslation
(5., 10., 0.);
TGeoTranslation
*tr5 =
new
TGeoTranslation
(20., 0., 0.);
TGeoTranslation
*tr6 =
new
TGeoTranslation
(-5., 0., 0.);
TGeoTranslation
*tr7 =
new
TGeoTranslation
(7.5, 7.5, 0.);
TGeoRotation
*rot1 =
new
TGeoRotation
(
"rot1"
, 90., 0., 90., 270., 0., 0.);
TGeoCombiTrans
*combi1 =
new
TGeoCombiTrans
(7.5, -7.5, 0., rot1);
TGeoTranslation
*tr8 =
new
TGeoTranslation
(7.5, -5., 0.);
TGeoTranslation
*tr9 =
new
TGeoTranslation
(7.5, 20., 0.);
TGeoTranslation
*tr10 =
new
TGeoTranslation
(85., 0., 0.);
TGeoTranslation
*tr11 =
new
TGeoTranslation
(35., 0., 0.);
TGeoTranslation
*tr12 =
new
TGeoTranslation
(-15., 0., 0.);
TGeoTranslation
*tr13 =
new
TGeoTranslation
(-65., 0., 0.);
TGeoTranslation
*tr14 =
new
TGeoTranslation
(0,0,-100);
TGeoCombiTrans
*combi2 =
new
TGeoCombiTrans
(0,0,100,
new
TGeoRotation
(
"rot2"
,90,180,90,90,180,0));
TGeoCombiTrans
*combi3 =
new
TGeoCombiTrans
(100,0,0,
new
TGeoRotation
(
"rot3"
,90,270,0,0,90,180));
TGeoCombiTrans
*combi4 =
new
TGeoCombiTrans
(-100,0,0,
new
TGeoRotation
(
"rot4"
,90,90,0,0,90,0));
TGeoCombiTrans
*combi5 =
new
TGeoCombiTrans
(0,100,0,
new
TGeoRotation
(
"rot5"
,0,0,90,180,90,270));
TGeoCombiTrans
*combi6 =
new
TGeoCombiTrans
(0,-100,0,
new
TGeoRotation
(
"rot6"
,180,0,90,180,90,90));
//--- make the top container volume
Double_t
worldx = 110.;
Double_t
worldy = 50.;
Double_t
worldz = 5.;
TGeoVolume
*top = geom->
MakeBox
(
"TOP"
, Vacuum, 270., 270., 120.);
geom->
SetTopVolume
(top);
TGeoVolume
*replica = geom->
MakeBox
(
"REPLICA"
, Vacuum,120,120,120);
replica->
SetVisibility
(
kFALSE
);
TGeoVolume
*rootbox = geom->
MakeBox
(
"ROOT"
, Vacuum, 110., 50., 5.);
rootbox->
SetVisibility
(
kFALSE
);
//--- make letter 'R'
TGeoVolume
*
R
= geom->
MakeBox
(
"R"
, Vacuum, 25., 25., 5.);
R
->SetVisibility(
kFALSE
);
TGeoVolume
*bar1 = geom->
MakeBox
(
"bar1"
, Al, 5., 25, 5.);
bar1->
SetLineColor
(
kRed
);
R
->AddNode(bar1, 1, tr1);
TGeoVolume
*bar2 = geom->
MakeBox
(
"bar2"
, Al, 5., 5., 5.);
bar2->
SetLineColor
(
kRed
);
R
->AddNode(bar2, 1, tr2);
R
->AddNode(bar2, 2, tr3);
TGeoVolume
*tub1 = geom->
MakeTubs
(
"tub1"
, Al, 5., 15., 5., 90., 270.);
tub1->
SetLineColor
(
kRed
);
R
->AddNode(tub1, 1, tr4);
TGeoVolume
*bar3 = geom->
MakeArb8
(
"bar3"
, Al, 5.);
bar3->
SetLineColor
(
kRed
);
TGeoArb8
*arb = (
TGeoArb8
*)bar3->
GetShape
();
arb->
SetVertex
(0, 15., -5.);
arb->
SetVertex
(1, 0., -25.);
arb->
SetVertex
(2, -10., -25.);
arb->
SetVertex
(3, 5., -5.);
arb->
SetVertex
(4, 15., -5.);
arb->
SetVertex
(5, 0., -25.);
arb->
SetVertex
(6, -10., -25.);
arb->
SetVertex
(7, 5., -5.);
R
->AddNode(bar3, 1,
gGeoIdentity
);
//--- make letter 'O'
TGeoVolume
*O = geom->
MakeBox
(
"O"
, Vacuum, 25., 25., 5.);
O->
SetVisibility
(
kFALSE
);
TGeoVolume
*bar4 = geom->
MakeBox
(
"bar4"
, Al, 5., 7.5, 5.);
bar4->
SetLineColor
(
kYellow
);
O->
AddNode
(bar4, 1, tr5);
O->
AddNode
(bar4, 2, tr6);
TGeoVolume
*tub2 = geom->
MakeTubs
(
"tub1"
, Al, 7.5, 17.5, 5., 0., 180.);
tub2->
SetLineColor
(
kYellow
);
O->
AddNode
(tub2, 1, tr7);
O->
AddNode
(tub2, 2, combi1);
//--- make letter 'T'
TGeoVolume
*T = geom->
MakeBox
(
"T"
, Vacuum, 25., 25., 5.);
T->SetVisibility(
kFALSE
);
TGeoVolume
*bar5 = geom->
MakeBox
(
"bar5"
, Al, 5., 20., 5.);
bar5->
SetLineColor
(
kBlue
);
T->AddNode(bar5, 1, tr8);
TGeoVolume
*bar6 = geom->
MakeBox
(
"bar6"
, Al, 17.5, 5., 5.);
bar6->
SetLineColor
(
kBlue
);
T->AddNode(bar6, 1, tr9);
rootbox->
AddNode
(
R
, 1, tr10);
rootbox->
AddNode
(O, 1, tr11);
rootbox->
AddNode
(O, 2, tr12);
rootbox->
AddNode
(T, 1, tr13);
replica->
AddNode
(rootbox, 1, tr14);
replica->
AddNode
(rootbox, 2, combi2);
replica->
AddNode
(rootbox, 3, combi3);
replica->
AddNode
(rootbox, 4, combi4);
replica->
AddNode
(rootbox, 5, combi5);
replica->
AddNode
(rootbox, 6, combi6);
top->
AddNode
(replica, 1,
new
TGeoTranslation
(-150, -150, 0));
top->
AddNode
(replica, 2,
new
TGeoTranslation
(150, -150, 0));
top->
AddNode
(replica, 3,
new
TGeoTranslation
(150, 150, 0));
top->
AddNode
(replica, 4,
new
TGeoTranslation
(-150, 150, 0));
//--- close the geometry
geom->
CloseGeometry
();
//--- draw the ROOT box.
// by default the picture will appear in the standard ROOT TPad.
//if you have activated the following line in system.rootrc,
//it will appear in the GL viewer
//#Viewer3D.DefaultDrawOption: ogl
geom->
SetVisLevel
(4);
if
(vis) top->
Draw
(
"ogle"
);
}
kFALSE
constexpr Bool_t kFALSE
Definition
RtypesCore.h:94
Double_t
double Double_t
Definition
RtypesCore.h:59
kRed
@ kRed
Definition
Rtypes.h:66
kBlue
@ kBlue
Definition
Rtypes.h:66
kYellow
@ kYellow
Definition
Rtypes.h:66
gGeoIdentity
R__EXTERN TGeoIdentity * gGeoIdentity
Definition
TGeoMatrix.h:537
R
TGeoArb8
Definition
TGeoArb8.h:17
TGeoArb8::SetVertex
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
TGeoCombiTrans
Class describing rotation + translation.
Definition
TGeoMatrix.h:317
TGeoManager
The manager class for any TGeo geometry.
Definition
TGeoManager.h:44
TGeoManager::MakeArb8
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
Definition
TGeoManager.cxx:3161
TGeoManager::SetVisLevel
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
Definition
TGeoManager.cxx:2459
TGeoManager::CloseGeometry
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
Definition
TGeoManager.cxx:1480
TGeoManager::MakeBox
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.
Definition
TGeoManager.cxx:3169
TGeoManager::SetTopVolume
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Definition
TGeoManager.cxx:3655
TGeoManager::MakeTubs
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Definition
TGeoManager.cxx:3213
TGeoMaterial
Base class describing materials.
Definition
TGeoMaterial.h:34
TGeoMedium
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition
TGeoMedium.h:23
TGeoRotation
Class describing rotations.
Definition
TGeoMatrix.h:168
TGeoTranslation
Class describing translations.
Definition
TGeoMatrix.h:116
TGeoVolume
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition
TGeoVolume.h:43
TGeoVolume::SetVisibility
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
Definition
TGeoVolume.cxx:2347
TGeoVolume::AddNode
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
Definition
TGeoVolume.cxx:975
TGeoVolume::Draw
void Draw(Option_t *option="") override
draw top volume according to option
Definition
TGeoVolume.cxx:1206
TGeoVolume::SetLineColor
void SetLineColor(Color_t lcolor) override
Set the line color.
Definition
TGeoVolume.cxx:2169
TGeoVolume::GetShape
TGeoShape * GetShape() const
Definition
TGeoVolume.h:190
rootgeom
TGeoNode * rootgeom()
Definition
eveGeoBrowser.C:47
Author
Andrei Gheata
Definition in file
rootgeom.C
.
tutorials
geom
rootgeom.C
ROOT master - Reference Guide Generated on Fri Dec 13 2024 09:37:50 (GVA Time) using Doxygen 1.9.8