Message: Re: PrimaryParticleGenerator Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: PrimaryParticleGenerator 

Forum: Particles
Re: Question PrimaryParticleGenerator (Bauyrzhan Yessenov)
Date: 18 Mar, 2015
From: Makoto Asai <Makoto Asai>

Hello Bauyrzhan,

Please note that the constructor of your GGPrimaryGeneratorAction class is invoked only once when this class object is instantiated. Given you want to randomize the position and direction of your primary neutron event by event, you need to implement such randomization logic in the method GGPrimaryGeneratorAction::GeneratePrimaries() that is invoked at the beginning of each event. This method could be like this.

void GGPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
  //this function is called at the begining of ecah event

  //fGlobal->pEnergy = G4RandFlat::shoot(0.661*MeV);
  fGlobal->pEnergy = 14.1*MeV;
  //G4cout << "pEnergy: " << pEnergy << G4endl;


  G4double SigmaAngle = 2*deg;
  G4double angle = (G4UniformRand()-0.5)*fSigmaAngle;
  G4double cosTheta = 1.0 + 2.0*G4UniformRand();
  G4double phi = twopi*G4UniformRand();
  G4double sinTheta = sqrt(1 - cosTheta*cosTheta);


Hope this helps,

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

1 Ok: Re: PrimaryParticleGenerator   (Bauyrzhan Yessenov - 19 Mar, 2015)
(_ None: Re: PrimaryParticleGenerator   (Bauyrzhan Yessenov - 22 Apr, 2015)
(_ None: Re: PrimaryParticleGenerator   (Makoto Asai - 22 Apr, 2015)
 Add Message Add Message
to: "Re: PrimaryParticleGenerator"

 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 ]