mmikhasenko / ThreeBodyDecays.jl

Builder of the three-body decay model using cascade approach
https://mmikhasenko.github.io/ThreeBodyDecays.jl/
MIT License
2 stars 0 forks source link

Projection recipe #42

Open mmikhasenko opened 1 month ago

mmikhasenko commented 1 month ago

it would be nice to introduce the projection recipe. One problem is that the function needs to know how to integrate, while the package does not depend on any integrator

Here is how one would do it

begin
    @shorthands dalitz_plot_projection
    # 
    @recipe function f(::Type{Val{:dalitz_plot_projection}}, x, y, z)
        d = plotattributes
        # 
        function_on_dalitz = get(d, :function_on_dalitz, nothing)
        if function_on_dalitz == nothing
            error("what do you want me to plot? Provide it with `f` argument.")
        end
        ms = get(d, :masses, nothing)
        if ms == nothing
            error("Provide masses with the `masses` argument.")
        end
        axis = get(d, :axis_k, nothing)
        if axis == nothing
            error("Provide axis (k) with the `axis` argument.")
        end

        function projection_function(σk)
            integrand = projection_integrand(function_on_dalitz, ms, σk; k=axis)
            quadgk(integrand, 0, 1)[1]
        end
        # 
        seriestype := :path
        x := y
        y := projection_function.(y)
        # 
        ()
    end
end