Dear all,
I have used the general framework of example B1 to write my simulation. Its scope is to collect the phase space of photons that arrive at some volume. I do this at my SteppingAction class(if post step is inside the volume, give me kinematics).
Because of already existing analysis scripts, I want to score the phase space (lines of 8 colums: particle type, energy, x,y,z, cx,cy,cz) in ASCII format but I would like to do it in multi-threaded mode so that each thread will have its own .txt output file. My unsuccessful efforts from within my SteppingAction class are the following:
-
Using G4cout with macro command /control/cout/setCoutfile which does write the .txt files but some of the photons are still written on the terminal. Also, some lines are written half way. That might be because even though I use in main: G4VmodularPhysicsList* physicslist = new QBBC(0), I still get the hadronic interactions info on my terminal?
-
Opening an std::ofstream each time RunAction is initialised by each thread but I haven’t managed to pass the stream pointer to my SteppingAction class. To do this, my RunAction class has a private std::ofstream* outputfile data member and a public Get method to return it. The pointer to the instance of RunAction is passed as an argument to SteppingAction in the ActionInitialisation (following B1 example methodology) so that I can call the Get method from within SteppingAction. I only know that at least I open the stream correctly in the RunAction class because if I “<<” some string in BeginOfRunAction and in EndOfRunAction it gets written correctly at the proper output file.
Unless there is a way to correct the half-way writing of G4cout from the first example, I think I need a way to correctly pass the thread-local std::ofstream as a pointer or reference in my thread-local SteppingAction. Then I should be able to use “<<” to write my lines.
Are there any suggestions?