DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4ParticleDumpAction.cpp
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 #ifndef DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H
14 #define DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H
15 
16 // Framework include files
17 #include <DDG4/Geant4EventAction.h>
18 
19 // Forward declarations
20 class G4VHitsCollection;
21 
23 namespace dd4hep {
24 
26  namespace sim {
27 
28  // Forward declarations
29  class Geant4ParticleMap;
30 
32 
40  public:
42  Geant4ParticleDumpAction(Geant4Context* context, const std::string& nam);
44  virtual ~Geant4ParticleDumpAction();
46  virtual void begin(const G4Event* event) override;
48  virtual void end(const G4Event* event) override;
49  };
50 
51  } // End namespace sim
52 } // End namespace dd4hep
53 
54 #endif /* DD4HEP_DDG4_GEANT4PARTICLEDUMPACTION_H */
55 
56 //====================================================================
57 // AIDA Detector description implementation
58 //--------------------------------------------------------------------
59 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
60 // All rights reserved.
61 //
62 // For the licensing terms see $DD4hepINSTALL/LICENSE.
63 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
64 //
65 // Author : M.Frank
66 //
67 //====================================================================
68 
69 // Framework include files
70 #include <DD4hep/InstanceCount.h>
71 #include <DDG4/Geant4DataDump.h>
73 
74 // Geant 4 includes
75 #include <G4HCofThisEvent.hh>
76 #include <G4Event.hh>
77 
78 using namespace dd4hep::sim;
79 
82  : Geant4EventAction(ctxt, nam)
83 {
84  m_needsControl = true;
86 }
87 
91 }
92 
94 void Geant4ParticleDumpAction::begin(const G4Event* /* event */) {
95 }
96 
98 void Geant4ParticleDumpAction::end(const G4Event* event) {
100  if ( parts ) {
101  Geant4DataDump dump(name());
102  dump.print(ALWAYS,parts);
103  return;
104  }
105  warning("+++ [Event:%d] No particle map available!",event->GetEventID());
106 }
107 
108 #include <DDG4/Factories.h>
dd4hep::sim::Geant4Action::m_needsControl
bool m_needsControl
Default property: Flag to create control instance.
Definition: Geant4Action.h:123
Geant4HitCollection.h
dd4hep::sim::Geant4DataDump
Class to dump the records of the intrinsic Geant4 event model.
Definition: Geant4DataDump.h:37
Geant4EventAction.h
G4VHitsCollection
Class of the Geant4 toolkit. See http://www-geant4.kek.jp/Reference.
Definition: Geant4Classes.h:47
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::sim::Geant4Context::event
Geant4Event & event() const
Access the geant4 event – valid only between BeginEvent() and EndEvent()!
Definition: Geant4Context.cpp:84
DECLARE_GEANT4ACTION
#define DECLARE_GEANT4ACTION(name)
Plugin defintion to create Geant4Action objects.
Definition: Factories.h:210
dd4hep::sim::Geant4Action::warning
void warning(const char *fmt,...) const
Support of warning messages.
Definition: Geant4Action.cpp:223
Geant4DataDump.h
dd4hep::sim::Geant4ParticleMap
Data structure to map particles produced during the generation and the simulation.
Definition: Geant4Particle.h:337
dd4hep::sim::Geant4Event::extension
T * extension(bool alert=true)
Access to type safe extension object. Exception is thrown if the object is invalid.
Definition: Geant4Context.h:151
dd4hep::sim::Geant4EventAction
Concrete basic implementation of the Geant4 event action.
Definition: Geant4EventAction.h:53
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4Action::name
const std::string & name() const
Access name of the action.
Definition: Geant4Action.h:280
dd4hep::sim::Geant4ParticleDumpAction::end
virtual void end(const G4Event *event) override
Geant4EventAction interface: End-of-event callback.
Definition: Geant4ParticleDumpAction.cpp:98
dd4hep::sim::Geant4ParticleDumpAction::Geant4ParticleDumpAction
Geant4ParticleDumpAction(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4ParticleDumpAction.cpp:81
Factories.h
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28
dd4hep::sim::Geant4ParticleDumpAction
Class to measure the energy of escaping tracks.
Definition: Geant4ParticleDumpAction.cpp:39
dd4hep::sim::Geant4ParticleDumpAction::begin
virtual void begin(const G4Event *event) override
Geant4EventAction interface: Begin-of-event callback.
Definition: Geant4ParticleDumpAction.cpp:94
InstanceCount.h
dd4hep::sim::Geant4ParticleDumpAction::~Geant4ParticleDumpAction
virtual ~Geant4ParticleDumpAction()
Default destructor.
Definition: Geant4ParticleDumpAction.cpp:89
dd4hep::sim::Geant4DataDump::print
void print(PrintLevel level, Geant4ParticleHandle p) const
Print a single particle to the output logging using the specified print level.
Definition: Geant4DataDump.cpp:30
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201
dd4hep::sim::Geant4Action::context
Geant4Context * context() const
Access the context.
Definition: Geant4Action.h:270