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

support per-event weights for PackedSelection.cutflow #1270

Open
kratsg opened this issue Feb 6, 2025 · 4 comments
Open

support per-event weights for PackedSelection.cutflow #1270

kratsg opened this issue Feb 6, 2025 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@kratsg
Copy link
Contributor

kratsg commented Feb 6, 2025

Is your feature request related to a problem? Please describe.

Right now, cutflow provides a histogram that is effectively raw event yields (where weight is just 1 (num of events). The current problem is that this is hard-coded.

Describe the solution you'd like

It would be great to pass in an array or broadcast-able value for the weights to fill (such as weights=1 recovers original behavior and weights=events.weight allows per-event weighting).

Describe alternatives you've considered

None? Unless I make my own histograms lazily...

Additional context

From discussion with @ikrommyd on IRIS-HEP Slack in #coffea channel

@kratsg kratsg added the enhancement New feature or request label Feb 6, 2025
@ikrommyd
Copy link
Collaborator

ikrommyd commented Feb 6, 2025

I guess it makes the most sense to do this not only for the histograms, but for the raw count lists as well. Basically anything that is summing to count events, it should also consider a user provided weight for each event.

Should also be added for the N-1 method as well apart from cutflow.

@NJManganelli
Copy link
Collaborator

I had an implementation for this but didn't clean it up (and of course it's also quite opinionated). I'll see if I can minimally put that in a gist

@NJManganelli
Copy link
Collaborator

#1272

@NJManganelli
Copy link
Collaborator

Hi @kratsg , the PR mentioned above has been merged in. From your description, I'm unsure if this will be usable in the workflow you're iterating on now, but if and when you have time, you can have a look and share feedback on whether it works and how things could be altered to accommodate your needs, if not. Right now, the cutflow expects a coffea Weights() instance, but that could be extended to accept just straight arrays of weights if the output of your tools can be passed through that class. Additionally, the case for handling scalars to be broadcast is done with the scale method in the print, yieldhists and plot_vars methods. Some examples of using most of these are available in the updated packed_selection notebook / docs

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

No branches or pull requests

3 participants