DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4ParticleHandler.h
Go to the documentation of this file.
1 // $Id: $
2 //==========================================================================
3 // AIDA Detector description implementation for LCD
4 //--------------------------------------------------------------------------
5 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
6 // All rights reserved.
7 //
8 // For the licensing terms see $DD4hepINSTALL/LICENSE.
9 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
10 //
11 // Author : M.Frank
12 //
13 //==========================================================================
14 
15 #ifndef DD4HEP_DDG4_GEANT4PARTICLEHANDLER_H
16 #define DD4HEP_DDG4_GEANT4PARTICLEHANDLER_H
17 
18 // Framework include files
19 #include "DDG4/Geant4Primary.h"
22 
23 // Forward declarations
24 class G4Step;
25 class G4Track;
26 class G4Event;
27 class G4SteppingManager;
28 
30 namespace DD4hep {
31 
33  namespace Simulation {
34 
35  // Forward declarations
36  class Geant4UserParticleHandler;
37 
39 
64  public:
68 #if defined(__CINT__) || defined(__MAKECINT__) || defined(G__DICTIONARY)
69  // Need to force to public for the ROOT dictionary
70  public:
71 #else
72  private:
73 #endif
78 
79  public:
80  typedef std::vector<std::string> Processes;
81 
82  protected:
83 
90  bool m_keepAll;
99 
103 
105  int m_globalParticleID;
115 
117  int recombineParents();
119  void clear();
121  void checkConsistency() const;
122 
124  void rebaseSimulatedTracks(int base);
126  void dumpMap(const char* tag) const;
127 
129  void setVertexEndpointBit();
130 
131  public:
133  Geant4ParticleHandler(Geant4Context* context, const std::string& nam);
135  virtual ~Geant4ParticleHandler();
137  bool adopt(Geant4Action* action);
139  virtual void operator()(G4Event* event);
141  virtual void step(const G4Step* step, G4SteppingManager* mgr);
143  virtual void beginEvent(const G4Event* event);
145  virtual void endEvent(const G4Event* event);
147  virtual void begin(const G4Track* track);
149  virtual void end(const G4Track* track);
150 
152  virtual void mark(const G4Track* track);
154  virtual void mark(const G4Track* track, int reason);
156  virtual void mark(const G4Step* step);
158  virtual void mark(const G4Step* step, int reason);
159 
161  static bool defaultKeepParticle(Particle& particle);
162 
163  };
164  } // End namespace Simulation
165 } // End namespace DD4hep
166 
167 #endif // DD4HEP_DDG4_GEANT4PARTICLEHANDLER_H
Geant4ParticleMap::ParticleMap ParticleMap
TrackEquivalents m_equivalentTracks
Map associating the G4Track identifiers with identifiers of existing MCParticles. ...
virtual ~Geant4ParticleHandler()
Default destructor.
std::map< int, Particle * > ParticleMap
Processes m_processNames
Property: All the processes of which the decay products will be explicitly stored.
double m_kinEnergyCut
Property: Energy cut below which particles are not collected, but assigned to the parent...
Data structure to store the MC particle information.
bool m_ownsParticles
Property: Flag if the handler is executed in standalone mode and hence must manage particles...
Default Interface class to handle monte carlo truth records.
bool m_printStartTracking
Property: Steer printout at tracking action begin.
ParticleMap m_particleMap
Map with stored MC Particles.
void rebaseSimulatedTracks(int base)
Rebase the simulated tracks, so that they fit to the generator particles.
Geant4ParticleMap::TrackEquivalents TrackEquivalents
void dumpMap(const char *tag) const
Debugging: Dump Geant4 particle map.
virtual void beginEvent(const G4Event *event)
Pre-event action callback.
void checkConsistency() const
Check the record consistency.
Geant4ParticleHandler user extension action called by the particle handler.
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:261
Data structure to map primaries to particles.
Definition: Geant4Primary.h:65
virtual void mark(const G4Track *track)
Mark a Geant4 track to be kept for later MC truth analysis. Default flag: CREATED_HIT.
void setVertexEndpointBit()
set the endpointIsNotVertexOfParentFlag at the end of the event
Geant4PrimaryMap * m_primaryMap
Primary map.
double m_minDistToParentVertex
Property: Minimal distance after which the vertexIsNotEndpointOfParent flag is set.
virtual void end(const G4Track *track)
Post-track action callback.
Geant4Action to collect the MC particle information.
virtual void begin(const G4Track *track)
Pre-track action callback.
Particle m_currTrack
Local buffer about the 'current' G4Track.
Concrete implementation of the Geant4 generator action base class.
bool m_keepAll
Property: Flag to keep all particles generated.
int recombineParents()
Recombine particles and associate the to parents with cleanup.
Geant4ParticleHandler & operator=(const Geant4ParticleHandler &c)
No assignment operator.
virtual void step(const G4Step *step, G4SteppingManager *mgr)
User stepping callback.
static bool defaultKeepParticle(Particle &particle)
Default callback to be answered if the particle should be kept if NO user handler is installed...
Generic context to extend user, run and event information.
bool m_printEndTracking
Property: Steer printout at tracking action end.
int m_globalParticleID
Global particle identifier. Obtained at the begin of the event.
bool adopt(Geant4Action *action)
Adopt the user particle handler.
virtual void operator()(G4Event *event)
Event generation action callback.
Geant4UserParticleHandler * m_userHandler
User action pointer.
virtual void endEvent(const G4Event *event)
Post-event action callback.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91