Multiple Outputs in Multithreading Mode

Hey,

I have been modifying the **ExampleB1** to calculating the Energy Deposit. I am writing the total Energy deposit to a ROOT File using the G4AnalysisManager. But when i use more number of threads, it creates more number of output files. For example, if run it on a single thread, then the output file is created as output.root, when i use 4 threads, 4 files are created: output_t0.root, output_t1.root,....output_t3.root its like a file for each thread. Is there any to fix it such that i can get a single output file

My codes can be accessed via this repository:

I am using Geant4 version 11.2.1 on windows 11 with visual studio compilers.

Thanks
Anantha Padmanabhan

I think that you should add some code in the runaction.
liking following
runaction::runaction()

{

G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();


analysisManager->SetNtupleMerging(true);

}