Skip to content
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

Weird behavior with field replacement and method that uses apply_global_index #1101

Open
ikrommyd opened this issue Jun 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ikrommyd
Copy link
Contributor

ikrommyd commented Jun 1, 2024

This

from coffea.nanoevents import NanoEventsFactory

events = NanoEventsFactory.from_root({"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root": "Events"}).events()
events["Photon", "eta_to_use"] = events.Photon.eta
events["Electron", "eta_to_use"] = events.Electron.eta + events.Electron.deltaEtaSC
print(events.Photon.matched_electron.eta_to_use.compute()[-10:])

events = NanoEventsFactory.from_root({"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root": "Events"}).events()
events["Photon", "eta_to_use"] = events.Photon.eta
events["Electron", "eta_to_use"] = events.Electron.eta
print(events.Photon.matched_electron.eta_to_use.compute()[-10:])

incorrectly prints

[[], [0.776], [], [2.02], [], [-0.00642], [], [], [], []]
[[], [0.776], [], [2.02], [], [-0.00642], [], [], [], []]

while the eta_to_use field is different in both cases for electrons. The seemingly redundant events["Photon", "eta_to_use"] = events.Photon.eta is part of the reproducer. If you remove it, it works.
The correct output should be

[[], [0.776], [], [2.02], [], [-0.00642], [], [], [], []]
[[], [0.785], [], [2.02], [], [-0.0595], [], [], [], []]
@ikrommyd ikrommyd added the bug Something isn't working label Jun 1, 2024
@ikrommyd
Copy link
Contributor Author

ikrommyd commented Jun 1, 2024

If you remove the second events reading in the above reproducer and run it like this in a notebook:

from coffea.nanoevents import NanoEventsFactory

events = NanoEventsFactory.from_root({"https://github.com/CoffeaTeam/coffea/raw/master/tests/samples/nano_dy.root": "Events"}).events()
events["Photon", "eta_to_use"] = events.Photon.eta
events["Electron", "eta_to_use"] = events.Electron.eta + events.Electron.deltaEtaSC
print(events.Photon.matched_electron.eta_to_use.compute()[-10:])

events["Photon", "eta_to_use"] = events.Photon.eta
events["Electron", "eta_to_use"] = events.Electron.eta
print(events.Photon.matched_electron.eta_to_use.compute()[-10:])

You will get the correct output the first time you run the cell

[[], [0.776], [], [2.02], [], [-0.00642], [], [], [], []]
[[], [0.785], [], [2.02], [], [-0.0595], [], [], [], []]

and all the following times you rerun the same cell you will be getting

[[], [0.785], [], [2.02], [], [-0.0595], [], [], [], []]
[[], [0.785], [], [2.02], [], [-0.0595], [], [], [], []]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant