DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4GeneratorActionInit.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 
14 // Framework include files
15 #include <DD4hep/Printout.h>
16 #include <DD4hep/InstanceCount.h>
17 #include <DDG4/Geant4Kernel.h>
18 #include <DDG4/Geant4RunAction.h>
21 
22 #include <G4Run.hh>
23 
24 using namespace dd4hep::sim;
25 
28  : Geant4GeneratorAction(ctxt,nam)
29 {
33  declareProperty("numberOfEvents", m_evtTotal);
34  declareProperty("numberOfRuns", m_evtRun);
35 }
36 
40 }
41 
43 void Geant4GeneratorActionInit::begin(const G4Run* run) {
44  m_evtRun = 0;
45  m_run = run->GetRunID();
46 }
47 
49 void Geant4GeneratorActionInit::end(const G4Run* /* run */) {
50  printP1("+++ Finished run %d after %d events (%d events in total)",m_run,m_evtRun,m_evtTotal);
51  m_evtRun = 0;
52  m_run = 0;
53 }
54 
56 void Geant4GeneratorActionInit::operator()(G4Event* /* event */) {
58  ++m_evtTotal;
59  ++m_evtRun;
61  print("+++ Initializing event %d. Within run:%d event %d.",m_evtTotal,m_run,m_evtRun);
63 }
dd4hep::sim::Geant4Action::printP1
void printP1(const char *fmt,...) const
Support for messages with variable output level using output level+1.
Definition: Geant4Action.cpp:177
dd4hep::sim::Geant4GeneratorActionInit::operator()
virtual void operator()(G4Event *event)
Event generation action callback.
Definition: Geant4GeneratorActionInit.cpp:56
dd4hep::sim::Geant4GeneratorActionInit::Geant4GeneratorActionInit
Geant4GeneratorActionInit(Geant4Context *context, const std::string &nam)
Standard constructor.
Definition: Geant4GeneratorActionInit.cpp:27
dd4hep::sim::Geant4ActionContainer::runAction
Geant4RunActionSequence * runAction(bool create)
Access run action sequence.
Definition: Geant4ActionContainer.cpp:92
dd4hep::sim::Geant4GeneratorActionInit::end
void end(const G4Run *run)
End-run action callback.
Definition: Geant4GeneratorActionInit.cpp:49
dd4hep::sim::Geant4GeneratorActionInit::m_evtTotal
int m_evtTotal
Counter for total number of events.
Definition: Geant4GeneratorActionInit.h:59
dd4hep::sim::Geant4GeneratorActionInit::m_evtRun
int m_evtRun
Counter for total number of events in current run.
Definition: Geant4GeneratorActionInit.h:61
Geant4GeneratorActionInit.h
dd4hep::sim::Geant4GeneratorActionInit::~Geant4GeneratorActionInit
virtual ~Geant4GeneratorActionInit()
Default destructor.
Definition: Geant4GeneratorActionInit.cpp:38
Geant4RunAction.h
dd4hep::sim::generationInitialization
int generationInitialization(const Geant4Action *caller, const Geant4Context *context)
Initialize the generation of one event.
Definition: Geant4InputHandling.cpp:143
dd4hep::sim::Geant4RunActionSequence::callAtBegin
void callAtBegin(Q *p, void(T::*f)(const G4Run *))
Register begin-of-run callback. Types Q and T must be polymorph!
Definition: Geant4RunAction.h:144
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
Geant4InputHandling.h
dd4hep::sim::Geant4RunActionSequence::callAtEnd
void callAtEnd(Q *p, void(T::*f)(const G4Run *))
Register end-of-run callback. Types Q and T must be polymorph!
Definition: Geant4RunAction.h:149
dd4hep::sim::Geant4Action::declareProperty
Geant4Action & declareProperty(const std::string &nam, T &val)
Declare property.
Definition: Geant4Action.h:366
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4GeneratorAction
Concrete implementation of the Geant4 generator action base class.
Definition: Geant4GeneratorAction.h:47
dd4hep::sim::Geant4GeneratorActionInit::m_run
int m_run
Current run identifier.
Definition: Geant4GeneratorActionInit.h:57
dd4hep::sim::Geant4Action::print
void print(const char *fmt,...) const
Support for messages with variable output level using output level.
Definition: Geant4Action.cpp:144
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4Context::kernel
Geant4Kernel & kernel() const
Access to the kernel object.
Definition: Geant4Context.h:233
Geant4Kernel.h
InstanceCount.h
dd4hep::sim::Geant4GeneratorActionInit::begin
void begin(const G4Run *run)
Begin-run action callback.
Definition: Geant4GeneratorActionInit.cpp:43
Printout.h
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