diff --git a/src/hardware.jl b/src/hardware.jl index 97555fcf173a4454da344adc8655b8c72658b7cb..e833a18ed6cc0d2fc2c0cf3b2b21df5a1de7ef68 100644 --- a/src/hardware.jl +++ b/src/hardware.jl @@ -364,6 +364,7 @@ function Detector(io::IO) # a counter to work around the floor == -1 bug in some older DETX files floor_counter = 1 last_string = -1 + floorminusone_warning_has_been_shown = false for mod ∈ 1:n_modules elements = split(lines[idx]) @@ -372,6 +373,10 @@ function Detector(io::IO) # floor == -1 bug. We determine the floor position by assuming an ascending order # of modules in the DETX file if floor == -1 + if !floorminusone_warning_has_been_shown + @warn "'Floor == -1' found in the detector file. The actual floor number will be inferred, assuming that modules and lines are sorted." + floorminusone_warning_has_been_shown = true + end if last_string == -1 last_string = string elseif last_string != string diff --git a/test/hardware.jl b/test/hardware.jl index 1e2b31a187f92725876f1cac65a4680889013f23..71fdb273614a2c34c1a6ec2622af667d7aaef27c 100644 --- a/test/hardware.jl +++ b/test/hardware.jl @@ -1,6 +1,7 @@ using Test using KM3io +using KM3NeTTestData using Dates const SAMPLES_DIR = joinpath(@__DIR__, "samples") @@ -107,6 +108,15 @@ end @test 0 < length(det) end end +@testset "DETX floor == -1 bug" begin + det = Detector(datapath("detx", "orca_115strings_av20min17mhorizontal_18OMs_alt9mvertical_v2.detx")) + @assert Location(1, 1) == det[1].location + @assert Location(1, 2) == det[2].location + @assert Location(1, 18) == det[18].location + @assert Location(2, 1) == det[19].location + @assert Location(3, 1) == det[37].location + @assert Location(115, 18) == det[2070].location +end @testset "DETX writing" begin for from_version ∈ 1:5 for to_version ∈ 1:5