Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//==========================================================================
// 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
#include "DDG4/Geant4Action.h"
/// Geant4 include files
#include "G4RunManager.hh"
typedef G4RunManager G4__RunManager;
/// 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<G4__RunManager> G4RunManager;
}
}
#endif // DDG4_GEANT4RUNMANAGER_H
#include "DDG4/Factories.h"
using namespace dd4hep::sim;
DECLARE_GEANT4ACTION(G4RunManager)
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
typedef G4MTRunManager G4__MTRunManager;
/// 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->RUNMANAGER::SetNumberOfThreads(m_numThreads);
printout(WARNING,"Geant4RunManager","+++ Configured run manager of type: %s with %d threads.",
typeName(typeid(G4MTRunManager)).c_str(), m_numThreads);
}
typedef Geant4RunManager<G4__MTRunManager> G4MTRunManager;
}
}
DECLARE_GEANT4ACTION(G4MTRunManager)
#endif