I’m comparing dose deposition between Geant4 and MCNP. In MCNP, it’s possible to have a volume with no material inside. For this I’m setting the density to universe_mean_density = 1.e-25 g/cm³ in Geant4. As dose deposition calculates the energy deposited per cell mass, the very low cell mass gives me weird results. I end up with the same order of magnitude of dose as in normal material cells due to the division by the tiny cell mass, despite the actual energy deposition being barely there. I have experimented a bit with other low densities, but the change in energy deposition and cell mass seem to cancel each other out.
Therefore I wanted to create a modified doseDeposit scorer which sets the dose zero if the local density is below a certain threshold. As I’m using command based scoring with a mesh, I tried to followed advice given in this thread and from a talk by M.Asai called Scoring I.
I have copied into my subroutine folder and renamed G4PSDoseDeposit, G4PSDoseDeposit3D and G4ScoreQuantityMessenger replacing “G4” with “My”. I added
G4ScoringManager *scManager = G4ScoringManager::GetScoringManager();
MyScoreQuantityMessenger *quantMess = new MyScoreQuantityMessenger(scManager);
into my main().
In MyScoreQuantityMessenger, I added a new G4UIcommand* qnoVacDoseDepCmd, copied the usual doseDeposit part in SetNewValue() and edited it in (left the cylinder mesh part as it was as I’m not going to use it). I also put the QuantityCommands() part here and again copied the usual doseDeposit stuff and replaced with my qnoVacDoseDepCmd.
When I run this, I get to the point where 1-2 threads finish (possibly without ever encountering any dose deposition since I’m trying with low history numbers) and then there’s a segmentation fault. I put some G4cout lines in and this tells me it gets to MyPSDoseDeposit(), but never to Initialize() or ProcessHits(). I haven’t even introduced the change I wanted to make to the doseDeposit scoring yet.
What am I getting wrong here? I have also tried removing all of the stuff not relating to my new scorer out of the MyScoreQuantityMessenger, but that didn’t change the results.