Message: Re: G4UniformRand for isotropic gamma source Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: G4UniformRand for isotropic gamma source 

Forum: Event and Track Management
Re: Question G4UniformRand for isotropic gamma source (T)
Date: 23 Feb, 2013
From: michel maire <michel maire>

On Fri, 22 Feb 2013 20:48:02 GMT, T wrote:
> I am new to Geant4. I am trying to simulate an isotropic gamma emitting
> point source. To randomize momentum direction, my
> PrimaryGeneratorAction.cc code includes
> 
>         CLHEP::HepRandom::setTheEngine(new CLHEP::DRand48Engine);
>         G4int Seed = time(NULL);
>         long seeds[2];
>         seeds[0]=(long) Seed; 
>         seeds[1]=(long) (Seed * G4UniformRand());
>                 CLHEP::HepRandom::getTheEngine()->setSeeds(seeds, -1);
>         G4double cosTheta = -1.0+2.0*G4UniformRand();
>         G4double phi = twopi * G4UniformRand();
>         G4double sinTheta = sqrt(1-cosTheta*cosTheta);
>         particleGun->SetParticleMomentumDirection(G4ThreeVector(sinTheta * cos(phi) , sinTheta * sin(phi), cosTheta));
> 
> The output gives the same x,y,z momentum components for all emitted
> photons (n=100000). This output does not change even with repeated
> executions of the code. It seems that the randomizing process is not
> properly invoked.
> 
> Thank you.
> 

 You can find a simple example on extended/electromagnetic/TestEm4

 Add Message Add Message
to: "Re: G4UniformRand for isotropic gamma source"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]