Problem 1430 - ProcessHits function in G4PSEnergyDeposit, G4PSDoseDeposit, and G4PSNofStep, etc
Summary: ProcessHits function in G4PSEnergyDeposit, G4PSDoseDeposit, and G4PSNofStep, etc
Status: RESOLVED WONTFIX
Alias: None
Product: Geant4
Classification: Unclassified
Component: digits_hits/utils (show other problems)
Version: 9.6
Hardware: All All
: P5 critical
Assignee: asai
URL:
Depends on:
Blocks:
 
Reported: 2013-01-21 05:21 CET by Fada Guan
Modified: 2013-10-25 22:15 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Fada Guan 2013-01-21 05:21:57 CET
00058 G4bool G4PSEnergyDeposit::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00059 {
00060   G4double edep = aStep->GetTotalEnergyDeposit();
00061   if ( edep == 0. ) return FALSE;
00062   edep *= aStep->GetPreStepPoint()->GetWeight(); // (Particle Weight)
00063   G4int  index = GetIndex(aStep);
00064   EvtMap->add(index,edep);  
00065   return TRUE;
00066 }


There is a comparison using "==" between two double, and I think it is not safe and sometimes not accurate to do this because of the computation precision of computers. We'd better not use "==" when we want to compare two double. No problem to use "==" to compare two int.

Actually, we can use 
if (edep < 1e-9*eV) return FALSE;
to avoid this problem even though it can also result in some precision problems.

This also happens in G4PSDoseDeposit and G4PSNofStep and others.

Thanks a lot!

Fada

00051 G4bool G4PSNofStep::ProcessHits(G4Step* aStep,G4TouchableHistory*)
00052 {
00053   if ( boundaryFlag ) {
00054       if ( aStep->GetStepLength() == 0. ) return FALSE;
00055   }
00056   G4int  index = GetIndex(aStep);
00057   G4double val = 1.0;
00058   EvtMap->add(index,val);  
00059   return TRUE;
00060 }
Comment 1 asai 2013-10-25 22:15:39 CEST
Thanks for reporting.
In this case, aStep->GetTotalEnergyDeposit() is defined and initialized to exact zero if a track makes no energy deposition (e.g. for neutral particle, for zero-length step due to special kind of boundary crossing).
Thus, we believe this treatment is correct. When by chance a step is ultra-short, energy deposition of the step could be almost DBL_MIN. Thus comparison with any non-zero number would cause precision concern.
Makoto