juobs_obs.jl 3.78 KB
Newer Older
Javier's avatar
Javier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
@doc raw"""
meff(corr::Vector{uwreal}, plat::Vector{Int64}; pl::Bool=true, data::Bool=false )     

meff(corr::Corr, plat::Vector{Int64}; pl::Bool=true, data::Bool=false)

Computes effective mass for a given correlator corr at a given plateau plat.
Correlator can be passed as an Corr struct or Vector{uwreal}.
    
The flags pl and data allow to show the plots and return data as an extra result.

```@example
data = read_mesons(path, "G5", "G5")
corr_pp = corr_obs.(data)
m = meff(corr_pp[1], [50, 60], pl=false)
```
"""
function meff(corr::Vector{uwreal}, plat::Vector{Int64}; pl::Bool=true, data::Bool=false)     
    dim = length(corr)                                                                                    
    aux = log.(corr[2:dim-2] ./ corr[3:dim-1])     
Javier's avatar
Javier committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    mass = plat_av(aux, plat)                                                                            
    uwerr(mass)                       
    if pl == true
        x = 1:length(aux)
        y = value.(aux)
        dy = err.(aux)
        v = value(mass)
        e = err(mass)
        
        figure()
        fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75)
        errorbar(x, y, dy, fmt="x", color="black")
        ylabel(L"$m_\mathrm{eff}$")
        xlabel(L"$x_0$")
        display(gcf())
    end                                                  
    if data == false                   
        return mass                                        
    else               
        return (mass, aux)     
    end                    
end   
42 43
meff(corr::Corr, plat::Vector{Int64}; pl::Bool=true, data::Bool=false) = 
    meff(corr.obs, plat, pl=pl, data=data)
Javier's avatar
Javier committed
44 45

## Decay constants                                                                                       
Javier's avatar
Javier committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
@doc raw"""
dec_const_pcvc(corr::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false)meff(corr::Corr, plat::Vector{Int64}; pl::Bool=true, data::Bool=false)

dec_const_pcvc(corr::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=true, data::Bool=false)

Computes decay constant using the PCVC relation for twisted mass fermions. The decay constant is computed in the plateau plat.
Correlator can be passed as an Corr struct or Vector{uwreal}. If it is passed as a uwreal vector, vector of twisted masses mu and source position y0
must be specified.

The flags pl and data allow to show the plots and return data as an extra result.

```@example
data = read_mesons(path, "G5", "G5")
corr_pp = corr_obs.(data)
m = meff(corr_pp[1], [50, 60], pl=false)
f = dec_const_pcvc(corr_pp[1], [50, 60], m, pl=false)
```
"""
function dec_const_pcvc(corr::Vector{uwreal}, plat::Vector{Int64}, m::uwreal, mu::Vector{Float64}, y0::Int64 ; pl::Bool=true, data::Bool=false)
Javier's avatar
Javier committed
65 66 67
    """
    compute the decay constant when the source is far from the boundaries
    """
Javier's avatar
Javier committed
68
    corr_pp = corr[2:end-1]
Javier's avatar
Javier committed
69
    dim = length(corr_pp)
70 71
                                                                 
    aux = exp.((collect(1:dim) .- y0 ) .* [m for k in 1:dim])
Javier's avatar
Javier committed
72 73 74 75
    R = (aux .* corr_pp).^0.5
    R_av = plat_av(R, plat)
    f = sqrt(2) * (mu[1] + mu[2]) *R_av / m^1.5
    uwerr(f)
76 77 78 79
    if pl == true
        uwerr(R_av)
        v = value(R_av)
        e = err(R_av)                                
Javier's avatar
Javier committed
80
        uwerr.(R)
81 82 83
        figure()
        fill_between(plat[1]:plat[2], v-e, v+e, color="green", alpha=0.75)                                            
        errorbar(1:length(R), value.(R), err.(R), fmt="x", color="black")
Javier's avatar
Javier committed
84 85 86 87 88 89 90 91 92 93
        ylabel(L"$R$")
        xlabel(L"$x_0$")
        display(gcf())          
    end 
    if data == false
        return f
    else
        return (f, R)                   
    end 
end 
94 95
dec_const_pcvc(corr::Corr, plat::Vector{Int64}, m::uwreal; pl::Bool=true, data::Bool=false) =
    dec_const_pcvc(corr.obs, plat, m, corr.mu, corr.y0, pl=pl, data=data)