source: trunk/MagicSoft/Simulation/Corsika/Mmcs/mpoiss.f@ 402

Last change on this file since 402 was 286, checked in by harald, 25 years ago
This is the start point for further developments of the Magic Monte Carlo Simulation written by Jose Carlos Gonzales. Now it is under control of one CVS repository for the whole collaboration. Everyone should use this CVS repository for further developments.
File size: 2.8 KB
Line 
1 SUBROUTINE MPOISS(AMEAN,NPRAN)
2
3C-----------------------------------------------------------------------
4C M(UON COULOMB SCATTERING) POISS(ON DISTRIBUTION)
5C
6C GENERATES A RANDOM NUMBER POISSON DISTRIBUTED WITH MEAN VALUE AMEAN.
7C THIS SUBROUTINE IS IN ANALOGY WITH SUBROUTINE GPOISS.
8C (AUTHOR: L. URBAN) OF GEANT321
9C SEE CERN PROGRAM LIBRARY LONG WRITEUP W5013.
10C THIS SUBROUTINE IS CALLED FROM MUCOUL
11C ARGUMENTS:
12C AMEAN = MEAN VALUE OF RANDOM NUMBER
13C NPRAN = RANDOM NUMBER POISSON DISTRIBUTED
14C
15C REDESIGN: D. HECK IK3 FZK KARLSRUHE
16C-----------------------------------------------------------------------
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/
56C-----------------------------------------------------------------------
57
58C 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
Note: See TracBrowser for help on using the repository browser.