init_camera Function

private function init_camera(p1, p2, p3, layer, nbins, maxval, trackHistory) result(out)

Initalise Camera detector

Arguments

Type IntentOptional Attributes Name
type(vector), intent(in) :: p1

Position of the 1st corner of the detector

type(vector), intent(in) :: p2

Distance from p1 to the 2nd corner

type(vector), intent(in) :: p3

Distance from p1 to the 3rd corner

integer, intent(in) :: layer

Layer ID

integer, intent(in) :: nbins

Number of bins in the detector

real(kind=wp), intent(in) :: maxval

Maximum value to store in bins

logical, intent(in) :: trackHistory

Boolean on if to store photon's history prior to hitting the detector.

Return Value type(camera)


Source Code

    function init_camera(p1, p2, p3, layer, nbins, maxval, trackHistory) result(out)
        !! Initalise Camera detector

        !> Position of the 1st corner of the detector
        type(vector),  intent(in) :: p1
        !> Distance from p1 to the 2nd corner
        type(vector),  intent(in) :: p2
        !> Distance from p1 to the 3rd corner
        type(vector),  intent(in) :: p3
        !> Layer ID
        integer,       intent(in) :: layer
        !> Number of bins in the detector
        integer,       intent(in) :: nbins
        !> Maximum value to store in bins
        real(kind=wp), intent(in) :: maxval
        !> Boolean on if to store photon's history prior to hitting the detector.
        logical,       intent(in) :: trackHistory
        type(camera) :: out

        out%pos = p1
        out%p2 = p2
        out%p3 = p3
        out%e1 = p2 - p1
        out%e2 = p3 - p1
        out%width = length(out%e1)
        out%height = length(out%e2)
        out%n = out%e2 .cross. out%e1
        out%n = out%n%magnitude()
        out%layer = layer
        !extra bin for data beyond end of array
        out%nbinsX = nbins + 1
        out%nbinsY = nbins + 1
        allocate(out%data(out%nbinsX, out%nbinsY))
        out%data = 0.0_wp
        if(nbins == 0)then
            out%bin_wid_x = 1._wp
            out%bin_wid_y = 1._wp
        else
            out%bin_wid_x = maxval / real(out%nbinsX, kind=wp)
            out%bin_wid_y = maxval / real(out%nbinsY, kind=wp)
        end if
        out%trackHistory = trackHistory

    end function init_camera