Hello,
I have geant4 application (Geant4-10.5.1.) for simulating Ecal and HCal detectors. The sensitive detector class is similar to the one from the example basic/B5, in particular the first part of the ProcessHit() method:
auto touchable = step->GetPreStepPoint()->GetTouchable();
auto physical = touchable->GetVolume();
auto copyNo = physical->GetCopyNo();
auto hit = (*fHitsCollection)[copyNo];
The application works and produces consistent data, but sometimes the job crashes. The problem seems to come from the line
auto hit = (*fHitsCollection)[copyNo];
It occurs in multi-thread mode. When I use only one thread (mono-thred), all jobs work well.
I have checked the geometry construction and the creation of the indexed hit collection (fHitsCollection - one hit for each cell). Everything seems OK.
I was wondering, is it possible that, in some cases, two threads try to access the same SD?
Thank you for your help!
Emilia