Skip to content

Generic filters #755

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Generic filters #755

wants to merge 2 commits into from

Conversation

alexis-pereda
Copy link
Contributor

A new system to configure filters for actors.

The main idea is to be able to write for example:

actors.filter = "kinetic_energy < 20 * MeV or particle_name == 'gamma' and track_id != 0"

Current proof of concept works, run time overhead yet to assess to compare to another implementation (partial) using C++ JIT compilation (preliminary tests show a factor of around 2 for short simulations on m'y computer).
To discuss : optional dependency on (py)ROOT (for C++ JIT) to reduce simulation time when using generic filters.

Demo in test023 generic (not an actual test yet, must be executed with options, e.g. -san1e2).

The entrypoint is in the base actor interface, using filter member.
This string can be defined to a Python expression like:

"particle_name == "gamma" and pre_kinetic_energy <= 20 * MeV"

A Transformer will:
- pre compute constants (e.g. 20 * MeV will become a direct value);
- turn attribute names into function calls to acquire its value.

The AST is then used as the body of a Python function.
This function is given to the C++-side corresponding base actor to be
used as the filter.

This POC works, though it is noticeably slower than another experiment
using a JIT compiled C++ function (using ROOT.gInterpreter).
@alexis-pereda alexis-pereda self-assigned this May 13, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary file to move to data

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary file to move to data

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary file to move to data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for all) yes, no problem. These files probably won't exist in a few commits anyway, but I will follow this for the files that will be produced by the actual test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants