Skip to content
Snippets Groups Projects

Muonscanfit

Merged Tamas Gal requested to merge muonscanfit into master
Compare and Show latest version
2 files
+ 104
27
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 14
18
@@ -41,10 +41,6 @@ HitL1(m::DetectorModule, hits) = HitL1(m.id, hits)
@@ -41,10 +41,6 @@ HitL1(m::DetectorModule, hits) = HitL1(m.id, hits)
HitL2(m::DetectorModule, hits) = HitL2(m.id, hits)
HitL2(m::DetectorModule, hits) = HitL2(m.id, hits)
Base.length(c::AbstractCoincidenceHit) = length(c.hits)
Base.length(c::AbstractCoincidenceHit) = length(c.hits)
Base.eltype(c::AbstractCoincidenceHit) = HitL0
Base.eltype(c::AbstractCoincidenceHit) = HitL0
function Base.show(io::IO, c::AbstractCoincidenceHit)
times = [time(h) for h in c]
print(io, "$(c.dom_id) $(minimum(times)) $(length(c))")
end
function Base.iterate(c::AbstractCoincidenceHit, state=1)
function Base.iterate(c::AbstractCoincidenceHit, state=1)
@inbounds state > length(c) ? nothing : (c.hits[state], state+1)
@inbounds state > length(c) ? nothing : (c.hits[state], state+1)
end
end
@@ -66,11 +62,11 @@ struct HitR1 <: AbstractReducedHit
@@ -66,11 +62,11 @@ struct HitR1 <: AbstractReducedHit
end
end
Base.isless(lhs::HitR1, rhs::HitR1) = lhs.dom_id == rhs.dom_id ? time(lhs) < time(rhs) : lhs.dom_id < rhs.dom_id
Base.isless(lhs::HitR1, rhs::HitR1) = lhs.dom_id == rhs.dom_id ? time(lhs) < time(rhs) : lhs.dom_id < rhs.dom_id
const HitR2 = HitR1
const HitR2 = HitR1
function HitR1(m::DetectorModule, hits::Vector{HitL0})
function HitR1(dom_id::Integer, hits::Vector{HitL0})
combined_hit = combine(hits)
combined_hit = combine(hits)
h = first(hits)
h = first(hits)
count = weight = length(hits)
count = weight = length(hits)
HitR1(m.id, h.pos, combined_hit.t, combined_hit.tot, count, weight)
HitR1(dom_id, h.pos, combined_hit.t, combined_hit.tot, count, weight)
end
end
# function HitR1(m::DetectorModule, hit::HitL1)
# function HitR1(m::DetectorModule, hit::HitL1)
# count = weight = length(hit)
# count = weight = length(hit)
@@ -292,16 +288,16 @@ end
@@ -292,16 +288,16 @@ end
"""
"""
Calibrates hits.
Calibrates hits.
"""
"""
function calibrate(T::Type{HitR1}, det::Detector, hits)
function KM3io.calibrate(T::Type{HitR1}, det::Detector, hits)
rhits = sizehint!(Vector{T}(), length(hits))
rhits = sizehint!(Vector{T}(), length(hits))
for hit hits
for hit hits
pmt = det[hit.dom_id][hit.channel_id]
pmt = det[hit.dom_id][hit.channel_id]
t = hit.t + pmt.t₀
t = hit.t + pmt.t₀
push!(rhits, T(hit.dom_id, pmt.pos, Hit(t, hit.tot)))
push!(rhits, T(hit.dom_id, pmt.pos, t, hit.tot, 1, 0))
end
end
rhits
rhits
end
end
function calibrate(T::Type{HitL0}, m::DetectorModule, hits)
function KM3io.calibrate(T::Type{HitL0}, m::DetectorModule, hits)
chits = sizehint!(Vector{T}(), length(hits))
chits = sizehint!(Vector{T}(), length(hits))
for hit hits
for hit hits
pmt = m[hit.channel_id]
pmt = m[hit.channel_id]
@@ -377,7 +373,7 @@ function _findL1!(out::Vector{H}, m::DetectorModule, hits, Δt, combine::Bool) w
@@ -377,7 +373,7 @@ function _findL1!(out::Vector{H}, m::DetectorModule, hits, Δt, combine::Bool) w
if ref_idx != end_idx
if ref_idx != end_idx
coincident_hits = [chits[i] for i ref_idx:end_idx]
coincident_hits = [chits[i] for i ref_idx:end_idx]
# push!(out, H(m, HitL1(m.id, coincident_hits)))
# push!(out, H(m, HitL1(m.id, coincident_hits)))
push!(out, H(m, coincident_hits))
push!(out, H(m.id, coincident_hits))
if combine
if combine
ref_idx = end_idx
ref_idx = end_idx
end
end
@@ -550,12 +546,12 @@ function (m::Match1D)(hit1, hit2)
@@ -550,12 +546,12 @@ function (m::Match1D)(hit1, hit2)
x = hit1.pos.x - hit2.pos.x
x = hit1.pos.x - hit2.pos.x
y = hit1.pos.y - hit2.pos.y
y = hit1.pos.y - hit2.pos.y
d = (m.x*m.x + m.y*m.y);
d = (x^2 + y^2)
if m.d <= 0.5 * m.roadwidth
if d <= 0.5 * m.roadwidth
return m.t <= m.d * KM3io.Constants.TAN_THETA_C_WATER * KM3io.Constants.C_INVERSE + m.tmaxextra
return m.t <= d * KM3io.Constants.TAN_THETA_C_WATER * KM3io.Constants.C_INVERSE + m.tmaxextra
elseif m.d <= m.roadwidth
elseif d <= m.roadwidth
return m.t <= (m.roadwidth - m.d) * KM3io.Constants.TAN_THETA_C_WATER * KM3io.Constants.C_INVERSE + m.tmaxextra
return m.t <= (m.roadwidth - d) * KM3io.Constants.TAN_THETA_C_WATER * KM3io.Constants.C_INVERSE + m.tmaxextra
end
end
false
false
@@ -570,7 +566,7 @@ end
@@ -570,7 +566,7 @@ end
Clique clusterizer which takes a matcher algorithm like `Match3B` as input.
Clique clusterizer which takes a matcher algorithm like `Match3B` as input.
"""
"""
struct Clique{T<:AbstractMatcher}
struct Clique{T<:AbstractMatcher}
m::T
match::T
weights::Vector{Float64}
weights::Vector{Float64}
Clique(m::T) where T = new{T}(m, Float64[])
Clique(m::T) where T = new{T}(m, Float64[])
end
end
@@ -592,7 +588,7 @@ function clusterize!(hits::Vector{T}, c::Clique) where T<:AbstractSpecialHit
@@ -592,7 +588,7 @@ function clusterize!(hits::Vector{T}, c::Clique) where T<:AbstractSpecialHit
@inbounds for i 1:N
@inbounds for i 1:N
@inbounds for j i:N
@inbounds for j i:N
j == i && continue
j == i && continue
if c.m(hits[i], hits[j])
if c.match(hits[i], hits[j])
c.weights[i] += weight(hits[j])
c.weights[i] += weight(hits[j])
c.weights[j] += weight(hits[i])
c.weights[j] += weight(hits[i])
end
end
@@ -626,7 +622,7 @@ function clusterize!(hits::Vector{T}, c::Clique) where T<:AbstractSpecialHit
@@ -626,7 +622,7 @@ function clusterize!(hits::Vector{T}, c::Clique) where T<:AbstractSpecialHit
# Decrease weight of associated hits for each associated hit.
# Decrease weight of associated hits for each associated hit.
@inbounds for i 1:n
@inbounds for i 1:n
c.weights[n] <= weight(hits[n]) && break
c.weights[n] <= weight(hits[n]) && break
if c.m(hits[i], hits[n])
if c.match(hits[i], hits[n])
c.weights[i] -= weight(hits[n])
c.weights[i] -= weight(hits[n])
c.weights[n] -= weight(hits[i])
c.weights[n] -= weight(hits[i])
end
end
Loading