record_hit_1D_sub Subroutine

private subroutine record_hit_1D_sub(this, hitpoint, history)

check if a hit is on the detector and record it if so

Type Bound

detector1D

Arguments

Type IntentOptional Attributes Name
class(detector1D), intent(inout) :: this
type(hit_t), intent(in) :: hitpoint

Interaction information

type(history_stack_t), intent(inout) :: history

Photon packet history


Source Code

    subroutine record_hit_1D_sub(this, hitpoint, history)
        !! check if a hit is on the detector and record it if so

        use historyStack,  only : history_stack_t
        use sim_state_mod, only : state

        class(detector1D),     intent(inout) :: this
        !> Interaction information
        type(hit_t),           intent(in)    :: hitpoint
        !> Photon packet history
        type(history_stack_t), intent(inout) :: history

        real(kind=wp) :: value
        integer       :: idx

        if(this%check_hit(hitpoint))then
            value = hitpoint%value
            idx = min(nint(value / this%bin_wid) + 1, this%nbins)
            !$omp atomic
            this%data(idx) = this%data(idx) + 1
            if(this%trackHistory)then
                call history%write()
            end if
        end if
        if(state%trackHistory)call history%zero()
    end subroutine record_hit_1D_sub