Customized scoring filter in multi-thread mode

Hello!

I simulate a proton beam inject water phantom and score the dose deposition with G4ScoringManager. Further more, I want to separate the dose contribution from primary and secondary particles.

However, there is no pre-defined filter which can do the separation I want, so I code my own filter and apply it to the scoring mesh. (Refer to the source code of G4ScoringManager, G4ScoringMessenger).

My filter works correctly under single thread mode, but under multi-thread mode, seems the filter does not work, and the output result of the scoring quantity looks like no filter applied on the quantity.

Any ideas about this problem? Thanks in advance.

Hi people, I think I have figure out this problem.

In my designing of filter application, I declare a messenger at main.cc file, however, code defined here will work only on master thread. So I move the code to the constructor of RunAction class, then the filter is applied to each worker threads, and I got the result I want.

Hope this can help you when you can similar problem in multi-thread work.