]> git.uio.no Git - u/mrichter/AliRoot.git/blame - GEANT321/gphys/gpoiss.F
Use TLorentzVector for position and momentum
[u/mrichter/AliRoot.git] / GEANT321 / gphys / gpoiss.F
CommitLineData
fe4da5cc 1*
2* $Id$
3*
4* $Log$
5* Revision 1.1.1.1 1995/10/24 10:21:32 cernlib
6* Geant
7*
8*
9#include "geant321/pilot.h"
10*CMZ : 3.21/02 29/03/94 15.41.23 by S.Giani
11*-- Author :
12 SUBROUTINE GPOISS(AMVEC,NPVEC,LEN)
13C.
14C. ******************************************************************
15C. * *
16C. * Generates a vector NPVEC of LEN random numbers *
17C. * POISSON distribued with mean values AMVEC *
18C. * *
19C. * If the mean value A greater than PLIM, N is calculated *
20C. * according to the Gaussian approximation of the Poisson *
21C. * distribution. *
22C. * *
23C. * ==> Called by : GLANDZ,GMCOUL *
24C. * *
25C. * Author : L.Urban *
26C. * Date : 28.04.1988 Last update : 1.02.1990 *
27C. * *
28C. ******************************************************************
29C.
30#include "geant321/gconsp.inc"
31 REAL AMVEC(*),RNDM(2), N
32 INTEGER NPVEC(*)
33 PARAMETER (PLIM=16.,HMXINT=2E+9)
34*
35 DO 30 I=1,LEN
36* Protection against negative mean values
37 N=0.
38 IF(AMVEC(I).GT.0.) THEN
39 IF(AMVEC(I).LE.PLIM) THEN
40 CALL GRNDM(RNDM,1)
41 R=RNDM(1)
42 P=EXP(-AMVEC(I))
43 S=P
44 IF(R.LE.S) GOTO 20
45 10 N=N+1.
46 P=P*AMVEC(I)/N
47 S=S+P
48 IF(S.LT.R.AND.P.GT.1.E-30) GOTO 10
49 ELSE
50 CALL GRNDM(RNDM,2)
51 RR=SQRT(-2.*LOG(RNDM(1)))
52 PHI=TWOPI*RNDM(2)
53 X=RR*COS(PHI)
54 N=MIN(MAX(AMVEC(I)+X*SQRT(AMVEC(I)),0.),HMXINT)
55 ENDIF
56 ENDIF
57*
58 20 NPVEC(I) = N
59 30 CONTINUE
60*
61 END