DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
Geant4UserInitialization.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/InstanceCount.h>
17 
18 using namespace dd4hep::sim;
19 
22  : Geant4Action(ctxt, nam) {
23  m_needsControl = false;
25 }
26 
30 }
31 
34 }
35 
38 }
39 
42  : Geant4UserInitialization(ctxt, nam) {
43  m_needsControl = false;
45 }
46 
53  m_actors.clear();
54 }
55 
58  if (action) {
59  action->addRef();
60  m_actors.add(action);
61  return;
62  }
63  except("Attempt to add invalid actor!");
64 }
65 
69  m_workerCalls();
70 }
71 
75  m_masterCalls();
76 }
77 
80  m_context = ctxt;
81  m_actors.updateContext(ctxt);
82 }
83 
dd4hep::sim::Geant4UserInitializationSequence::adopt
void adopt(Geant4UserInitialization *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Definition: Geant4UserInitialization.cpp:57
dd4hep::sim::Geant4Action::m_needsControl
bool m_needsControl
Default property: Flag to create control instance.
Definition: Geant4Action.h:123
dd4hep::sim::Geant4Action::m_context
Geant4Context * m_context
Reference to the Geant4 context.
Definition: Geant4Action.h:116
dd4hep::sim::Geant4UserInitialization::~Geant4UserInitialization
virtual ~Geant4UserInitialization()
Default destructor.
Definition: Geant4UserInitialization.cpp:28
dd4hep::InstanceCount::increment
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
dd4hep::sim::Geant4UserInitialization::build
virtual void build() const
Callback function to build setup for the MT worker thread.
Definition: Geant4UserInitialization.cpp:33
dd4hep::sim::Geant4UserInitializationSequence::m_actors
Actors< Geant4UserInitialization > m_actors
The list of action objects to be called.
Definition: Geant4UserInitialization.h:59
dd4hep::sim::Geant4UserInitialization::Geant4UserInitialization
Geant4UserInitialization(Geant4Context *c, const std::string &nam)
Standard constructor.
Definition: Geant4UserInitialization.cpp:21
dd4hep::sim::Geant4Action::except
void except(const char *fmt,...) const
Support of exceptions: Print fatal message and throw runtime_error.
Definition: Geant4Action.cpp:256
dd4hep::InstanceCount::decrement
static void decrement(T *)
Decrement count according to type information.
Definition: InstanceCount.h:102
dd4hep::sim::Geant4UserInitialization
Base class to initialize a multi-threaded or single threaded Geant4 application.
Definition: Geant4UserInitialization.h:33
dd4hep::sim::Geant4Action
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:113
dd4hep::sim::Geant4Action::release
long release()
Decrease reference count. Implicit destruction.
Definition: Geant4Action.cpp:76
dd4hep::sim::Geant4UserInitializationSequence::m_masterCalls
CallbackSequence m_masterCalls
Callback sequence to initialize the thread master.
Definition: Geant4UserInitialization.h:55
dd4hep::sim::Geant4UserInitializationSequence::m_workerCalls
CallbackSequence m_workerCalls
Callback sequence to initialize worker elements.
Definition: Geant4UserInitialization.h:57
dd4hep::CallbackSequence::clear
void clear()
Clear the sequence and remove all callbacks.
Definition: Callback.h:363
dd4hep::sim::Geant4Action::addRef
long addRef()
Increase reference count.
Definition: Geant4Action.cpp:71
dd4hep::sim
Namespace for the Geant4 based simulation part of the AIDA detector description toolkit.
Definition: Geant4Output2EDM4hep.cpp:49
dd4hep::sim::Geant4UserInitializationSequence::~Geant4UserInitializationSequence
virtual ~Geant4UserInitializationSequence()
Default destructor.
Definition: Geant4UserInitialization.cpp:48
dd4hep::sim::Geant4UserInitializationSequence::updateContext
virtual void updateContext(Geant4Context *ctxt) override
Set client context.
Definition: Geant4UserInitialization.cpp:79
dd4hep::sim::Geant4UserInitialization::buildMaster
virtual void buildMaster() const
Callback function to build setup for the MT master thread.
Definition: Geant4UserInitialization.cpp:37
Geant4UserInitialization.h
dd4hep::sim::Geant4UserInitializationSequence::build
virtual void build() const override
Callback function to build setup for the MT worker thread.
Definition: Geant4UserInitialization.cpp:67
dd4hep::sim::Geant4UserInitializationSequence::Geant4UserInitializationSequence
Geant4UserInitializationSequence(Geant4Context *c, const std::string &nam)
Standard constructor.
Definition: Geant4UserInitialization.cpp:41
InstanceCount.h
dd4hep::sim::Geant4UserInitializationSequence::buildMaster
virtual void buildMaster() const override
Callback function to build setup for the MT master thread.
Definition: Geant4UserInitialization.cpp:73
dd4hep::sim::Geant4Context
Generic context to extend user, run and event information.
Definition: Geant4Context.h:201