Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
eveGeoBrowser.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve_7
3///
4/// \macro_code
5///
6
9
10namespace REX = ROOT::Experimental;
11
12TGeoNode *getNodeFromPath(TGeoNode *top, std::string path)
13{
14 TGeoNode *node = top;
15 std::istringstream f(path);
16 std::string s;
17 while (getline(f, s, '/'))
18 node = node->GetVolume()->FindNode(s.c_str());
19
20 return node;
21}
22
24{
26
27 TGeoManager::Import("https://root.cern/files/cms.root");
28
44
45 TGeoNode *top = gGeoManager->GetTopVolume()->FindNode("CMSE_1");
46 TGeoNode *n = getNodeFromPath(top, "MUON_1");
47 return top;
48}
49
51{
52 TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");
53
54 TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
55 TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7);
56 // //--- define some media
57 TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
58 TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl);
59
60 //--- define the transformations
61 TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.);
62 TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.);
63 TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.);
64 TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.);
65 TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.);
66 TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.);
67 TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.);
68 TGeoRotation *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.);
69 TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1);
70 TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.);
71 TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.);
72 TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.);
73 TGeoTranslation *tr11 = new TGeoTranslation(35., 0., 0.);
74 TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.);
75 TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.);
76
77 TGeoTranslation *tr14 = new TGeoTranslation(0, 0, -100);
78 TGeoCombiTrans *combi2 = new TGeoCombiTrans(0, 0, 100, new TGeoRotation("rot2", 90, 180, 90, 90, 180, 0));
79 TGeoCombiTrans *combi3 = new TGeoCombiTrans(100, 0, 0, new TGeoRotation("rot3", 90, 270, 0, 0, 90, 180));
80 TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100, 0, 0, new TGeoRotation("rot4", 90, 90, 0, 0, 90, 0));
81 TGeoCombiTrans *combi5 = new TGeoCombiTrans(0, 100, 0, new TGeoRotation("rot5", 0, 0, 90, 180, 90, 270));
82 TGeoCombiTrans *combi6 = new TGeoCombiTrans(0, -100, 0, new TGeoRotation("rot6", 180, 0, 90, 180, 90, 90));
83
84 //--- make the top container volume
85 Double_t worldx = 110.;
86 Double_t worldy = 50.;
87 Double_t worldz = 5.;
88 TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.);
89 geom->SetTopVolume(top);
90 TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum, 120, 120, 120);
91 replica->SetVisibility(kFALSE);
92 TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.);
93 rootbox->SetVisibility(kFALSE);
94
95 //--- make letter 'R'
96 TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.);
97 R->SetVisibility(kFALSE);
98 TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.);
99 bar1->SetLineColor(kRed);
100 R->AddNode(bar1, 1, tr1);
101 TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.);
102 bar2->SetLineColor(kRed);
103 R->AddNode(bar2, 1, tr2);
104 R->AddNode(bar2, 2, tr3);
105 TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.);
106 tub1->SetLineColor(kRed);
107 R->AddNode(tub1, 1, tr4);
108 TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.);
109 bar3->SetLineColor(kRed);
110 TGeoArb8 *arb = (TGeoArb8 *)bar3->GetShape();
111 arb->SetVertex(0, 15., -5.);
112 arb->SetVertex(1, 0., -25.);
113 arb->SetVertex(2, -10., -25.);
114 arb->SetVertex(3, 5., -5.);
115 arb->SetVertex(4, 15., -5.);
116 arb->SetVertex(5, 0., -25.);
117 arb->SetVertex(6, -10., -25.);
118 arb->SetVertex(7, 5., -5.);
119 R->AddNode(bar3, 1, gGeoIdentity);
120
121 //--- make letter 'O'
122 TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.);
123 O->SetVisibility(kFALSE);
124 TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.);
125 bar4->SetLineColor(kYellow);
126 O->AddNode(bar4, 1, tr5);
127 O->AddNode(bar4, 2, tr6);
128 TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.);
129 tub2->SetLineColor(kYellow);
130 O->AddNode(tub2, 1, tr7);
131 O->AddNode(tub2, 2, combi1);
132
133 //--- make letter 'T'
134 TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.);
135 T->SetVisibility(kFALSE);
136 TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.);
137 bar5->SetLineColor(kBlue);
138 T->AddNode(bar5, 1, tr8);
139 TGeoVolume *bar6 = geom->MakeBox("bar6", Al, 17.5, 5., 5.);
140
141 bar6->SetLineColor(kBlue);
142 T->AddNode(bar6, 1, tr9);
143
144 rootbox->AddNode(R, 1, tr10);
145 rootbox->AddNode(O, 1, tr11);
146 rootbox->AddNode(O, 2, tr12);
147 rootbox->AddNode(T, 1, tr13);
148
149 replica->AddNode(rootbox, 1, tr14);
150 replica->AddNode(rootbox, 2, combi2);
151 replica->AddNode(rootbox, 3, combi3);
152 replica->AddNode(rootbox, 4, combi4);
153 replica->AddNode(rootbox, 5, combi5);
154 replica->AddNode(rootbox, 6, combi6);
155
156 top->AddNode(replica, 1, new TGeoTranslation(-150, -150, 0));
157 top->AddNode(replica, 2, new TGeoTranslation(150, -150, 0));
158 top->AddNode(replica, 3, new TGeoTranslation(150, 150, 0));
159 top->AddNode(replica, 4, new TGeoTranslation(-150, 150, 0));
160
161 //--- close the geometry
162 geom->CloseGeometry();
163 return gGeoManager->GetTopNode();
164}
165
166void eveGeoBrowser(bool showDet = true)
167{
168 auto eveMng = REX::REveManager::Create();
169 // eveMng->AllowMultipleRemoteConnections(false, false);
170
171 TGeoNode *gn;
172 int vislevel = 4;
173 if (showDet) {
174 gn = testCmsGeo();
175 vislevel = 2;
176 } else {
177 gn = rootgeom();
178 vislevel = 8;
179 }
180
181 // initialize RGeomDesc from TGeoNode
182 auto data = new REX::REveGeoTopNodeData();
183 data->SetTNode(gn);
184 data->RefDescription().SetVisLevel(vislevel);
185
186 // make geoTable
187 auto scene = eveMng->SpawnNewScene("GeoSceneTable");
188 auto view = eveMng->SpawnNewViewer("GeoTable");
189 view->AddScene(scene);
190 scene->AddElement(data);
191
192 // 3D representation
193 auto geoViz = new REX::REveGeoTopNodeViz();
194 geoViz->SetGeoData(data);
195 geoViz->SetPickable(true);
196 data->AddNiece(geoViz);
198
199 eveMng->Show();
200}
#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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:4673
An arbitrary trapezoid with less than 8 vertices standing on two parallel planes perpendicular to Z a...
Definition TGeoArb8.h:17
Class describing rotation + translation.
Definition TGeoMatrix.h:317
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
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.
TGeoNode * GetTopNode() const
TGeoVolume * GetTopVolume() const
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
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.
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