Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Luter 345 Experiments
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
How to Generate Primary Action
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Get shortened URL
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
==How to Generate a Primary Action== G4userPrimaryGeneratorAction is one of the mandatory classes available for deriving your own concrete class. In your concrete class, you have to specify how a primary event should be generated. Actual generation of primary particles will be done by concrete classes of G4VPrimaryGenerator. void S1PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { ===Selection of the Generator=== In the constructor of your G4VUserPrimaryGeneratorAction, you should instantiate the primary generator(s). If necessary, you need to set some initial conditions for the generator(s). This is an example of a constructor S1PrimaryGeneratorAction::S1PrimaryGeneratorAction() :G4VUserPrimaryGeneratorAction(), //inside this constructor you should have some code calling your generator(s) ===G4Primary Generator=== G4ParticleGun is a generator provided by Geant4. We called This class generates primary particle(s) with a given momentum and position. It does not provide any sort of randomizing. The constructor of G4ParticleGun takes an integer which causes the generation of one or more primaries of exactly same kinematics. It is a rather frequent user requirement to generate a primary with randomized energy, momentum, and/or position. Such randomization can be achieved by invoking various set methods provided by G4ParticleGun. Geant4 provides various random number generation methods with various distributions [http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch03s02.html (see Section 3.2)]. Within your Primary Generator Action you must establish your conditions of your experiment {Example} *establish a random position on both top and bottom of your geometry within your envelope xtop = (G4UniformRand()*(Variables->getGeometryX()*0.5)); ytop = (G4UniformRand()*(Variables->getGeometryY()*0.5)); xbottom = (G4UniformRand()*(Variables->getGeometrytX()*0.5)); ybottom = = (G4UniformRand()*(Variables->getGeometryY()*0.5)); *establish how far below the bottom geometry the particles should start G4double bottomOfBottomGeo = (Variables->getGeoZ()*-0.5)+Variables->getBottomGeoPos(); zinitial = (bottomOfBottomGeo - 1.0); *establish the components of the vector to fire along to hit both random points baseX = (xtop-xbottom); baseY = (ytop-ybottom); heightZ = (Variables->getTopGeoPos() - Variables->getBottomGeoPos()); ===G4ParticleGun Generator=== G4ParticleGun is a generator provided by Geant4. This class generates primary particle(s) with a given momentum and position. It does not provide any sort of randomizing. The constructor of G4ParticleGun takes an integer which causes the generation of one or more primaries of exactly same kinematics. It is a rather frequent user requirement to generate a primary with randomized energy, momentum, and/or position. G4ParticleGun is normally found in one of your constructors within your PrimaryGeneratorAction. fParticleGun = new G4ParticleGun(n_particle); Next you must decribe the default Particle Kinematics: G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4String particleName = "nameofparticlehere"; G4ParticleDefinition* particle = particleTable->FindParticle(particleName); fParticleGun->SetParticleDefinition(particle);
Summary:
Please note that all contributions to Luter 345 Experiments may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Luter 345 Experiments:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)