|
32 | 32 | "outputs": [], |
33 | 33 | "source": [ |
34 | 34 | "import sys\n", |
| 35 | + "\n", |
35 | 36 | "sys.path.append(module_path)" |
36 | 37 | ] |
37 | 38 | }, |
|
67 | 68 | " unique_labels, contiguous_labels = np.unique(elem[\"hit_labels\"], return_inverse=True)\n", |
68 | 69 | " elem[\"hit_labels_contiguous\"] = contiguous_labels\n", |
69 | 70 | " elems.append(elem)\n", |
70 | | - " if len(elems)>=100:\n", |
| 71 | + " if len(elems) >= 100:\n", |
71 | 72 | " break\n", |
72 | 73 | "\n", |
73 | 74 | "elems = [[ak.from_iter(elem)] for elem in elems]\n", |
|
81 | 82 | "metadata": {}, |
82 | 83 | "outputs": [], |
83 | 84 | "source": [ |
84 | | - "plt.hist(ak.max(elems[\"hit_labels_contiguous\"], axis=1), bins=np.linspace(0,400,41));\n", |
| 85 | + "plt.hist(ak.max(elems[\"hit_labels_contiguous\"], axis=1), bins=np.linspace(0, 400, 41))\n", |
85 | 86 | "plt.xlabel(\"Clusters per event\")\n", |
86 | 87 | "plt.ylabel(\"Event count\")" |
87 | 88 | ] |
|
104 | 105 | "metadata": {}, |
105 | 106 | "outputs": [], |
106 | 107 | "source": [ |
107 | | - "plt.hist(calo_hit_features_f[:, 0], np.linspace(-5000,5000,100), histtype=\"step\", lw=2, label=\"x\")\n", |
108 | | - "plt.hist(calo_hit_features_f[:, 1], np.linspace(-5000,5000,100), histtype=\"step\", lw=2, label=\"y\")\n", |
109 | | - "plt.hist(calo_hit_features_f[:, 2], np.linspace(-5000,5000,100), histtype=\"step\", lw=2, label=\"z\");\n", |
| 108 | + "plt.hist(calo_hit_features_f[:, 0], np.linspace(-5000, 5000, 100), histtype=\"step\", lw=2, label=\"x\")\n", |
| 109 | + "plt.hist(calo_hit_features_f[:, 1], np.linspace(-5000, 5000, 100), histtype=\"step\", lw=2, label=\"y\")\n", |
| 110 | + "plt.hist(calo_hit_features_f[:, 2], np.linspace(-5000, 5000, 100), histtype=\"step\", lw=2, label=\"z\")\n", |
110 | 111 | "plt.xlabel(\"Hit position (mm)\")\n", |
111 | 112 | "plt.ylabel(\"Hit count\")\n", |
112 | 113 | "plt.legend()" |
|
119 | 120 | "metadata": {}, |
120 | 121 | "outputs": [], |
121 | 122 | "source": [ |
122 | | - "plt.hist(10*calo_hit_features_f[:, 3], np.logspace(-3,1,100))\n", |
| 123 | + "plt.hist(10 * calo_hit_features_f[:, 3], np.logspace(-3, 1, 100))\n", |
123 | 124 | "plt.xscale(\"log\")\n", |
124 | 125 | "plt.xlabel(\"Hit energy (GeV)\")\n", |
125 | 126 | "plt.ylabel(\"Hit count\")" |
|
160 | 161 | " cluster_hit_count = []\n", |
161 | 162 | " cluster_id = []\n", |
162 | 163 | " for clid in cluster_ids:\n", |
163 | | - " cl_mask = elem[\"hit_labels_contiguous\"]==clid\n", |
| 164 | + " cl_mask = elem[\"hit_labels_contiguous\"] == clid\n", |
164 | 165 | " std_x = np.std(elem[\"calo_hit_features\"][:, 0][cl_mask])\n", |
165 | 166 | " std_y = np.std(elem[\"calo_hit_features\"][:, 1][cl_mask])\n", |
166 | 167 | " std_z = np.std(elem[\"calo_hit_features\"][:, 2][cl_mask])\n", |
167 | 168 | " sum_e = np.sum(elem[\"calo_hit_features\"][:, 3][cl_mask])\n", |
168 | 169 | " hit_count = np.sum(cl_mask)\n", |
169 | | - " \n", |
| 170 | + "\n", |
170 | 171 | " cluster_std_x.append(std_x)\n", |
171 | 172 | " cluster_std_y.append(std_y)\n", |
172 | 173 | " cluster_std_z.append(std_z)\n", |
173 | 174 | " cluster_sum_e.append(sum_e)\n", |
174 | 175 | " cluster_hit_count.append(hit_count)\n", |
175 | 176 | " cluster_id.append(clid)\n", |
176 | | - " \n", |
| 177 | + "\n", |
177 | 178 | " all_cluster_std_x.append(cluster_std_x)\n", |
178 | 179 | " all_cluster_std_y.append(cluster_std_y)\n", |
179 | 180 | " all_cluster_std_z.append(cluster_std_z)\n", |
|
198 | 199 | "outputs": [], |
199 | 200 | "source": [ |
200 | 201 | "plt.hist2d(\n", |
201 | | - " ak.to_numpy(ak.flatten(all_cluster_hit_count[all_cluster_hit_count>5])),\n", |
202 | | - " ak.to_numpy(ak.flatten(all_cluster_std_x[all_cluster_hit_count>5])),\n", |
203 | | - " bins=(np.logspace(0,3,100), np.logspace(-2,4,100))\n", |
| 202 | + " ak.to_numpy(ak.flatten(all_cluster_hit_count[all_cluster_hit_count > 5])),\n", |
| 203 | + " ak.to_numpy(ak.flatten(all_cluster_std_x[all_cluster_hit_count > 5])),\n", |
| 204 | + " bins=(np.logspace(0, 3, 100), np.logspace(-2, 4, 100)),\n", |
204 | 205 | ")\n", |
205 | 206 | "plt.xscale(\"log\")\n", |
206 | 207 | "plt.yscale(\"log\")\n", |
|
218 | 219 | "plt.hist2d(\n", |
219 | 220 | " ak.to_numpy(ak.flatten(ak.Array(all_cluster_hit_count))),\n", |
220 | 221 | " ak.to_numpy(ak.flatten(ak.Array(all_cluster_std_y))),\n", |
221 | | - " bins=(np.logspace(0,3,100), np.logspace(-2,4,100))\n", |
| 222 | + " bins=(np.logspace(0, 3, 100), np.logspace(-2, 4, 100)),\n", |
222 | 223 | ")\n", |
223 | 224 | "plt.xscale(\"log\")\n", |
224 | 225 | "plt.yscale(\"log\")\n", |
|
234 | 235 | "outputs": [], |
235 | 236 | "source": [ |
236 | 237 | "plt.hist2d(\n", |
237 | | - " ak.to_numpy(ak.flatten(ak.Array(all_cluster_hit_count[all_cluster_hit_count>5]))),\n", |
238 | | - " ak.to_numpy(ak.flatten(ak.Array(all_cluster_std_z[all_cluster_hit_count>5]))),\n", |
239 | | - " bins=(np.logspace(0,3,100), np.logspace(-2,4,100))\n", |
| 238 | + " ak.to_numpy(ak.flatten(ak.Array(all_cluster_hit_count[all_cluster_hit_count > 5]))),\n", |
| 239 | + " ak.to_numpy(ak.flatten(ak.Array(all_cluster_std_z[all_cluster_hit_count > 5]))),\n", |
| 240 | + " bins=(np.logspace(0, 3, 100), np.logspace(-2, 4, 100)),\n", |
240 | 241 | ")\n", |
241 | 242 | "plt.xscale(\"log\")\n", |
242 | 243 | "plt.yscale(\"log\")\n", |
|
251 | 252 | "metadata": {}, |
252 | 253 | "outputs": [], |
253 | 254 | "source": [ |
254 | | - "plt.figure(figsize=(5,5))\n", |
| 255 | + "plt.figure(figsize=(5, 5))\n", |
255 | 256 | "plt.hist2d(\n", |
256 | 257 | " ak.to_numpy(ak.flatten(ak.Array(all_cluster_hit_count))),\n", |
257 | 258 | " ak.to_numpy(ak.flatten(ak.Array(all_cluster_sum_e))),\n", |
258 | | - " bins=(np.logspace(0,3,100), np.logspace(-2,3,100))\n", |
| 259 | + " bins=(np.logspace(0, 3, 100), np.logspace(-2, 3, 100)),\n", |
259 | 260 | ")\n", |
260 | 261 | "plt.xscale(\"log\")\n", |
261 | 262 | "plt.yscale(\"log\")\n", |
|
270 | 271 | "metadata": {}, |
271 | 272 | "outputs": [], |
272 | 273 | "source": [ |
273 | | - "plt.hist(ak.flatten(all_cluster_hit_count), bins=np.linspace(0,1500,100));\n", |
| 274 | + "plt.hist(ak.flatten(all_cluster_hit_count), bins=np.linspace(0, 1500, 100))\n", |
274 | 275 | "plt.yscale(\"log\")\n", |
275 | 276 | "plt.xlabel(\"Number of hits per cluster\")\n", |
276 | 277 | "plt.ylabel(\"Cluster count\")" |
|
283 | 284 | "metadata": {}, |
284 | 285 | "outputs": [], |
285 | 286 | "source": [ |
286 | | - "fig, axs = plt.subplots(3,3, figsize=(10,10))\n", |
| 287 | + "fig, axs = plt.subplots(3, 3, figsize=(10, 10))\n", |
287 | 288 | "axs = axs.flatten()\n", |
288 | 289 | "for ielem in range(9):\n", |
289 | 290 | " plt.sca(axs[ielem])\n", |
290 | 291 | " elem = elems[ielem]\n", |
291 | | - " \n", |
| 292 | + "\n", |
292 | 293 | " unique_labels, contiguous_labels = np.unique(elem[\"hit_labels\"], return_inverse=True)\n", |
293 | | - " cmap = plt.get_cmap('viridis')\n", |
| 294 | + " cmap = plt.get_cmap(\"viridis\")\n", |
294 | 295 | " distinct_colors = cmap(np.linspace(0, 1, len(unique_labels)))\n", |
295 | | - " \n", |
| 296 | + "\n", |
296 | 297 | " plt.scatter(\n", |
297 | 298 | " elem[\"calo_hit_features\"][:, 0],\n", |
298 | 299 | " elem[\"calo_hit_features\"][:, 1],\n", |
299 | | - " s=np.clip(100*elem[\"calo_hit_features\"][:, 3], 0.1, 10),\n", |
300 | | - " c=distinct_colors[contiguous_labels])\n", |
| 300 | + " s=np.clip(100 * elem[\"calo_hit_features\"][:, 3], 0.1, 10),\n", |
| 301 | + " c=distinct_colors[contiguous_labels],\n", |
| 302 | + " )\n", |
301 | 303 | " plt.xlim(-6000, 6000)\n", |
302 | 304 | " plt.ylim(-6000, 6000)\n", |
303 | | - " plt.title(\"$N_{{hit}}$={}, $N_{{cl}}$={}\".format(len(elem[\"calo_hit_features\"]), len(np.unique(elem[\"hit_labels\"]))))\n", |
| 305 | + " plt.title(\n", |
| 306 | + " \"$N_{{hit}}$={}, $N_{{cl}}$={}\".format(len(elem[\"calo_hit_features\"]), len(np.unique(elem[\"hit_labels\"])))\n", |
| 307 | + " )\n", |
304 | 308 | " plt.xticks([])\n", |
305 | 309 | " plt.yticks([])" |
306 | 310 | ] |
307 | 311 | } |
308 | 312 | ], |
309 | 313 | "metadata": { |
310 | 314 | "kernelspec": { |
311 | | - "display_name": "Python 3 (ipykernel)", |
| 315 | + "display_name": "python3", |
312 | 316 | "language": "python", |
313 | 317 | "name": "python3" |
314 | | - }, |
315 | | - "language_info": { |
316 | | - "codemirror_mode": { |
317 | | - "name": "ipython", |
318 | | - "version": 3 |
319 | | - }, |
320 | | - "file_extension": ".py", |
321 | | - "mimetype": "text/x-python", |
322 | | - "name": "python", |
323 | | - "nbconvert_exporter": "python", |
324 | | - "pygments_lexer": "ipython3", |
325 | | - "version": "3.11.13" |
326 | 318 | } |
327 | 319 | }, |
328 | 320 | "nbformat": 4, |
|
0 commit comments