# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .jl
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Julia 1.5.0
#     language: julia
#     name: julia-1.5
# ---

# +
using LaTeXStrings
using CxxWrap: StdVector
using StatsPlots
using LinearAlgebra
using Corpuscles
using OnlineStats
using Distributed
using JLD2
using FileIO

gr()
theme(:gruvbox_dark)
# -

pdgHistograms = Dict(
    :ss => CountMap(Int32),
    :bb => CountMap(Int32),
    :cc => CountMap(Int32),
    :gg => CountMap(Int32)
)

bbHisto = load("bb.jld2")["pdgHistograms"][:bb]
ccHisto = load("cc.jld2")["pdgHistograms"][:cc]
ssHisto = load("ss.jld2")["pdgHistograms"][:ss]
ggHisto = load("gg.jld2")["pdgHistograms"][:gg]

# before normalization
plot(bbHisto, fillcolor=nothing, linecolor=:red, label="bb")
plot!(ccHisto, fillcolor=nothing, linecolor=:yellow, label="cc")
plot!(ggHisto, fillcolor=nothing, linecolor=:cyan, label="gg")
plot!(ssHisto, fillcolor=nothing, linecolor=:white, label="ss")

pdgValues = sort(union([collect(keys(x)) for x in (bbHisto, ssHisto, ggHisto, ccHisto)]...))

data = [get(sample.value, pdg, 0)/sample.n for pdg in pdgValues, sample in (bbHisto, ccHisto, ggHisto, ssHisto)]

labels = [Particle(Int(pdg)).name for pdg in pdgValues]

unicodeLabels = [latexstring(Particle(Int(pdg)).latex) for pdg in pdgValues]

# following the recipe from https://github.com/JuliaPlots/StatsPlots.jl
ctg = repeat(["bb", "cc", "gg", "ss"], inner = length(pdgValues))
nam = repeat(labels, outer = 4)
groupedbar(nam, data, group=ctg, xlabel="PDG Values", lw=0)



StarcoderdataJupyterScriptsDedupFiltered