Severe speed drop when using scoring mesh

Hello,

I am attempting to simulate dosimetry in CT datasets and essentially have everything working except for being able to output data efficiently. My detector is constructed using G4PVParameterised as an array of voxels of various materials and runs efficiently by itself. However when I try to accumulate and output the dose deposited in each voxel I code slows down by over a factor of 30, which I feel shouldn’t be the case given I can access the dose deposited in my stepping action (based on example b1) without any appreciable drop in speed. All I need is to be able to save these values to ram for later output.
To save values I am currently using a scoring mesh with the macro commands
###########################
/score/create/boxMesh DetectorGrid
/score/mesh/boxSize 75 75 19.275 mm
/score/mesh/nBin 500 500 500
/score/quantity/doseDeposit dose
###########################
I then output it to a file using a customised score writer.

Does anyone have guidance on how to perform this without compromising efficiency, or is this slow down standard? Obviously a factor of thirty could be the difference between calculations taking one day vs one month so I would really appreciate help on this.

Let me know if any more information is needed.

500^3 is not just a few voxels, I would say… that is 1.25e8 voxels, times the number of threads, times the size of each entry (not sure if that is just 8 byte for a double, or if there is more to it). That would be 1 GB per thread at least… could it be that you start swapping ram to disk with additional mesh?

By adding the boxMesh on top of your detector geometry, you increase the complexity (additional geometric boundaries). Can you alternatively use a SensitiveDetector instead and make use of the parametrisation that you already have in place?

Thank you Weller!
Running the code my RAM doesn’t appear to go up when using the scoring mesh and I can’t notice any increase in disk write speed but then again I don’t know how the scoring mesh marco works.
I am currently working to define a sensitive detector based on the DICOM example and have it functioning to the point where I have got a G4THitsMap* type and am iterating through it just to get a total sum of the dose as a test. My issue is that occasionally some of the values output as -nan(ind). I am not sure what a nan could mean in this context, I changed back to using a default physics list and saw no changes, additionally I have no stuck track warnings or anything like that.
Is this an easy fix or should I start another question for it?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.