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

Question G4UniformRand for isotropic gamma source 

Forum: Event and Track Management
Date: 22 Feb, 2013
From: T <T>

I am new to Geant4. I am trying to simulate an isotropic gamma emitting point source. To randomize momentum direction, my 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.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Disagree: Re: G4UniformRand for isotropic gamma source   (Gumplinger Peter - 22 Feb, 2013)
2 None: Re: G4UniformRand for isotropic gamma source   (michel maire - 23 Feb, 2013)
 Add Message Add Message
to: "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 ]