Skip to content

Commit

Permalink
Added basic check to record hit in detector_base.f90
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisfish committed Oct 4, 2023
1 parent 495045a commit 0bae907
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions test/detector/test_detector.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ end subroutine detector_suite
subroutine hit_circle(error)

use vector_class, only : vector
use historyStack

type(error_type), allocatable, intent(out) :: error

Expand All @@ -36,6 +37,7 @@ subroutine hit_circle(error)
integer :: layer, nbins
real(kind=wp) :: radius, maxval, val
logical :: flag
type(history_stack_t) :: history

pos = vector(0._wp, 0._wp, 0._wp)
dir = vector(1._wp, 0._wp, 0._wp)
Expand All @@ -52,16 +54,21 @@ subroutine hit_circle(error)
hitpoint = hit_t(pos, dir, val, layer)

flag = a%check_hit(hitpoint)

call check(error, flag, .true.)
if(allocated(error))return

call a%record_hit(hitpoint, history)

call check(error, sum(a%data), 1.0_wp)
if(allocated(error))return

end subroutine hit_circle


subroutine hit_camera(error)

use vector_class, only : vector
use historyStack

type(error_type), allocatable, intent(out) :: error

Expand All @@ -71,7 +78,8 @@ subroutine hit_camera(error)
integer :: layer, nbins
real(kind=wp) :: maxval, val
logical :: flag

type(history_stack_t) :: history

p1 = vector(-1._wp, -1._wp, -1._wp)
p2 = vector(0._wp, 2._wp, 0._wp)
p3 = vector(0._wp, 0._wp, 2._wp)
Expand All @@ -90,6 +98,10 @@ subroutine hit_camera(error)

call check(error, flag, .true.)
if(allocated(error))return

call a%record_hit(hitpoint, history)
call check(error, sum(a%data), 1.0_wp)
if(allocated(error))return

pos = vector(10._wp, 0._wp, 0._wp)
dir = vector(1._wp, 0._wp, 0._wp)
Expand All @@ -107,6 +119,7 @@ end subroutine hit_camera
subroutine hit_annulus(error)

use vector_class, only : vector
use historyStack

type(error_type), allocatable, intent(out) :: error

Expand All @@ -116,7 +129,8 @@ subroutine hit_annulus(error)
integer :: layer, nbins
real(kind=wp) :: maxval, val, r1, r2
logical :: flag

type(history_stack_t) :: history

layer = 1
nbins = 100
maxval = 100._wp
Expand All @@ -134,6 +148,10 @@ subroutine hit_annulus(error)
call check(error, flag, .true.)
if(allocated(error))return

call a%record_hit(hitpoint, history)
call check(error, sum(a%data), 1.0_wp)
if(allocated(error))return

pos = vector(0._wp, 0._wp, 0._wp)
dir = vector(1._wp, 0._wp, 0._wp)
val = 1._wp
Expand Down

0 comments on commit 0bae907

Please sign in to comment.