Newer
Older
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
#ifndef DDG4_GEANT4RUNMANAGER_H
#define DDG4_GEANT4RUNMANAGER_H 1
/// Framework include files
/// Geant4 include files
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/// Namespace for the AIDA detector description toolkit
namespace dd4hep {
/// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
namespace sim {
/// Geant4 run manager plugin class.
/**
* The plugin acts as a normal Geant4Action. However, it must support a
* dynamic_cast to G4RunManager.
* The templated class may be specialized by any user defined class
* which has G4RunManager as a super class.
*
* Current specializations are:
* - G4RunManager for single threaded applications
* - G4MTRunManager for multi threaded applications
*
* For convenience we name the factory instances according to the G4 classes.
*
* \author M.Frank
* \version 1.0
* \ingroup DD4HEP_SIMULATION
*/
template <typename RUNMANAGER>
class Geant4RunManager : public Geant4Action, public RUNMANAGER {
public:
Geant4RunManager(Geant4Context* ctxt, const std::string& nam)
: Geant4Action(ctxt, nam), RUNMANAGER()
{
declareProperty("NumberOfThreads", m_numThreads);
}
virtual ~Geant4RunManager() { }
/// Enable and install UI messenger
virtual void enableUI();
private:
/// global range cut for secondary productions
int m_numThreads;
};
template <> void Geant4RunManager<G4RunManager>::enableUI() {
Geant4Action::enableUI();
printout(WARNING,"Geant4RunManager","+++ Configured run manager of type: %s.",
typeName(typeid(G4RunManager)).c_str());
printout(WARNING,"Geant4Kernel","+++ Multi-threaded mode requested, "
"but not supported by this compilation of Geant4.");
printout(WARNING,"Geant4Kernel","+++ Falling back to single threaded mode.");
m_numThreads = 0;
}
typedef Geant4RunManager<G4RunManager> Geant4STRunManager;
}
}
#endif // DDG4_GEANT4RUNMANAGER_H
using namespace dd4hep::sim;
DD4HEP_PLUGINSVC_FACTORY(Geant4STRunManager,G4RunManager,dd4hep::sim::Geant4Action*(_ns::CT*,std::string),__LINE__)
#ifdef G4MULTITHREADED
/// Namespace for the AIDA detector description toolkit
namespace dd4hep {
/// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
namespace sim {
template <> void Geant4RunManager<G4MTRunManager>::enableUI() {
Geant4Action::enableUI();
this->G4MTRunManager::SetNumberOfThreads(m_numThreads);
printout(WARNING,"Geant4RunManager","+++ Configured run manager of type: %s with %d threads.",
typeName(typeid(G4MTRunManager)).c_str(), m_numThreads);
}
typedef Geant4RunManager<G4MTRunManager> Geant4MTRunManager;
}
}
DD4HEP_PLUGINSVC_FACTORY(Geant4MTRunManager,G4MTRunManager,dd4hep::sim::Geant4Action*(_ns::CT*,std::string),__LINE__)