*
* $Id: gpgaus.F,v 1.5 2009-06-12 18:39:58 pam-rm2 Exp $
*
* $Log: gpgaus.F,v $
* Revision 1.5  2009-06-12 18:39:58  pam-rm2
* - Introduced user-defined names of output files and random seeds number.
* Users can do it use options of PamVMCApplication constructor:
* PamVMCApplication(const char* name,  const char *title, const char*
* filename="pamtest", Int_t seed=0).
* The Random object that I use is TRandom3 object which has astronomical
* large period (in case of default initialization 0). All random generators
* in the code use this object by calling of gRandom singleton which keeps
* it.
*
* - Corrected TOF digitization routine. No problems with TDC hits due to
* hadronic interactions anymore.
*
* - Some small changes was done to compile code under Root 5.23. +
* geant4_vmc v. 2.6 without any warnings
*
* - Some classes of PamG4RunConfiguartion was changed for geant4_vmc v.
* 2.6.Some obsolete classes was deleted as soon as developers implemented
* regions.
*
* - Navigation was changed from "geomRootToGeant4" to "geomRoot", because on
* VMC web page written that as soon as Geant4 has no option ONLY/MANY
* translation of overlapped geometry to Geant4 through VGM could be wrong.
* I'd like to stay with Root navigation:
* http://root.cern.ch/root/vmc/Geant4VMC.html. This should be default
* option.
*
* - New Tracker digitization routine written by Sergio was implemented
*
* - PamVMC again became compatible with geant4_vmc v.2.5 and ROOT 5.20.
*  The problem was that ROOT developers introduced in TVirtualMC class a new
* method SetMagField and new base class:TVirtualMagField from which
* user-defined classes shoukd be derived
*
* Revision 1.1  2009-02-19 17:46:25  nikolas
* Cleaning up before releasing
*
* Revision 3.1.1.1  2002/07/11 16:02:00  cafagna
* First GPAMELA release on CVS
*
*
*CMZ :  2.01/00 05/04/2000  14.35.18  by  Marialuigia Ambriola
*CMZ :  2.00/00 03/03/2000  15.39.05  by  Francesco Cafagna
*CMZ :  1.01/00 06/05/96  12.57.18  by  Francesco Cafagna
*-- Author :    Francesco Cafagna   03/05/96
      REAL FUNCTION GPGAUS(XDUMMY)
************************************************************************
*                                                                      *
* To generate a normally distribute deviate with zero mean and unit variance *
* From GASDEV, Numerical recepies $7.3.                                *
* Variables definition:                                                *
* IN:                                                                  *
*  XDUMMY, dummy argument                                              *
*                                                                      *
* Called by:<USER>                                                     *
* Author: Francesco Cafagna, 03/05/96 17.11.14                         *
*                                                                      *
************************************************************************
      INTEGER ISET
      REAL V1,V2,GAS1,RVAL(2),R
*
      DATA ISET/0/
*
* Generate a random number in the circle of radius 1
*
      IF (ISET.EQ.0) THEN
c         PRINT*,'GPGAUSS.F calls RNDM'
   10    CALL GRNDMC(RVAL,2)
         V1 = 2.*RVAL(1) -1.
         V2 = 2.*RVAL(2) -1.
         R  = V1**2 + V2**2
         IF(R.GE.1.) GO TO 10
         GAS1 = V1 * SQRT(-2.*LOG(R)/R)
         GPGAUS = V2 * SQRT(-2.*LOG(R)/R)
         ISET = 1
      ELSE
         GPGAUS = GAS1
         ISET = 0
      ENDIF
*
      RETURN
      END
