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

Merge branch '30-helper-functions-for-parameters-which-use-0-based-indexing' into 'main'

Make fitinf use 0-based indexing

Closes #30

See merge request !36
parents a934c463 f47532b0
No related branches found
No related tags found
1 merge request!36Make fitinf use 0-based indexing
......@@ -75,6 +75,7 @@ MCTrk,
TriggeredHit,
Trk,
XCalibratedHit,
FitInformation,
# Calibration
AbstractCalibratedHit,
......
......@@ -37,6 +37,21 @@ struct CalibratedMCHit
dir::Direction{Float64}
end
"""
A container object to store fit information which uses 0-based indexing.
"""
struct FitInformation
values::Vector{Float64}
end
Base.getindex(fitinf::FitInformation, idx) = fitinf.values[idx + 1]
Base.length(fitinf::FitInformation) = length(fitinf.values)
Base.firstindex(::FitInformation) = 0
Base.lastindex(fitinf::FitInformation) = length(fitinf) - 1
Base.eltype(::FitInformation) = Float64
function Base.iterate(fitinf::FitInformation, state=0)
state > length(fitinf)-1 ? nothing : (fitinf[state], state+1)
end
"""
Represents a reconstructed "track", which can be e.g. a muon track but also a shower.
"""
......@@ -50,7 +65,7 @@ struct Trk
lik::Float64
rec_type::Int32
rec_stages::Vector{Int32}
fitinf::Vector{Float64}
fitinf::FitInformation
end
"""
......@@ -304,7 +319,7 @@ function Base.getindex(f::OfflineTree, idx::Integer)
e.trks_lik[i],
e.trks_rec_type[i],
e.trks_rec_stages[i],
e.trks_fitinf[i],
FitInformation(e.trks_fitinf[i]),
)
)
end
......
......@@ -17,7 +17,7 @@ using Test
0,
0,
[0],
[0]
FitInformation([0])
)
γs = cherenkov(track, hits)
......
......@@ -18,7 +18,7 @@ const USRFILE = datapath("offline", "usr-sample.root")
@test 56 == length(t[1].trks)
@test 0 == length(t[1].w)
@test 17 == length(t[1].trks[1].fitinf)
@test 0.009290906625313346 == t[end].trks[1].fitinf[1]
@test 0.009290906625313346 == t[end].trks[1].fitinf[0]
close(f)
f = ROOTFile(datapath("offline", "numucc.root"))
......
......@@ -91,7 +91,8 @@ const ONLINEFILE = datapath("online", "km3net_online.root")
@test 56 == length(t[1].trks)
@test 0 == length(t[1].w)
@test 17 == length(t[1].trks[1].fitinf)
@test 0.009290906625313346 == t[end].trks[1].fitinf[1]
@test 63.92088448673299 == sum(t[end].trks[2].fitinf)
@test 101.0 == t[1].trks[1].fitinf[end]
close(f)
f = ROOTFile(datapath("offline", "numucc.root"))
......
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