Analysis part in multi-threading mode

Hi experts!
I’m trying to write the analysis part in multi-threading mode and I have some questions.
Is it possible to use root? There are some good examples to follow?

Cheers,
Dayron.

Of course you can use root. Just check the header file about “Analysis.hh”. And you can also try to use the class “G4AnalysisManager” to generate the root file. A good example is shown in the basic example B4.

1 Like

If you use G4Analysis to generate your output ROOT file, it’s fully thread safe. In particular, G4Analysis does not actually depend on ROOT; it simply produces a binary-compatible output file which matches ROOT’s specification.

Historically, ROOT has not been thread-safe. In our simulation framework, we use ROOT directly (rather than through G4Analysis), and so we wrapped as much of our ROOT-specific code into a few classes, which are protected by mutexes.

Supposedly, you can use the most recent versions of ROOT directly in a multithreaded application, provided you call ROOT::EnableThreadSafety() in your main(). I have not tried this myself.

Actually, I tried call ROOT::EnableThreadSafety() , it will mention me *** Break *** segmentation violation. But what makes me surprised is that the data recorded in root file is normal! So I think it’s too dangerous.

Oh, I think it worked. I succeeded in running it yesterday. So it’s a good idea. And “G4AutoLock” must be added in each function about recording.