How to draw a TH1 from a TTree branch with a selection in JSROOT?

Dear experts,

I’m new to using JSROOT. I was wondering if there is a way to draw a TH1, from a TBranch of a TTree, by applying a selection directly from the web interface, without modifying the JavaScript code.

For instance, by opening this sample file:

https://root.cern.ch/js/latest/api.htm#url_syntax_open_file

I would like to display the following histogram:

ntuple->Draw(“px”, “py>0”)

Thank you in advance for your assistance.

Best regards,

Marco

Hi Marco,

There is section “TTree draw” in JSROOT documentation.

It also explains how to use cut expression. In your case draw option for the tree should be “px::py>0”. Full link is:

https://root.cern/js/latest/?file=../files/hsimple.root&item=ntuple&opt=px::py>0

Regards,
Sergey

1 Like

Hi Sergey,

It worked. Thank you very much for your prompt response.

Best regards,
Marco

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.