hit_npa_detector Subroutine

public subroutine hit_npa_detector(r0, v0, d_index, rd, det)

Routine to check if a particle will hit a NPA detector

Arguments

TypeIntentOptionalAttributesName
real(kind=Float64), intent(in), dimension(3):: r0

Starting point of particle

real(kind=Float64), intent(in), dimension(3):: v0

Particle velocity

integer, intent(out) :: d_index

Index of NPA detector. Zero if particle doesn't hit

real(kind=Float64), intent(out), optional dimension(3):: rd

Point where particle hit detector

integer, intent(in), optional :: det

Index of NPA detector to check


Calls

proc~~hit_npa_detector~~CallsGraph proc~hit_npa_detector hit_npa_detector proc~line_plane_intersect line_plane_intersect proc~hit_npa_detector->proc~line_plane_intersect proc~in_boundary in_boundary proc~hit_npa_detector->proc~in_boundary

Called by

proc~~hit_npa_detector~~CalledByGraph proc~hit_npa_detector hit_npa_detector proc~pnpa_mc pnpa_mc proc~pnpa_mc->proc~hit_npa_detector proc~pnpa_f pnpa_f proc~pnpa_f->proc~hit_npa_detector proc~npa_mc npa_mc proc~npa_mc->proc~hit_npa_detector proc~npa_weights npa_weights proc~npa_weights->proc~hit_npa_detector proc~npa_f npa_f proc~npa_f->proc~hit_npa_detector proc~make_diagnostic_grids make_diagnostic_grids proc~make_diagnostic_grids->proc~hit_npa_detector program~fidasim fidasim program~fidasim->proc~pnpa_mc program~fidasim->proc~pnpa_f program~fidasim->proc~npa_mc program~fidasim->proc~npa_weights program~fidasim->proc~npa_f program~fidasim->proc~make_diagnostic_grids

Contents

Source Code


Source Code

subroutine hit_npa_detector(r0, v0, d_index, rd, det)
    !+ Routine to check if a particle will hit a NPA detector
    real(Float64), dimension(3), intent(in)            :: r0
        !+ Starting point of particle
    real(Float64), dimension(3), intent(in)            :: v0
        !+ Particle velocity
    integer, intent(out)                               :: d_index
        !+ Index of NPA detector. Zero if particle doesn't hit
    real(Float64), dimension(3), intent(out), optional :: rd
        !+ Point where particle hit detector
    integer, intent(in), optional :: det
        !+ Index of NPA detector to check

    real(Float64), dimension(3) :: d, a
    real(Float64) :: t_a,t_d
    integer :: i, s, ndet

    if(present(det)) then
        s = det
        ndet = det
    else
        s = 1
        ndet = npa_chords%nchan
    endif

    d_index = 0
    detector_loop: do i=s,ndet
        !! Find where trajectory crosses detector plane
        call line_plane_intersect(r0,v0,npa_chords%det(i)%detector%origin, &
             npa_chords%det(i)%detector%basis(:,3),d,t_d)

        !! Find where trajectory crosses aperture plane
        call line_plane_intersect(r0,v0,npa_chords%det(i)%aperture%origin, &
             npa_chords%det(i)%aperture%basis(:,3),a,t_a)

        !! If both points are in plane boundaries and the
        !! particle is heading toward the detector then its a hit
        if(in_boundary(npa_chords%det(i)%aperture,a) .and. &
           in_boundary(npa_chords%det(i)%detector,d) .and. &
           (t_d.gt.0.0) ) then
            d_index = i
            exit detector_loop
        endif
    enddo detector_loop
    if(present(rd)) rd = d

end subroutine hit_npa_detector