From 6db4ce0673f4d8987533d91073c394f580cf13c5 Mon Sep 17 00:00:00 2001 From: 9GaoHong <88077350+9GaoHong@users.noreply.github.com> Date: Thu, 21 Mar 2024 22:18:39 +0800 Subject: [PATCH 1/4] Update CorrectedMETFactory.py --- src/coffea/jetmet_tools/CorrectedMETFactory.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/coffea/jetmet_tools/CorrectedMETFactory.py b/src/coffea/jetmet_tools/CorrectedMETFactory.py index 5853dc5b2..113700664 100644 --- a/src/coffea/jetmet_tools/CorrectedMETFactory.py +++ b/src/coffea/jetmet_tools/CorrectedMETFactory.py @@ -4,11 +4,11 @@ def corrected_polar_met( - met_pt, met_phi, jet_pt, jet_phi, jet_pt_orig, positive=None, dx=None, dy=None + met_pt, met_phi, jet_pt, jet_phi, positive=None, dx=None, dy=None ): sj, cj = numpy.sin(jet_phi), numpy.cos(jet_phi) - x = met_pt * numpy.cos(met_phi) + awkward.sum((jet_pt - jet_pt_orig) * cj, axis=1) - y = met_pt * numpy.sin(met_phi) + awkward.sum((jet_pt - jet_pt_orig) * sj, axis=1) + x = met_pt * numpy.cos(met_phi) + awkward.sum(jet_pt * cj, axis=1) + y = met_pt * numpy.sin(met_phi) + awkward.sum(jet_pt * sj, axis=1) if positive is not None and dx is not None and dy is not None: x = x + dx if positive else x - dx y = y + dy if positive else y - dy @@ -36,7 +36,7 @@ def __init__(self, name_map): self.name_map = name_map - def build(self, in_MET, in_corrected_jets): + def build(self, in_MET, type1_MET,in_corrected_jets): if not isinstance( in_MET, (awkward.highlevel.Array, dask_awkward.Array) ) or not isinstance( @@ -60,7 +60,6 @@ def switch_properties(raw_met, corrected_jets, dx, dy, positive, save_orig): raw_met[self.name_map["METphi"]], corrected_jets[self.name_map["JetPt"]], corrected_jets[self.name_map["JetPhi"]], - corrected_jets[self.name_map["ptRaw"]], positive=positive, dx=dx, dy=dy, @@ -144,10 +143,10 @@ def create_variants(raw_met, corrected_jets_or_variants, dx, dy): out_dict["MET_UnclusteredEnergy"] = dask_awkward.map_partitions( create_variants, - MET, + type1_MET, corrected_jets, - MET[self.name_map["UnClusteredEnergyDeltaX"]], - MET[self.name_map["UnClusteredEnergyDeltaY"]], + type1_MET[self.name_map["UnClusteredEnergyDeltaX"]], + type1_MET[self.name_map["UnClusteredEnergyDeltaY"]], label="UnclusteredEnergy_met", ) From 885d9bdb54142a179d1db505ceb5c03b8036f972 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 14:19:22 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/coffea/jetmet_tools/CorrectedMETFactory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coffea/jetmet_tools/CorrectedMETFactory.py b/src/coffea/jetmet_tools/CorrectedMETFactory.py index 113700664..33ad74904 100644 --- a/src/coffea/jetmet_tools/CorrectedMETFactory.py +++ b/src/coffea/jetmet_tools/CorrectedMETFactory.py @@ -36,7 +36,7 @@ def __init__(self, name_map): self.name_map = name_map - def build(self, in_MET, type1_MET,in_corrected_jets): + def build(self, in_MET, type1_MET, in_corrected_jets): if not isinstance( in_MET, (awkward.highlevel.Array, dask_awkward.Array) ) or not isinstance( From 4ba4688436763d64f8f8636d63da0b45406edb7b Mon Sep 17 00:00:00 2001 From: 9GaoHong <88077350+9GaoHong@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:27:28 +0800 Subject: [PATCH 3/4] Update test_jetmet_tools.py --- tests/test_jetmet_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_jetmet_tools.py b/tests/test_jetmet_tools.py index 3443f4837..61297fdbb 100644 --- a/tests/test_jetmet_tools.py +++ b/tests/test_jetmet_tools.py @@ -919,12 +919,12 @@ def smear_factor(jetPt, pt_gen, jersf): toc = time.time() print("setup corrected MET time =", toc - tic) - + rawmet = events.RawMET met = events.MET tic = time.time() # prof = pyinstrument.Profiler() # prof.start() - corrected_met = met_factory.build(met, corrected_jets) + corrected_met = met_factory.build(rawmet, met, corrected_jets) # prof.stop() toc = time.time() From 8cccaeb6ff2374c5353e13317665db8bd4026388 Mon Sep 17 00:00:00 2001 From: 9GaoHong <88077350+9GaoHong@users.noreply.github.com> Date: Fri, 22 Mar 2024 11:30:08 +0800 Subject: [PATCH 4/4] Update CorrectedMETFactory.py --- src/coffea/jetmet_tools/CorrectedMETFactory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coffea/jetmet_tools/CorrectedMETFactory.py b/src/coffea/jetmet_tools/CorrectedMETFactory.py index 33ad74904..25d979b84 100644 --- a/src/coffea/jetmet_tools/CorrectedMETFactory.py +++ b/src/coffea/jetmet_tools/CorrectedMETFactory.py @@ -7,8 +7,8 @@ def corrected_polar_met( met_pt, met_phi, jet_pt, jet_phi, positive=None, dx=None, dy=None ): sj, cj = numpy.sin(jet_phi), numpy.cos(jet_phi) - x = met_pt * numpy.cos(met_phi) + awkward.sum(jet_pt * cj, axis=1) - y = met_pt * numpy.sin(met_phi) + awkward.sum(jet_pt * sj, axis=1) + x = met_pt * numpy.cos(met_phi) - awkward.sum(jet_pt * cj, axis=1) + y = met_pt * numpy.sin(met_phi) - awkward.sum(jet_pt * sj, axis=1) if positive is not None and dx is not None and dy is not None: x = x + dx if positive else x - dx y = y + dy if positive else y - dy