Message: Particle generation over hemisphere Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Particle generation over hemisphere 

Keywords: primary generation, event generation
Forum: Event and Track Management
Date: 28 Apr, 2005
From: Sean Turnbull <Sean Turnbull>

Hello all, I am simulating a simple NaI detector and want to generate a uniform distribution of particles over a hemisphere from a point source to hit the detector. Rather like a shower of particles. This is my PrimaryGenerator class.

PrimaryGeneratorAction::PrimaryGeneratorAction()
{
  G4int n_particle = 1;
  particleGun = new G4ParticleGun(n_particle);

  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  G4String particleName;
  particleGun->SetParticleDefinition(particleTable->FindParticle(particleName="gamma"));
  particleGun->SetParticleEnergy(2.61*MeV);
  particleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, -8.81*cm)); //
}

PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
  delete particleGun;
}

void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
  //distribution uniform in solid angle - hemispherical

  G4double cosTheta = G4UniformRand() - 1., phi = twopi*G4UniformRand();
  G4double sinTheta = sqrt(1. - cosTheta*cosTheta);
  G4double ux = sinTheta*cos(phi),
           uy = sinTheta*sin(phi),
           uz = cosTheta;

  particleGun->SetParticleMomentumDirection(G4ThreeVector(ux,uy,-uz));
  particleGun->GeneratePrimaryVertex(anEvent);
}

for any more info please let me know....

Thanks

Sean

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

1 Feedback: Re: Particle generation over hemisphere   (Giovanni Santin - 28 Apr, 2005)
 Add Message Add Message
to: "Particle generation over hemisphere"

 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 ]