Problem 1898 - Bug in G4PhysicsOrderedFreeVector.cc
Summary: Bug in G4PhysicsOrderedFreeVector.cc
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global (show other problems)
Version: other
Hardware: All All
: P4 normal
Assignee: Gabriele Cosmo
URL:
Depends on:
Blocks:
 
Reported: 2016-10-04 19:09 CEST by porosev
Modified: 2016-10-05 05:05 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 porosev 2016-10-04 19:09:49 CEST
Dear Sir,

I tried to simulate optical photons and I tried to define scintillator properties. I found that GEANT4 makes incorrect interpolation when I try to define more than 2 data points on energy grid.... The origin of the problem is in "G4PhysicsOrderedFreeVector.cc" file.

In "G4PhysicsOrderedFreeVector.cc" there is the function to get an energy value:

G4double G4PhysicsOrderedFreeVector::GetEnergy(G4double aValue)
{
        G4double e;
        if (aValue <= GetMinValue()) {
          e = edgeMin;
        } else if (aValue >= GetMaxValue()) {
          e = edgeMax;
        } else { 
          size_t closestBin = FindValueBinLocation(aValue);
          e = LinearInterpolationOfEnergy(aValue, closestBin);
	}
        return e;
}
But instead of:

inline
G4double G4PhysicsOrderedFreeVector::GetMaxLowEdgeEnergy()
{
	return binVector.back();
}
inline
G4double G4PhysicsOrderedFreeVector::GetMinLowEdgeEnergy()
{
	return binVector.front();
}
"GetMinValue()" and "GetMaxValue()" are used !!!!

Additionaly,  "e = LinearInterpolationOfEnergy(aValue, closestBin)" looks very strange because inside of "LinearInterpolationOfEnergy"  you make interpolation of the function values (dataVector[]) instead of energy grid (binVector[]).

Please check it!
Comment 1 porosev 2016-10-05 05:05:29 CEST
I am sorry, I was wrong. 
The code has no any comments it was rather hard to understood a logic.