Str55
September 21, 2019, 10:57pm
1
Is it possible to, having access to a root dataset, plot two variables against each other using only JSRoot? Or would I have to use root to plot the variables against each other, and then have JSRoot output the resultant graph?
Thank you.
linev
September 22, 2019, 5:48am
2
Hi,
Here is several examples how TTree::Draw - like expression can be performed in JSROOT:
https://root.cern/js/latest/examples.htm#ttree_2d
And here is brief docu:
# JavaScript ROOT
The JSROOT project intends to implement ROOT graphics for web browsers.
Reading of binary ROOT files is supported.
It is the successor of the JSRootIO project.
## Installing JSROOT
In most practical cases it is not necessary to install JSROOT - it can be used directly from project web sites <https://root.cern/js/> and <http://jsroot.gsi.de/>.
When required, there are following alternatives to install JSROOT on other web servers:
- download and unpack [provided](https://github.com/root-project/jsroot/releases) packages (recommended)
- use [bower](https://bower.io/) package manager and invoke `bower install jsroot`
- clone master branch from [repository](https://github.com/root-project/jsroot/)
One could use JSROOT directly from local file system. If source code was unpacked/checked-out in `/home/user/jsroot/` subfolder, one could just open it in browser with <file:///home/user/jsroot/index.htm> address.
This file has been truncated. show original
Regards,
Sergey
Str55
September 29, 2019, 7:58pm
3
Thanks Sergey!
I was able to plot what I wanted using the following syntax:
var filename1 = "https://root.cern/js/files/hsimple.root"
JSROOT.OpenFile(filename1, function(file){
file.ReadObject("ntuple;1", function(obj) {
JSROOT.draw("drawing1", obj, "px:py");
});
});
My follow up question is whether it is possible to do something similar if the variables px and py are coming from different trees in a root file (or even different root files). Would the TSelector class be the best way of doing this?
All the best,
-Steve
linev
September 30, 2019, 5:54am
4
Normally one process data from the same TTree - see docu and examples here:
# JavaScript ROOT
The JSROOT project allows:
- reading of binary and JSON ROOT files in JavaScript;
- drawing of different ROOT classes in web browsers;
- reading and drawing TTree data;
- using in node.js.
## Installing JSROOT
In most practical cases it is not necessary to install JSROOT - it can be used directly from project web sites <https://root.cern/js/> and <https://jsroot.gsi.de/>.
When required, there are following alternatives to install JSROOT on other web servers:
- download and unpack [provided](https://github.com/root-project/jsroot/releases) packages (recommended)
- use [npm](https://npmjs.com/package/jsroot) package manager and invoke `npm install jsroot`
- clone master branch from [repository](https://github.com/root-project/jsroot/)
This file has been truncated. show original
But because of asynchronous API it is very difficult to use data from different TTree objects.
Main problem - there is no GetEntry()
method in JSROOT.
For such complex tasks I recommend to use ROOT functionality - primary goal of JSROOT is display data, but not make complex evaluation in browser.
Regards,
Sergey
system
Closed
October 14, 2019, 5:54am
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.