Repository navigation
Conversation
Only TMath::Exp, Abs, Prob and Gaus were mapped, so expressions like TMath::Sqrt(x) or TMath::Pi() failed with a syntax error on '::'. Map the common TMath functions to their Math equivalents and add TMath::Pi() and TMath::E().
In ROOT '^' is the power operator in TTree::Draw expressions, in JS it is bitwise XOR, so expressions like "x^2" silently gave wrong values. Rewrite '^' to '**' before compiling the expression. Operands are taken as names, numbers, brackets or calls, so "-x^2" is -(x**2) and "a^b^c" is evaluated from the left, as in ROOT.
|
Do we need support of not existing It was done for But Same is about |
|
Fair point, i didnt notice the docs say draw expressions use js Math. I'll drop the TMath part. The only reason i did |
|
We do not need mimic C++ functionality here. But it is valid point for If you interested - you can try extend functionality in the |
|
Thanks, that makes sense, i realize treeDraw doesnt need it since its all js. I'll close this one and look into TFormula in func.mjs instead. |
This Pull request:
In ROOT
^is the power operator in draw expressions, but jsroot passes the expression straight into a js function where^is like the bitwise xor operator thing. Sotree.Draw("x^2")gives a histogram of x XOR 2, it doesnt give error but gives just wrong numbers. Also onlyTMath::Exp/Abs/Prob/Gauswere mapped, so things likeTMath::Sqrt(x)orTMath::Pi()throw a syntax error on the::.values at x=3 from a small tree (x = 0..9), compared with
TTree::Drawin ROOT 6.40:Changes:
^gets rewritten to**before the expression is compiled. operands are taken as names, numbers, brackets or calls, so-x^2stays-(x**2)anda^b^cgoes frpm the left side to right side, both like ROOT does (2^3^2is 64 in root).TMath::Pi()andTMath::E(), mapped to the js Math equivalents.things like tree_draw, tree_dump, tree_selector and tree_staged give the same output as before.
Fixes:
draw expressions using
^or common TMath functions now give the same values as ROOT instead of different wrong numbers or a syntax error.