COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cmagneticDef.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine cmagneticdef (aTrack, B, leng, dr, dir)
 

Function/Subroutine Documentation

◆ cmagneticdef()

subroutine cmagneticdef ( type(track aTrack,
type(magfield B,
real*8  leng,
type(coord dr,
type(coord dir 
)

Definition at line 5 of file cmagneticDef.f.

References cos, cscalerprod(), cvecprod(), d, and d0.

Referenced by cmagdef().

5 ! ************************************************
6 ! This is exact if B is const.
7 ! Note that:
8 ! dr must be added as newpos = oldpos + dr
9 ! dir is the new direction cos. These two are differenct
10 ! from the old version.
11 !
12 
13  implicit none
14 #include "Ztrack.h"
15 
16 
17  type(track)::atrack !input. a charged ptcl
18  type(magfield)::b !input. magnetic field vector.
19 
20 ! ptcl and magfiled coord is in Exyz
21 
22  real*8 leng !input. length travelled in m
23  type(coord)::dr !output. displacement vector in m
24  type(coord)::dir !output. new direction cos.
25 !
26  type(coord)::tx
27  type(coord)::ty
28  type(coord)::tz
29  type(coord)::w
30  type(coord)::r
31 
32  real*8 babs, sint, cost, rgt, sinl, cosl
33  real*8 pabs, temp
34 !
35 ! get abs(B)
36  babs = sqrt( b%x**2 + b%y**2 + b%z**2 )
37  if(babs .gt. 0.) then
38 ! p in GeV
39  pabs = sqrt(atrack%p%fm%p(4)**2 - atrack%p%mass**2)
40  if(pabs .gt. 0.) then
41 ! transverse gyroradius in m. B in T, p in GeV
42 ! For negative charge, rgt < 0. This is o.k
43  rgt = 3.3358*pabs/atrack%p%charge/babs
44 
45  tz%r(1) = b%x/babs
46  tz%r(2) = b%y/babs
47  tz%r(3) = b%z/babs
48 
49  call cscalerprod(atrack%vec%w, b, cost)
50  cost =max( min(cost/babs, 1.0d0), -1.d0)
51  sint = sqrt(1.0d0-cost**2)
52  if(abs(sint) .gt. 1.d-6) then
53  call cvecprod(atrack%vec%w, tz, tx)
54  tx%r(1) = tx%r(1)/sint
55  tx%r(2) = tx%r(2)/sint
56  tx%r(3) = tx%r(3)/sint
57  call cvecprod(tz, tx, ty)
58 !////////////////
59 ! call checkuv('Tx', sint, Tx)
60 ! call checkuv('Ty', sint, Ty)
61 ! call checkuv('Tz', sint, Tz)
62 ! call checkorth('TxTy', sint, Tx, Ty)
63 ! call checkorth('TxTz', sint, Tx, Tz)
64 !//////////////////////
65  else
66  tx%r(1) = 1.d0
67  tx%r(2) = 0.
68  tx%r(3) = 0.
69  ty%r(1) = 0.
70  ty%r(2) = 1.d0
71  ty%r(3) = 0.
72  endif
73 ! get wz0=wz
74  call cscalerprod(tz, atrack%vec%w, w%r(3))
75  temp = leng /rgt
76  sinl = sin(temp) ! this may be < 0
77  cosl = cos(temp)
78 
79  w%r(1) = sint*sinl
80  w%r(2) = sint*cosl
81 !///////////
82 ! call checkuv('w ', sint, w)
83 !///////////
84  r%r(1) = - rgt*sint*(cosl - 1.d0)
85 
86 
87  r%r(2) = rgt*sint*sinl
88  r%r(3) = leng*w%r(3)
89 
90 ! convert to original system.
91  dr%r(1) =
92  * tx%r(1)*r%r(1) + ty%r(1)*r%r(2) + tz%r(1)*r%r(3)
93  dr%r(2) =
94  * tx%r(2)*r%r(1) + ty%r(2)*r%r(2) + tz%r(2)*r%r(3)
95  dr%r(3) =
96  * tx%r(3)*r%r(1) + ty%r(3)*r%r(2) + tz%r(3)*r%r(3)
97 
98 
99  dir%r(1) =
100  * tx%r(1)*w%r(1) + ty%r(1)*w%r(2) + tz%r(1)*w%r(3)
101  dir%r(2) =
102  * tx%r(2)*w%r(1) + ty%r(2)*w%r(2) + tz%r(2)*w%r(3)
103  dir%r(3) =
104  * tx%r(3)*w%r(1) + ty%r(3)*w%r(2) + tz%r(3)*w%r(3)
105  else
106  dr%r(1) = 0.
107  dr%r(2) = 0.
108  dr%r(3) = 0.
109  dir = atrack%vec%w
110  endif
111  else
112  dr%r(1) = leng*atrack%vec%w%r(1)
113  dr%r(2) = leng*atrack%vec%w%r(2)
114  dr%r(3) = leng*atrack%vec%w%r(3)
115  dir = atrack%vec%w
116  endif
*Zfirst p fm *Zfirst p Zfirst p Zfirst p *Zfirst p *Zfirst pos xyz r
Definition: ZavoidUnionMap.h:1
! for length to thickness conversion or v v ! integer maxnodes real Hinf ! This is used when making table for dim simulation ! The slant length for vertical height to km is ! divided by LenStep m steps ! It can cover the slant length of about km for cos
Definition: Zatmos.h:8
Definition: Ztrack.h:44
integer leng
Definition: interface2.h:1
subroutine cvecprod(a, b, c)
Definition: cvecProd.f:4
real(4), dimension(:), allocatable, save temp
Definition: cNRLAtmos.f:29
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
real(4), save b
Definition: cNRLAtmos.f:21
Definition: Zcoord.h:43
subroutine cscalerprod(a, b, c)
Definition: cscalerProd.f:4
Here is the call graph for this function:
Here is the caller graph for this function: