Ignore:
Timestamp:
Sep 10, 2008, 5:40:37 PM (16 years ago)
Author:
garnier
Message:

geant4.8.2 beta

Location:
trunk/source/global/HEPRandom/include
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/global/HEPRandom/include/G4Poisson.hh

    r833 r850  
    2626//
    2727// $Id: G4Poisson.hh,v 1.9 2006/06/29 19:00:44 gunter Exp $
    28 // GEANT4 tag $Name: $
     28// GEANT4 tag $Name: HEAD $
    2929//
    3030//
  • trunk/source/global/HEPRandom/include/G4RandomDirection.hh

    r833 r850  
    2525//
    2626//
    27 // $Id: G4RandomDirection.hh,v 1.3 2006/06/29 19:00:47 gunter Exp $
    28 // GEANT4 tag $Name: geant4-09-01-patch-02 $
     27// $Id: G4RandomDirection.hh,v 1.5 2008/03/19 17:00:20 gcosmo Exp $
     28// GEANT4 tag $Name: HEAD $
    2929//
    3030//
     
    3434// Class description:
    3535//
    36 // Funtion returning a unit 3-vector homogeneously randomised over 4pi
     36// Function returning a unit 3-vector homogeneously randomised over 4pi
    3737// solid angle. It can be used in any particle scattering methods
    3838// instead of:
    3939//   z=R1, x=SQRT(1-R1*R1)*SIN(2*pi*R2), y=SQRT(1-R1*R1)*COS(2*pi*R2)
    4040// providing more performant results.
     41
     42// History:
     43//    18.03.08 V. Grichine, unit radius sphere surface based algorithm
     44//      ~ 2007 M. Kossov, algorithm based on 8 Quadrants technique
     45//
    4146// ------------------------------------------------------------
    4247#ifndef G4RANDOMDIR_HH
     
    4954inline G4ThreeVector G4RandomDirection()
    5055{
    51   // Randomization in one of 8 Quadrants (x>0, y>0, z>0)
    52   //
    53   G4double x=G4UniformRand(), y=G4UniformRand(), z=G4UniformRand();
    54   G4double r2= x*x+y*y+z*z;
    55   while(r2>1.||r2<.000001)
    56   {
    57     x = G4UniformRand(); y = G4UniformRand(); z = G4UniformRand();
    58     r2=x*x+y*y+z*z;
    59   }
    60   G4double r=std::sqrt(r2), quad=G4UniformRand();
    61 
    62   if(quad>0.5)
    63   {
    64     if(quad>0.75)
    65     {
    66       if(quad>0.875)    return G4ThreeVector(-x/r,-y/r,-z/r);
    67       else              return G4ThreeVector(-x/r,-y/r, z/r);
    68     }
    69     else
    70     {
    71       if(quad>0.625)    return G4ThreeVector(-x/r, y/r,-z/r);
    72       else              return G4ThreeVector(-x/r, y/r, z/r);
    73     }
    74   }
    75   else
    76   {
    77     if(quad>0.25)
    78     {
    79       if(quad>0.375)    return G4ThreeVector( x/r,-y/r,-z/r);
    80       else              return G4ThreeVector( x/r,-y/r, z/r);
    81     }
    82     else if(quad>0.125) return G4ThreeVector( x/r, y/r,-z/r);
    83   }
    84   return                       G4ThreeVector( x/r, y/r, z/r);
     56  G4double cosTheta  = 2.*G4UniformRand()-1.;
     57  G4double sinTheta2 = 1. - cosTheta*cosTheta;
     58  if( sinTheta2 < 0.)  sinTheta2 = 0.;
     59  G4double sinTheta  = std::sqrt(sinTheta2);
     60  G4double phi       = twopi*G4UniformRand();
     61  return G4ThreeVector(sinTheta*std::cos(phi),
     62                       sinTheta*std::sin(phi), cosTheta).unit();
    8563}
    8664
  • trunk/source/global/HEPRandom/include/Randomize.hh

    r833 r850  
    2626//
    2727// $Id: Randomize.hh,v 1.7 2006/06/29 19:00:50 gunter Exp $
    28 // GEANT4 tag $Name: $
     28// GEANT4 tag $Name: HEAD $
    2929//
    3030#ifndef randomize_h
Note: See TracChangeset for help on using the changeset viewer.