primary particle koi, tatsumi geant4 v9.4 geant4 tutorial at texas a&m 11-jan- 2011 1
TRANSCRIPT
1
Primary Particle
KOI, Tatsumi
Geant4 V9.4 Geant4 Tutorial at Texas A&M 11-Jan-2011
Geant4 Tutorial at Texas A&M 11-Jan-2011 2
G4VUserPrimaryGeneratorAction
• This is one of the three mandatory classes which user must implement in the code.– The others are G4VUserDetectorConstruction and
G4VUserPhysicsList– Geant4 is a toolkit, so that the main() should be also prepared by
user• Control the generation of primary particles
– Primaries particles are initial particles of each event. they will be transported in the Geometry.• 290AMeV Carbon beam• Cosmic ray particles bombarding space craft• All secondary particles which produced by a 7TeV cms proton-proton
collision
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 3
G4VUserPrimaryGeneratorAction Cont.
• One or more concrete class of G4VPrimaryGenerator (primary generator) should be member of this class.
• This class itself should NOT generate primaries but invoke GeneratePrimaryVertex() method of the concrete class to generate primaries.
• In the Constructor – Instantiate primary generator(s)– Set default values to it(them)
• In the GeneratePrimaries() method– Randomize particle-by-particle (event-by-event) value(s)
• Posisiton and momentum of particle• Type of particle
– Set these values to primary generator(s)– Invoke GeneratePrimaryVertex() method of primary generator(s)
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 4
Example of UserPrimaryGeneratorAction
• Constructor • GeneratePrimaryVertex()
Geant4 V9.4
PrimaryGeneratorAction::PrimaryGeneratorAction( DetectorConstruction* DC):Detector(DC),rndmFlag("off"){ G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); //create a messenger for this class gunMessenger = new PrimaryGeneratorMessenger(this); // default particle kinematic G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4String particleName; G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-"); particleGun->SetParticleDefinition(particle); particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); particleGun->SetParticleEnergy(50.*MeV); G4double position = -0.5*(Detector->GetWorldSizeX()); particleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));
}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){ //this function is called at the begining of event // G4double x0 = -0.5*(Detector->GetWorldSizeX()); G4double y0 = 0.*cm, z0 = 0.*cm; if (rndmFlag == "on") {y0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5); z0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5); } particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
particleGun->GeneratePrimaryVertex(anEvent);}
Geant4 Tutorial at Texas A&M 11-Jan-2011 5
Primary particle and Primary vertex• G4PrimaryVertex and G4PrimaryParticle classes
– These classes don’t have any dependency to G4ParticleDefinition nor G4Track.– Usually create in concrete class of G4VPrimaryGenerator
• G4PrimaryVertex object has one or more G4PrimaryParticle objects as primary particle.
• These are stored in G4Event in advance to processing an event.• Primary Vertex
– Capability of bookkeeping decay chains• Pre-assigned decay products (See in appendix) • Primary particles may not necessarily be particles which can be tracked by Geant4.
• Geant4 provides some concrete class of G4VPrimaryGenerator.– G4ParticleGun– G4GeneralParticleSource– G4HEPEvtInterface, G4HEPMCInterface (See in appendix)
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 6
G4ParticleGun• Concrete implementations of G4VPrimaryGenerator
– A good example for experiment-specific primary generator implementation• It shoots one primary particle of a certain energy from a certain point at a
certain time to a certain direction.– Various set methods are available– Intercoms commands are also available for setting initial values
• One of most frequently asked questions is :– I want “particle shotgun”, “particle machinegun”, etc.
• Instead of implementing such a fancy weapon, in your implementation of UserPrimaryGeneratorAction, you can– Shoot random numbers in arbitrary distribution– Use set methods of G4ParticleGun– Use G4ParticleGun as many times as you want– Use any other primary generators as many times as you want to make overlapping
events
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 7
How to useParticleGun
• Constructor • GeneratePrimaryVertex()
Geant4 V9.4
PrimaryGeneratorAction::PrimaryGeneratorAction( DetectorConstruction* DC):Detector(DC),rndmFlag("off"){ G4int n_particle = 1; particleGun = new G4ParticleGun(n_particle); //create a messenger for this class gunMessenger = new PrimaryGeneratorMessenger(this); // default particle kinematic G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4String particleName; G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-"); particleGun->SetParticleDefinition(particle); particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); particleGun->SetParticleEnergy(50.*MeV); G4double position = -0.5*(Detector->GetWorldSizeX()); particleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){ //this function is called at the begining of event // G4double x0 = -0.5*(Detector->GetWorldSizeX()); G4double y0 = 0.*cm, z0 = 0.*cm; if (rndmFlag == "on") {y0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5); z0 = (Detector->GetCalorSizeYZ())*(G4UniformRand()-0.5); } particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
particleGun->GeneratePrimaryVertex(anEvent);}
Geant4 Tutorial at Texas A&M 11-Jan-2011 8
G4GeneralParticleSource
• Concrete implementations of G4VPrimaryGenerator• Primary vertex can be randomly chosen on the surface of a
certain volume.• Momentum direction and kinetic energy of the primary
particle can also be randomized.• Distribution could be set by UI commands.• Capability of event biasing (variance reduction).
– By enhancing particle type, distribution of vertex point, energy and/or direction
• Detailed description– http://reat.space.qinetiq.com/gps/
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 9
Example of primary particle generation through G4GeneralParticleSource
Geant4 V9.4
• Spherical surface, isotropic radiation, black-body energy
• Square plane, cosine-law direction, linear energy
Geant4 Tutorial at Texas A&M 11-Jan-2011 10
Example of primary particle generation through G4GeneralParticleSource
Geant4 V9.4
• Spherical volume with z biasing, isotropic radiation with theta and phi biasing, integral arbitrary point-wise energy distribution with linear interpolation.
• Cylindrical surface, cosine-law radiation, Cosmic diffuse energy
Geant4 Tutorial at Texas A&M 11-Jan-2011 11
How to useG4GeneralParticleSource
• User PrimaryGeneratorAction
MyPrimaryGeneratorAction::MyPrimaryGeneratorAction()
{ generator = new G4GeneralParticleSource; }
void MyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent){ generator->GeneratePrimaryVertex(anEvent); }
• Command lime /control/verbose 0/tracking/verbose 0/event/verbose 0/gps/verbose 2/gps/particle gamma/gps/pos/type Plane/gps/pos/shape Square/gps/pos/centre 1 2 1 cm/gps/pos/halfx 2 cm/gps/pos/halfy 2 cm/gps/ang/type cos/gps/ene/type Lin/gps/ene/min 2 MeV/gps/ene/max 10 MeV/gps/ene/gradient 1/gps/ene/intercept 1/run/beamOn 10000
The above macro defines a planar source, square in shape, 4 cm by 4 cm and centred at (1,2,1) cms. By default the normal of this plane is the z-axis. The angular distribution is to follow the cosine-law. The energy spectrum is linear, with gradient and intercept equal to 1, and extends from 2 to 10 MeV. 10,000 primaries are to be generated.
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 12
G4ParticleGun vs. G4GeneralParticleSource
• Particle Gun– Simple and naïve– Shoot one track at a time
• You can shoot more than one tracks within an event.
– Easy to handle.• Use set methods to alternate
track-by-track or event-by-event values.
• General Particle Source– Powerful– Controlled by UI commands.
• Almost impossible to control through set methods
– Capability of shooting particles from a surface of a volume.
– Capability of randomizing kinetic energy, position and/or direction following a user-specified distribution (histogram).
Geant4 V9.4
• If you need to shoot primary particles from a surface of a complicated volume, either outward or inward, GPS is the choice. • If you need a complicated distribution, GPS is the choice.• Otherwise, use Particle Gun.
Geant4 Tutorial at Texas A&M 11-Jan-2011 13
What to do and where to do• In the constructor of your UserPrimaryGeneratorAction
– Instantiate G4ParticleGun– Set default values by set methods of G4ParticleGun
• Particle type, kinetic energy, position and direction
• In your macro file or from your interactive terminal session– Set values for a run
• Particle type, kinetic energy, position and direction
• In the GeneratePrimaries() method of your UserPrimaryGeneratorAction– Shoot random number(s) and prepare track-by-track or event-by-event values
• Kinetic energy, position and direction
– Use set methods of G4ParticleGun to set such values– Then invoke GeneratePrimaryVertex() method of G4ParticleGun– If you need more than one primary tracks per event, loop over randomization and
GeneratePrimaryVertex().• examples/extended/analysis/A01/src/A01PrimaryGeneratorAction.cc is a good example to
start with.– Also, new example to demonstrate how to use ParticleGun to alternate most of the GPS
functionalities is to be included in Geant4 9.4.
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 14
Summary
• UserPrimaryActionGenerator– User's mandatory action class for primary vertex/particle generation.– have one or more G4VPrimaryGenerator concrete classes– set/change properties of generator(s)
• Primary Particle– This class represents a primary particle
• Primary Vertex– This class has one or more G4PrimaryParticle objects as primary particles.
• PrimaryGenerator– This class set Primary Vertex to G4Event object
• G4ParticleGun and G4GeneralParticleSource– Concrete class of G4VPrimaryGenerator
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 15
Appendix
• Pre-assigned decay products• Interfaces to HEPEvt and HepMC
Geant4 V9.4
Geant4 Tutorial at Texas A&M 11-Jan-2011 16
Pre-assigned decay products• Physics generator can assign a decay channel for each individual particle
separately, while in Geant4 you cannot specify a decay channel for each particle.– Decay chain can be “pre-assigned”.
• A parent particle in the form of G4Track object travels in the detector, bringing “pre-assigned” decay daughters as objects of G4DynamicParticle.– When the parent track comes to the decay point, pre-assigned daughters become to
secondary tracks, instead of randomly selecting a decay channel defined to the particle type. Decay time of the parent can be pre-assigned as well.
Geant4 V9.4Geant4 Tutorial at Texas A&M 11-Jan-2011 16
D0 m- nm
K- m+ nm
B-
G4PrimaryParticle
B-
G4Track
D0 m- nm
K- m+ nm
pre-assigned decay products
K- m+ nm
D0
m-
nm
B-
K-
m+
nm
D0
Geant4 Tutorial at Texas A&M 11-Jan-2011 17
Interfaces to HEPEvt and HepMC
• Concrete implementations of G4VPrimaryGenerator
– A good example for experiment-specific primary generator implementation
• G4HEPEvtInterface
– Suitable to /HEPEVT/ common block, which many of (FORTRAN) HEP physics
generators are compliant to.
– ASCII file input
• G4HepMCInterface
– An interface to HepMC class, which a few new (C++) HEP physics generators
are compliant to.
– ASCII file input or direct linking to a generator through HepMC.
Geant4 V9.4