1 | SUBROUTINE MPOISS(AMEAN,NPRAN)
|
---|
2 |
|
---|
3 | C-----------------------------------------------------------------------
|
---|
4 | C M(UON COULOMB SCATTERING) POISS(ON DISTRIBUTION)
|
---|
5 | C
|
---|
6 | C GENERATES A RANDOM NUMBER POISSON DISTRIBUTED WITH MEAN VALUE AMEAN.
|
---|
7 | C THIS SUBROUTINE IS IN ANALOGY WITH SUBROUTINE GPOISS.
|
---|
8 | C (AUTHOR: L. URBAN) OF GEANT321
|
---|
9 | C SEE CERN PROGRAM LIBRARY LONG WRITEUP W5013.
|
---|
10 | C THIS SUBROUTINE IS CALLED FROM MUCOUL
|
---|
11 | C ARGUMENTS:
|
---|
12 | C AMEAN = MEAN VALUE OF RANDOM NUMBER
|
---|
13 | C NPRAN = RANDOM NUMBER POISSON DISTRIBUTED
|
---|
14 | C
|
---|
15 | C REDESIGN: D. HECK IK3 FZK KARLSRUHE
|
---|
16 | C-----------------------------------------------------------------------
|
---|
17 |
|
---|
18 | IMPLICIT NONE
|
---|
19 | *KEEP,CONST.
|
---|
20 | COMMON /CONST/ PI,PI2,OB3,TB3,ENEPER
|
---|
21 | DOUBLE PRECISION PI,PI2,OB3,TB3,ENEPER
|
---|
22 | *KEEP,RANDPA.
|
---|
23 | COMMON /RANDPA/ FAC,U1,U2,RD,NSEQ,ISEED,KNOR
|
---|
24 | DOUBLE PRECISION FAC,U1,U2
|
---|
25 | REAL RD(3000)
|
---|
26 | INTEGER ISEED(103,10),NSEQ
|
---|
27 | LOGICAL KNOR
|
---|
28 | *KEEP,RUNPAR.
|
---|
29 | COMMON /RUNPAR/ FIXHEI,THICK0,HILOECM,HILOELB,
|
---|
30 | * STEPFC,NRRUN,NSHOW,PATAPE,MONIIN,
|
---|
31 | * MONIOU,MDEBUG,NUCNUC,
|
---|
32 | * CETAPE,
|
---|
33 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
34 | * N1STTR,MDBASE,
|
---|
35 | * DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
36 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
37 | * ,GHEISH,GHESIG
|
---|
38 | COMMON /RUNPAC/ DSN,HOST,USER
|
---|
39 | DOUBLE PRECISION FIXHEI,THICK0,HILOECM,HILOELB
|
---|
40 | REAL STEPFC
|
---|
41 | INTEGER NRRUN,NSHOW,PATAPE,MONIIN,MONIOU,MDEBUG,NUCNUC,
|
---|
42 | * SHOWNO,ISHW,NOPART,NRECS,NBLKS,MAXPRT,NDEBDL,
|
---|
43 | * N1STTR,MDBASE
|
---|
44 | INTEGER CETAPE
|
---|
45 | CHARACTER*79 DSN
|
---|
46 | CHARACTER*20 HOST,USER
|
---|
47 |
|
---|
48 | LOGICAL DEBDEL,DEBUG,FDECAY,FEGS,FIRSTI,FIXINC,FIXTAR,
|
---|
49 | * FIX1I,FMUADD,FNKG,FPRINT,FDBASE
|
---|
50 | * ,GHEISH,GHESIG
|
---|
51 | *KEND.
|
---|
52 |
|
---|
53 | DOUBLE PRECISION AMEAN,AN,HMXINT,P,PLIM,RR,S,X
|
---|
54 | INTEGER NPRAN
|
---|
55 | DATA PLIM/16.D0/,HMXINT/2.D9/
|
---|
56 | C-----------------------------------------------------------------------
|
---|
57 |
|
---|
58 | C PROTECTION AGAINST NEGATIVE MEAN VALUES
|
---|
59 | AN = 0.D0
|
---|
60 | IF ( AMEAN .GT. 0.D0 ) THEN
|
---|
61 | IF ( AMEAN .LE. PLIM ) THEN
|
---|
62 | CALL RMMAR(RD,1,1)
|
---|
63 | P = EXP(-AMEAN)
|
---|
64 | S = P
|
---|
65 | IF ( RD(1) .LE. S ) GOTO 20
|
---|
66 | 10 AN = AN + 1.D0
|
---|
67 | P = P * AMEAN / AN
|
---|
68 | S = S + P
|
---|
69 | IF ( S .LT. RD(1) .AND. P .GT. 1.D-30 ) GOTO 10
|
---|
70 | ELSE
|
---|
71 | CALL RMMAR(RD,2,1)
|
---|
72 | RR = SQRT( -2.D0*LOG(RD(1)) )
|
---|
73 | X = RR * COS( PI2 * RD(2) )
|
---|
74 | AN = MIN( MAX( AMEAN+X*SQRT(AMEAN), 0.D0 ), HMXINT )
|
---|
75 | ENDIF
|
---|
76 | ENDIF
|
---|
77 | 20 NPRAN = AN
|
---|
78 |
|
---|
79 | RETURN
|
---|
80 | END
|
---|