diff --git a/Project.toml b/Project.toml index dd86f9a..e5480b3 100644 --- a/Project.toml +++ b/Project.toml @@ -5,6 +5,7 @@ version = "0.3.0" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" +CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193" EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" @@ -20,6 +21,7 @@ JetVisualisation = "Makie" [compat] Accessors = "0.1.36" +CodecZlib = "0.7.4" EnumX = "1.0.4" JSON = "0.21.4" LoopVectorization = "0.12.170" diff --git a/examples/Project.toml b/examples/Project.toml index fd546ef..e6ab21f 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -3,10 +3,12 @@ ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89" +GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196" LorentzVectorHEP = "f612022c-142a-473f-8cfd-a09cf3793c6c" +Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781" +PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8" Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" ProfileSVG = "132c30aa-f267-4189-9183-c8a63c7e05e6" StatProfilerHTML = "a8a75453-ed82-57c9-9e16-4cd1196ecbf5" -WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008" diff --git a/examples/visualise-jets-pluto.jl b/examples/visualise-jets-pluto.jl new file mode 100644 index 0000000..e6c31d8 --- /dev/null +++ b/examples/visualise-jets-pluto.jl @@ -0,0 +1,97 @@ +### A Pluto.jl notebook ### +# v0.19.42 + +# Do not format this code, it's under the control of the Pluto.jl notebook +#! format: off + +using Markdown +using InteractiveUtils + +# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error). +macro bind(def, element) + quote + local iv = try Base.loaded_modules[Base.PkgId(Base.UUID("6e696c72-6542-2067-7265-42206c756150"), "AbstractPlutoDingetjes")].Bonds.initial_value catch; b -> missing; end + local el = $(esc(element)) + global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : iv(el) + el + end +end + +# ╔═╡ cf88f2f9-bf19-47e2-ae04-b4476eb26efb +import Pkg + +# ╔═╡ 24dd666c-49be-4c44-9b9d-d27128c1ffbb +Pkg.activate(".") + +# ╔═╡ 0a1a8211-507b-4dc0-9060-0d18a5a695a4 +using GLMakie + +# ╔═╡ f7ec7400-bbb2-4f28-9f13-881dea775f41 +using PlutoUI + +# ╔═╡ 32b48d85-40cb-42c8-b3ad-ab613081da38 +using JetReconstruction + +# ╔═╡ dff6a188-2cbe-11ef-32d0-73c4c05efad2 +md"""# Jet Reconstruction Visualisation + +This Pluto script visualises the result of a jet reconstruction process. + +Use the sliders below to change the reconstructed event, the algorithm and the jet radius parameter.""" + +# ╔═╡ 0642cc6e-290e-4e01-9882-5c12d7585ead + + +# ╔═╡ 4e569f74-570b-4b30-9ea7-9cbc420f50f8 +md"Event number:" + +# ╔═╡ 83030910-8d00-4949-b69e-fa492b61db6b +@bind event_no PlutoUI.Slider(1:100, show_value=true) + +# ╔═╡ 306f6e66-788c-4a95-a9df-3ac4c37cf776 +md"``k_T`` algorithm power (-1=Anti-``k_T``, 0 = Cambridge/Aachen, 1=Inclusive kT)" + +# ╔═╡ 864d7a31-b634-4edc-b6c4-0835fee53304 +@bind power PlutoUI.Slider(-1:1, show_value=true) + +# ╔═╡ 9f7988a5-041e-4a83-9da9-d48db34cea98 +md"Jet radius parameter" + +# ╔═╡ 187315d4-ac3c-4847-ae00-e7da1b27d63f +@bind radius PlutoUI.Slider(range(start=0.4, stop=2.0, step=0.1), show_value=true) + +# ╔═╡ 79f24ec1-a63e-4e96-bd67-49661125be66 +input_file = joinpath(dirname(pathof(JetReconstruction)), "..", "test", "data", "events.hepmc3.gz") + +# ╔═╡ 7d7a8b11-19b3-4b83-a0b1-8201b74b588e +events::Vector{Vector{PseudoJet}} = read_final_state_particles(input_file, + maxevents = event_no, skipevents = event_no); + +# ╔═╡ 2a899d67-71f3-4fe0-8104-7633a44a06a8 +cs = jet_reconstruct(events[1], p=power, R=radius) + +# ╔═╡ b5fd4e96-d073-4e5f-8de1-41addaa0dc3d +jetreco_vis = jetsplot(events[1], cs; Module = GLMakie) + +# ╔═╡ 81b14eba-6981-4943-92fe-529c53b0ac35 +display(jetreco_vis); + +# ╔═╡ Cell order: +# ╟─dff6a188-2cbe-11ef-32d0-73c4c05efad2 +# ╠═0642cc6e-290e-4e01-9882-5c12d7585ead +# ╠═cf88f2f9-bf19-47e2-ae04-b4476eb26efb +# ╠═24dd666c-49be-4c44-9b9d-d27128c1ffbb +# ╠═0a1a8211-507b-4dc0-9060-0d18a5a695a4 +# ╠═f7ec7400-bbb2-4f28-9f13-881dea775f41 +# ╠═32b48d85-40cb-42c8-b3ad-ab613081da38 +# ╟─4e569f74-570b-4b30-9ea7-9cbc420f50f8 +# ╟─83030910-8d00-4949-b69e-fa492b61db6b +# ╟─306f6e66-788c-4a95-a9df-3ac4c37cf776 +# ╟─864d7a31-b634-4edc-b6c4-0835fee53304 +# ╟─9f7988a5-041e-4a83-9da9-d48db34cea98 +# ╟─187315d4-ac3c-4847-ae00-e7da1b27d63f +# ╟─79f24ec1-a63e-4e96-bd67-49661125be66 +# ╠═7d7a8b11-19b3-4b83-a0b1-8201b74b588e +# ╠═2a899d67-71f3-4fe0-8104-7633a44a06a8 +# ╠═b5fd4e96-d073-4e5f-8de1-41addaa0dc3d +# ╠═81b14eba-6981-4943-92fe-529c53b0ac35 diff --git a/examples/visualise-jets.ipynb b/examples/visualise-jets.ipynb index ae7e1bb..439d876 100644 --- a/examples/visualise-jets.ipynb +++ b/examples/visualise-jets.ipynb @@ -11,125 +11,58 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "using JetReconstruction\n", - "using WGLMakie" + "using GLMakie" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "-1" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "input_file = joinpath(dirname(pathof(JetReconstruction)), \"..\", \"test\", \"data\", \"events.hepmc3\")\n", + "input_file = joinpath(dirname(pathof(JetReconstruction)), \"..\", \"test\", \"data\", \"events.hepmc3.gz\")\n", "event_number = 5\n", - "power = JetReconstruction.algorithm2power[JetAlgorithm.AntiKt]" + "power = JetReconstruction.algorithm2power[JetAlgorithm.AntiKt];" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "┌ Info: Total Events: 1\n", - "└ @ JetReconstruction /Users/graemes/code/JetReconstruction.jl/src/Utils.jl:25\n" - ] - }, - { - "data": { - "text/plain": [ - "1-element Vector{Vector{PseudoJet}}:\n", - " [Pseudojet(px: 0.10735113569266963 py: 0.2004614564282816 pz: 4.422690640225503 E: 4.430731468492096; pt: 0.22739626612557606 eta: 3.5020136230471057 phi: 1.0791380602175356, m: 0.13957000000001873), Pseudojet(px: 0.0011180093991561963 py: 0.012301879085520844 pz: 22.359575220942624 E: 22.365027980969874; pt: 0.01235257762782233 eta: 4.506078564441087 phi: 1.4801641127937162, m: 0.49367999999995554), Pseudojet(px: -0.33118180618811155 py: -0.24231713636363833 pz: -3.25942622170417 E: 3.2881207494491758; pt: 0.4103644518297046 eta: -2.715069658291437 phi: 3.773261626597981, m: 0.1395699999999775), Pseudojet(px: 0.2845031139591477 py: -0.2609196772690977 pz: 0.5824183002026259 E: 0.7125390944710178; pt: 0.3860325113752232 eta: 1.148884934008853 phi: 5.540999045397645, m: 0.13957000000000067), Pseudojet(px: 0.277302069395142 py: 0.03634561140067778 pz: 39.80187826849783 E: 39.80592231168471; pt: 0.27967381207205877 eta: 4.943811191960002 phi: 0.13032576256213585, m: 0.49367999999988865), Pseudojet(px: 0.5585153132771401 py: -0.3956483216555057 pz: -3.612052304986627 E: 3.6789779271494787; pt: 0.6844537600115003 eta: -2.345409125258054 phi: 5.666848658975102, m: 0.13956999999996506), Pseudojet(px: 0.18720823164796177 py: -0.1318330234187746 pz: -0.01476649422315373 E: 0.2685604258116496; pt: 0.22896914215782896 eta: -0.055039390302584666 phi: 5.669642585890234, m: 0.13957000000000006), Pseudojet(px: -0.284009089213228 py: 0.19114033359969312 pz: 0.5990537728620824 E: 0.7039467292094088; pt: 0.34233870637765934 eta: 1.259742297825951 phi: 2.549212870154946, m: 0.13957000000000028), Pseudojet(px: -0.1198632609880622 py: -1.01567218528733 pz: 12.315390709550222 E: 12.358571329368008; pt: 1.0227204844438351 eta: 3.1740560094308856 phi: 4.59491858779022, m: 0.1395699999999233), Pseudojet(px: 0.14193817088911215 py: -0.10210725343936139 pz: -491.6296473818766 E: 491.63057629580845; pt: 0.17484946542748359 eta: -6.936184139290346 phi: 5.659571757044644, m: 0.9395699999616959) … Pseudojet(px: -0.22734940597450876 py: -0.19391176346017772 pz: 1.2342343780389635 E: 1.269891343516611; pt: 0.29881352781491993 eta: 2.125875213203082 phi: 3.8477817997568358, m: -4.012260442327338e-8), Pseudojet(px: -0.523471846359122 py: -0.48320925068178905 pz: 2.179296432537861 E: 2.2927814755766254; pt: 0.7124001360717755 eta: 1.836968693576574 phi: 3.887016739844139, m: -6.664001874625056e-8), Pseudojet(px: -0.2312767181096859 py: -0.21992677138349426 pz: 0.4294329015812787 E: 0.5350414208930659; pt: 0.31914997275693896 eta: 1.1059220830216552 phi: 3.9018412914459106, m: -1.235539015514925e-8), Pseudojet(px: -0.11069390032673052 py: -0.08757514264029723 pz: 0.3836884534292784 E: 0.4088268269976469; pt: 0.14114724644148235 eta: 1.7254081403827335 phi: 3.8109120397691947, m: -1.3301947021005397e-8), Pseudojet(px: -0.10329088004039041 py: -0.06428883857518583 pz: 0.8355555651306337 E: 0.8558241337948111; pt: 0.12166371959160473 eta: 2.212114260143481 phi: 3.6983242717426164, m: 0.13957000000000566), Pseudojet(px: -0.47893890239446585 py: -0.7722751051190008 pz: 7.740016906120406 E: 7.794429600820265; pt: 0.9087306037618517 eta: 2.8271088536617697 phi: 4.157273223909725, m: 0.13957000000024747), Pseudojet(px: 0.26463547776785407 py: 0.1378250615977995 pz: -0.33116508213450935 E: 0.44575553313785565; pt: 0.29837507217905723 eta: -0.9569868503353292 phi: 0.480157443201187, m: -3.725290298461914e-9), Pseudojet(px: 0.12023014344988193 py: -0.02895697531429787 pz: -0.14561313580629956 E: 0.19104182561071778; pt: 0.12366807920127183 eta: -1.0014573565077023 phi: 6.046840349964005, m: 4.562530187486071e-9), Pseudojet(px: 0.23193210651528592 py: -0.20537892641762634 pz: -0.18706512331287167 E: 0.3618927545684421; pt: 0.3097951023645705 eta: -0.5721105945608865 phi: 5.55843189731101, m: 9.125060374972142e-9), Pseudojet(px: 0.13205569774138806 py: -0.1001219907287217 pz: -0.23680434557793556 E: 0.2890318640185567; pt: 0.16572000583347526 eta: -1.1546901232363953 phi: 5.634469512021886, m: 5.890201144234053e-9)]" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "# We read only one event\n", - "events::Vector{Vector{PseudoJet}} = read_final_state_particles(input_file, maxevents = event_number, skipevents = event_number)" + "events::Vector{Vector{PseudoJet}} = read_final_state_particles(input_file, maxevents = event_number, \n", + " skipevents = event_number);" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "ClusterSequence(JetReconstruction.JetAlgorithm.AntiKt, JetReconstruction.RecoStrategy.N2Tiled, PseudoJet[Pseudojet(px: 0.10735113569266963 py: 0.2004614564282816 pz: 4.422690640225503 E: 4.430731468492096; pt: 0.22739626612557606 eta: 3.5020136230471057 phi: 1.0791380602175356, m: 0.13957000000001873), Pseudojet(px: 0.0011180093991561963 py: 0.012301879085520844 pz: 22.359575220942624 E: 22.365027980969874; pt: 0.01235257762782233 eta: 4.506078564441087 phi: 1.4801641127937162, m: 0.49367999999995554), Pseudojet(px: -0.33118180618811155 py: -0.24231713636363833 pz: -3.25942622170417 E: 3.2881207494491758; pt: 0.4103644518297046 eta: -2.715069658291437 phi: 3.773261626597981, m: 0.1395699999999775), Pseudojet(px: 0.2845031139591477 py: -0.2609196772690977 pz: 0.5824183002026259 E: 0.7125390944710178; pt: 0.3860325113752232 eta: 1.148884934008853 phi: 5.540999045397645, m: 0.13957000000000067), Pseudojet(px: 0.277302069395142 py: 0.03634561140067778 pz: 39.80187826849783 E: 39.80592231168471; pt: 0.27967381207205877 eta: 4.943811191960002 phi: 0.13032576256213585, m: 0.49367999999988865), Pseudojet(px: 0.5585153132771401 py: -0.3956483216555057 pz: -3.612052304986627 E: 3.6789779271494787; pt: 0.6844537600115003 eta: -2.345409125258054 phi: 5.666848658975102, m: 0.13956999999996506), Pseudojet(px: 0.18720823164796177 py: -0.1318330234187746 pz: -0.01476649422315373 E: 0.2685604258116496; pt: 0.22896914215782896 eta: -0.055039390302584666 phi: 5.669642585890234, m: 0.13957000000000006), Pseudojet(px: -0.284009089213228 py: 0.19114033359969312 pz: 0.5990537728620824 E: 0.7039467292094088; pt: 0.34233870637765934 eta: 1.259742297825951 phi: 2.549212870154946, m: 0.13957000000000028), Pseudojet(px: -0.1198632609880622 py: -1.01567218528733 pz: 12.315390709550222 E: 12.358571329368008; pt: 1.0227204844438351 eta: 3.1740560094308856 phi: 4.59491858779022, m: 0.1395699999999233), Pseudojet(px: 0.14193817088911215 py: -0.10210725343936139 pz: -491.6296473818766 E: 491.63057629580845; pt: 0.17484946542748359 eta: -6.936184139290346 phi: 5.659571757044644, m: 0.9395699999616959) … Pseudojet(px: -0.39835711999954054 py: 0.2670425498120344 pz: 0.7823069850508971 E: 0.9340296824136827; pt: 0.4795832758389738 eta: 1.2129464793726437 phi: 2.551037707350037, m: 0.17437634675018016), Pseudojet(px: -0.951550846981664 py: -0.9977730565509817 pz: 2.4230718853428095 E: 3.73223181209067; pt: 1.3787675970846611 eta: 0.7739642228927174 phi: 3.9506982929567993, m: 2.481386074530168), Pseudojet(px: 0.575045650586158 py: -0.5793693320717683 pz: 119.64892585365241 E: 119.65220155609016; pt: 0.8163003878495616 eta: 5.5994728271350915 phi: 5.494041817072272, m: 0.3428308084295518), Pseudojet(px: 0.7430438203838197 py: -0.628041726281588 pz: 141.8604114139369 E: 141.8648142562351; pt: 0.9729082839411632 eta: 5.536755612159961 phi: 5.581467943888408, m: 0.5501335253218786), Pseudojet(px: -0.7419306814989711 py: -1.2366670329604335 pz: -624.3010720899828 E: 624.3038227364076; pt: 1.4421534199108947 eta: -6.512850727112166 phi: 4.17201082701939, m: 1.163900383803333), Pseudojet(px: 0.8187724552223374 py: -1.067476764067555 pz: 231.86864600370112 E: 231.87426160333024; pt: 1.3453233720020452 eta: 5.66076861307267 phi: 5.366692093104101, m: 0.8912348314063477), Pseudojet(px: -0.744694588399963 py: -0.009592334481453038 pz: 208.62889484542603 E: 208.63058856570524; pt: 0.7447563647750817 eta: 6.207268055736434 phi: 3.154472838529462, m: 0.38994718343853185), Pseudojet(px: -0.1192134634148563 py: -0.3533286513298661 pz: 28.166510818816608 E: 28.169333465655836; pt: 0.37289809024711745 eta: 4.950705618562694 phi: 4.386981945468061, m: 0.14129121379207538), Pseudojet(px: 0.23303548004166347 py: -0.13392810235789748 pz: 912.9974388192057 E: 912.9976433113742; pt: 0.26877922456811276 eta: 8.002430623603196 phi: 5.761568088926931, m: 0.5487799398343952), Pseudojet(px: -0.08919052127372945 py: -0.11399069359282013 pz: -13.401707836816184 E: 13.4025408354216; pt: 0.1447370972171675 eta: -5.189519498733623 phi: 4.04844938780284, m: 0.0371358916999187)], 627, JetReconstruction.HistoryElement[JetReconstruction.HistoryElement(-2, -2, 920, 1, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 875, 2, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 990, 3, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 665, 4, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 1247, 5, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 1059, 6, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 1045, 7, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 1224, 8, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 948, 9, 0.0, 0.0), JetReconstruction.HistoryElement(-2, -2, 1216, 10, 0.0, 0.0) … JetReconstruction.HistoryElement(248, -1, -3, -3, 9.280205444134888, 9.280205444134888), JetReconstruction.HistoryElement(270, -1, -3, -3, 10.433687082239864, 10.433687082239864), JetReconstruction.HistoryElement(5, -1, -3, -3, 12.784872340278474, 12.784872340278474), JetReconstruction.HistoryElement(1243, -1, -3, -3, 13.842311134655677, 13.842311134655677), JetReconstruction.HistoryElement(117, -1, -3, -3, 23.637588808292218, 23.637588808292218), JetReconstruction.HistoryElement(67, 408, 1251, 1203, 30.63667250108433, 30.63667250108433), JetReconstruction.HistoryElement(1250, -1, -3, -3, 47.73536891403872, 47.73536891403872), JetReconstruction.HistoryElement(11, -1, -3, -3, 65.27369292060092, 65.27369292060092), JetReconstruction.HistoryElement(494, -1, -3, -3, 396.63695275112633, 396.63695275112633), JetReconstruction.HistoryElement(429, -1, -3, -3, 29349.05857739363, 29349.05857739363)], 13000.000000397144)" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ - "cs = jet_reconstruct(events[1], R = 1.0, p = power)" + "cs = jet_reconstruct(events[1], R = 1.0, p = power);" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "