Skip to content

[treeplayer] Don't mistake formulas for script files in TTree::Draw#22774

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:ROOT-8000
Open

[treeplayer] Don't mistake formulas for script files in TTree::Draw#22774
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:ROOT-8000

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

TTree::Draw can take the name of a C++ script file instead of a TTreeFormula expression for both the variable expression and the selection. To decide between the two, TTreePlayer::DrawSelect checked whether a matching file exists via TSystem::IsFileInIncludePath(), which strips a trailing parenthesized part as ACLiC-style macro arguments. A formula like "abs(Bs_TRUEID)" was thus reduced to "abs", and if an unrelated file with that name happened to exist in the current directory, the Draw call failed:

root [0] tree->Draw("Bs_MCORR", "abs(Bs_TRUEID)")
Error in <TTreePlayer::DrawSelect>: Drawing using a C++ file
currently requires that both the expression and the selection are
files: "Bs_MCORR" is not a file

Two inconsistencies made the trap wider: the selection branch did not require a dot in the candidate string at all, and the varexp branch checked for a dot before stripping the arguments, so a decimal constant inside the parentheses (e.g. "abs(x+0.5)") satisfied it.

Factor the decision into a single helper used for both arguments, which requires the candidate - after stripping the ACLiC mode and arguments - to have an extension. This is not a new restriction: TTreeProxyGenerator::WriteProxy() already refuses a script without an extension (the function name is derived from the basename minus the extension, for the cut script too), so such a file could never be processed anyway. It now evaluates as a formula instead of failing with a misleading error.

Add a regression test that exercises the previously failing Draw calls in the presence of a shadowing file named "abs".

Fixes https://its.cern.ch/jira/browse/ROOT-8000

🤖 Done with the help of AI

`TTree::Draw` can take the name of a C++ script file instead of a
TTreeFormula expression for both the variable expression and the
selection. To decide between the two, `TTreePlayer::DrawSelect` checked
whether a matching file exists via `TSystem::IsFileInIncludePath()`,
which strips a trailing parenthesized part as ACLiC-style macro
arguments. A formula like `"abs(Bs_TRUEID)"` was thus reduced to
`"abs"`, and if an unrelated file with that name happened to exist in
the current directory, the Draw call failed:

```
root [0] tree->Draw("Bs_MCORR", "abs(Bs_TRUEID)")
Error in <TTreePlayer::DrawSelect>: Drawing using a C++ file
currently requires that both the expression and the selection are
files: "Bs_MCORR" is not a file
```

Two inconsistencies made the trap wider: the selection branch did not
require a dot in the candidate string at all, and the varexp branch
checked for a dot before stripping the arguments, so a decimal
constant inside the parentheses (e.g. `"abs(x+0.5)"`) satisfied it.

Factor the decision into a single helper used for both arguments, which
requires the candidate - after stripping the ACLiC mode and arguments -
to have an extension. This is not a new restriction:
`TTreeProxyGenerator::WriteProxy()` already refuses a script without an
extension (the function name is derived from the basename minus the
extension, for the cut script too), so such a file could never be
processed anyway. It now evaluates as a formula instead of failing with
a misleading error.

Add a regression test that exercises the previously failing Draw
calls in the presence of a shadowing file named "abs".

Fixes https://its.cern.ch/jira/browse/ROOT-8000

🤖 Done with the help of AI
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 17h 4m 59s ⏱️
 3 872 tests  3 870 ✅   0 💤 2 ❌
79 695 runs  79 583 ✅ 110 💤 2 ❌

For more details on these failures, see this check.

Results for commit 5fc9c32.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant