I recorded the dose deposited in the same volume using “UI-command base scoring” and the method in exampleB1, but the results confused me.This is the macro command file:
And the result_1 is(using “UI-command base scoring” ,I use “/score/quantity/get/unit” and it shows the unit is “Gy”):
The result_2 is:
The two results differ by exactly 10^12, why?
When you print out a quantity in Geant4, you need to (a) divide out the units, and (b) print the units you divded by. Geant4 internally uses a large collection of multipliers which together form a consistent set of unit. But all of the numerical quantities are simply doubles.
For a simple example, let’s store the radius of the Earth:
What?!? That’s not the 6380 I put in! Internally Geant4 uses units where mm = 1. Consequently, km = 1e+6, with the result you see. The correct way to print out a variable with units is
So we have gray = metermeter / (secondsecond). Geant4 uses units, as I noted above of mm=1 and ns=1. So gray = 1e31e3 / (1e91e9) = 1e6/1e18 = 1e-12. If you print out your result as
G4cout << result_1/gray << " Gy" << G4endl;
you’ll get 3.19e-19 / 1e-12 = 3.19e-7 Gy, just as you expect.