Skip to content

Commit

Permalink
test for events containment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofia Calgaro committed Jan 16, 2025
1 parent 94751d0 commit 7e5224c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/io/test_all.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Test.@testset "io" begin
include("test_get_signal_prior_info.jl")
include("test_get_energy_scale_pars.jl")
include("test_get_efficiency.jl")
include("test_event_is_contained.jl")
end
33 changes: 33 additions & 0 deletions test/io/test_event_is_contained.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Pkg
Pkg.activate(".") # activate the environment
Pkg.instantiate() # instantiate the environment
include("../../src/ZeroNuFit.jl")
using .ZeroNuFit
include("../../main.jl")
include("../../src/utils.jl")

@testset "" begin

@info "Testing function to flag if an event is contained or not in the fit ranges (function 'event_is_contained' in src/utils.jl)"
fit_range = [[1930.0, 2098.511], [2108.511, 2113.513], [2123.513, 2190.0]]

# contained event
event = 1950.0
flag = nothing
try
flag = ZeroNuFit.event_is_contained(event, fit_range)
catch e
@error "Error in event_is_contained: $e"
throw(e)
end

@testset "Check flag is valid" begin
@test !isnothing(flag)
end
@test flag == true

# event outside fit window
event = 150.0
flag = ZeroNuFit.event_is_contained(event, fit_range)
@test flag == false
end

0 comments on commit 7e5224c

Please sign in to comment.