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

Go to the source code of this file.

Functions/Subroutines

subroutine cmpaire (xai, ee, nc)
 

Function/Subroutine Documentation

◆ cmpaire()

subroutine cmpaire ( real*8  xai,
real*8  ee,
integer  nc 
)

Definition at line 14 of file cmPairE.f.

References d0, kgauss(), and rndc().

Referenced by cmpair().

14  implicit none
15  real*8 xai ! input. xai = Bsin/Bc * Eg/m/2
16  real*8 ee ! output. fractional electron energy >= 0.5
17  integer nc ! output. nubmer of retrial for rejection method.
18 !
19  real*8 v, maxf, ve, xs5, xs, vx, a, b, beta, xse
20  real*8 u, cmpairspec
21  integer i, j
22  real*8 xaisave, sigma
23  save xaisave, maxf, vx
24  save a, b, xs5
25  data xaisave/0./
26 
27  if(xai .ne. xaisave ) then
28  xs5 = cmpairspec(xai, 0.5d0)
29  if(xai .gt. 4.526) then
30 ! find peak which is not 0.5
31  v = .5d0
32  maxf = 0.
33  do while (v .lt. .999d0)
34  xs = cmpairspec(xai, v)
35  if(xs .gt. maxf) then
36  maxf = xs
37  vx = v
38  endif
39  v = v + .005d0
40  enddo
41  a = (maxf - xs5)/(vx - 0.5)
42  b = -0.5 * a + xs5
43  else
44  vx = 0.5d0
45  maxf = xs5
46  endif
47  xaisave = xai
48  endif
49  if(vx .ne. .5d0) then
50  do i = 1, 1000
51  call rndc(u)
52  beta = (3./8.*a + b/2)* u - (a/2 + b)
53  ve = (- b + sqrt(b**2 - 2*a*beta))/a
54 ! write(*, *) ' beta, ve', beta, ve, ' b^2-2beta',
55 ! * b**2 - 2*beta
56  call rndc(u)
57  xse = cmpairspec(xai, ve)
58 ! write(*,*) ' xse=',xse, ' a*ve+b=', a*ve+b
59  if(u .lt. xse/(a*ve + b)) goto 10
60  enddo
61  stop 9875
62  10 continue
63  ee = ve
64  elseif(xai .lt. .005) then
65  ee = .5
66  nc = 1
67  elseif(xai .lt. 1.) then
68 ! envelop is close to Gausssian of
69 ! sigma= .50/root(2)*xai**.53
70  sigma= .50/1.4142*xai**0.53
71  do j = 1, 1000
72  do i = j, 1000
73  call kgauss(0.5d0, sigma, ve)
74  if(ve .gt. 0. .and. ve .lt. 1.) goto 5
75  enddo
76  5 continue
77  xse = cmpairspec(xai, ve)
78  call rndc(u)
79  if(u .lt.
80  * xse /( ( exp(-((ve - 0.5)/sigma)**2/2) * maxf)))
81  * goto 8
82  enddo
83  8 continue
84  ee = ve
85  if(ee .lt. 0.5) ee = 1. - ee
86  else
87  do i =1, 1000
88  call rndc(u)
89  ve = u/2.+ 0.5
90  xse = cmpairspec(xai, ve)
91  call rndc(u)
92  if(u .lt. xse/maxf) goto 20
93  enddo
94  stop 1234
95  20 continue
96  ee =ve
97  endif
98  nc = i
nodes i
real *8 function cmpairspec(xai, x)
Definition: cmPairSpec.f:15
subroutine rndc(u)
Definition: rnd.f:91
! constants thru Cosmos real ! if multiplied to deg radian Torad ! light velocity m sec ! infinty ! kg m2 *Togpcm2 g cm2 ! g cm2 *Tokgpm2 kg m2 ! cm *Tom m ! m *Tocm cm ! g cm3 *Tokgpm3 kg m3 ! kg m3 *Togpcm3 g cm3 ! sec *Tonsec nsec ! Tesla m ! Avogadro *A2deninv ! mfp *n * xs
Definition: Zglobalc.h:18
********************block data cblkHeavy ********************integer j data *HeavyG2symbol *data *HeavyG2code kiron data j
Definition: cblkHeavy.h:36
subroutine kgauss(m, v, g1)
Definition: kgauss.f:10
block data cblkEvhnp ! currently usable models data RegMdls ad *special data *Cekaon d0
Definition: cblkEvhnp.h:5
real(4), save a
Definition: cNRLAtmos.f:20
real(4), save b
Definition: cNRLAtmos.f:21
real cut integer nc
Definition: Zprivate.h:1
Here is the call graph for this function:
Here is the caller graph for this function: