Using ROOT with multithreaded GEANT4 simulation

Hello, I am trying to store the results of my simulation in TTree and TH1s
The problem comes when I want to fill the histograms and the tree at each event. It crashes at the beginning of the simulation.
I attached the class in charge of the analysis managing of my simulation and the bactrace I get. Note that it crashes even if I set only one thread (with G4MTRunManager). It does not crash with G4RunManager.
Please, let me know if you need more files to understand how my simulation work. However, from the backtrace, it looks like the crash occurs because of ROOT. This is validated by the fact if I comment all the content of the “AddEvent” method, it does not crash anymore.
Any idea?
backtrace.txt (11.7 KB) (4.43 KB)


we are working hard to improve the thread safety of ROOT. At the moment, in absence of any user managed resource protection mechanism, these are the requirements to fill histograms and trees in a multithreaded environment:

  1. Each thread must read(write) from a separate root file
  2. The TThread::Initialize() static function must be invoked before starting the parallel work
  3. The user must create a TThread object per thread, being it pthread or std::thread.

An outlook: constraints 2) and 3) will be lifted very soon (next release, the changes are in master already).