Message: Re: GPS Cylindrical surface source : how to generate particules towards the outside of the cylinder? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: GPS Cylindrical surface source : how to generate particules towards the outside of the cylinder? 

Forum: Particles
Re: Question GPS Cylindrical surface source : how to generate particules towards the outside of the cylinder? (Jérôme Roccaz)
Re: Idea Re: GPS Cylindrical surface source : how to generate particules towards the outside of the cylinder? (Gumplinger Peter)
Date: 21 Mar, 2013
From: Michael H. Kelsey <Michael H. Kelsey>

On Thu, 21 Mar 2013 00:47:36 GMT, Gumplinger Peter wrote:
> You can always code your source in C++ in
> PrimaryGeneratorAction::GeneratePrimaries. Calculate a random position
> on your cylinder then call particleGun->SetParticlePosition. Next
> calculate a direction you want always away from the cylinder surface and
> call particleGun->SetParticleMomentumDirection.

You can do this directly with the G4 geometry as well. If it's part of your detector model, get the volume pointer and dig down to access the associated G4VSolid*. If you want to use an "arbitrary" cylinder, then you can instantiate your own private G4Tubs in your generator action.

Either way, this is the code:

    G4VSolid* mycyl = (whatever);    // See above for filling the pointer
    G4ThreeVector gunpoint = mycyl->GetPointOnSurface();
    G4ThreeVector gundir   = mycyl->SurfaceNormal(gunpoint);
    particleGun->SetParticlePosition(gunpoint);
    particleGun->SetParticleMomentumDirection(gundir);

I assume you configure the particle type and energy/momentum separately.

  -- Michael Kelsey

 Add Message Add Message
to: "Re: GPS Cylindrical surface source : how to generate particules towards the outside of the cylinder?"

 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 ]