Hi,
I can load a saved Geometry created via TGeo locally. It displays on a firefox browser nicely. See the code extract below.
My question is: is it possible to interactively load TEVE tracks or TEVEBoxSets (or their equivalent in JSROOT)?
I other words there would be a button that runs a script (Python or C++) which retrieves an event from a run.root file and displays the hits in the JSROOT geometry on the webpage.
So far the examples which I have seen (like this one) are not interactive, i.e the tracks are pre-loaded from the geometry and the user cannot press on a button to load the next event.
Is there a way to do this in JSROOT?
There are many ways to place button on the HTML page and assign JavaScript call.
You can use plain HTML, jQuery or OpenUI5 or many-many other frameworks. See JSROOT example with openui.
When button pressed, in JavaScript you can use XMLHttpRequest to ask your HTTP server produce some new data for you. It can be any server, supporting CGI or PHP scripts. Or you can use THttpServer class, which can provide such data directly from running ROOT application.
And finally, retrieved objects (hits, tracks, …) can be displayed together with geometry. Simple example doing this with ROOT files I can provide next week.
But next steps - navigating through displayed objects, enable/disable some tracks/hits, show extra info about tracks - not yet fully implemented in JSROOT.
This functionality planned in WebEve project, which is developed recently.
thanks a lot for the example. Do you have the files evegeoshape.json.gz and the root file with the tracks eve_tracks.root? I will help to understand and I can’t find them for some reason.
If I understand correctly in the example you load Evetracks and geometry from pre-generated root files. I would like to directly load the tracks and hits in the window by reading and processing a run file interactively. Exactly like I do in TEVE but online essentially.
I tried running my root macro with the THttpServer and then open a browser window with the corresponding address http://localhost:8080. I summarised what the macro does below (if you need the full code I can also provide it)
The canvas with the filled histograms loads nicely on the browser, but the geometry and the TEVEBoxSet objects are nowhere to be found. Locally no problem I get it all on the TEVEWindow.
I guess WebEve will be able to cope with this? For now is there a workaround? Essentially I would like the user to press on “next event” and have the tracks appearing on the pre-loaded geometry.
When you say “retrieved objects (hits, tracks, …) can be displayed together with geometry”, you mean they should first be saved in a root file and then this root file must be re-opened?
Or is there a way to do something like myTEVEBoxset.Draw() directly on the pre-loaded geometry?
Cheers,
Sebastien
serv=THttpServer("http:8080?top=job1")
gEve= TEveManager.Create()
#declare some histograms to be filled
h=TH1F("hit_start_time","hit_start_time",200,-100,100)
h2=TH2F("h2 hit_start_time","h2_hit_start_time",200,-100,100,200,-100,100)
#load geometry in TGeo
gEve= TEveManager.Create()
GDML_file_name="my_Geometry.gdml.xml"
gGeo= gEve.GetGeometry(GDML_file_name)
gGeo.SetVerboseLevel(0)
gGeo.DefaultColors()
top_node = gGeo.GetTopNode()
TopGeoNode = TEveGeoTopNode(gGeo, top_node)
TopGeoNode.SetVisLevel(4)
TopGeoNode.GetNode().GetVolume().SetVisibility(False)
gEve.AddGlobalElement(TopGeoNode)
# now load a root file and loop on tracks and hits, fill a EVEboxset
EveBoxSet_1[iev_itr][itrk].AddBox(hit_x,hit_y,hit_z,box_height,1,1)
EveBoxSet_1[iev_itr][itrk].DigitColor(int(ColorPalette[hit_color_index]))
gEve.AddElement(EveBoxSet_1[iev_itr][itrk])
#outside of loop update the window
gEve.GetViewers().SwitchColorSet()
gEve.FullRedraw3D(ROOT.kTRUE)
# also draw the canvas with the histograms
c=TCanvas("c","c")
c.Divide(2)
c.cd(1)
h.Draw()
c.cd(2)
h_hit_index.Draw()
Of course, you can use THttpServer. There is no big difference if you read data from files
or access same data from THttpServer. Here is minimal example, which reads data in ROOT macro and export them to THttpServer:
ok thanks. This looks good. From what I get by reading the example I could run the python script which fills a TList with the TEveObjects (tracks, boxsets,…) retrieve them directly and display them on the geometry. (I don’t want to have to write object to root file, close the file and then re-open it or each event).
I will try and let you know how it goes.
Not all TEVE primitives are supported. Tracks and points -yes, but not TEveBoxSet.
But they could be implemented - just let me know that is missing. Best if you can provide ROOT files with such data.