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
Geant4UserInitialization.cpp
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 // Framework include files
16 #include "DD4hep/InstanceCount.h"
18 
19 // C/C++ include files
20 #include <stdexcept>
21 
22 using namespace std;
23 using namespace DD4hep::Simulation;
24 
26 Geant4UserInitialization::Geant4UserInitialization(Geant4Context* ctxt, const string& nam)
27  : Geant4Action(ctxt, nam) {
28  m_needsControl = false;
30 }
31 
35 }
36 
39 }
40 
43 }
44 
47  : Geant4UserInitialization(ctxt, nam) {
48  m_needsControl = false;
50 }
51 
58  m_actors.clear();
59 }
60 
63  if (action) {
64  action->addRef();
65  m_actors.add(action);
66  return;
67  }
68  throw runtime_error("Geant4UserInitializationSequence: Attempt to add invalid actor!");
69 }
70 
74  m_workerCalls();
75 }
76 
80  m_masterCalls();
81 }
82 
85  m_context = ctxt;
86  m_actors.updateContext(ctxt);
87 }
88 
long release()
Decrease reference count. Implicit destruction.
Actors< Geant4UserInitialization > m_actors
The list of action objects to be called.
virtual void build() const
Callback function to build setup for the MT worker thread.
static void decrement(T *)
Decrement count according to type information.
CallbackSequence m_masterCalls
Callback sequence to initialize the thread master.
Geant4Context * m_context
Reference to the Geant4 context.
Definition: Geant4Action.h:94
CallbackSequence m_workerCalls
Callback sequence to initialize worker elements.
long addRef()
Increase reference count.
void clear()
Clear the sequence and remove all callbacks.
Definition: Callback.h:358
virtual void buildMaster() const
Callback function to build setup for the MT master thread.
Geant4UserInitializationSequence(Geant4Context *c, const std::string &nam)
Standard constructor.
void adopt(Geant4UserInitialization *action)
Add an actor responding to all callbacks. Sequence takes ownership.
Base class to initialize a multi-threaded or single threaded Geant4 application.
bool m_needsControl
Default property: Flag to create control instance.
Definition: Geant4Action.h:101
virtual void updateContext(Geant4Context *ctxt)
Set client context.
static void increment(T *)
Increment count according to type information.
Definition: InstanceCount.h:98
virtual void build() const
Callback function to build setup for the MT worker thread.
Generic context to extend user, run and event information.
Default base class for all Geant 4 actions and derivates thereof.
Definition: Geant4Action.h:91
virtual void buildMaster() const
Callback function to build setup for the MT master thread.