Limit number of entries in the TTree draw in JSROOT

Hi Dominik,

If you have such server running, send me output of command:

curl -ik -L http://127.0.0.1/flask_test/static/file.root -H "Range: bytes=0-15,1000-1015" --output - 

JSROOT does not print much debug output at this place, but content-type in response header must include multipart string. It is starting point in the modules/io.mjs code around line 3045.

Regards,
Sergey

Hi Sergey,

the result of the above curl command is the following:

HTTP/1.1 416 REQUESTED RANGE NOT SATISFIABLE
Date: Tue, 15 Apr 2025 20:13:28 GMT
Server: Apache/2.4.58 (Ubuntu)
Content-Range: bytes */1135099764
Content-Length: 177
Content-Type: text/html; charset=utf-8

<!doctype html>
<html lang=en>
<title>416 Requested Range Not Satisfiable</title>
<h1>Requested Range Not Satisfiable</h1>
<p>The server cannot provide the requested range.</p>

When I use /files route as in the last version of the send_file_partial function I am able to get rid of 416 error but the request is still single:

HTTP/1.1 206 PARTIAL CONTENT
Date: Tue, 15 Apr 2025 20:16:17 GMT
Server: Apache/2.4.58 (Ubuntu)
Content-Range: bytes 0-15/1135099764
Content-Length: 16
Accept-Ranges: bytes
Content-Type: application/octet-stream

root�\dC�?t

Best,
Dominik

I hope, you can see now the problem.
Server has to support multipart requests - otherwise it will take too long time with single requests.

Hi Sergey,

just to let you know that I was able to resolve the issue with multirange requests in flask. The function I used for sending partial file chunk (last version of send_file_partial above) had a bug on this line:

match = re.finditer(r"bytes=(\d+)-(\d*)", range_header)

and should be

match = re.finditer(r"(\d+)-(\d*)", range_header)

So this is now solved. The only issue I now have is that when I use treeDraw with your improvements like staged and nmatch:1 options I can’t access the fHistogram object of the resulting graph and I need this to retrieve the axes for the multigraph at the end, like this:

            let mgraph = JSROOT.createTMultiGraph(g_cur, g_ref);

            let h1 = JSROOT.createHistogram('TH1I', npoints);
            h1.fName = 'axis_draw';
            h1.fTitle = null;
            h1.fXaxis = g_cur_tree.fHistogram.fXaxis;
            h1.fYaxis = g_cur_tree.fHistogram.fYaxis;
            h1.fXaxis.fTitle = "Time [ns]";
            h1.fYaxis.fTitle = "Amplitude";
            h1.fYaxis.fTitleOffset = 1.4;
            h1.fXaxis.fTitleOffset = 1.2;
            h1.fYaxis.fTitleFont = 62;
            h1.fXaxis.fTitleFont = 62;
            mgraph.fHistogram = h1;

            let mgraph_plot = await JSROOT.draw(plot_id, mgraph, "LP");

With treeDraw there is null for fHistogram while it was correctly filled when I used simple draw. Is there anything to get fHistogram object or some workaround to retrieve axes?

Thanks,
Dominik

Hi Dominik,

Grate!

If you using treeDraw, you get just TGraph object produced. fHistogram member set only after graph is drawn by JSROOT. Therefore you first need to draw graph and then can modify graphical attributes.

Or you can assign fHistogram yourself like:

graph.fHistogram = JSROOT.createHistogram('TH1I', npoints, xmin, xmax);

Regards,
Sergey

Hi Sergey,

perfect, that works! Now I am able to get the plots in ~5s with all the improvements. Thanks again for all your help and patience in resolving this issue.

Best,
Dominik

1 Like

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