You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using pyRoot, preparing a selection string to use in TTree.GetEntries(const string * selection), it seems that a string of the type: _value1_ <= _variable_ <= _value2_"
should be working but insteads it returns an error: TTreeFormula bad expression "=_value2_"
when other operators work just fine (no error), e.g.:
_value1_ < _variable_ < _value2_"
_value1_ <= _variable_ < _value2_"
etc.
I have tried with and without parentheses around the conditions. The only working solution (for now) to write: _value1_ <= _variable_ && _variable_ <= _value2_"
but this sensibly slows the code.
Expected behavior
Using _value1_ <= _variable_ <= _value2_" should not return an error when trying to limit a variable to a closed interval, in the same way it works when limiting a variable to an open interval.
To Reproduce
Steps to reproduce the behavior:
The code that can reproduce the issue is the following:
import itertools
import numpy as np
import ROOT as rt
paramList = { 'Variable_1' : np.linspace(0,1,4),
'Variable_2' : np.linspace(0,3,5) }
boundaries = list(itertools.product(*[itertools.combinations(val,2) for val in paramList.values()]))
for val in boundaries:
string = 'dmID_signal == <whatever ID for final particle>'
for bounds, key in enumerate(paramList.keys()):
string += " && ({} <= {} <= {})".format(val[bounds][0], key, key, val[bounds][1])
signal = sigData.GetEntries(string)
I cannot really join a .root file here, but it is just a matter of changing Variable_1 and Variable_2 of paramList for 2 variables of a TTree. Also, I start the selection string with a selection of dmID but that can be removed, you just need to modify the string so that it doesn't start with &&.
To run the code, write it in a python file or jupyter notebook and run it using Python 3.
Setup
JupyROOT 6.22/08
Linux Mint 19.3 Cinnamon
Installed Root using conda
Additional context
Using PyRoot
The text was updated successfully, but these errors were encountered:
Describe the bug
Using pyRoot, preparing a selection string to use in TTree.GetEntries(const string * selection), it seems that a string of the type:
_value1_ <= _variable_ <= _value2_"
should be working but insteads it returns an error:
TTreeFormula bad expression "=_value2_"
when other operators work just fine (no error), e.g.:
_value1_ < _variable_ < _value2_"
_value1_ <= _variable_ < _value2_"
I have tried with and without parentheses around the conditions. The only working solution (for now) to write:
_value1_ <= _variable_ && _variable_ <= _value2_"
but this sensibly slows the code.
Expected behavior
Using
_value1_ <= _variable_ <= _value2_"
should not return an error when trying to limit a variable to a closed interval, in the same way it works when limiting a variable to an open interval.To Reproduce
Steps to reproduce the behavior:
I cannot really join a .root file here, but it is just a matter of changing Variable_1 and Variable_2 of paramList for 2 variables of a TTree. Also, I start the selection string with a selection of dmID but that can be removed, you just need to modify the string so that it doesn't start with &&.
To run the code, write it in a python file or jupyter notebook and run it using Python 3.
Setup
Additional context
Using PyRoot
The text was updated successfully, but these errors were encountered: