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: temporary fix for vector issue #498 #84

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/egamma_tnp/nanoaod_efficiency.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from coffea.analysis_tools import Weights
from coffea.lumi_tools import LumiMask
from coffea.nanoevents import NanoAODSchema
from coffea.nanoevents.methods import nanoaod

from egamma_tnp._base_tagnprobe import BaseTagNProbe
from egamma_tnp.utils import calculate_photon_SC_eta, custom_delta_r
Expand Down Expand Up @@ -512,6 +513,13 @@ def __repr__(self):
return f"PhotonTagNProbeFromNanoAOD(Filters: {self.filters}, Number of files: {n_of_files})"

def find_probes(self, events, cut_and_count, mass_range, vars):
# TODO: remove this temporary fix when https://github.com/scikit-hep/vector/issues/498 is resolved
photon_dict = {field: events.Photon[field] for field in events.Photon.fields} | {
"mass": dak.zeros_like(events.Photon.pt),
"charge": dak.zeros_like(events.Photon.pt),
}
events["Photon"] = dak.zip(photon_dict, with_name="Photon", behavior=nanoaod.behavior)

if self.use_sc_eta:
if "superclusterEta" not in events.Photon.fields:
events["Photon", "superclusterEta"] = calculate_photon_SC_eta(events.Photon, events.PV)
Expand Down
9 changes: 9 additions & 0 deletions tests/dummy_tag_and_probe_nanoaod.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import awkward as ak
from coffea.nanoevents.methods import nanoaod

from egamma_tnp.utils import custom_delta_r

Expand Down Expand Up @@ -121,6 +122,14 @@ def tag_and_probe_electrons(events, is_id):


def tag_and_probe_photons(events, start_from_diphotons, is_id):
# TODO: remove this temporary fix when https://github.com/scikit-hep/vector/issues/498 is resolved
photon_dict = {field: events.Photon[field] for field in events.Photon.fields} | {
"mass": ak.zeros_like(events.Photon.pt),
"charge": ak.zeros_like(events.Photon.pt),
}

events["Photon"] = ak.zip(photon_dict, with_name="Photon", behavior=nanoaod.behavior)

events["Photon", "eta_to_use"] = events.Photon.eta
events["Photon", "phi_to_use"] = events.Photon.phi
events["Electron", "eta_to_use"] = events.Electron.eta
Expand Down
Loading