DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
dd4hep::sim::Geant4ParticleHandler Class Reference

Geant4Action to collect the MC particle information. More...

#include <Geant4ParticleHandler.h>

Inheritance diagram for dd4hep::sim::Geant4ParticleHandler:
dd4hep::sim::Geant4GeneratorAction dd4hep::sim::Geant4MonteCarloTruth dd4hep::sim::Geant4Action

Public Types

typedef Geant4ParticleMap::Particle Particle
 
typedef Geant4ParticleMap::ParticleMap ParticleMap
 
typedef Geant4ParticleMap::TrackEquivalents TrackEquivalents
 
typedef std::vector< std::string > Processes
 
- Public Types inherited from dd4hep::sim::Geant4GeneratorAction
typedef Geant4SharedGeneratorAction shared_type
 

Public Member Functions

 Geant4ParticleHandler (Geant4Context *context, const std::string &nam)
 Standard constructor. More...
 
virtual ~Geant4ParticleHandler ()
 Default destructor. More...
 
bool adopt (Geant4Action *action)
 Adopt the user particle handler. More...
 
virtual void operator() (G4Event *event) override
 Event generation action callback. More...
 
virtual void step (const G4Step *step, G4SteppingManager *mgr)
 User stepping callback. More...
 
virtual void beginEvent (const G4Event *event)
 Pre-event action callback. More...
 
virtual void endEvent (const G4Event *event)
 Post-event action callback. More...
 
virtual void begin (const G4Track *track)
 Pre-track action callback. More...
 
virtual void end (const G4Track *track)
 Post-track action callback. More...
 
virtual void mark (const G4Track *track) override
 Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT. More...
 
virtual void mark (const G4Track *track, int reason) override
 Store a track. More...
 
virtual void mark (const G4Step *step) override
 Mark a Geant4 track of the step to be kept for later MC truth analysis. Default flag: CREATED_HIT. More...
 
virtual void mark (const G4Step *step, int reason) override
 Store a track produced in a step to be kept for later MC truth analysis. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4GeneratorAction
 Geant4GeneratorAction (Geant4Context *context, const std::string &name)
 Standard constructor. More...
 
virtual ~Geant4GeneratorAction ()
 Default destructor. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4Action
 Geant4Action (Geant4Context *context, const std::string &nam)
 Standard constructor. More...
 
long addRef ()
 Increase reference count. More...
 
long release ()
 Decrease reference count. Implicit destruction. More...
 
Geant4Contextcontext () const
 Access the context. More...
 
virtual void updateContext (Geant4Context *ctxt)
 Set or update client context. More...
 
virtual void configureFiber (Geant4Context *thread_context)
 Set or update client for the use in a new thread fiber. More...
 
const std::string & name () const
 Access name of the action. More...
 
const char * c_name () const
 Access name of the action. More...
 
void setName (const std::string &new_name)
 Set the object name. More...
 
PropertyManagerproperties ()
 Access to the properties of the object. More...
 
PrintLevel outputLevel () const
 Access the output level. More...
 
PrintLevel setOutputLevel (PrintLevel new_level)
 Set the output level; returns previous value. More...
 
Geant4UIMessengercontrol () const
 Access to the UI messenger. More...
 
virtual void enableUI ()
 Enable and install UI messenger. More...
 
template<typename T >
Geant4ActiondeclareProperty (const std::string &nam, T &val)
 Declare property. More...
 
template<typename T >
Geant4ActiondeclareProperty (const char *nam, T &val)
 Declare property. More...
 
bool hasProperty (const std::string &name) const
 Check property for existence. More...
 
Propertyproperty (const std::string &name)
 Access single property. More...
 
virtual void installMessengers ()
 Install property control messenger if wanted. More...
 
virtual void installCommandMessenger ()
 Install command control messenger if wanted. More...
 
virtual void installPropertyMessenger ()
 Install property control messenger if wanted. More...
 
void print (const char *fmt,...) const
 Support for messages with variable output level using output level. More...
 
void printM1 (const char *fmt,...) const
 Support for messages with variable output level using output level-1. More...
 
void printM2 (const char *fmt,...) const
 Support for messages with variable output level using output level-2. More...
 
void printP1 (const char *fmt,...) const
 Support for messages with variable output level using output level+1. More...
 
void printP2 (const char *fmt,...) const
 Support for messages with variable output level using output level+2. More...
 
void always (const char *fmt,...) const
 Support of always printed messages. More...
 
void debug (const char *fmt,...) const
 Support of debug messages. More...
 
void info (const char *fmt,...) const
 Support of info messages. More...
 
void warning (const char *fmt,...) const
 Support of warning messages. More...
 
void error (const char *fmt,...) const
 Support of error messages. More...
 
bool return_error (bool return_value, const char *fmt,...) const
 Action to support error messages. More...
 
void fatal (const char *fmt,...) const
 Support of fatal messages. Throws exception. More...
 
void except (const char *fmt,...) const
 Support of exceptions: Print fatal message and throw runtime_error. More...
 
void abortRun (const std::string &exception, const char *fmt,...) const
 Abort Geant4 Run by throwing a G4Exception with type RunMustBeAborted. More...
 
Geant4RunActionSequencerunAction () const
 Access to the main run action sequence from the kernel object. More...
 
Geant4EventActionSequenceeventAction () const
 Access to the main event action sequence from the kernel object. More...
 
Geant4SteppingActionSequencesteppingAction () const
 Access to the main stepping action sequence from the kernel object. More...
 
Geant4TrackingActionSequencetrackingAction () const
 Access to the main tracking action sequence from the kernel object. More...
 
Geant4StackingActionSequencestackingAction () const
 Access to the main stacking action sequence from the kernel object. More...
 
Geant4GeneratorActionSequencegeneratorAction () const
 Access to the main generator action sequence from the kernel object. More...
 
- Public Member Functions inherited from dd4hep::sim::Geant4MonteCarloTruth
virtual ~Geant4MonteCarloTruth ()
 Default destructor. More...
 

Static Public Member Functions

static bool defaultKeepParticle (Particle &particle)
 Default callback to be answered if the particle should be kept if NO user handler is installed. More...
 

Protected Member Functions

int recombineParents ()
 Recombine particles and associate the to parents with cleanup. More...
 
void clear ()
 Clear particle maps. More...
 
void checkConsistency () const
 Check the record consistency. More...
 
void rebaseSimulatedTracks (int base)
 Rebase the simulated tracks, so that they fit to the generator particles. More...
 
void dumpMap (const char *tag) const
 Debugging: Dump Geant4 particle map. More...
 
void setVertexEndpointBit ()
 set the endpointIsNotVertexOfParentFlag at the end of the event More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4GeneratorAction
 DDG4_DEFINE_ACTION_CONSTRUCTORS (Geant4GeneratorAction)
 Define standard assignments and constructors. More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4Action
 DDG4_DEFINE_ACTION_CONSTRUCTORS (Geant4Action)
 Define standard assignments and constructors. More...
 
virtual ~Geant4Action ()
 Default destructor. More...
 
- Protected Member Functions inherited from dd4hep::sim::Geant4MonteCarloTruth
 Geant4MonteCarloTruth ()
 Standard constructor. More...
 

Protected Attributes

bool m_printStartTracking
 Property: Steer printout at tracking action begin. More...
 
bool m_printEndTracking
 Property: Steer printout at tracking action end. More...
 
bool m_keepAll
 Property: Flag to keep all particles generated. More...
 
bool m_ownsParticles
 Property: Flag if the handler is executed in standalone mode and hence must manage particles. More...
 
double m_kinEnergyCut
 Property: Energy cut below which particles are not collected, but assigned to the parent. More...
 
double m_minDistToParentVertex
 Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set. More...
 
Processes m_processNames
 Property: All the processes of which the decay products will be explicitly stored. More...
 
Geant4UserParticleHandlerm_userHandler
 User action pointer. More...
 
int m_globalParticleID
 Global particle identifier. Obtained at the begin of the event. More...
 
Geant4PrimaryMapm_primaryMap
 Primary map. More...
 
Particle m_currTrack
 Local buffer about the 'current' G4Track. More...
 
ParticleMap m_particleMap
 Map with stored MC Particles. More...
 
ParticleMap m_suspendedPM
 Map with stored MC Particles that were suspended by the stepping action. More...
 
bool m_haveSuspended = false
 
TrackEquivalents m_equivalentTracks
 Map associating the G4Track identifiers with identifiers of existing MCParticles. More...
 
- Protected Attributes inherited from dd4hep::sim::Geant4GeneratorAction
Callback m_calls
 
- Protected Attributes inherited from dd4hep::sim::Geant4Action
Geant4Contextm_context { nullptr }
 Reference to the Geant4 context. More...
 
Geant4UIMessengerm_control { nullptr }
 Control directory of this action. More...
 
int m_outputLevel { 3 }
 Default property: Output level. More...
 
bool m_needsControl { false }
 Default property: Flag to create control instance. More...
 
std::string m_name { }
 Action name. More...
 
PropertyManager m_properties { }
 Property pool. More...
 
long m_refCount { 1 }
 Reference count. Initial value: 1. More...
 

Private Member Functions

 Geant4ParticleHandler ()
 No default constructor. More...
 
Geant4ParticleHandleroperator= (const Geant4ParticleHandler &c)
 No assignment operator. More...
 

Detailed Description

Geant4Action to collect the MC particle information.

Extract the relevant particle information during the simulation step.

This procedure works as follows:

Any of these actions may be intercepted by a {\tt{Geant4UserParticleHandler}} attached to the particle handler. See class {\tt{Geant4UserParticleHandler}} for details.

Author
M.Frank
Version
1.0

Definition at line 72 of file Geant4ParticleHandler.h.

Member Typedef Documentation

◆ Particle

Definition at line 74 of file Geant4ParticleHandler.h.

◆ ParticleMap

Definition at line 75 of file Geant4ParticleHandler.h.

◆ Processes

typedef std::vector<std::string> dd4hep::sim::Geant4ParticleHandler::Processes

Definition at line 89 of file Geant4ParticleHandler.h.

◆ TrackEquivalents

Definition at line 76 of file Geant4ParticleHandler.h.

Constructor & Destructor Documentation

◆ Geant4ParticleHandler() [1/2]

dd4hep::sim::Geant4ParticleHandler::Geant4ParticleHandler ( )
private

No default constructor.

◆ Geant4ParticleHandler() [2/2]

dd4hep::sim::Geant4ParticleHandler::Geant4ParticleHandler ( Geant4Context context,
const std::string &  nam 
)

Standard constructor.

◆ ~Geant4ParticleHandler()

virtual dd4hep::sim::Geant4ParticleHandler::~Geant4ParticleHandler ( )
virtual

Default destructor.

Member Function Documentation

◆ adopt()

bool dd4hep::sim::Geant4ParticleHandler::adopt ( Geant4Action action)

Adopt the user particle handler.

◆ begin()

virtual void dd4hep::sim::Geant4ParticleHandler::begin ( const G4Track *  track)
virtual

Pre-track action callback.

◆ beginEvent()

virtual void dd4hep::sim::Geant4ParticleHandler::beginEvent ( const G4Event *  event)
virtual

Pre-event action callback.

◆ checkConsistency()

void dd4hep::sim::Geant4ParticleHandler::checkConsistency ( ) const
protected

Check the record consistency.

◆ clear()

void dd4hep::sim::Geant4ParticleHandler::clear ( )
protected

Clear particle maps.

◆ defaultKeepParticle()

static bool dd4hep::sim::Geant4ParticleHandler::defaultKeepParticle ( Particle particle)
static

Default callback to be answered if the particle should be kept if NO user handler is installed.

◆ dumpMap()

void dd4hep::sim::Geant4ParticleHandler::dumpMap ( const char *  tag) const
protected

Debugging: Dump Geant4 particle map.

◆ end()

virtual void dd4hep::sim::Geant4ParticleHandler::end ( const G4Track *  track)
virtual

Post-track action callback.

◆ endEvent()

virtual void dd4hep::sim::Geant4ParticleHandler::endEvent ( const G4Event *  event)
virtual

Post-event action callback.

◆ mark() [1/4]

virtual void dd4hep::sim::Geant4ParticleHandler::mark ( const G4Step *  step)
overridevirtual

Mark a Geant4 track of the step to be kept for later MC truth analysis. Default flag: CREATED_HIT.

Implements dd4hep::sim::Geant4MonteCarloTruth.

◆ mark() [2/4]

virtual void dd4hep::sim::Geant4ParticleHandler::mark ( const G4Step *  step,
int  reason 
)
overridevirtual

Store a track produced in a step to be kept for later MC truth analysis.

Implements dd4hep::sim::Geant4MonteCarloTruth.

◆ mark() [3/4]

virtual void dd4hep::sim::Geant4ParticleHandler::mark ( const G4Track *  track)
overridevirtual

Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT.

Implements dd4hep::sim::Geant4MonteCarloTruth.

◆ mark() [4/4]

virtual void dd4hep::sim::Geant4ParticleHandler::mark ( const G4Track *  track,
int  reason 
)
overridevirtual

Store a track.

Implements dd4hep::sim::Geant4MonteCarloTruth.

◆ operator()()

virtual void dd4hep::sim::Geant4ParticleHandler::operator() ( G4Event *  event)
overridevirtual

Event generation action callback.

Reimplemented from dd4hep::sim::Geant4GeneratorAction.

◆ operator=()

Geant4ParticleHandler& dd4hep::sim::Geant4ParticleHandler::operator= ( const Geant4ParticleHandler c)
private

No assignment operator.

◆ rebaseSimulatedTracks()

void dd4hep::sim::Geant4ParticleHandler::rebaseSimulatedTracks ( int  base)
protected

Rebase the simulated tracks, so that they fit to the generator particles.

◆ recombineParents()

int dd4hep::sim::Geant4ParticleHandler::recombineParents ( )
protected

Recombine particles and associate the to parents with cleanup.

◆ setVertexEndpointBit()

void dd4hep::sim::Geant4ParticleHandler::setVertexEndpointBit ( )
protected

set the endpointIsNotVertexOfParentFlag at the end of the event

◆ step()

virtual void dd4hep::sim::Geant4ParticleHandler::step ( const G4Step *  step,
G4SteppingManager *  mgr 
)
virtual

User stepping callback.

Member Data Documentation

◆ m_currTrack

Particle dd4hep::sim::Geant4ParticleHandler::m_currTrack
protected

Local buffer about the 'current' G4Track.

Definition at line 119 of file Geant4ParticleHandler.h.

◆ m_equivalentTracks

TrackEquivalents dd4hep::sim::Geant4ParticleHandler::m_equivalentTracks
protected

Map associating the G4Track identifiers with identifiers of existing MCParticles.

Definition at line 126 of file Geant4ParticleHandler.h.

◆ m_globalParticleID

int dd4hep::sim::Geant4ParticleHandler::m_globalParticleID
protected

Global particle identifier. Obtained at the begin of the event.

EVENT DEPENDENT: variables containing data depending on the current event.

Definition at line 115 of file Geant4ParticleHandler.h.

◆ m_haveSuspended

bool dd4hep::sim::Geant4ParticleHandler::m_haveSuspended = false
protected

Definition at line 124 of file Geant4ParticleHandler.h.

◆ m_keepAll

bool dd4hep::sim::Geant4ParticleHandler::m_keepAll
protected

Property: Flag to keep all particles generated.

Definition at line 99 of file Geant4ParticleHandler.h.

◆ m_kinEnergyCut

double dd4hep::sim::Geant4ParticleHandler::m_kinEnergyCut
protected

Property: Energy cut below which particles are not collected, but assigned to the parent.

Definition at line 103 of file Geant4ParticleHandler.h.

◆ m_minDistToParentVertex

double dd4hep::sim::Geant4ParticleHandler::m_minDistToParentVertex
protected

Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set.

Definition at line 105 of file Geant4ParticleHandler.h.

◆ m_ownsParticles

bool dd4hep::sim::Geant4ParticleHandler::m_ownsParticles
protected

Property: Flag if the handler is executed in standalone mode and hence must manage particles.

Definition at line 101 of file Geant4ParticleHandler.h.

◆ m_particleMap

ParticleMap dd4hep::sim::Geant4ParticleHandler::m_particleMap
protected

Map with stored MC Particles.

Definition at line 121 of file Geant4ParticleHandler.h.

◆ m_primaryMap

Geant4PrimaryMap* dd4hep::sim::Geant4ParticleHandler::m_primaryMap
protected

Primary map.

Definition at line 117 of file Geant4ParticleHandler.h.

◆ m_printEndTracking

bool dd4hep::sim::Geant4ParticleHandler::m_printEndTracking
protected

Property: Steer printout at tracking action end.

Definition at line 97 of file Geant4ParticleHandler.h.

◆ m_printStartTracking

bool dd4hep::sim::Geant4ParticleHandler::m_printStartTracking
protected

Property: Steer printout at tracking action begin.

Property variables used to configure the object

Definition at line 95 of file Geant4ParticleHandler.h.

◆ m_processNames

Processes dd4hep::sim::Geant4ParticleHandler::m_processNames
protected

Property: All the processes of which the decay products will be explicitly stored.

Definition at line 107 of file Geant4ParticleHandler.h.

◆ m_suspendedPM

ParticleMap dd4hep::sim::Geant4ParticleHandler::m_suspendedPM
protected

Map with stored MC Particles that were suspended by the stepping action.

Definition at line 123 of file Geant4ParticleHandler.h.

◆ m_userHandler

Geant4UserParticleHandler* dd4hep::sim::Geant4ParticleHandler::m_userHandler
protected

User action pointer.

Object variables, which are constant after initialization

Definition at line 111 of file Geant4ParticleHandler.h.


The documentation for this class was generated from the following file: