A simple TGeo
(root) / GDML
geometry web browser using ROOT's THttpServer
.
Only ROOT, the minimal version should work. It has been tested on ROOT v6.22.08
. If you don't have ROOT installed, you can also run it in docker using the official ROOT image
To start the server, just run the ROOT macro.
root GeometryBrowser.C
You can access the server in http://localhost:8090. If you want to use a different port, change the PORT
variable in the script, or define an environment variable named GEOMETRYBROWSER_PORT
to be equal to the port you want to use.
The default browser for THttpServer
will open.
To open a new geometry, click on the UpdateGeometryFile
icon (open folder). A prompt will open asking you for the file path. You can use relative or absolute path in your file system.
After selecting the file to view its necessary to click the reload
button for the changes to be visible. If the file was valid (valid GDML or root file with TGeoManager
) there should be a new entry under the "Objects" directory with the name of your file. If the file was not valid, an empty object will appear.
As this is built using ROOT's THttpServer, the usual endpoints are exposed. More detailed information is available in the documentation.
To obtain the json
representation of the geometry (which is itself a ROOT object) you would perform a get
request to http://host:port/Objects/name/root.json.gz
.
If we want to do this for a file called /home/path/geometry.gdml.root
, the logic inside this code will strip the full file path of all leading directories and extensions so the name of the object will be: geometry
. If we had a local server running on port 8090, we would do:
http://localhost:8090/Objects/geometry/root.json.gz
Beware that we have to add /root.json.gz
at the end even though the object name didn't have any extension.