COSMOS v7.655  COSMOSv7655
(AirShowerMC)
csampPolAng.f
Go to the documentation of this file.
1 ! **************************************************************
2 ! *
3 ! * csampPolAng: sample a polar angle from a distribution
4 ! * (a+b*cos(t)+c*cos(t)**2 ) dcos(t)
5 ! *
6 ! **************************************************************
7  subroutine csamppolang(a, b, c, cost, icon)
8  implicit none
9  real*8 a, b, c, cost
10  integer icon
11 
12  real*8 eps/1.e-3/, u, xn, tmpc, x, tmp
13  integer nc
14 !
15  call rndc(u)
16  xn=2*u-1.
17  tmpc= (2*a+2./3.*c)*u
18  nc=0
19 ! *** until loop***
20  do while (.true.)
21  x=xn
22  xn=x -
23  * ((x**3+1.)*c/3 + (x**2-1.)*b/2 +a*(x+1.)
24  * - tmpc ) / ( (c*x + b)*x + a )
25  tmp=abs(x-xn)
26  nc=nc+1
27  if(nc .gt. 15 .or. abs(xn) .gt. 1.) then
28  icon=1
29  goto 900
30  endif
31  if (tmp .lt. eps)
32  * goto 100
33  enddo
34  100 continue
35  icon=0
36  cost=x
37  900 continue
38  end
block data cblkElemag data *AnihiE ! Eposi< 1 TeV, anihilation considered *X0/365.667/, ! radiation length of air in kg/m2 *Ecrit/81.e-3/, ! critical energy of air in GeV *MaxComptonE/1./, ! compton is considered below 1 GeV *MaxPhotoE/1.e-3/, ! above this, PhotoElectric effect neg. *MinPhotoProdE/153.e-3/, ! below 153 MeV, no gp --> hadrons ! scattering const not MeV *Knockon true
Definition: cblkElemag.h:7
subroutine rndc(u)
Definition: rnd.f:91
subroutine csamppolang(a, b, c, cost, icon)
Definition: csampPolAng.f:8