JsROOT treeplayer

Hello,

I was playing with the fantastic JsRoot. Kudos for this very powerful tool.

I was looking at the treeplayer example https://root.cern.ch/js/3.6/httpserver.C/ but could not really adjust it to work for me.
I see that in the example the information about file, branches etc is set up using json, so I tried to adjust this to what I had in my case but I only ever get the hierarchy displayed in the left pane but without the usual player interface appearing when clicking on the TTree object.

I was looking for documentation that would explain how to use it, but did not find anything (which might be entirely my fault).

Any hints on how to proceed would be gladly appreciated.

Erik

Hi Erik,

So you are running a macro based on httpserver.C, right? Can you be more precise about what you did exactly? Could you provide a running macro showing the issue?

Cheers, Bertrand.

Hi Erik,

As mentioned by Bertrand, you could start from tutorials/http/httpserver.C macro.

Or if you have your tree already in the file, you should do following:

  1. Start ROOT and load ROOT file with the tree.
  2. Load you tree into memory.
  3. Start HTTP server.
shell>   root -b -l hsimple.root 
root [1] gFile->Get("ntuple");
root [2] new THttpServer("http:8080;rw");

After these steps you can open in browser address localhost:8080 and use
tree player. Please try and let me know.
Step with reading TTree object is not desired - I will try to fix problem for the future.

Unfortunately it is not your fault. There is no full documentation about many different features in JSROOT and THttpServer. I physically do not have enough time to write and update it.

Regards,
Sergey

Hi Erik,

Now fixed in repository. You could just open file and then start http server:

shell>   root -b -l hsimple.root
root [1] new THttpServer("http:8080;rw");

Regards,
Sergey

Hello Sergey, Bertrand,

many thanks for your replies. I think I was a bit on a wrong trail initially, I was basically trying to work only with the javascript part, without firing up root.

Sergey, the example you gave me is a good starting point. I’ll play a bit with this and see if I can achieve what I have in mind or if I have follow-up questions.

Cheers,

Erik

Hi Erik,

Just to be clear - there is no plans to read and evaluate TTree content in the browser with JavaScript.
Current approach - run all TTree I/O and TTree::Draw() in normal ROOT environment, just providing
HTML/JavaScript interface to display results in the browser.

Similar ROOT_server / web_client approach could be applied for many other applications.

Regards,
Sergey

Hi Sergey,

thanks for the clarification. In any case, now that I know better how it works, I think I can still make good use of it, it was really just that my initial idea was wrong.

Erik

Hi Erik,

Small update on this topic.

Since a new JSROOT version 5 it is possible to perform TTree::Draw directly in the browser.
JSROOT implements not all features of normal TTree::Draw, but one can specify cut expressions, use math functions, automatically iterate over array elements. Examples you can find here:

root.cern/js/latest/examples.htm#ttree_draw

With best regards,
Sergey