Skip to content
Snippets Groups Projects
Verified Commit a33a42eb authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add prefit stuff

parent 24f5a3cb
No related branches found
No related tags found
No related merge requests found
Pipeline #41802 failed
......@@ -10,6 +10,7 @@ Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
FHist = "68837c9b-b678-4cd5-9925-8a54edc8f695"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
......
......@@ -36,6 +36,7 @@ export
include("math.jl")
include("hits.jl")
include("mc.jl")
include("prefit.jl")
include("fit.jl")
include("plot.jl")
include("db.jl")
......
......@@ -74,3 +74,26 @@ The function to fit time residual plot distributions.
function langauss(x, LA, , , GA, , , offset)
LA * pdf(Landau(, ), x) + GA * pdf(Normal(, ), x) + offset
end
"""
Creates directions (points on a unit sphere) which are quite evenly distributed
with respect to their space angles using the Fibonacci lattice algorithm. The
axial anisotropy is much smaller compared to a simple latitude-longitude
lattice.
"""
function fibonaccisphere(N)
ϕ = π * (√5 - 1) # golden angle in rad
directions = sizehint!(Direction[], N)
for i 0:N-1
y = 1 - 2(i / (N - 1))
r = (1 - y * y)
θ = ϕ * i
x = cos(θ) * r
z = sin(θ) * r
push!(directions, Direction(x, y, z))
end
directions
end
struct Hit
t::Float64
tot::Float64
end
starttime(hit) = hit.t
endtime(hit) = hit.t + hit.tot
function combine(hits::Vector{Hit})
isempty(hits) && return Hit(0.0, 0.0)
t1 = starttime(first(hits))
t2 = endtime(first(hits))
@inbounds for hit hits[2:end]
_t1 = starttime(hit)
_t2 = endtime(hit)
if t1 > _t1
t1 = _t1
end
if t2 < _t2
t2 = _t2
end
end
Hit(t1, t2 - t1)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment