COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cmagneticDef.f
Go to the documentation of this file.
1 ! Compute magnetic deflection (angle and displacement)
2 !
3 ! ************************************************
4  subroutine cmagneticdef(aTrack, B, leng, dr, dir)
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
117  end
118 !c///////////////
119 ! subroutine checkuv(com, sint, v)
120 ! implicit none
121 !#include "Zcoord.h"
122 ! character*(*) com
123 ! record /coord/ v
124 !
125 ! real*8 eps, sint
126 ! eps = abs( (v.r(1)**2 + v.r(2)**2 + v.r(3)**2)-1.d0 )
127 ! if( eps .gt. 1.d-5) then
128 ! write(0,*) 'not unit', com, eps, sint
129 ! endif
130 ! end
131 ! subroutine checkorth(com, sint, v, u)
132 ! implicit none
133 !#include "Zcoord.h"
134 ! character*(*) com
135 ! record /coord/ v, u
136 ! real*8 temp, sint
137 ! call cscalerProd(u, v, temp)
138 ! if(abs(temp) .gt. 1.d-5) then
139 ! write(0,*) ' uxv nrt orth', com, temp, sint
140 ! endif
141 ! end
142 
143 
144 
145 
! 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
subroutine cvecprod(a, b, c)
Definition: cvecProd.f:4
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
subroutine cmagneticdef(aTrack, B, leng, dr, dir)
Definition: cmagneticDef.f:5
Definition: Zcoord.h:43
subroutine cscalerprod(a, b, c)
Definition: cscalerProd.f:4