get_indices Subroutine

public subroutine get_indices(pos, ind)

Find closests beam_grid indices ind to position pos

Arguments

Type IntentOptional AttributesName
real(kind=Float64), intent(in), dimension(3):: pos

Position [cm]

integer(kind=Int32), intent(out), dimension(3):: ind

Closest indices to position


Called by

proc~~get_indices~~CalledByGraph proc~get_indices get_indices proc~store_fw_photons store_fw_photons proc~store_fw_photons->proc~get_indices proc~track track proc~track->proc~get_indices proc~npa_f npa_f proc~npa_f->proc~get_indices proc~npa_mc npa_mc proc~npa_mc->proc~get_indices proc~store_bes_photons store_bes_photons proc~store_bes_photons->proc~get_indices proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~get_indices proc~dcx dcx proc~dcx->proc~track proc~fida_weights_mc fida_weights_mc proc~fida_weights_mc->proc~track proc~fida_weights_los fida_weights_los proc~fida_weights_los->proc~track proc~ndmc ndmc proc~ndmc->proc~track proc~fida_f fida_f proc~fida_f->proc~track proc~read_chords read_chords proc~read_chords->proc~track proc~halo halo proc~halo->proc~track program~fidasim fidasim program~fidasim->proc~npa_f program~fidasim->proc~npa_mc program~fidasim->proc~dcx program~fidasim->proc~fida_weights_mc program~fidasim->proc~fida_weights_los program~fidasim->proc~ndmc program~fidasim->proc~fida_f program~fidasim->proc~read_chords program~fidasim->proc~halo proc~fida_mc fida_mc program~fidasim->proc~fida_mc proc~fida_mc->proc~track

Contents

Source Code


Source Code

subroutine get_indices(pos, ind)
    !+ Find closests [[libfida:beam_grid]] indices `ind` to position `pos`
    real(Float64),  dimension(3), intent(in)  :: pos
        !+ Position [cm]
    integer(Int32), dimension(3), intent(out) :: ind
        !+ Closest indices to position

    real(Float64),  dimension(3) :: mini
    integer(Int32), dimension(3) :: maxind
    integer :: i

    maxind(1) = beam_grid%nx
    maxind(2) = beam_grid%ny
    maxind(3) = beam_grid%nz

    mini(1) = minval(beam_grid%xc) - 0.5*beam_grid%dr(1)
    mini(2) = minval(beam_grid%yc) - 0.5*beam_grid%dr(2)
    mini(3) = minval(beam_grid%zc) - 0.5*beam_grid%dr(3)

    do i=1,3
        ind(i) = floor((pos(i)-mini(i))/beam_grid%dr(i)) + 1
        if (ind(i).gt.maxind(i)) ind(i)=maxind(i)
        if (ind(i).lt.1) ind(i)=1
    enddo

end subroutine get_indices