Module trackswim_mod
module trackswim_mod
! Uses
use precision_mod
use physicalconstants_mod
! Types
private type tdata_type
private type tstep_type
! Subroutines and functions
private function VectorMultiply (a, b) result (c)
private function V3mag (a) result (c)
private function V3magsq (a)
private subroutine V3unit (V3, Vunit, Vmag)
private function Prime (B3, V3, P3, Q, K, tdata) result (success)
private subroutine StepV (tdata, S, tstep, V3)
private subroutine StepP (tdata, tstep, P3)
public function TrackGetCR (V3, P3, Q, C, R) result (success)
public function TrackToSK (V3, P3, Q, S, K) result (success)
public function TrackToS (V3, P3, Q, S) result (success)
public function TrackToZKS (V3, P3, Q, ENDZ, K, S) result (success)
public function TrackToZS (V3, P3, Q, ENDZ, S) result (success)
public function TrackToZ (V3, P3, Q, ENDZ) result (success)
public function TrackToZK (V3, P3, Q, ENDZ, K) result (success)
end module trackswim_mod
===============================================================
Author: K.Olchanski
Date: 13 May 2001
CVS: $Id: trackswim_mod.f90,v 1.22 2005/07/02 23:51:20 olchansk Exp $
--------------------------------------------------------
Description: Calculate particle trajectories in magnetic field
=========================================================
Description of Types
tdata_type
private type tdata_type
real (kind=R8) :: P3Mag
momentum
real (kind=R8) :: PpMag
parallel momentum
real (kind=R8) :: PtMag
transverse momentum
real (kind=R8) :: sint
angle between P3 and B
real (kind=R8) :: cost
sin and cos
real (kind=R8), dimension (3) :: Runit
Radial unit vector
real (kind=R8), dimension (3) :: PtUnit
Transverse unit vector
real (kind=R8), dimension (3) :: PpUnit
Parallel unit vector
real (kind=R8), dimension (3) :: C
Center of the helix
real (kind=R8) :: R
Radius of the helix
real (kind=R8) :: dRdS
Energy loss, dR/dS
real (kind=R8) :: dPdS
Energy loss, dP/dS
real (kind=R8) :: PhiCorr
Energy loss correction
integer :: Q
Charge
end type tdata_type
Invariant track parameters
tstep_type
private type tstep_type
real (kind=R8) :: S
arc length
real (kind=R8) :: R
radius at new point
real (kind=R8) :: Phi
rotation angle
real (kind=R8) :: sinphi
sin and cos
real (kind=R8) :: cosphi
sin and cos
real (kind=R8), dimension (3) :: Runit
rotated unit
real (kind=R8), dimension (3) :: PtUnit
vectors
end type tstep_type
Step-dependant track parameters
Description of Subroutines and Functions
VectorMultiply
private function VectorMultiply (a, b) result (c)
real (kind=R8), INTENT(in), dimension (3) :: a
real (kind=R8), INTENT(in), dimension (3) :: b
real (kind=R8), dimension (3) :: c
end function VectorMultiply
V3mag
private function V3mag (a) result (c)
real (kind=R8), INTENT(in), dimension (3) :: a
real (kind=R8) :: c
end function V3mag
V3magsq
private function V3magsq (a)
real (kind=R8), INTENT(in), dimension (3) :: a
real (kind=R8) :: V3magsq
end function V3magsq
V3unit
private subroutine V3unit (V3, Vunit, Vmag)
real (kind=R8), INTENT(in), dimension (3) :: V3
input vector
real (kind=R8), INTENT(out), dimension (3) :: Vunit
return unit vector
real (kind=R8), INTENT(out) :: Vmag
return magnitude
end subroutine V3unit
Purpose: Calculate magnitude and unit vector
Prime
private function Prime (B3, V3, P3, Q, K, tdata) result (success)
real (kind=R8), INTENT(in), dimension (3) :: B3
Arguments:
magnetic field (T)
real (kind=R8), INTENT(in), dimension (3) :: V3
starting point (cm)
real (kind=R8), INTENT(in), dimension (3) :: P3
momentum vector (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: K
energy loss, dP/dS (MeV/cm)
type (tdata_type), INTENT(out) :: tdata
output helix data
logical :: success
! Calls: V3unit
end function Prime
Description: Calculate invariant helix data
StepV
private subroutine StepV (tdata, S, tstep, V3)
type (tdata_type), INTENT(in) :: tdata
invariant helix data
real (kind=R8), INTENT(in) :: S
arc length
type (tstep_type), INTENT(out) :: tstep
step data
real (kind=R8), INTENT(inout), dimension (3) :: V3
new position
end subroutine StepV
Description: Given arc length S, calculate position on the helix
StepP
private subroutine StepP (tdata, tstep, P3)
type (tdata_type), INTENT(in) :: tdata
invariant helix data
type (tstep_type), INTENT(in) :: tstep
step data
real (kind=R8), INTENT(out), dimension (3) :: P3
new momentum
end subroutine StepP
Description: Calculate the end-point momentum
TrackGetCR
public function TrackGetCR (V3, P3, Q, C, R) result (success)
real (kind=R8), INTENT(in), dimension (3) :: V3
Purpose: Return the center and radius of the helix
position (cm)
real (kind=R8), INTENT(in), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(out), dimension (3) :: C
return center of the helix
real (kind=R8), INTENT(out) :: R
return radius
logical :: success
end function TrackGetCR
TrackToSK
public function TrackToSK (V3, P3, Q, S, K) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: S
arc length
real (kind=R8), INTENT(in) :: K
energy loss dP/dS (MeV/cm)
logical :: success
return value
! Calls: StepP, StepV
end function TrackToSK
Description: move along the helix by given arc length S
Return value: .TRUE. success, .FALSE. failure
TrackToS
public function TrackToS (V3, P3, Q, S) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: S
arc length
logical :: success
return value
end function TrackToS
===================================================
Description: see TrackToSK()
====================================================
TrackToZKS
public function TrackToZKS (V3, P3, Q, ENDZ, K, S) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: ENDZ
z plane
real (kind=R8), INTENT(in) :: K
energy loss, dR/dS
real (kind=R8), INTENT(out) :: S
return arc length
logical :: success
return value
! Calls: kerror
end function TrackToZKS
==========================================================
Description: Find point of intersection with given Z plane
Return value: .TRUE. success, .FALSE. failure
============================================================
TrackToZS
public function TrackToZS (V3, P3, Q, ENDZ, S) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: ENDZ
z plane
real (kind=R8), INTENT(out) :: S
return arc length
logical :: success
return value
end function TrackToZS
Description: See TrackToZKS()
For calcs without energy loss
TrackToZ
public function TrackToZ (V3, P3, Q, ENDZ) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: ENDZ
z plane
logical :: success
return value
end function TrackToZ
For no energy loss
Description: See TrackToSKZ()
TrackToZK
public function TrackToZK (V3, P3, Q, ENDZ, K) result (success)
real (kind=R8), INTENT(inout), dimension (3) :: V3
position (cm)
real (kind=R8), INTENT(inout), dimension (3) :: P3
momentum (MeV)
integer (kind=I4), INTENT(in) :: Q
charge
real (kind=R8), INTENT(in) :: ENDZ
z plane
real (kind=R8), INTENT(in) :: K
energy loss, dP/dS (MeV/cm)
logical :: success
return value
end function TrackToZK
Description: See TrackToZKS()
No energy loss