Generates multiple root files when running multithreading

image
Hi everyone, I am wanting to record the deposition energy spectrum of a Cobalt-60 source in a germanium crystal. I managed to do this and output the results as a Histogram with root. But when I run in multithreading it generates 4 files equivalent to 4 threads (The total entries of 4 files is equal to my own simulation history). Index 0 is equivalent to my 0th run. But another file '1_t1 ’ is created which I obviously only run once. How can I fix this?. Thank in advance.


when I run in multithreading it generates 5 files equivalent to 4 threads. I think t0,t1,t2,t3 were files of every threads, and MuProtonSimple.root was all. Maybe you can check why it does not produce output0.root. Hope can help you .

Add this two lines in before the creation of your root files

  G4AnalysisManager *man = G4AnalysisManager::Instance();
  man->SetNtupleMerging(true);
1 Like

@idrissi_abdelghani and @Dengyun_Mu Thanks, I have fixed this error.