-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help: Cut application while iterating a tree is not working properly #194
Comments
I made the change bellow and plotted tree_sel[0]['D_MM'] and tree_sel[1]['D_MM'] histograms, the cuts were only applied in the first one, ` for x,report in tree.iterate(entry_stop=100000,step_size=50000,cut=Cuts,report=True): ` |
You found the issue: it's not " >>> # allowed
>>> ak.Array([True, False, True]) & ak.Array([False, True, True])
<Array [False, False, True] type='3 * bool'>
>>> # not allowed
>>> ak.Array([True, False, True]) and ak.Array([False, True, True])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jpivarski/irishep/awkward-1.0/awkward1/highlevel.py", line 1440, in __bool__
raise ValueError(
ValueError: the truth value of an array whose length is not 1 is ambiguous; use ak.any() or ak.all() This PR was included in On the second point, is the cut only being applied to the first file or the first step in iteration? Can you be explicit and provide a reproducer? Here's a test I just ran: >>> for arrays in uproot4.iterate("Zmumu*.root:events", ["px1"]): print(arrays)
...
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: -41.2}, {px1: 35.1}, {px1: 35.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
>>> for arrays in uproot4.iterate("Zmumu*.root:events", ["px1"], cut="px1 > 0"): print(arrays)
...
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}]
[{px1: 35.1}, {px1: 35.1}, {px1: 34.1}, ... {px1: 32.4}, {px1: 32.4}, {px1: 32.5}] The cut applied to all of these files, eliminating the negative |
Hi @jpivarski, Each step of the iterator produces a batch array with events selected by the cuts if I understand correctly the tutorial. I'm saving these batches in the tree_sel list and plotting the invariant mass distribution of each batch (2) to check if the cut has been applied. The problem is that the cuts seem to be only applied in the batch returned in the first step. The second batch still untouched. As I'm using LHCb data, I think I can't provide a reproducer here. But, I can show you in a zoom call if it ok. Thanks! |
I'm in a Zoom meeting, and I think it's technically impossible to run two at once. (I have used Zoom and Vidyo at the same time, but that gets complicated fast!) Also, debugging through Zoom is going to be hard, since I wouldn't be able to touch the code. It sounds like your procedure for identifying this is complex—the first thing we'd have to do anyway is break it down to focus just on Uproot itself. The Cuts = "(D_MM>1910) & (D_MM<2030)"
for x,report in tree.iterate(entry_stop=100000,step_size=50000,cut=Cuts,report=True): should be entirely equivalent to for arrays,report in tree.iterate(entry_stop=100000,step_size=50000,report=True):
x = arrays[(arrays.D_MM>1910) & (arrays.D_MM<2030)] If this isn't true, then there's some bug with In writing this response, I noticed a difference between my example and yours—mine used |
Hi @jpivarski , The equivalent way is working fine! Thank you very much! :) |
Hi,
I'm trying to reduce a very large sample by applying rectangular cuts. But the cuts are not been applied correctly.
For this, I'm following the tree iterator example in the tutorial.
`
tree = uproot4.open("file_MagDown.root:DecayTree")
tree_sel = []
for tree_sel in tree.iterate(cut="D_MM>1910 and D_MM<2030.",step_size=100000):
print(repr(tree_sel))
`
When I plot the mass distribution using the returned tree (tree_sel), it shows that no cut has been applied.
I'm doing something wrong or it's a bug? :/
The text was updated successfully, but these errors were encountered: