Message: Problems with set methods of G4GeneralParticleSource class? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Problems with set methods of G4GeneralParticleSource class? 

Keywords: hard code, set methods of G4GeneralParticleSource
Forum: Event and Track Management
Date: 25 Jun, 2006
From: Shahrokh <Shahrokh>

Hi, 
My program is run interactively with the command: /control/execute myMacro.mac.
A part of this macro file (myMacro.mac) is shown below:

#beam #0
#
#the intensity of source
/gps/source/intensity 1
#
#the type of particles
#/gps/particle gamma
/gps/pos/rot1 -1 0 0
/gps/pos/rot2 0 1 0
#
#the position and shape of source
/gps/pos/type Plane
/gps/pos/shape Annulus
/gps/pos/centre 0. 0. -24.615 cm
/gps/pos/inner_radius 0 cm
/gps/pos/radius 0.5 cm
#
#the direction of particles
/gps/ang/type iso
/gps/ang/mintheta 179.98 deg
/gps/ang/maxtheta 180 deg
#
#the energy of particles
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.4 2.
/gps/hist/point 0.6 5.
/gps/hist/point 0.8 8.
/gps/hist/point 1 5.
/gps/hist/point 1.2 5.
/gps/hist/point 1.4 1.
/gps/hist/point 1.6 2.
/gps/hist/point 1.8 5.
/gps/hist/point 2 3.
/gps/hist/point 2.2 2.
/gps/hist/point 2.4 2.
/gps/hist/point 2.6 2.
/gps/hist/point 3 2.
/gps/hist/point 3.2 1.
/gps/hist/point 3.4 5.
/gps/hist/point 3.6 2.
/gps/hist/point 3.8 1.
/gps/hist/point 4.6 1.
/gps/hist/point 4.8 1.
/gps/hist/point 5.2 2.
/gps/hist/point 6 1.
/gps/hist/point 6.4 3.
/gps/hist/point 8 1.
/gps/hist/point 8.6 1.
/gps/hist/point 9 1.

#beam #1
#
#the intensity of source
/gps/source/add 2.80952
#
#the type of particles
#/gps/particle gamma
/gps/pos/rot1 -1 0 0
/gps/pos/rot2 0 1 0
#
#the position and shape of source
/gps/pos/type Plane
/gps/pos/shape Annulus
/gps/pos/centre 0. 0. -24.615 cm
/gps/pos/inner_radius 0.5 cm
/gps/pos/radius 1 cm
#
#the direction of particles
/gps/ang/type iso
/gps/ang/mintheta 179.959 deg
/gps/ang/maxtheta 179.98 deg
#
#the energy of particles
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.6 7.
/gps/hist/point 0.8 5.
/gps/hist/point 1 12.
/gps/hist/point 1.2 9.
/gps/hist/point 1.4 7.
/gps/hist/point 1.6 16.
/gps/hist/point 1.8 11.
/gps/hist/point 2 6.
/gps/hist/point 2.2 11.
/gps/hist/point 2.4 5.
/gps/hist/point 2.6 16.
/gps/hist/point 2.8 6.
/gps/hist/point 3 7.
/gps/hist/point 3.2 5.
/gps/hist/point 3.4 4.
/gps/hist/point 3.6 6.
/gps/hist/point 3.8 3.
/gps/hist/point 4 4.
/gps/hist/point 4.2 1.
/gps/hist/point 4.4 3.
/gps/hist/point 4.6 2.
/gps/hist/point 4.8 4.
/gps/hist/point 5 1.
/gps/hist/point 5.2 2.
/gps/hist/point 5.4 1.
/gps/hist/point 5.6 1.
/gps/hist/point 5.8 2.
/gps/hist/point 6 2.
/gps/hist/point 6.2 1.
/gps/hist/point 6.4 2.
/gps/hist/point 6.6 1.
/gps/hist/point 7 3.
/gps/hist/point 7.2 1.
/gps/hist/point 7.6 1.
/gps/hist/point 8.2 1.
/gps/hist/point 8.4 2.
/gps/hist/point 8.6 1.
/gps/hist/point 9 1.
/gps/hist/point 9.4 1.
/gps/hist/point 10 1.
...

#beam #29
#
#the intensity of source
/gps/source/add 2.12698
#
#the type of particles
#/gps/particle gamma
/gps/pos/rot1 -1 0 0
/gps/pos/rot2 0 1 0
#
#the position and shape of source
/gps/pos/type Plane
/gps/pos/shape Annulus
/gps/pos/centre 0. 0. -24.615 cm
/gps/pos/inner_radius 14.5 cm
/gps/pos/radius 15 cm
#
#the direction of particles
/gps/ang/type iso
/gps/ang/mintheta 179.453 deg
/gps/ang/maxtheta 179.468 deg
#
#the energy of particles
/gps/ene/type User
/gps/hist/type energy
/gps/hist/point 0.2 5.
/gps/hist/point 0.4 12.
/gps/hist/point 0.6 33.
/gps/hist/point 0.8 14.
/gps/hist/point 1 8.
/gps/hist/point 1.2 11.
/gps/hist/point 1.4 2.
/gps/hist/point 1.6 11.
/gps/hist/point 1.8 5.
/gps/hist/point 2 6.
/gps/hist/point 2.2 2.
/gps/hist/point 2.4 6.
/gps/hist/point 2.6 3.
/gps/hist/point 3 3.
/gps/hist/point 3.2 2.
/gps/hist/point 3.4 8.
/gps/hist/point 3.8 2.
/gps/hist/point 4 1.
/gps/hist/point 4.2 4.
/gps/hist/point 4.6 5.
/gps/hist/point 5.8 1.
/gps/hist/point 6.2 2.
/gps/hist/point 7.2 1.
/gps/hist/point 8.8 1.
/gps/hist/point 9.2 1.

/run/beamOn 100000

This is my code in the PrimaryGeneratorAction.cc: 
#include "PrimaryGeneratorAction.hh"

#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"

PrimaryGeneratorAction::PrimaryGeneratorAction()
{
   particleGun = new G4GeneralParticleSource();
}

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

void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
  particleGun->GeneratePrimaryVertex(anEvent) ;
}

How can I invoke set methods instead of the commands in the macro file (myMacro.mac)?
In other words, how can I replace those commands with using the methods and classes of 
the GPS (I want to write my simulation in purely hard code)?
For example, I know that I can replace the command /gps/particle gamma with the below lines 
in  PrimaryGeneratorAction::PrimaryGeneratorAction() function:
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4ParticleDefinition* particle = particleTable->FindParticle("gamma");
particleGun->SetParticleDefinition(particle);

When I use anything like:
particleGun->SetCentreCoords(G4ThreeVector(0., 0., -24.615));
or,
particleGun->SetPosRot1(G4ThreVector(-1., 0., 0.));
particleGun->SetPosRot2(G4ThreeVector(0., 1., 0.));
or
particleGun->SetPosDisType(“Plane”);
particleGun->SetPosDisShape(“Annulus”);
I can get error messages!!!

Also I read  “Geant4 General Particle Source Users Manual”
(internet address: http://reat.space.qinetiq.com/gps/new_gps_sum_files/Document.htm) and 
its technical node “Genral purpose Source Particle Module for GEANT4/SPARSET Technical Note” 
(internet address: http://reat.space.qinetiq.com/gps/gspm_docs/gspm_tn1.pdf), 
but I do not find G4GSPMGun class in geant4.7.1.

Please help me. 
Thanks alot,
Shahrokh.

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

1 None: Re: Problems with set methods of G4GeneralParticleSource class?   (Paul Nicholas Colin Gloster - 26 May, 2009)
 Add Message Add Message
to: "Problems with set methods of G4GeneralParticleSource class?"

 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 ]