Message: Re: How to shoot gammarays/particles in a specified direction randomly? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: How to shoot gammarays/particles in a specified direction randomly? 

Forum: Particles
Re: Question How to shoot gammarays/particles in a specified direction randomly? (Pradip Datta)
Date: 07 May, 2009
From: michel maire <michel maire>

On Thu, 07 May 2009 13:47:37 GMT, Pradip Datta wrote:
> Hi All,
> 
> Can any body help to throw particles through a defined solid angle
> randomly using particle gun. More specifically I would like to shoot
> gamma rays within the solid angle sustained by the detector face at the
> source point. My Detector face is circular shape of radius 60.
> 
> Any suggestion is highly appreciated.
> 
> Pradip
> 

 As Giovanni said you can use GeneralParticleSource instead of ParticleGun.
 However, if you prefere to stay with ParticleGun, the code below generate particle uniformly in 4pi. You can adapt/restrict it to your case.

  void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
 {
   //this function is called at the begining of event
   //
   //distribution uniform in solid angle
   //
   G4double cosTheta = 2*G4UniformRand() - 1., phi = twopi*G4UniformRand();
   G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
   G4double ux = sinTheta*std::cos(phi),
            uy = sinTheta*std::sin(phi),
            uz = cosTheta;

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

   particleGun->GeneratePrimaryVertex(anEvent);
 }

 Add Message Add Message
to: "Re: How to shoot gammarays/particles in a specified direction randomly?"

 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 ]