handle_annulus_dect Subroutine

private subroutine handle_annulus_dect(child, dects, counts, context, error)

Read in Annulus_detector settings and initalise variable

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(in), pointer :: child

Detector Table

type(annulus_dect), intent(inout) :: dects(:)

Array of annulus_dects

integer, intent(inout) :: counts

Number of anulluar dects to create

type(toml_context), intent(in) :: context

Context handle for error reporting.

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

Error message


Source Code

    subroutine handle_annulus_dect(child, dects, counts, context, error)
        !! Read in Annulus_detector settings and initalise variable
        
        use detectors,     only : annulus_dect
        use sim_state_mod, only : state
        use utils,         only : str

        !> Detector Table
        type(toml_table), pointer,     intent(in)    :: child
        !> Array of annulus_dects
        type(annulus_dect),            intent(inout) :: dects(:)
        !> Number of anulluar dects to create
        integer,                       intent(inout) :: counts
        !> Context handle for error reporting.
        type(toml_context),            intent(in)    :: context
        !> Error message
        type(toml_error), allocatable, intent(out)   :: error

        integer       :: layer, nbins, origin
        real(kind=wp) :: maxval, radius1, radius2
        type(vector)  :: pos, dir
        logical       :: trackHistory

        pos = get_vector(child, "position", context=context, error=error)
        dir = get_vector(child, "direction", default=vector(0.0, 0.0, -1.0), context=context, error=error)
        call get_value(child, "layer", layer, 1)
        call get_value(child, "radius1", radius1)
        call get_value(child, "radius2", radius2, origin=origin)
        
        if(radius2 <= radius1)then
            call make_error(error,&
            context%report("Radii are invalid", origin, &
            "Expected radius2 ("//str(radius2,6)//") > radius 1 ("//str(radius1,6)//")"), -1)
            return
        end if
        
        call get_value(child, "nbins", nbins, 100)
        call get_value(child, "maxval", maxval, 100._wp)
        call get_value(child, "trackHistory", trackHistory, .false.)
        if(trackHistory)state%trackHistory=.true.
#ifdef _OPENMP
        if(trackHistory)then
            call make_error(error, "Track history currently incompatable with OpenMP!", -1)
            return
        end if
#endif
        dects(counts) = annulus_dect(pos, dir, layer, radius1, radius2, nbins, maxval, trackHistory)
        counts = counts + 1
    end subroutine handle_annulus_dect