Upload
ellen-wade
View
230
Download
0
Tags:
Embed Size (px)
Citation preview
Basics ofBasics ofPrimary Particle Primary Particle
GenerationGenerationand Trackingand Tracking
Makoto Asai (SLAC)Makoto Asai (SLAC)
Geant4 Tutorial Course @ CERNGeant4 Tutorial Course @ CERN
May 25-27, 2005May 25-27, 2005
May 2005, Geant4 v7.0p01
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 22
ContentsContents Primary particle generationPrimary particle generation
G4VUserPrimaryGeneratorActionG4VUserPrimaryGeneratorAction Primary vertex and primary particlePrimary vertex and primary particle Built-in primary particle generatorsBuilt-in primary particle generators
Tracking mechanism in Geant4Tracking mechanism in Geant4 Tracking mechanismTracking mechanism Track and step statusesTrack and step statuses TrajectoryTrajectory
Primary particle generationPrimary particle generation
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 44
G4VUserPrimaryGeneratorActionG4VUserPrimaryGeneratorAction This class is one of mandatory user action classes to This class is one of mandatory user action classes to control control
the generationthe generation of primaries. of primaries. This class itself This class itself should NOTshould NOT generate primaries but generate primaries but invokeinvoke
GeneratePrimaryVertex()GeneratePrimaryVertex() method of primary generator(s) method of primary generator(s)
to make primaries.to make primaries. ConstructorConstructor
Instantiate primary generator(s)Instantiate primary generator(s) Set default values to it(them)Set default values to it(them)
GeneratePrimaries() methodGeneratePrimaries() method Randomize particle-by-particle value(s)Randomize particle-by-particle value(s) Set them to primary generator(s)Set them to primary generator(s)
Never use hard-coded UI commandsNever use hard-coded UI commands Invoke Invoke GeneratePrimaryVertex()GeneratePrimaryVertex() method of primary method of primary
generator(s)generator(s)
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 55
Primary vertices and particlesPrimary vertices and particles Primary vertices and primary particles should be stored in Primary vertices and primary particles should be stored in
G4Event before processing an event.G4Event before processing an event. G4PrimaryVertexG4PrimaryVertex and and G4PrimaryParticleG4PrimaryParticle classes classes
These classes don’t have any dependency to These classes don’t have any dependency to G4ParticleDefinition nor G4Track.G4ParticleDefinition nor G4Track.
Capability of bookkeeping decay chainsCapability of bookkeeping decay chains Primary particles Primary particles may notmay not necessarily be particles which necessarily be particles which
can be tracked by Geant4.can be tracked by Geant4. Geant4 provides some concrete implementations of Geant4 provides some concrete implementations of
G4VPrimaryGeneratorG4VPrimaryGenerator.. G4ParticleGunG4ParticleGun G4HEPEvtInterfaceG4HEPEvtInterface G4HEPMCInterfaceG4HEPMCInterface G4GeneralParticleSourceG4GeneralParticleSource
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 66
G4ParticleGunG4ParticleGun Concrete implementations of G4VPrimaryGeneratorConcrete implementations of G4VPrimaryGenerator
A good example for experiment-specific primary generator A good example for experiment-specific primary generator implementationimplementation
It shoots one primary particle of a certain energy from a certain point It shoots one primary particle of a certain energy from a certain point at a certain time to a certain direction.at a certain time to a certain direction. Various set methods are availableVarious set methods are available Intercoms commands are also availableIntercoms commands are also available
One of most frequently asked questions is :One of most frequently asked questions is :
I want “particle shotgun”, “particle machinegun”, etc. I want “particle shotgun”, “particle machinegun”, etc. Instead of implementing such a fancy weapon, in your implementation Instead of implementing such a fancy weapon, in your implementation
of UserPrimaryGeneratorAction, you canof UserPrimaryGeneratorAction, you can Shoot random numbers in arbitrary distributionShoot random numbers in arbitrary distribution Use set methods of G4ParticleGunUse set methods of G4ParticleGun Use G4ParticleGun as many times as you wantUse G4ParticleGun as many times as you want Use any other primary generators as many times as you want to Use any other primary generators as many times as you want to
make overlapping eventsmake overlapping events
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 77
G4VUserPrimaryGeneratorActionG4VUserPrimaryGeneratorActionvoid T01PrimaryGeneratorAction::void T01PrimaryGeneratorAction:: GeneratePrimaries(G4Event* anEvent)GeneratePrimaries(G4Event* anEvent){ G4ParticleDefinition* particle;{ G4ParticleDefinition* particle; G4int i = (int)(5.*G4UniformRand());G4int i = (int)(5.*G4UniformRand()); switch(i)switch(i) { case 0: particle = positron; break; ... }{ case 0: particle = positron; break; ... } particleGun->SetParticleDefinition(particle);particleGun->SetParticleDefinition(particle); G4double pp =G4double pp = momentum+(G4UniformRand()-0.5)*sigmaMomentum;momentum+(G4UniformRand()-0.5)*sigmaMomentum; G4double mass = particle->GetPDGMass();G4double mass = particle->GetPDGMass(); G4double Ekin = sqrt(pp*pp+mass*mass)-mass;G4double Ekin = sqrt(pp*pp+mass*mass)-mass; particleGun->SetParticleEnergy(Ekin);particleGun->SetParticleEnergy(Ekin); G4double angle = (G4UniformRand()-0.5)*sigmaAngle;G4double angle = (G4UniformRand()-0.5)*sigmaAngle; particleGun->SetParticleMomentumDirectionparticleGun->SetParticleMomentumDirection (G4ThreeVector(sin(angle),0.,cos(angle)));(G4ThreeVector(sin(angle),0.,cos(angle))); particleGun->GeneratePrimaryVertex(anEvent);particleGun->GeneratePrimaryVertex(anEvent);}}
You can repeat this for generating more than one primary particles.You can repeat this for generating more than one primary particles.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 88
Interfaces to HEPEvt and HepMCInterfaces to HEPEvt and HepMC Concrete implementations of G4VPrimaryGeneratorConcrete implementations of G4VPrimaryGenerator
A good example for experiment-specific primary generator A good example for experiment-specific primary generator
implementationimplementation
G4HEPEvtInterfaceG4HEPEvtInterface
Suitable to /HEPEVT/ common block, which many of (FORTRAN) Suitable to /HEPEVT/ common block, which many of (FORTRAN)
HEP physics generators are compliant to.HEP physics generators are compliant to.
ASCII file inputASCII file input
G4HepMCInterfaceG4HepMCInterface
An interface to HepMC class, which a few new (C++) HEP physics An interface to HepMC class, which a few new (C++) HEP physics
generators are compliant to.generators are compliant to.
ASCII file input or direct linking to a generator through HepMC.ASCII file input or direct linking to a generator through HepMC.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 99
G4GeneralParticleSourceG4GeneralParticleSource A concrete implementation of G4VPrimaryGeneratorA concrete implementation of G4VPrimaryGenerator
Suitable especially to space applicationsSuitable especially to space applications
MyPrimaryGeneratorAction::MyPrimaryGeneratorAction::
MyPrimaryGeneratorAction()MyPrimaryGeneratorAction()
{ { generator = new G4GeneralParticleSource;generator = new G4GeneralParticleSource; } }
void MyPrimaryGeneratorAction::void MyPrimaryGeneratorAction::
GeneratePrimaries(G4Event* anEvent)GeneratePrimaries(G4Event* anEvent)
{ { generator->GeneratePrimaryVertex(anEvent); generator->GeneratePrimaryVertex(anEvent); }}
Detailed descriptionDetailed description
http://reat.space.qinetiq.com/gps/http://reat.space.qinetiq.com/gps/
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1010
G4GeneralParticleSourceG4GeneralParticleSource Primary vertex can be randomly chosen on the surface of a certain Primary vertex can be randomly chosen on the surface of a certain
volume.volume.
Momentum direction and kinetic energy of the primary particle can Momentum direction and kinetic energy of the primary particle can
also be randomized.also be randomized.
Distribution could be set by UI commands.Distribution could be set by UI commands.
Capability of event biasing (variance reduction).Capability of event biasing (variance reduction).
By enhancing particle type, distribution of vertex point, energy By enhancing particle type, distribution of vertex point, energy
and/or directionand/or direction
Square plane, cosine-law direction, linear energy Spherical surface, isotropic radiation, black-body
energy Cylindrical surface, cosine-law radiation, Cosmic diffuse energy
Spherical volume with z biasing, isotropic radiation with theta and phi biasing, integral arbitrary point-wise energy distribution with linear interpolation.
Tracking mechanismTracking mechanismin Geant4in Geant4
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1212
Tracking and processesTracking and processes Geant4 tracking is general. Geant4 tracking is general.
It is independent to It is independent to
the particle type the particle type
the physics processes involving to a particlethe physics processes involving to a particle
It gives the chance to all processes It gives the chance to all processes
To contribute to determining the step lengthTo contribute to determining the step length
To contribute any possible changes in physical To contribute any possible changes in physical
quantities of the trackquantities of the track
To generate secondary particlesTo generate secondary particles
To suggest changes in the state of the trackTo suggest changes in the state of the track
e.g. to suspend, postpone or kill it.e.g. to suspend, postpone or kill it.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1313
Processes in Geant4Processes in Geant4 In Geant4, particle transportation is a process as well, by which a In Geant4, particle transportation is a process as well, by which a
particle interacts with geometrical volume boundaries and field of particle interacts with geometrical volume boundaries and field of
any kind.any kind.
Because of this, shower parameterization process can take Because of this, shower parameterization process can take
over from the ordinary transportation without modifying the over from the ordinary transportation without modifying the
transportation process.transportation process.
Each particle type has its own list of applicable processes. At each Each particle type has its own list of applicable processes. At each
step, all processes listed are invoked to get proposed physical step, all processes listed are invoked to get proposed physical
interaction lengths.interaction lengths.
The process which requires the shortest interaction length (in The process which requires the shortest interaction length (in
space-time) limits the step. space-time) limits the step.
All processes are derived from All processes are derived from G4VProcessG4VProcess abstract base class. abstract base class.
Each particle type has its individual Each particle type has its individual G4ProcessManagerG4ProcessManager class class
object which holds a vector of assigned processes.object which holds a vector of assigned processes.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1414
Process and stepProcess and step Each process has one or combination of the following natures.Each process has one or combination of the following natures.
AtRestAtRest e.g. muon decay at reste.g. muon decay at rest
AlongStep (a.k.a. continuous process)AlongStep (a.k.a. continuous process) e.g. Celenkov processe.g. Celenkov process
PostStep (a.k.a. discrete process)PostStep (a.k.a. discrete process) e.g. decay on the flye.g. decay on the fly
Continuous processes contribute cumulatively along the step, Continuous processes contribute cumulatively along the step, while discrete processes contribute selectively (if not while discrete processes contribute selectively (if not exclusively) at the end point of the step. exclusively) at the end point of the step. A special process, e.g. shower parameterization process, A special process, e.g. shower parameterization process,
may take over all continuous and discrete processes.may take over all continuous and discrete processes.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1515
How Geant4 runs (one step)How Geant4 runs (one step)
Stepping Manager
Physics Process
Particle Change
Step Track Logical Volume
Sensitive Detector
GetPhysicalInteractionLength
SelectShortest
DoIt Fill
Update
Update
IsSensitive
GenerateHits
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1616
Track statusTrack status At the end of each step, according to the processes involved, the state At the end of each step, according to the processes involved, the state
of a track may be changed.of a track may be changed. The user can also change the status in UserSteppingAction.The user can also change the status in UserSteppingAction. Statuses shown in Statuses shown in yellowyellow are artificial, i.e. Geant4 kernel won’t set are artificial, i.e. Geant4 kernel won’t set
them, but the user can set.them, but the user can set.
fAlivefAlive Continue the tracking.Continue the tracking.
fStopButAlivefStopButAlive The track has come to zero kinetic energy, but still AtRest process The track has come to zero kinetic energy, but still AtRest process
to occur.to occur. fStopAndKillfStopAndKill
The track has lost its identity because it has decayed, interacted or The track has lost its identity because it has decayed, interacted or gone beyond the world boundary.gone beyond the world boundary.
Secondaries will be pushed to the stack.Secondaries will be pushed to the stack. fKillTrackAndSecondariesfKillTrackAndSecondaries
Kill the current track and also associated secondaries.Kill the current track and also associated secondaries. fSuspendfSuspend
Suspend processing of the current track and push it and its Suspend processing of the current track and push it and its secondaries to the stack.secondaries to the stack.
fPostponeToNextEventfPostponeToNextEvent Postpone processing of the current track to the next event. Postpone processing of the current track to the next event. Secondaries are still being processed within the current event.Secondaries are still being processed within the current event.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1717
Set the track statusSet the track status In UserSteppingAction, user can change the status of a track.In UserSteppingAction, user can change the status of a track.
void MySteppingAction::UserSteppingActionvoid MySteppingAction::UserSteppingAction
(const G4Step * theStep)(const G4Step * theStep)
{{
G4Track* theTrack = theStep->G4Track* theTrack = theStep->GetTrackGetTrack();();
if(…) theTrack->if(…) theTrack->SetTrackStatusSetTrackStatus(fSuspend);(fSuspend);
}}
If a track is killed in UserSteppingAction, physics quantities of the If a track is killed in UserSteppingAction, physics quantities of the track (energy, charge, etc.) are not conserved but completely lost.track (energy, charge, etc.) are not conserved but completely lost.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1818
Step statusStep status Step status is attached to G4StepPoint to indicate why that particular Step status is attached to G4StepPoint to indicate why that particular
step was determined.step was determined. Use “Use “PostPostStepPoint” to get the status of this step.StepPoint” to get the status of this step. ““PrePreStepPoint” has the status of the previous step.StepPoint” has the status of the previous step.
fWorldBoundaryfWorldBoundary Step reached the world boundaryStep reached the world boundary
fGeomBoundary fGeomBoundary Step is limited by a volume boundary except the worldStep is limited by a volume boundary except the world
fAtRestDoItProc, fAlongStepDoItProc, fPostStepDoItProcfAtRestDoItProc, fAlongStepDoItProc, fPostStepDoItProc Step is limited by a AtRest, AlongStep or PostStep processStep is limited by a AtRest, AlongStep or PostStep process
fUserDefinedLimit fUserDefinedLimit Step is limited by the user Step limitStep is limited by the user Step limit
fExclusivelyForcedProc fExclusivelyForcedProc Step is limited by an exclusively forced (e.g. shower Step is limited by an exclusively forced (e.g. shower
parameterization) process parameterization) process fUndefined fUndefined
Step not defined yetStep not defined yet
If you want to identify If you want to identify the first step in a volumethe first step in a volume, pick , pick fGeomBoudaryfGeomBoudary status in status in PreStepPointPreStepPoint. .
If you want to identify If you want to identify a step getting out of a volumea step getting out of a volume, pick , pick fGeomBoundaryfGeomBoundary status in status in PostStepPointPostStepPoint
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 1919
Trajectory and trajectory pointTrajectory and trajectory point Trajectory and trajectory point class objects persist until the end of an Trajectory and trajectory point class objects persist until the end of an
event.event.
And most likely stored to disk as "simulation truth"And most likely stored to disk as "simulation truth"
G4VTrajectoryG4VTrajectory is the abstract base class to represent a trajectory, and is the abstract base class to represent a trajectory, and
G4VTrajectoryPointG4VTrajectoryPoint is the abstract base class to represent a point is the abstract base class to represent a point
which makes up the trajectory.which makes up the trajectory.
In general, trajectory class is expected to have a vector of In general, trajectory class is expected to have a vector of
trajectory points.trajectory points.
Geant4 provides Geant4 provides G4TrajectoyG4Trajectoy and and G4TrajectoryPointG4TrajectoryPoint concrete classes concrete classes
as defaults. These classes keep only the most common quantities.as defaults. These classes keep only the most common quantities.
If the user wants to keep some additional information and/or wants If the user wants to keep some additional information and/or wants
to change the drawing style of a trajectory, he/she is encouraged to change the drawing style of a trajectory, he/she is encouraged
to implement his/her own concrete classes.to implement his/her own concrete classes.
Basics of Primary Particle Generation and Tracking - M.Asai (SLAC)Basics of Primary Particle Generation and Tracking - M.Asai (SLAC) 2020
Creation of trajectoriesCreation of trajectories Naïve creation of trajectories occasionally causes a memory
consumption concern, especially for high energy EM showers. In UserTrackingAction, you can switch on/off the creation of a
trajectory for the particular track.
void MyTrackingAction
::PreUserTrackingAction(const G4Track* aTrack)
{
if(...)
{ fpTrackingManager->SetStoreTrajectory(true); }
else
{ fpTrackingManager->SetStoreTrajectory(false); }
}
If you want to use user-defined trajectory, object should be If you want to use user-defined trajectory, object should be instantiated in this method and set to G4TrackingManager by instantiated in this method and set to G4TrackingManager by SetTrajectory()SetTrajectory() method. method.