{
"cells": [
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-05-16T13:18:07.059621Z",
"start_time": "2025-05-16T13:18:06.341690Z"
}
},
"cell_type": "code",
"source": [
"import pickle\n",
"import torch\n",
"import os\n",
"import matplotlib.pyplot as plt\n",
"from src.utils.paths import get_path\n",
"from src.utils.utils import CPU_Unpickler\n",
"from pathlib import Path\n",
"import fastjet\n",
"from src.dataset.dataset import EventDataset\n",
"import numpy as np\n",
"\n",
"filename = get_path(\"/pnfs/psi.ch/cms/trivcat/store/user/gkrzmanc/jetclustering/results/train/Eval_DelphesPFfix_FullDataset_2025_05_13_13_45_30_914/eval_0.pkl\", \"results\")\n",
"# for rinv=0.7, see /work/gkrzmanc/jetclustering/results/train/Test_betaPt_BC_rinv07_2025_01_03_15_38_58\n",
"\n",
"result = CPU_Unpickler(open(filename, \"rb\")).load()\n",
"dataset = EventDataset.from_directory(result[\"filename\"], mmap=True)\n"
],
"id": "862bda2d2f12153f",
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/work/gkrzmanc/jetclustering/code/src/utils/utils.py:91: FutureWarning:\n",
"\n",
"You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n",
"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"File: matrix_element_gen_particles.pkl\n",
"File: final_gen_particles.pkl\n",
"File: final_parton_level_particles.pkl\n",
"File: pfcands.pkl\n",
"get_pfcands_key\n"
]
}
],
"execution_count": 14
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-05-16T13:18:08.574412Z",
"start_time": "2025-05-16T13:18:08.472201Z"
}
},
"cell_type": "code",
"source": [
"# plotly 3d plot of result[\"pred\"], colored by result[\"GT_cluster\"]\n",
"from src.plotting.plot_coordinates import plot_coordinates\n",
"filt = result[\"event_idx\"] == 19\n",
"# normalized coordinates\n",
"norm_coords = result[\"pred\"][filt, 1:4] #/ np.linalg.norm(result[\"pred\"][filt, 1:4] , axis=1 ,keepdims=1)\n",
"pt_scaled = torch.tensor(result[\"pt\"][filt])\n",
"pt_scaled[pt_scaled < 0.3] = 0.3\n",
"plot_coordinates(norm_coords, pt_scaled, torch.tensor(result[\"GT_cluster\"][filt])).show()\n"
],
"id": "d584df4044d8a585",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('X', (134, 1)), ('Y', (134, 1)), ('Z', (134, 1)), ('tIdx', (134, 1)), ('pt', (134, 1))]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_423/2132609012.py:6: UserWarning:\n",
"\n",
"To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
"\n",
"/tmp/ipykernel_423/2132609012.py:8: UserWarning:\n",
"\n",
"To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).\n",
"\n"
]
},
{
"data": {
"application/vnd.plotly.v1+json": {
"data": [
{
"hovertemplate": "X=%{x}
Y=%{y}
Z=%{z}
pt=%{marker.size}
tIdx=%{marker.color}