DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4ParticleHandler.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 
24 #ifndef DDG4_GEANT4PARTICLEHANDLER_H
25 #define DDG4_GEANT4PARTICLEHANDLER_H
26 
27 // Framework include files
28 #include <DDG4/Geant4Primary.h>
31 
32 // Forward declarations
33 class G4Step;
34 class G4Track;
35 class G4Event;
36 class G4SteppingManager;
37 
39 namespace dd4hep {
40 
42  namespace sim {
43 
44  // Forward declarations
46 
48 
73  public:
77 #if defined(__CINT__) || defined(__MAKECINT__) || defined(G__DICTIONARY)
78  // Need to force to public for the ROOT dictionary
79  public:
80 #else
81  private:
82 #endif
87 
88  public:
89  typedef std::vector<std::string> Processes;
90 
91  protected:
92 
99  bool m_keepAll;
108 
112 
114  int m_globalParticleID;
124  bool m_haveSuspended = false;
127 
131  void clear();
133  void checkConsistency() const;
134 
136  void rebaseSimulatedTracks(int base);
138  void dumpMap(const char* tag) const;
139 
142 
143  public:
145  Geant4ParticleHandler(Geant4Context* context, const std::string& nam);
149  bool adopt(Geant4Action* action);
151  virtual void operator()(G4Event* event) override;
153  virtual void step(const G4Step* step, G4SteppingManager* mgr);
155  virtual void beginEvent(const G4Event* event);
157  virtual void endEvent(const G4Event* event);
159  virtual void begin(const G4Track* track);
161  virtual void end(const G4Track* track);
162 
164  virtual void mark(const G4Track* track) override;
166  virtual void mark(const G4Track* track, int reason) override;
168  virtual void mark(const G4Step* step) override;
170  virtual void mark(const G4Step* step, int reason) override;
171 
173  static bool defaultKeepParticle(Particle& particle);
174 
175  };
176  } // End namespace sim
177 } // End namespace dd4hep
178 
179 #endif // DDG4_GEANT4PARTICLEHANDLER_H
Geant4MonteCarloTruth.h
dd4hep::sim::Geant4ParticleHandler::endEvent
virtual void endEvent(const G4Event *event)
Post-event action callback.
dd4hep::sim::Geant4ParticleHandler::m_keepAll
bool m_keepAll
Property: Flag to keep all particles generated.
Definition: Geant4ParticleHandler.h:99
dd4hep::sim::Geant4ParticleHandler::Geant4ParticleHandler
Geant4ParticleHandler()
No default constructor.
dd4hep::sim::Geant4PrimaryMap
Data structure to map primaries to particles.
Definition: Geant4Primary.h:64
dd4hep::sim::Geant4ParticleHandler::Particle
Geant4ParticleMap::Particle Particle
Definition: Geant4ParticleHandler.h:74
Geant4ParticleHandler
Geant4Action to collect the MC particle information.
dd4hep::sim::Geant4ParticleHandler::recombineParents
int recombineParents()
Recombine particles and associate the to parents with cleanup.
dd4hep::sim::Geant4ParticleHandler::m_primaryMap
Geant4PrimaryMap * m_primaryMap
Primary map.
Definition: Geant4ParticleHandler.h:117
dd4hep::sim::Geant4ParticleHandler::m_printEndTracking
bool m_printEndTracking
Property: Steer printout at tracking action end.
Definition: Geant4ParticleHandler.h:97
dd4hep::sim::Geant4ParticleHandler::m_processNames
Processes m_processNames
Property: All the processes of which the decay products will be explicitly stored.
Definition: Geant4ParticleHandler.h:107
dd4hep::sim::Geant4ParticleHandler::operator=
Geant4ParticleHandler & operator=(const Geant4ParticleHandler &c)
No assignment operator.
dd4hep::sim::Geant4ParticleHandler::checkConsistency
void checkConsistency() const
Check the record consistency.
dd4hep::sim::Geant4ParticleHandler::begin
virtual void begin(const G4Track *track)
Pre-track action callback.
dd4hep::sim::Geant4ParticleHandler::mark
virtual void mark(const G4Step *step, int reason) override
Store a track produced in a step to be kept for later MC truth analysis.
dd4hep::sim::Geant4ParticleMap::TrackEquivalents
std::map< int, int > TrackEquivalents
Definition: Geant4Particle.h:341
dd4hep::sim::Geant4ParticleHandler::step
virtual void step(const G4Step *step, G4SteppingManager *mgr)
User stepping callback.
dd4hep::sim::Geant4ParticleHandler::~Geant4ParticleHandler
virtual ~Geant4ParticleHandler()
Default destructor.
dd4hep::sim::Geant4ParticleHandler::m_equivalentTracks
TrackEquivalents m_equivalentTracks
Map associating the G4Track identifiers with identifiers of existing MCParticles.
Definition: Geant4ParticleHandler.h:126
dd4hep::sim::Geant4ParticleHandler::Processes
std::vector< std::string > Processes
Definition: Geant4ParticleHandler.h:89
dd4hep::sim::Geant4ParticleHandler::m_suspendedPM
ParticleMap m_suspendedPM
Map with stored MC Particles that were suspended by the stepping action.
Definition: Geant4ParticleHandler.h:123
dd4hep::sim::Geant4ParticleHandler::dumpMap
void dumpMap(const char *tag) const
Debugging: Dump Geant4 particle map.
Geant4UserParticleHandler
Geant4ParticleHandler user extension action called by the particle handler.
Geant4GeneratorAction.h
dd4hep::sim::Geant4ParticleHandler::rebaseSimulatedTracks
void rebaseSimulatedTracks(int base)
Rebase the simulated tracks, so that they fit to the generator particles.
dd4hep::sim::Geant4ParticleHandler::TrackEquivalents
Geant4ParticleMap::TrackEquivalents TrackEquivalents
Definition: Geant4ParticleHandler.h:76
dd4hep::sim::Geant4ParticleMap::ParticleMap
std::map< int, Particle * > ParticleMap
Definition: Geant4Particle.h:340
dd4hep::sim::Geant4MonteCarloTruth
Default Interface class to handle monte carlo truth records.
Definition: Geant4MonteCarloTruth.h:43
dd4hep::sim::Geant4ParticleHandler::mark
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.
dd4hep::sim::Geant4GeneratorAction
Concrete implementation of the Geant4 generator action base class.
Definition: Geant4GeneratorAction.h:47
dd4hep::sim::Geant4ParticleHandler::m_minDistToParentVertex
double m_minDistToParentVertex
Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set.
Definition: Geant4ParticleHandler.h:105
dd4hep::sim::Geant4ParticleHandler::adopt
bool adopt(Geant4Action *action)
Adopt the user particle handler.
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4ParticleHandler::defaultKeepParticle
static bool defaultKeepParticle(Particle &particle)
Default callback to be answered if the particle should be kept if NO user handler is installed.
dd4hep::sim::Geant4ParticleHandler::m_globalParticleID
int m_globalParticleID
Global particle identifier. Obtained at the begin of the event.
Definition: Geant4ParticleHandler.h:115
dd4hep::sim::Geant4ParticleHandler::m_particleMap
ParticleMap m_particleMap
Map with stored MC Particles.
Definition: Geant4ParticleHandler.h:121
dd4hep::sim::Geant4ParticleHandler::m_haveSuspended
bool m_haveSuspended
Definition: Geant4ParticleHandler.h:124
dd4hep::sim::Geant4ParticleHandler::operator()
virtual void operator()(G4Event *event) override
Event generation action callback.
dd4hep::sim::Geant4ParticleHandler::setVertexEndpointBit
void setVertexEndpointBit()
set the endpointIsNotVertexOfParentFlag at the end of the event
dd4hep::sim::Geant4ParticleHandler::mark
virtual void mark(const G4Track *track, int reason) override
Store a track.
dd4hep::sim::Geant4ParticleHandler::m_userHandler
Geant4UserParticleHandler * m_userHandler
User action pointer.
Definition: Geant4ParticleHandler.h:111
dd4hep::sim::Geant4ParticleHandler::mark
virtual void mark(const G4Track *track) override
Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT.
dd4hep::sim::Geant4ParticleHandler::m_ownsParticles
bool m_ownsParticles
Property: Flag if the handler is executed in standalone mode and hence must manage particles.
Definition: Geant4ParticleHandler.h:101
dd4hep::sim::Geant4ParticleHandler::m_printStartTracking
bool m_printStartTracking
Property: Steer printout at tracking action begin.
Definition: Geant4ParticleHandler.h:95
dd4hep::sim::Geant4ParticleHandler::clear
void clear()
Clear particle maps.
Geant4Primary.h
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4ParticleHandler::m_currTrack
Particle m_currTrack
Local buffer about the 'current' G4Track.
Definition: Geant4ParticleHandler.h:119
dd4hep::sim::Geant4ParticleHandler::m_kinEnergyCut
double m_kinEnergyCut
Property: Energy cut below which particles are not collected, but assigned to the parent.
Definition: Geant4ParticleHandler.h:103
dd4hep::sim::Geant4ParticleHandler::end
virtual void end(const G4Track *track)
Post-track action callback.
dd4hep::sim::Geant4Particle
Data structure to store the MC particle information.
Definition: Geant4Particle.h:103
dd4hep::sim::Geant4ParticleHandler::ParticleMap
Geant4ParticleMap::ParticleMap ParticleMap
Definition: Geant4ParticleHandler.h:75
dd4hep::sim::Geant4ParticleHandler::beginEvent
virtual void beginEvent(const G4Event *event)
Pre-event action callback.
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4ParticleHandler::Geant4ParticleHandler
Geant4ParticleHandler(Geant4Context *context, const std::string &nam)
Standard constructor.
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270