function cmc_fish(x) c********************************************************************* c--> This function returns a random value weighted by a Poisson c distribution with a mean of x c--> Rather than using a continuous distribution which matches Poisson c for integer values of x, I calculate the probability of seeing zero c based on the value x, then round x to the nearest integer & c use the integrals stored in CMC_PL to choose an integer value to c return ... corresponding to a random value weighted by a Poisson c with a mean of ix = x rounded to the nearest integer. c--> Note that if x<.5 & P ge exp(-x), then x is rounded up to 1 rather c than down to zero, since the table starts with 1 expected. c--> Note that the seed (ICMC_SEED) for the random number generator is c not being written to the LOG file. This may change in the future. c C Revisions: C ========== C Date Who Description C -------- --- --------------------------------------------------- C 11/05/99 MWANG replaced random number generator with GEANT C subroutine GRNDM C c********************************************************************* SAVE INCLUDE 'CMC_COMMONS.FOR' REAL RNO(2) c--> Set P = A random number between 0 & 1 CALL GRNDM(RNO,1) P=RNO(1) cmc_fish=x c--> Probability of seeing zero, expecting x, = exp(-x) if(P.le.exp(-x))then cmc_fish=0. return endif c-->CMC_PL(IA,IE) = Probability of seeing less than or equal to IA, expecting IE ie=x+.5 if(ie.le.0)ix=1 if(ie.gt.36)ix=36 do 100 ia=1,35 if(P.gt.cmc_pl(ia,ie))goto 100 cmc_fish=float(ia) return 100 continue cmc_fish=35. return end