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