7 #include "G4WorkerRunManager.hh"
9 #include "G4UImanager.hh"
11 #include "G4MTRunManager.hh"
12 #include "G4WorkerThread.hh"
13 #include "G4UserWorkerThreadInitialization.hh"
14 #include "G4RunManager.hh"
15 #include "G4VUserActionInitialization.hh"
16 #include "G4UserWorkerInitialization.hh"
17 #include "G4AutoDelete.hh"
22 #include <sys/syscall.h>
41 ATH_MSG_INFO (
"==> tbb thread started with id: 0x" << std::hex
42 << pthread_self() << std::dec);
47 auto wThreadContext =
new G4WorkerThread;
48 G4AutoDelete::Register(wThreadContext);
53 #if defined(__USE_GNU) || defined(__CPPCHECK__)
55 wThreadContext->SetThreadId( tid );
57 #error "gettid() unavailable on this system"
60 G4int thisID = wThreadContext->GetThreadId();
61 G4Threading::G4SetThreadId(thisID);
64 G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
66 const G4UserWorkerThreadInitialization* workerInitializer = masterRM->GetUserWorkerThreadInitialization();
68 const CLHEP::HepRandomEngine* masterEngine = masterRM->getMasterRandomEngine();
69 workerInitializer->SetupRNGEngine(masterEngine);
72 wThreadContext->BuildGeometryAndPhysicsVector();
76 G4WorkerRunManager* wrm = workerInitializer->CreateWorkerRunManager();
77 wrm->SetWorkerThread(wThreadContext);
82 (masterRM->GetUserDetectorConstruction());
83 wrm->G4RunManager::SetUserInitialization(
detector);
86 auto physicslist
ATLAS_THREAD_SAFE =
const_cast<G4VUserPhysicsList*
>(masterRM->GetUserPhysicsList());
87 wrm->SetUserInitialization(physicslist);
90 if(masterRM->GetUserActionInitialization()) {
91 masterRM->GetNonConstUserActionInitialization()->Build();
95 if(masterRM->GetUserWorkerInitialization()) {
96 masterRM->GetUserWorkerInitialization()->WorkerStart();
106 ATH_MSG_INFO (
"==> tbb thread end of initThread with id: 0x" << std::hex <<
107 pthread_self() << std::dec );
117 << std::hex << pthread_self() << std::dec );
120 G4RunManager::GetRunManager()->RunTermination();