Variance calculation

Hi everyone,
I am trying to calculate dose variance in each voxel in the parameterized volume.
as you know, I must calculate the absorbed dose within each voxel at the end of the event and then square it.

But there are 1000000 voxels and it takes a very long time to loop over these voxels at the end of each event.

Is there another way to calculate dose variance?

I am using a sensitive detector for processing hits and use G4run to score them in an array.
many thanks