// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4LowEnergyPhotoElectric.icc,v 1.11.6.1 1999/12/07 20:50:20 gunter Exp $
// GEANT4 tag $Name: geant4-01-00 $
//
// 
// ---------------------------------------------------------------
//      GEANT 4 class inlined methods file
//
//      For information related to this code contact:
//      CERN, CN Division, ASD group
//      History: first implementation, based on object model of
//      2nd December 1995, G.Cosmo
//      ------------ G4LowEnergyPhotoElectric physics process ---------
//                   by Michel Maire, April 1996
// ***************************************************************
// 12-06-96, update by M.Maire
// 17-09-96, PartialSumSigma(i)
//           split ComputeBinbingEnergy(), M.Maire
// 08-01-97, crossection table + meanfreepath table , M.Maire
// 13-03-97, adapted for the new physics scheme, M.Maire
// 20-11-97, change for lowest energy limit default action
// ---------------------------------------------------------------

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

inline G4bool G4LowEnergyPhotoElectric::IsApplicable(const G4ParticleDefinition& particle)
{
   return ( &particle == G4Gamma::Gamma() ); 
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

inline G4double 
G4LowEnergyPhotoElectric::GetMeanFreePath(const G4Track& aTrack, G4double,
                                          G4ForceCondition*)
{
  // returns the gamma mean free path in GEANT4 internal units
  const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle();
  G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
  G4Material* aMaterial = aTrack.GetMaterial();

  G4bool isOutRange ;
  if (GammaEnergy > HighestEnergyLimit){
     MeanFreePath = DBL_MAX;
   }	
   else if(GammaEnergy < LowestEnergyLimit){

	MeanFreePath = DBL_MIN;
   }
  else {

    MeanFreePath = util.DataLogInterpolation(GammaEnergy, 
	                                     aMaterial->GetIndex(), 
					     theMeanFreePathTable);
  }                                     
  
  return MeanFreePath;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

inline G4double 
G4LowEnergyPhotoElectric::GetCrossSection(G4DynamicParticle* aDynamicGamma,
			                  G4Element* anElement)
 
// gives the microscopic total cross section in GEANT4 internal units

{
   G4double crossSection;
   G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
   G4bool isOutRange ;

   if (GammaEnergy < LowestEnergyLimit || GammaEnergy > HighestEnergyLimit)
      crossSection = 0.;
   else{

      G4int elemZ = (G4int) anElement->GetZ();	
	const G4FirstLevel* oneAtomCS
	  = (*theCrossSectionTable)[ZNumVec->index(elemZ)];

      crossSection = util.DataLogInterpolation(GammaEnergy,
                    (*(*oneAtomCS)[0]), (*(*oneAtomCS)[1]))*barn;

   }
   return crossSection;
} 

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......




