Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
eveGeoBrowser.C
Go to the documentation of this file.
1
4
5namespace REX = ROOT::Experimental;
6
7TGeoNode *getNodeFromPath(TGeoNode *top, std::string path)
8{
9 TGeoNode *node = top;
10 std::istringstream f(path);
11 std::string s;
12 while (getline(f, s, '/'))
13 node = node->GetVolume()->FindNode(s.c_str());
14
15 return node;
16}
17
19{
21
22 TGeoManager::Import("https://root.cern/files/cms.root");
23
39
40 TGeoNode *top = gGeoManager->GetTopVolume()->FindNode("CMSE_1");
41 TGeoNode *n = getNodeFromPath(top, "MUON_1");
42 return top;
43}
44
46{
47 TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");
48
49 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
50 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7);
51 // //--- define some media
52 TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
53 TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl);
54
55 //--- define the transformations
56 TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.);
57 TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.);
58 TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.);
59 TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.);
60 TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.);
61 TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.);
62 TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.);
63 TGeoRotation *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.);
64 TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1);
65 TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.);
66 TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.);
67 TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.);
68 TGeoTranslation *tr11 = new TGeoTranslation(35., 0., 0.);
69 TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.);
70 TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.);
71
72 TGeoTranslation *tr14 = new TGeoTranslation(0, 0, -100);
73 TGeoCombiTrans *combi2 = new TGeoCombiTrans(0, 0, 100, new TGeoRotation("rot2", 90, 180, 90, 90, 180, 0));
74 TGeoCombiTrans *combi3 = new TGeoCombiTrans(100, 0, 0, new TGeoRotation("rot3", 90, 270, 0, 0, 90, 180));
75 TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100, 0, 0, new TGeoRotation("rot4", 90, 90, 0, 0, 90, 0));
76 TGeoCombiTrans *combi5 = new TGeoCombiTrans(0, 100, 0, new TGeoRotation("rot5", 0, 0, 90, 180, 90, 270));
77 TGeoCombiTrans *combi6 = new TGeoCombiTrans(0, -100, 0, new TGeoRotation("rot6", 180, 0, 90, 180, 90, 90));
78
79 //--- make the top container volume
80 Double_t worldx = 110.;
81 Double_t worldy = 50.;
82 Double_t worldz = 5.;
83 TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.);
84 geom->SetTopVolume(top);
85 TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum, 120, 120, 120);
86 replica->SetVisibility(kFALSE);
87 TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.);
88 rootbox->SetVisibility(kFALSE);
89
90 //--- make letter 'R'
91 TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.);
92 R->SetVisibility(kFALSE);
93 TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.);
94 bar1->SetLineColor(kRed);
95 R->AddNode(bar1, 1, tr1);
96 TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.);
97 bar2->SetLineColor(kRed);
98 R->AddNode(bar2, 1, tr2);
99 R->AddNode(bar2, 2, tr3);
100 TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.);
101 tub1->SetLineColor(kRed);
102 R->AddNode(tub1, 1, tr4);
103 TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.);
104 bar3->SetLineColor(kRed);
105 TGeoArb8 *arb = (TGeoArb8 *)bar3->GetShape();
106 arb->SetVertex(0, 15., -5.);
107 arb->SetVertex(1, 0., -25.);
108 arb->SetVertex(2, -10., -25.);
109 arb->SetVertex(3, 5., -5.);
110 arb->SetVertex(4, 15., -5.);
111 arb->SetVertex(5, 0., -25.);
112 arb->SetVertex(6, -10., -25.);
113 arb->SetVertex(7, 5., -5.);
114 R->AddNode(bar3, 1, gGeoIdentity);
115
116 //--- make letter 'O'
117 TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.);
119 TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.);
120 bar4->SetLineColor(kYellow);
121 O->AddNode(bar4, 1, tr5);
122 O->AddNode(bar4, 2, tr6);
123 TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.);
124 tub2->SetLineColor(kYellow);
125 O->AddNode(tub2, 1, tr7);
126 O->AddNode(tub2, 2, combi1);
127
128 //--- make letter 'T'
129 TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.);
130 T->SetVisibility(kFALSE);
131 TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.);
132 bar5->SetLineColor(kBlue);
133 T->AddNode(bar5, 1, tr8);
134 TGeoVolume *bar6 = geom->MakeBox("bar6", Al, 17.5, 5., 5.);
135
136 bar6->SetLineColor(kBlue);
137 T->AddNode(bar6, 1, tr9);
138
139 rootbox->AddNode(R, 1, tr10);
140 rootbox->AddNode(O, 1, tr11);
141 rootbox->AddNode(O, 2, tr12);
142 rootbox->AddNode(T, 1, tr13);
143
144 replica->AddNode(rootbox, 1, tr14);
145 replica->AddNode(rootbox, 2, combi2);
146 replica->AddNode(rootbox, 3, combi3);
147 replica->AddNode(rootbox, 4, combi4);
148 replica->AddNode(rootbox, 5, combi5);
149 replica->AddNode(rootbox, 6, combi6);
150
151 top->AddNode(replica, 1, new TGeoTranslation(-150, -150, 0));
152 top->AddNode(replica, 2, new TGeoTranslation(150, -150, 0));
153 top->AddNode(replica, 3, new TGeoTranslation(150, 150, 0));
154 top->AddNode(replica, 4, new TGeoTranslation(-150, 150, 0));
155
156 //--- close the geometry
157 geom->CloseGeometry();
158 return gGeoManager->GetTopNode();
159}
160
161void eveGeoBrowser(bool showDet = true)
162{
163 auto eveMng = REX::REveManager::Create();
164 // eveMng->AllowMultipleRemoteConnections(false, false);
165
166 TGeoNode *gn;
167 int vislevel = 4;
168 if (showDet) {
169 gn = testCmsGeo();
170 vislevel = 2;
171 } else {
172 gn = rootgeom();
173 vislevel = 8;
174 }
175
176 // initialize RGeomDesc from TGeoNode
177 auto data = new REX::REveGeoTopNodeData();
178 data->SetTNode(gn);
179 data->RefDescription().SetVisLevel(vislevel);
180
181 // make geoTable
182 auto scene = eveMng->SpawnNewScene("GeoSceneTable");
183 auto view = eveMng->SpawnNewViewer("GeoTable");
184 view->AddScene(scene);
185 scene->AddElement(data);
186
187 // 3D representation
188 auto geoViz = new REX::REveGeoTopNodeViz();
189 geoViz->SetGeoData(data);
190 geoViz->SetPickable(true);
191 data->AddNiece(geoViz);
192 eveMng->GetEventScene()->AddElement(geoViz);
193
194 eveMng->Show();
195}
#define f(i)
Definition RSha256.hxx:104
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
@ kRed
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:537
virtual void AddElement(REveElement *el)
Add el to the list of children.
REveScene * GetEventScene() const
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4623
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
Class describing rotation + translation.
Definition TGeoMatrix.h:317
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
void DefaultColors()
Set default volume colors according to A of material.
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.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
TGeoNode * GetTopNode() const
TGeoVolume * GetTopVolume() const
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.
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
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
Class describing rotations.
Definition TGeoMatrix.h:168
Class describing translations.
Definition TGeoMatrix.h:116
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:376
void InvisibleAll(Bool_t flag=kTRUE)
Make volume and each of it daughters (in)visible.
void SetLineColor(Color_t lcolor) override
Set the line color.
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
ROOT::Experimental::REveManager * eveMng
void eveGeoBrowser(bool showDet=true)
TGeoNode * getNodeFromPath(TGeoNode *top, std::string path)
TGeoNode * rootgeom()
TGeoNode * testCmsGeo()
const Int_t n
Definition legend1.C:16