Average LET and Quality factor of neutron

I am trying to find out dose equivalent (Q* D) due to neutron beam at a sensitive detector. For that, I have modified B4d example to evaluate LET and respective Q value. But simply dividing Edep by PassageTrackLength is giving the wrong result. In an earlier forum, I have got the following formula

G4double preE = aStep->GetPreStepPoint()->GetKineticEnergy();
G4double postE = aStep->GetPostStepPoint()->GetKineticEnergy();
G4double length = aStep->GetStepLength();
G4double LET = (preE-postE)/length; // (preE-postE) is the energy loss

But as my programming knowledge is pretty poor, I am not able to understand how to derive LET value from the above equation in B4d example.
Can anybody please suggest the required modification in any given example to find out LET values.