How to determine the dose


I would like to store the deposited/absorbed dose inside a detector. Until now, I’m only using the deposited energy ( G4double partEdep = aStep->GetTotalEnergyDeposit(); )

in principle the dose is simply D = dE/dM but how do I get the mass of the detector? Is it also just a simple calculation or is there already something built inside Geant4 for the dose?

In your code, you can use G4VPhysicalVolume::GetLogicalVolume()->GetMass(). Look at G4LogicalVolume.hh to see what the optional arguments to GetMass() are.

Note that you should sum up all of the Edeps in your volume to get a total DeltaE/M value.

1 Like

thank you! I’m trying to use this but I don’t get it how to use it (in my code…).

I got this inside my

G4bool MySensitiveDetector::ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
    G4StepPoint *preStepPoint = aStep->GetPreStepPoint();
    G4StepPoint *postStepPoint = aStep->GetPostStepPoint();
    if(preStepPoint->GetStepStatus() == fGeomBoundary)
        const G4VTouchable *touchable = aStep->GetPreStepPoint()->GetTouchable();
        G4VPhysicalVolume *physVol = touchable->GetVolume();
        G4double mass = physVol->GetMass();	

but this results in

 C:\geant4\sim\,28): error C2039: 'GetMass': is not a member of 'G4VPhysicalVolume' [C:\geant4\build\toy_e

Why is that?

intellisense suggests this:


(the physical properties are encapsulated in the logical volume, although the name suggests otherwise :slight_smile: )

1 Like

indeed, this is working… in a different world it’s probably making sense but however, I’m always struggling how to solve issues like this.

How exactly are you using intellisense that it provided the solution?

However, when I print mass I receive mass: 2.32505e+20 as value. Which unit is it, but anyway, it seems to be quite a lot?

edit: I saw About the molar mass and absorbed dose - #4 by mkelsey and used G4cout << "mass: " << mass/kg << " kg" << G4endl; which gives mass: 3.72514e-05 kg which equals to 37 µg. Tbh, I have to check. The value is not far off but could be a bit little nevertheless. But it could be a valid value, I will check…
but is this correct, what I am doing?

And when I wanna’ know the dose I won’t convert it into other units, right?

it does make sense when you think of the “physical representation” of the volume, so kind of the actual placement of it → hence also the term “touchable”.

to be honest it did not suggest the whole solution, just that “GetMass()” is available for the “GetLogicalVolume”. Using visual studio code, the auto-complete suggestions appear when I start typing the arrow ->


yes. just don’t use any units until you store/display results, then you divide by the (combined) final unit that you prefer, e.g., (keV/kg) or CLHEP::joule/CLHEP::kilogram, or …

1 Like

Alright, thank you!

I checked the value meanwhile and I found a huge discrepancy. My detector is defined as follows:

G4Material *LiF = nist->FindOrBuildMaterial("G4_LITHIUM_FLUORIDE");	
G4Tubs *solidDetector = new G4Tubs("solidDetector", 0*mm, 6/2*mm, 0.5/2*mm, 0., 360.*deg);
logicDetector = new G4LogicalVolume(solidDetector, LiF, "logicDetector");

and when I print out the mass I receive:

G4cout << "mass: " << mass/kg << " kg" << G4endl;
mass: 3.72514e-05 kg

which is way too less?! When I calculate it manually I get:

density LiF: 2.64 g/cm³
volume dectector: Pi*(3mm)²*0.25mm = 7.069 mm³ = 0.07 cm³
m = rho * V = 0.18 g = 1.866e-4 kg

do I make a mistake or G4? :slight_smile:


I see two math mistakes:

volume dectector: Pi*(3mm)²*0.25mm = …

This should be
volume dectector: Pi*(3mm)²*0.5mm = …

since your G4Tubs is 5 mm long making your total volume 14.137mm³ = 0.014 cm³ (you missed one decimal place in your calculation: 7mm³ = 0.007 cm³

Then the mass becomes 0.037g, which is exactly what Geant is showing.


1 Like

Thank you very much! My mistake and so obvious… but glad to have that verified.
What would I do without you people :slight_smile:

Thanks again!

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