Skip to content

Commit f6493a0

Browse files
committed
Build and eslint with elist parameter
1 parent 9fea09d commit f6493a0

File tree

5 files changed

+86
-33
lines changed

5 files changed

+86
-33
lines changed

build/jsroot.js

Lines changed: 76 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const version_id = 'dev',
1212

1313
/** @summary version date
1414
* @desc Release date in format day/month/year like '14/04/2022' */
15-
version_date = '11/04/2025',
15+
version_date = '14/04/2025',
1616

1717
/** @summary version id and date
1818
* @desc Produced by concatenation of {@link version_id} and {@link version_date}
@@ -113723,7 +113723,8 @@ class TDrawSelector extends TSelector {
113723113723

113724113724
/** @summary Parse parameters */
113725113725
parseParameters(tree, args, expr) {
113726-
if (!expr || !isStr(expr)) return '';
113726+
if (!expr || !isStr(expr))
113727+
return '';
113727113728

113728113729
// parse parameters which defined at the end as expression;par1name:par1value;par2name:par2value
113729113730
let pos = expr.lastIndexOf(';');
@@ -113740,12 +113741,43 @@ class TDrawSelector extends TSelector {
113740113741
intvalue = undefined;
113741113742

113742113743
switch (parname) {
113743-
case 'entries':
113744+
case 'elist':
113744113745
if ((parvalue.at(0) === '[') && (parvalue.at(-1) === ']')) {
113745-
args.entries = JSON.parse(parvalue);
113746-
break;
113746+
parvalue = parvalue.slice(1, parvalue.length - 1).replaceAll(/\s/g, '');
113747+
args.elist = [];
113748+
let p = 0, last_v = -1;
113749+
const getInt = () => {
113750+
const p0 = p;
113751+
while ((p < parvalue.length) && (parvalue.charCodeAt(p) >= 48) && (parvalue.charCodeAt(p) < 58))
113752+
p++;
113753+
return parseInt(parvalue.slice(p0, p));
113754+
};
113755+
113756+
while (p < parvalue.length) {
113757+
const v1 = getInt();
113758+
if (v1 <= last_v) {
113759+
console.log('position', p);
113760+
throw Error(`Wrong entry id ${v1} in elist last ${last_v}`);
113761+
}
113762+
let v2 = v1;
113763+
if (parvalue[p] === '.' && parvalue[p + 1] === '.') {
113764+
p += 2;
113765+
v2 = getInt();
113766+
if (v2 < v1)
113767+
throw Error(`Wrong entry id ${v2} in range ${v1}`);
113768+
}
113769+
if (parvalue[p] === ',' || p === parvalue.length) {
113770+
for (let v = v1; v <= v2; ++v) {
113771+
args.elist.push(v);
113772+
last_v = v;
113773+
}
113774+
p++;
113775+
} else
113776+
throw Error('Wrong syntax for elist');
113777+
}
113747113778
}
113748-
// eslint-disable-next-line no-fallthrough
113779+
break;
113780+
case 'entries':
113749113781
case 'num':
113750113782
case 'numentries':
113751113783
if (parvalue === 'all')
@@ -113819,6 +113851,8 @@ class TDrawSelector extends TSelector {
113819113851
}
113820113852
if (harg === 'dump')
113821113853
args.dump = true;
113854+
else if (harg === 'elist')
113855+
args.dump_entries = true;
113822113856
else if (harg.indexOf('Graph') === 0)
113823113857
args.graph = true;
113824113858
else if (pos < 0) {
@@ -113840,15 +113874,31 @@ class TDrawSelector extends TSelector {
113840113874
if (args.dump) {
113841113875
this.dump_values = true;
113842113876
args.reallocate_objects = true;
113843-
if (args.numentries === undefined)
113877+
if (args.numentries === undefined) {
113844113878
args.numentries = 10;
113879+
args._dflt_entries = true;
113880+
}
113845113881
}
113846113882

113847113883
return expr;
113848113884
}
113849113885

113850113886
/** @summary Create draw expression for N-dim with cut */
113851113887
createDrawExpression(tree, names, cut, args) {
113888+
if (args.dump && names.length === 1 && names[0] === 'Entry$') {
113889+
args.dump_entries = true;
113890+
args.dump = false;
113891+
}
113892+
113893+
if (args.dump_entries) {
113894+
this.dump_entries = true;
113895+
this.hist = [];
113896+
if (args._dflt_entries) {
113897+
delete args._dflt_entries;
113898+
delete args.numentries;
113899+
}
113900+
}
113901+
113852113902
let is_direct = !cut && !this.dump_entries;
113853113903

113854113904
this.ndim = names.length;
@@ -113900,7 +113950,7 @@ class TDrawSelector extends TSelector {
113900113950
cut = args.cut;
113901113951
else {
113902113952
pos = expr.replace(/TMath::/g, 'TMath__').lastIndexOf('::'); // avoid confusion due-to :: in the namespace
113903-
if (pos > 0) {
113953+
if (pos >= 0) {
113904113954
cut = expr.slice(pos + 2).trim();
113905113955
expr = expr.slice(0, pos).trim();
113906113956
}
@@ -113927,15 +113977,14 @@ class TDrawSelector extends TSelector {
113927113977
if (!nbr1 && !nbr2 && (pos > prev))
113928113978
names.push(expr.slice(prev, pos));
113929113979

113930-
if ((names.length < 1) || (names.length > 3))
113931-
return false;
113932-
113933113980
if (args.staged) {
113934113981
args.staged_names = names;
113935113982
names = ['Entry$'];
113936-
this.dump_entries = true;
113937-
this.hist = [];
113938-
}
113983+
args.dump_entries = true;
113984+
} else if (cut && args.dump_entries)
113985+
names = ['Entry$'];
113986+
else if ((names.length < 1) || (names.length > 3))
113987+
return false;
113939113988

113940113989
return this.createDrawExpression(tree, names, cut, args);
113941113990
}
@@ -114583,7 +114632,7 @@ function detectBranchMemberClass(brlst, prefix, start) {
114583114632
* @param {object} [args] - different arguments
114584114633
* @param {number} [args.firstentry] - first entry to process, 0 when not specified
114585114634
* @param {number} [args.numentries] - number of entries to process, all when not specified
114586-
* @param {Array} [args.entries] - entries id to process
114635+
* @param {Array} [args.elist] - arrays of entries id to process
114587114636
* @return {Promise} with TSelector instance */
114588114637
async function treeProcess(tree, selector, args) {
114589114638
if (!args) args = {};
@@ -115209,10 +115258,10 @@ async function treeProcess(tree, selector, args) {
115209115258

115210115259
let resolveFunc, rejectFunc; // Promise methods
115211115260

115212-
if (args.entries) {
115213-
args.firstentry = args.entries.at(0);
115214-
args.numentries = args.entries.at(-1) - args.entries.at(0) + 1;
115215-
handle.process_entries = args.entries;
115261+
if (args.elist) {
115262+
args.firstentry = args.elist.at(0);
115263+
args.numentries = args.elist.at(-1) - args.elist.at(0) + 1;
115264+
handle.process_entries = args.elist;
115216115265
handle.process_entries_indx = 0;
115217115266
handle.process_arrays = false; // do not use arrays process for selected entries
115218115267
}
@@ -115632,8 +115681,8 @@ async function treeProcess(tree, selector, args) {
115632115681
* @param {string} [args.drawopt=undefined] - draw options for result histogram
115633115682
* @param {number} [args.firstentry=0] - first entry to process
115634115683
* @param {number} [args.numentries=undefined] - number of entries to process, all by default
115635-
* @param {Array} [args.entries] - array of entries to process
115636-
* @param {boolean} [args.staged] - staged processing, first cut selection and then perform drawing
115684+
* @param {Array} [args.elist=undefined] - array of entries id to process, all by default
115685+
* @param {boolean} [args.staged] - staged processing, first apply cut to select entries and then perform drawing for selected entries
115637115686
* @param {object} [args.branch=undefined] - TBranch object from TTree itself for the direct drawing
115638115687
* @param {function} [args.progress=undefined] - function called during histogram accumulation with obj argument
115639115688
* @return {Promise} with produced object */
@@ -115658,10 +115707,12 @@ async function treeDraw(tree, args) {
115658115707
if (!args.staged)
115659115708
return sel;
115660115709

115710+
delete args.dump_entries;
115711+
115661115712
const selector2 = new TDrawSelector(),
115662115713
args2 = Object.assign({}, args);
115663115714
args2.staged = false;
115664-
args2.entries = sel.hist; // assign entries found in first selection
115715+
args2.elist = sel.hist; // assign entries found in first selection
115665115716
if (!selector2.createDrawExpression(tree, args.staged_names, '', args2))
115666115717
return Promise.reject(Error(`Fail to create final draw expression ${args.expr}`));
115667115718
['arr_limit', 'htype', 'nmatch', 'want_hist', 'hist_nbins', 'hist_name', 'hist_args', 'draw_title']
@@ -159714,8 +159765,9 @@ async function treeDrawProgress(obj, final) {
159714159765
if (!final && !this.last_pr)
159715159766
return;
159716159767

159717-
if (this.dump || this.testio) {
159718-
if (!final) return;
159768+
if (this.dump || this.dump_entries || this.testio) {
159769+
if (!final)
159770+
return;
159719159771
if (isBatchMode()) {
159720159772
const painter = new BasePainter(this.drawid);
159721159773
painter.selectDom().property('_json_object_', obj);

changes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# JSROOT changelog
22

33
## Changes in dev
4-
1. Implement 'staged' method for `TTree::Draw` to first select entries and then apply draw expression
4+
1. Implement 'nmatch' parameter for `TTree::Draw` to limit processed events
5+
1. Implement 'elist' parameter for `TTree::Draw` to specify entries list for processing
56
1. Implement 'nmatch' parameter for `TTree::Draw` to limit processed events
67
1. Implement 'cont5' draw option for `TGraph2D` using Delaunay algorithm
78
1. Implement 'pol' and 'arr_colz' draw option for `TH2`
@@ -10,7 +11,7 @@
1011
1. Implement 'box1' for `TH3` with negative bins
1112
1. Introduce `settings.FilesTimeout` to configure global timeout for file reading operations
1213
1. Introduce `settings.FilesRemap` to let provide fallback address for http server, used for `root.cern`
13-
1. Introduce 'settings.TreeReadBunchSize' to configure bunch read size for TTree readingevents
14+
1. Introduce `settings.TreeReadBunchSize` to configure bunch read size for `TTree` processing
1415
1. Adjust histogram title drawing with native implementation
1516
1. Improve float to string conversion when 'g' is specified
1617
1. Support 'same' option for first histogram, draw directly on pad

docs/JSROOT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ At the end of expression one can add several parameters with the syntax:
334334
Following parameters are supported:
335335
- "first" - id of the first entry to process
336336
- "entries" - number of entries to process
337-
- "elist" - array of selected entries like `[7,12,25]`
337+
- "elist" - array of selected entries like `[7,12..25,40]`
338338
- "nmatch" - abort processing after accumulated number of matched entries
339339
- "staged" - first search entries with cut selection and then performed TTree::Draw
340340
- "monitor" - periodically show intermediate draw results (interval in milliseconds)

modules/core.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const version_id = 'dev',
44

55
/** @summary version date
66
* @desc Release date in format day/month/year like '14/04/2022' */
7-
version_date = '11/04/2025',
7+
version_date = '14/04/2025',
88

99
/** @summary version id and date
1010
* @desc Produced by concatenation of {@link version_id} and {@link version_date}

modules/tree.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -772,15 +772,15 @@ class TDrawSelector extends TSelector {
772772
switch (parname) {
773773
case 'elist':
774774
if ((parvalue.at(0) === '[') && (parvalue.at(-1) === ']')) {
775-
parvalue = parvalue.slice(1, parvalue.length - 1).replaceAll(/\s/g,'');
775+
parvalue = parvalue.slice(1, parvalue.length - 1).replaceAll(/\s/g, '');
776776
args.elist = [];
777777
let p = 0, last_v = -1;
778778
const getInt = () => {
779779
const p0 = p;
780780
while ((p < parvalue.length) && (parvalue.charCodeAt(p) >= 48) && (parvalue.charCodeAt(p) < 58))
781781
p++;
782782
return parseInt(parvalue.slice(p0, p));
783-
}
783+
};
784784

785785
while (p < parvalue.length) {
786786
const v1 = getInt();
@@ -802,7 +802,7 @@ class TDrawSelector extends TSelector {
802802
}
803803
p++;
804804
} else
805-
throw Error(`Wrong syntax for elist`);
805+
throw Error('Wrong syntax for elist');
806806
}
807807
}
808808
break;
@@ -1010,9 +1010,9 @@ class TDrawSelector extends TSelector {
10101010
args.staged_names = names;
10111011
names = ['Entry$'];
10121012
args.dump_entries = true;
1013-
} else if (cut && args.dump_entries) {
1013+
} else if (cut && args.dump_entries)
10141014
names = ['Entry$'];
1015-
} else if ((names.length < 1) || (names.length > 3))
1015+
else if ((names.length < 1) || (names.length > 3))
10161016
return false;
10171017

10181018
return this.createDrawExpression(tree, names, cut, args);

0 commit comments

Comments
 (0)