39 {
40
41 ATH_MSG_INFO (
"==> tbb thread started with id: 0x" << std::hex
42 << pthread_self() << std::dec);
43
44
45
46
47 auto wThreadContext = new G4WorkerThread;
48 G4AutoDelete::Register(wThreadContext);
49
50
51
52
53#if defined(__USE_GNU) || defined(__CPPCHECK__)
55 wThreadContext->SetThreadId( tid );
56#else
57 #error "gettid() unavailable on this system"
58#endif
59
60 G4int thisID = wThreadContext->GetThreadId();
61 G4Threading::G4SetThreadId(thisID);
62
63
64 G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
65
66 const G4UserWorkerThreadInitialization* workerInitializer = masterRM->GetUserWorkerThreadInitialization();
67
68 const CLHEP::HepRandomEngine* masterEngine = masterRM->getMasterRandomEngine();
69 workerInitializer->SetupRNGEngine(masterEngine);
70
71
72 wThreadContext->BuildGeometryAndPhysicsVector();
73
74
76 G4WorkerRunManager* wrm = workerInitializer->CreateWorkerRunManager();
77 wrm->SetWorkerThread(wThreadContext);
78
79
82 (masterRM->GetUserDetectorConstruction());
83 wrm->G4RunManager::SetUserInitialization(detector);
84
85
86 auto physicslist
ATLAS_THREAD_SAFE =
const_cast<G4VUserPhysicsList*
>(masterRM->GetUserPhysicsList());
87 wrm->SetUserInitialization(physicslist);
88
89
90 if(masterRM->GetUserActionInitialization()) {
91 masterRM->GetNonConstUserActionInitialization()->Build();
92 }
93
94
95 if(masterRM->GetUserWorkerInitialization()) {
96 masterRM->GetUserWorkerInitialization()->WorkerStart();
97 }
98
99
101 wrm->Initialize();
102
103
105
106 ATH_MSG_INFO (
"==> tbb thread end of initThread with id: 0x" << std::hex <<
107 pthread_self() << std::dec );
108
109}
#define ATLAS_THREAD_SAFE