From 4d0e36a3353b6cfaa5e4dcdf8b428f66491372a5 Mon Sep 17 00:00:00 2001 From: Ken Bloom Date: Thu, 31 Oct 2019 11:22:48 -0500 Subject: [PATCH 1/2] Good practices on > and < operations Educational note: when histograms are filled, it's typical that a given bin contains entries that are greater than *or equal to* the lower bin boundary and less then (but not equal to!) the upper bin boundary. I've adjusted the mass window to reflect that (even though admittedly the problem statement was vague on this point). --- benchmarks/example5.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmarks/example5.ipynb b/benchmarks/example5.ipynb index a959590..738826b 100644 --- a/benchmarks/example5.ipynb +++ b/benchmarks/example5.ipynb @@ -60,7 +60,7 @@ " opposites = (dimuons.i0.charge != dimuons.i1.charge)\n", " \n", " # Get only muons with energy between 60 and 120.\n", - " limits = (dimuons.mass > 60) & (dimuons.mass < 120)\n", + " limits = (dimuons.mass >= 60) & (dimuons.mass < 120)\n", " \n", " # Mask the dimuons with the opposites and the limits to get dimuons with opposite charge and mass between 60 and 120 GeV.\n", " good_dimuons = dimuons[opposites & limits]\n", From 7c3da8033b13c3677f92749d8e63f0f937f7d265 Mon Sep 17 00:00:00 2001 From: Ingo Mueller Date: Sat, 18 Apr 2020 18:03:26 +0200 Subject: [PATCH 2/2] Fix bug in Notebook 8 related to argdistincts (#5). --- benchmarks/example8.ipynb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/benchmarks/example8.ipynb b/benchmarks/example8.ipynb index ac792e0..e4c8fa3 100644 --- a/benchmarks/example8.ipynb +++ b/benchmarks/example8.ipynb @@ -180,15 +180,17 @@ " dimu = muons.distincts()\n", " \n", " # same for dileptons\n", - " diele = diele[(diele.i0.charge * diele.i1.charge < 0) & (diele.mass > 50) & (diele.mass < 160)]\n", - " dimu = dimu[(dimu.i0.charge * dimu.i1.charge < 0) & (dimu.mass > 50) & (dimu.mass < 160)]\n", + " diele_selection = (diele.i0.charge * diele.i1.charge < 0) & (diele.mass > 50) & (diele.mass < 160)\n", + " dimu_selection = (dimu.i0.charge * dimu.i1.charge < 0) & (dimu.mass > 50) & (dimu.mass < 160)\n", + " diele = diele[diele_selection]\n", + " dimu = dimu[dimu_selection]\n", " \n", " #get the dileptons closest to the z-pole\n", " best_diele = np.abs(diele.mass - 91.18).argmin()\n", " best_dimu = np.abs(dimu.mass - 91.18).argmin()\n", " \n", - " diele_args = electrons.argdistincts()[best_diele].compact()\n", - " dimu_args = muons.argdistincts()[best_dimu].compact()\n", + " diele_args = electrons.argdistincts()[diele_selection][best_diele].compact()\n", + " dimu_args = muons.argdistincts()[dimu_selection][best_dimu].compact()\n", " \n", " # select the third lepton with highest pT that's not in the z-candidate\n", " # it returns a mask that selects the appropriate dilepton and third lepton\n",