COSMOS v7.655  COSMOSv7655
(AirShowerMC)
cthick2len.f
Go to the documentation of this file.
1 !
2 ! Thickness of air is converted into length.
3 ! This should be placed rather in Tracking directory.
4 ! ****************************************
5  subroutine cthick2len(aTrack, tin, leng, t, jcut)
6 ! ****************************************
7 !
8 ! aTrack; considered track
9 ! tin: input. real*8. thickness of air to be travelled in kg/m2.
10 ! leng: output. real*8. if jcut=0; length in m corresponding to tin (= t).
11 ! if jcut=1; lenght in m correslponding to t ( < tin)
12 ! t: output. real*8. if jcut=0, this becomes the same as tin
13 ! else a shorter value than tin (kg/m2). This is
14 ! the thickness corresponding to leng (m).
15 ! for neutrino case, this is not true.
16 ! jcut: output. integer. if 0, thickness tin is successfully converted into leng.
17 ! else, tin is too long. It is cut to a value 't'
18 ! so that the resultant accuracy of leng is high.
19 ! cut is made if tin is longer than the (current vertical depth)/5.
20 !
21 !
22  implicit none
23 !---- include 'Zearth.h'
24 #include "Zearth.h"
25 #include "Zatmos.h"
26 #include "Ztrack.h"
27 #include "Ztrackp.h"
28 #include "Ztrackv.h"
29 #include "Zcode.h"
30  type(track)::aTrack
31 
32  real*8 z, cosz, tin, leng, t
33  integer jcut
34 !
35 ! z: input. real*8. current vertical height in m
36 ! cosz:input. real*8. cos of the current zenith angle
37 
38  real*8 maxkgm2/100./
39 
40  real*8 cvh2den, s, cnewcos, cnewh, zp, cosp
41  real*8 cutf/5./, cthick2h
42 ! Method.
43 !
44 ! If we expess a heigh z in terms of the distance from the
45 ! center of the earth, r = R + z (R: radius), and, the zenith angle
46 ! cos,
47 ! r cos - r'cos' = s (s is the distance between two points)
48 ! r sin = r'sin'
49 ! r^2 + s^2 -2rscos = r'^2
50 ! Hence,
51 ! z' = sqrt(r^2 + s^2 - 2rscos) - R
52 ! = sqrt( (r-scos)^2 +s^2(1-cos^2) ) - R
53 ! = h -s cos s^2(1-cos^2)/(r - scos)/2 + O(s^4)
54 ! = h - s cos + s^2(1-cos^2)/2/r + s^3/r^2/2 cos(1-cos^2) + O(s^4)
55 ! The slant thickness in the length s is
56 !
57 ! t = int[0,s](rho(s)ds
58 ! = int[0,s](rho(z + f(s, z))ds
59 ! where
60 ! f(s, z) = -s cos + s^2(1-cos^2)/r/2 + s^3/r^2/2 cos(1-cos^2)
61 !
62 ! rho(z + f(s,z)) = rho(z) + rho'(z)f(s,z) + rho''(z)/2 f(s,z)^2
63 !
64 ! Taking upto s^3, the indefinit integral is
65 !
66 ! f1(s,z) =int(f(s,z)ds = -s^2/2 cos + s^3/r/6(1-cos^2)
67 !
68 ! f2(s,z) =int(f^2)ds = s^3/3 cos^2
69 !
70 !
71 !
72  real*8 f1, f2, int1, int2, rp ! , clenbetween2h
73  real*8 cvh2denp, cvh2den2p, rho, rhop, d, cvh2thick
74  real*8 ct2lTA
75 
76  real*8 nearv/0.5/, nearv2/0.99/, t1, t2
77  real*8 maxact
78  integer i, icon, iterate
79 
80  f1(s) = -s**2/2*cosp + s**3/rp/6.d0 * (1.d0-cosp**2)
81 ! * + s**4/rp/rp/8.d0*cosp*(1.d0-cosp**2) ! negligible
82 
83  f2(s) = s**3/3.d0 * cosp**2
84 ! * - s**4/4.d0/rp*cosp*(1.d0-cosp**2) ! negligible
85 
86 !----------------------------------------------------------------------
87  z = atrack%pos%height
88  cosz = atrack%vec%coszenith
89  if( atrack%p%code .eq. kneumu .or.
90  * atrack%p%code .eq. kneue ) then
91  leng = 1.e5
92  jcut = 1
93  t = tin
94  return ! **************
95  endif
96  if( tin .eq. 0.) then
97  leng=0.
98  jcut = 0
99  t = tin
100  return ! *********
101  endif
102 
103  if(usetbl .and. z .lt. htop ) then
104  maxact = 100.d3
105  elseif(abs(cosz) .gt. nearv) then
106  maxact = 20*maxkgm2 *(abs(cosz) - nearv) + maxkgm2
107  else
108  maxact = maxkgm2
109  endif
110  t = min(tin, maxact)
111  if(t .eq. maxact) then
112  jcut= 1
113  else
114  jcut = 0
115  endif
116 
117  if(.not. (usetbl .and. z .lt. htop) .and.
118  * (abs(cosz) .lt. nearv) ) then
119 ! max movable thickness
120  t = min(t, cvh2thick(z)/cutf/(abs(cosz) + .1) )
121  if(t .ne. tin) then
122  jcut =1
123  endif
124  endif
125 !
126  iterate =0 ! flag for later use.
127 
128  if(usetbl .and. z .lt. htop) then
129  leng = ct2lta(z, t)
130 ! elseif( abs(cosz) .gt. nearv .or.
131 ! * ( z .lt. 15.d3 .and. t .lt. 350.0d0 ) ) then
132  elseif( abs(cosz) .gt. nearv ) then
133  t1 = cvh2thick(z)
134  t2 = t1 + cosz* t
135  if(t2 .le. 0.) then
136  t2 = t1/10.
137  t = (t2 - t1)/cosz
138  jcut = 1
139  endif
140  zp = cthick2h(t2)
141 ! leng = clenbetween2h(z+Eradius, zp+Eradius, cosz)
142  call clenbetw2h(z+eradius, zp+eradius, cosz, leng, icon)
143 
144 
145  if(icon .ne. 0) then
146 ! cannot reach to zp. This may happen if z is very large
147  iterate = 1
148  else
149 ! if(abs(cosz) .lt. nearv2) then
150  if( t .gt. 350.d0 ) then
151 ! correction by using cos at middle of leng
152  cosp = cnewcos(z+eradius, cosz, leng/2)
153  t2 = t1 + cosp * t
154  if(t2 .le. 0.) then
155 ! we shall move by real length rather than by thickness
156  jcut = 1
157  leng = leng/2
158  zp = cnewh(z+eradius, cosz, leng) - eradius
159  t2 = cvh2thick(zp)
160  t =( t2 - t1 )/((cosz+cosp)/2)
161  else
162  zp = cthick2h(t2)
163 ! leng = clenbetween2h(z+Eradius, zp+Eradius, cosz)
164  call clenbetw2h(z+eradius, zp+eradius, cosz,
165  * leng, icon)
166  if(icon .ne. 0) then
167  iterate = 1
168  endif
169  endif
170  endif
171  endif
172  else
173  iterate = 1
174  endif
175 
176  if( iterate .ne. 0) then
177  rho = cvh2den(z)
178  rhop = cvh2denp(z)
179 ! at very high altitude, rhop = 0
180  if(cosz .le. 0.d0 .or. rhop .le. 1.0d-18) then
181  s = t/rho ! length if density is const.
182  else
183  d = rho**2 - 2* rhop *cosz * t
184  s = (rho -sqrt(d) )/ rhop/cosz
185  endif
186 
187 
188  if(rhop .gt. 1.0d-18) then
189  do i=1,3
190 ! get height and cos at s/2 ahead.
191  cosp = cnewcos(eradius+z, cosz, s/2)
192  zp = cnewh(eradius+z, cosz, s/2) - eradius
193 ! write(0,*) " cosp =", cosp, " height at z-s/2*cos=",zp
194 ! once again
195 ! s = t/cvh2den(zp) ! length if density is const.
196 ! cosp = cnewcos(Eradius+z, cosz, s/2)
197 ! zp = cnewh(Eradius+z, cosz, s/2) - Eradius
198 !
199 ! expand rho at zp, and get integrals of f and f^2
200 ! [ -s/2 to s/2] ds
201 !
202  rp = zp + eradius
203  int1 = f1(s/2) - f1(-s/2)
204  int2 = f2(s/2) - f2(-s/2)
205 ! get new s
206  s = (t - cvh2denp(zp)*int1 - cvh2den2p(zp)*int2/2)
207  * / cvh2den(zp)
208  enddo
209  endif
210  leng = s
211  endif
212 ! &&&&&&&&&
213  if(leng .le. 0.) then
214  rho = cvh2den(z)
215  leng =t / rho
216  endif
217  end
218 
subroutine cthick2len(aTrack, tin, leng, t, jcut)
Definition: cthick2len.f:6
block data cblkIncident data *Za1ry *HeightOfInj d3
Definition: cblkIncident.h:7
Definition: Ztrack.h:44
max ptcl codes in the kneue
Definition: Zcode.h:2
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
max ptcl codes in the kneumu
Definition: Zcode.h:2
subroutine clenbetw2h(h1, h2, cost, leng, icon)
Definition: catmosutil.f:176