// 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: G4LowEnergyBremsstrahlung.icc,v 1.9.8.1 1999/12/07 20:50:19 gunter Exp $
// GEANT4 tag $Name: geant4-01-00 $
//
// 
// ---------------------------------------------------------------
//      GEANT 4 class inlined methods file
//
//      For information related to this code contact:
//      CERN, IT Division, ASD group
//      History: first implementation, based on object model of
//      2nd December 1995, G.Cosmo
//      ------------ G4LowEnergyBremsstrahlung physics process ---------
//                     by Michel Maire, 27 July 1996
// ***************************************************************
// 13-12-96 : Sign corrected in the ScreenFunctions, L.Urban
// 20/03/97 : new energy loss+ionisation+brems scheme, L.Urban
// ***************************************************************

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

inline G4bool G4LowEnergyBremsstrahlung::IsApplicable(
                            const G4ParticleDefinition& particle)
{
   return(  (&particle == G4Electron::Electron())
          ||(&particle == G4Positron::Positron()) );
}

inline G4double G4LowEnergyBremsstrahlung::GetMeanFreePath(const G4Track& track,
                                                         G4double,
                                                         G4ForceCondition*)
 
// gives the MeanFreePath in GEANT4 internal units

{

   const G4DynamicParticle* aDynamicParticle = track.GetDynamicParticle();
   G4double KineticEnergy = aDynamicParticle->GetKineticEnergy();
   G4Material* aMaterial  = track.GetMaterial();
   G4double MeanFreePath;
   G4bool isOutRange ;

   if (KineticEnergy <  LowestKineticEnergy)

     MeanFreePath = DBL_MIN;

   else {

     if (KineticEnergy > HighestKineticEnergy) KineticEnergy = 0.99*HighestKineticEnergy ;

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

   return MeanFreePath; 
} 


inline G4double G4LowEnergyBremsstrahlung::ComputeA(G4int AtomicNumber, G4double ElectronKinEnergy){

  G4double aVal;
  G4FirstLevel* oneAtomCoeff = (*ATable)[AtomicNumber-1];
  G4Data* ElectEnVec = (*oneAtomCoeff)[0];
  G4Data* AValueVec = (*oneAtomCoeff)[1];

  aVal = util.DataLogInterpolation(ElectronKinEnergy, (*ElectEnVec), (*AValueVec));
	
  if(AtomicNumber > 99){

    aVal = 0;	
  }

  return aVal;
} 

inline G4double G4LowEnergyBremsstrahlung::ComputeB(G4int AtomicNumber, G4double ElectronKinEnergy){

  G4double bVal;
  G4double constTerm  = (*(*BTable)[0])[AtomicNumber-1];
  G4double linearTerm = (*(*BTable)[1])[AtomicNumber-1];
  G4double logElectEn = log10(ElectronKinEnergy);
  if(logElectEn > -5 && logElectEn < (-constTerm/linearTerm)){

    bVal = linearTerm*logElectEn+constTerm;
  }
  else{

    bVal = 0;
  }

  if(AtomicNumber > 99){
    bVal = 0;	
  }

  return bVal;
}










