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

fix: add zero photon charge and fix their cutBased id #1092

Merged
merged 9 commits into from
May 26, 2024

Conversation

ikrommyd
Copy link
Contributor

@ikrommyd ikrommyd commented May 10, 2024

This adds a zero Photon charge like we do with mass so that operations like diphoton invariant mass (photon1 + photon2).mass don't run into

AttributeError: no field named 'charge'

This error occurred while calling

    numpy.add.__call__(
        <PhotonArray-typetracer [...] type='## * Photon[seediEtaOriX: int8[...'>
        <PhotonArray-typetracer [...] type='## * Photon[seediEtaOriX: int8[...'>
    )

Also fixes the cutBased ID of photons since it was changed in later NanoAOD versions and it is not caught by tests.

@ikrommyd
Copy link
Contributor Author

Will add a test soon!

@ikrommyd
Copy link
Contributor Author

I think this is also worth backporting to 0.7

@ikrommyd ikrommyd changed the title fix: add zero photon charge fix: add zero photon charge and fix their cutBased id May 14, 2024
@ikrommyd
Copy link
Contributor Author

ikrommyd commented May 15, 2024

@nsmith- I think it's no longer a bitmap and the documentation is just very bad.
I'm getting zero tight photons within two root files with 1150994 events and 1768508 photons. This isn't expected at all.

In [53]: ak.sum(events.Photon.cutBased & (1 << 2) != 0).compute()
Out[53]: 0

In [54]: ak.sum(events.Photon.isTight).compute()
Out[54]: 0

This is also the distribution of the cutbased id values in those files:
image
and this is the distribution in our nano_dy.root sample:
image
The documentation for nanoaod v10 says:
image
And for v12 it says:
image
and in v13 they dropped the second cutbased id. I think it was a bitmap when it was documented in the form of "2^(0 : loose ....)".

@ikrommyd
Copy link
Contributor Author

ikrommyd commented May 15, 2024

I don't know if this is the best way to initialize the cutbased attributes in the Photon class. Please let me know about requested changes. The downside with my implementation is that the LOOSE, MEDIUM, TIGHT attributes are not available before a cutbased id method is called. That's only a problem in eager mode though as they are not accessible in dask mode anyways. Doing events.Electron.TIGHT fails with TypeError: meta must be an instance of an Awkward Array, not <class 'int'>.

Another thing I thought of is to start with

    FAIL = 0
    "cutBased selection minimum value"
    VETO = 1
    "cutBased selection minimum value"
    LOOSE = 2
    "cutBased selection minimum value"
    MEDIUM = 3
    "cutBased selection minimum value"
    TIGHT = 4
    "cutBased selection minimum value"

by default and if cutBased is not in fields, then we switch to bitmasking on the spot without changing those attributes. No one is gonna use that old of a NanoAOD version anymore anyways.

edit: I actually did it like that in my commit below.

@lgray lgray merged commit 352fece into CoffeaTeam:master May 26, 2024
14 checks passed
@ikrommyd ikrommyd deleted the fix-photons branch May 26, 2024 18:56
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.

None yet

3 participants