Specify beam radius

Hello, experts!

How to specify pencil beam radius?

fParticleGun->SetParticleDefinition(G4Neutron::NeutronDefinition());
fParticleGun->SetParticleMomentumDirection(G4ParticleMomentum(cos(30.0deg),0.0,cos(60.0deg)));

void SimpleParticleSource::GeneratePrimaries(G4Event* anEvent)
{
G4double radius = 0.4*cm;
G4double phi = 360.*deg;

    G4double rRan = radius*(G4UniformRand());
    G4double phiRan = phi*(G4UniformRand());
    G4double z0 = -6.8*cm;

fParticleGun->SetParticlePosition(G4ThreeVector(rRan*cos(phiRan)-9.18*cm,rRan*sin(phiRan),z0));
fParticleGun->GeneratePrimaryVertex(anEvent);

}

Best regards,

@mkelsey @willmatava @allison
Please help to correct.
I don’t use macro file on my G4 code

Please don’t post the same question, which you’ve already asked here: How to make pencil beam radius, twice. It’s fine to bump that thread or notify others on that though!

1 Like