COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cmulScat.f
Go to the documentation of this file.
1 ! ****************************************
2 ! * *
3 ! * cmulScat: multiple Coulomb scattering
4 ! * *
5 ! ****************************************
6 !
7 !
8  subroutine cmulscat(theta)
9  use modxsecmedia
10  use modmcscontrol
11  implicit none
12 ! Using cTrack and Move, compute scattering angle
13 !
14 #include "Zglobalc.h"
15 #include "Zcode.h"
16 #include "Ztrack.h"
17 #include "Ztrackv.h"
18 #include "Zelemagp.h"
19 
20  real*8 theta ! output. sampled angle in radian.
21 !
22 !
23 !
24  integer cond
25  real(8):: sgr
26  integer ic
27 
28 ! sample theta
29  if(intinfarray(processno)%length .gt. 0.) then
30  if(activemcs == "El_con") then
31  ! total length in kg/m2; sample theta
32  sgr =intinfarray(processno)%thickness
33  call celsepacondense(sgr, theta)
34  elseif(abs(moliere) >= 2) then ! abs is historical reason
35  call csampmol(media(1), theta, cond) ! rigorous Moliere
36  if(cond /= 0 ) then
37  call cmulscat2(theta) ! Gauss
38  endif
39  elseif(abs(moliere) == 1) then
40  call cmulscat1(theta) ! simplified Moliere
41  elseif( moliere == 0 ) then
42  call cmulscat2(theta) ! Gauss
43  endif
44  else
45  theta = 0.
46  endif
47  end
48 ! **************************
49  subroutine cmulscat2(theta)
50  implicit none
51 ! Gaussian scattring
52 !
53 #include "Zglobalc.h"
54 #include "Ztrack.h"
55 #include "Ztrackv.h"
56 #include "Zelemagp.h"
57 
58 
59 
60  real*8 theta ! output. sampled spatial angle in radain.
61 
62  real*8 tetarms, g1, g2, u, beta2, dt
63  integer nc
64 
65  real*8 hpi
66  parameter(hpi = pi/2.)
67 
68  g1 = trackbefmove%p%fm%p(4)/movedtrack%p%mass
69  g2 = movedtrack%p%fm%p(4)/movedtrack%p%mass
70  beta2 = 1.d0 - 1.d0/g1/g2
71  if(beta2 .le. 0.) then
72  tetarms = 0.
73  else
74  dt = intinfarray(processno)%thickness/ x0 ! r%l
75  if(dt .gt. 1.d-3) then
76  tetarms = es/trackbefmove%p%fm%p(4)*
77  * abs(movedtrack%p%charge) *
78  * sqrt(dt/beta2)*(1.0 + 0.038*log(dt))
79  else
80  tetarms = es/trackbefmove%p%fm%p(4)*
81  * abs(movedtrack%p%charge) * sqrt(dt/beta2)
82  endif
83  endif
84  theta = pi
85  nc = 0
86  do while(theta .gt. hpi)
87  if(nc .gt. 10) then
88 ! tetarms seems too large
89  theta = u**0.1 * hpi ! give some value
90  else
91  call rndc(u)
92  theta = sqrt(-log(u))* tetarms
93  nc = nc +1
94  endif
95  enddo
96  end
97  subroutine cmulscat1(theta)
98  implicit none
99 #include "Zcode.h"
100 #include "Ztrack.h"
101 #include "Ztrackv.h"
102 #include "Zelemagp.h"
103 ! by Moliere thoery
104 
105  real*8 theta
106 
107  real*8 g1, g2, leng
108  integer cond
109 
110  real*8 t, tmp, avx, avy, disp, cs, sn, e1, e2, d1, d2
111  real*8 rho, cvh2den
112  integer chg
113 
114  e1 = trackbefmove%p%fm%p(4)
115  g1 = e1/trackbefmove%p%mass
116  e2 = movedtrack%p%fm%p(4)
117  g2 = e2/movedtrack%p%mass
118  rho = cvh2den(
119  * (trackbefmove%pos%height+movedtrack%pos%height)/2.d0
120  * )
121 
122  leng = intinfarray(processno)%length ! in m
123 
124  chg = movedtrack%p%charge
125  call cmoliere(rho, chg, movedtrack%p%mass, g1, g2,
126  * leng, theta, cond)
127  if(cond .ne. 0) then
128 ! Moliere theory cannot be applied
129  call cmulscat2(theta)
130  endif
131  end
132 
133  subroutine celsepacondense(sgr, theta)
134  use modmcscontrol
135  use modsoftmcs
136  use modcmcs
137  use modxsecmedia
138  implicit none
139 
140  real(8),intent(in):: sgr ! path length in kg/m2
141  real(8),intent(out):: theta ! sampled angle
142 
143  real(8)::cm2topgrm,s0,s1, s2, ls1, ls2
144  real(8):: mu, cosa, sina
145 !!! call ciniFsoft(KEeV, sgr) is for integration
146 !!! from 0 to muc. We need here from 0 to 1. so
147 !!! do below
148 ! 1 is to get s in cm2
149  call ctpxs(tpxsnow, 1, keev, s0, s1, s2)
150 ! not 0.1 (/(kg/m2))-->(/g/cm2)
151  cm2topgrm = media(1)%mbtoPkgrm/ 1d-27
152  ls1 =1.0/(s1*cm2topgrm)
153  ls2 =1.0/(s2*cm2topgrm)
154 
155  avemu = (1.0d0 - exp(-sgr/ls1))/2
156  avemu2 = avemu - (1- exp(-sgr/ls2) )/6.d0
157  if( avemu > 0.49999999d0 ) then
158  ! mu is uniform (asoft =1 bsoft =1 is also ok)
159  bsoft = 0.5d0
160  asoft = 0.5d0
161  else
162  bsoft =( 2*avemu - 3*avemu2 )/(1-2*avemu)
163  asoft = (1-2*avemu) + bsoft
164  endif
165  call csampsoftmcsang(mu, cosa)
166  theta = acos(cosa)
167  end
integer npitbl real *nx parameter(n=101, npitbl=46, nx=n-1) real *8 uconst
subroutine cmulscat1(theta)
Definition: cmulScat.f:98
subroutine rndc(u)
Definition: rnd.f:91
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
subroutine cmoliere(rhoin, z, mass, g1, g2, leng, teta, cond)
Definition: cmoliere.f:3
! constants thru Cosmos real * pi
Definition: Zglobalc.h:2
subroutine cmulscat2(theta)
Definition: cmulScat.f:50
dE dx *! Nuc Int sampling table d
Definition: cblkMuInt.h:130
subroutine celsepacondense(sgr, theta)
Definition: cmulScat.f:134
subroutine csampmol(mediax, teta, cond)
Definition: cSampMol.f:7
subroutine cmulscat(theta)
Definition: cmulScat.f:9