| Summary: | ProcessHits function in G4PSEnergyDeposit, G4PSDoseDeposit, and G4PSNofStep, etc | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Fada Guan <guanfada> |
| Component: | digits_hits/utils | Assignee: | asai |
| Status: | RESOLVED WONTFIX | ||
| Severity: | critical | ||
| Priority: | P5 | ||
| Version: | 9.6 | ||
| Hardware: | All | ||
| OS: | All | ||
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 |
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 }