Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,151 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EnergyLossTables.hh,v 2.7 1998/10/27 12:26:43 urban Exp $
// GEANT4 tag $Name: geant4-00 $
//
// $Id:
#ifndef included_G4EnergyLossTables
#define included_G4EnergyLossTables
#include "globals.hh"
#include <rw/tvhdict.h>
#include "G4PhysicsTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4Material.hh"
#include "G4ios.hh"
// A utility class, containing the energy loss tables
// for each particle
//
// Energy loss processes have to register their tables with this
// class. The responsibility of creating and deleting the tables
// remains with the energy loss classes.
//
// P. Urban, 06/04/1998
// L. Urban, 27/05/1988 , modifications + new functions added
// L.Urban , 13/10/98 , revision
// L.Urban, 26/10/98 , revision, Interpolate removed
// don't use the helper class.
// It can't be hidden for Rogue Wave uses it.
class G4EnergyLossTablesHelper {
friend class G4EnergyLossTables;
// the only instances are within the class G4EnergyLossTables
public:
G4EnergyLossTablesHelper();
private:
G4EnergyLossTablesHelper(const G4PhysicsTable* aDEDXTable,
const G4PhysicsTable* aRangeTable,
const G4PhysicsTable* anInverseRangeTable,
const G4PhysicsTable* aLabTimeTable,
const G4PhysicsTable* aProperTimeTable,
G4double aLowestKineticEnergy,
G4double aHighestKineticEnergy,
G4double aMassRatio,
G4int aNumberOfBins);
// data to be stored in the dictionary
const G4PhysicsTable* theDEDXTable;
const G4PhysicsTable* theRangeTable;
const G4PhysicsTable* theInverseRangeTable;
const G4PhysicsTable* theLabTimeTable;
const G4PhysicsTable* theProperTimeTable;
G4double theLowestKineticEnergy;
G4double theHighestKineticEnergy;
G4double theMassRatio;
G4int theNumberOfBins;
};
class G4EnergyLossTables {
public:
// get the table for a given particle
// (0 if the table was not found)
static const G4PhysicsTable* GetDEDXTable(
const G4ParticleDefinition* p);
static const G4PhysicsTable* GetRangeTable(
const G4ParticleDefinition* p);
static const G4PhysicsTable* GetInverseRangeTable(
const G4ParticleDefinition* p);
static const G4PhysicsTable* GetLabTimeTable(
const G4ParticleDefinition* p);
static const G4PhysicsTable* GetProperTimeTable(
const G4ParticleDefinition* p);
// get the DEDX or the range for a given particle/energy/material
static G4double GetDEDX(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetRange(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetLabTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetDeltaLabTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergyStart,
G4double KineticEnergyEnd,
G4Material *aMaterial);
static G4double GetProperTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetDeltaProperTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergyStart,
G4double KineticEnergyEnd,
G4Material *aMaterial);
static G4double GetPreciseDEDX(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetPreciseRangeFromEnergy(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial);
static G4double GetPreciseEnergyFromRange(
const G4ParticleDefinition *aParticle,
G4double range,
G4Material *aMaterial);
// to be called only by energy loss processes
static void Register(
const G4ParticleDefinition* p,
const G4PhysicsTable* tDEDX,
const G4PhysicsTable* tRange,
const G4PhysicsTable* tInverseRange,
const G4PhysicsTable* tLabTime,
const G4PhysicsTable* tProperTime,
G4double lowestKineticEnergy,
G4double highestKineticEnergy,
G4double massRatio,
G4int NumberOfBins);
public:
typedef const G4ParticleDefinition* K;
private:
static RWTValHashDictionary<K, G4EnergyLossTablesHelper> dict;
static unsigned HashFun(const K& particle);
static G4EnergyLossTablesHelper GetTables(const G4ParticleDefinition* p);
};
#include "G4EnergyLossTables.icc"
#endif
@@ -0,0 +1,403 @@
// This code implementation is the intellectual property of
// the RD44 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: G4EnergyLossTables.icc,v 2.8 1998/10/13 08:24:29 urban Exp $
// GEANT4 tag $Name: geant4-00 $
//
// $Id:
// Inline members of the G4EnergyLossTables class
//
// first version created by P.Urban , 06/04/1998
// modified by L.Urban , 27/05/98
//
inline unsigned G4EnergyLossTables::HashFun(
const G4EnergyLossTables::K& particle)
{
return particle->GetParticleName().hash();
}
inline G4EnergyLossTablesHelper::G4EnergyLossTablesHelper(
const G4PhysicsTable* aDEDXTable,
const G4PhysicsTable* aRangeTable,
const G4PhysicsTable* anInverseRangeTable,
const G4PhysicsTable* aLabTimeTable,
const G4PhysicsTable* aProperTimeTable,
G4double aLowestKineticEnergy,
G4double aHighestKineticEnergy,
G4double aMassRatio,
G4int aNumberOfBins)
:
theDEDXTable(aDEDXTable), theRangeTable(aRangeTable),
theInverseRangeTable(anInverseRangeTable),
theLabTimeTable(aLabTimeTable),
theProperTimeTable(aProperTimeTable),
theLowestKineticEnergy(aLowestKineticEnergy),
theHighestKineticEnergy(aHighestKineticEnergy),
theMassRatio(aMassRatio),
theNumberOfBins(aNumberOfBins)
{
}
inline G4EnergyLossTablesHelper::G4EnergyLossTablesHelper()
{
}
///////////////////////////////////////////////////////////////////////
inline const G4PhysicsTable* G4EnergyLossTables::GetDEDXTable(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper v;
G4bool found= dict.findValue(p, v);
return found ? v.theDEDXTable : 0;
}
inline const G4PhysicsTable* G4EnergyLossTables::GetRangeTable(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper v;
G4bool found= dict.findValue(p, v);
return found ? v.theRangeTable : 0;
}
inline const G4PhysicsTable* G4EnergyLossTables::GetInverseRangeTable(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper v;
G4bool found= dict.findValue(p, v);
return found ? v.theInverseRangeTable : 0;
}
inline const G4PhysicsTable* G4EnergyLossTables::GetLabTimeTable(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper v;
G4bool found= dict.findValue(p, v);
return found ? v.theLabTimeTable : 0;
}
inline const G4PhysicsTable* G4EnergyLossTables::GetProperTimeTable(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper v;
G4bool found= dict.findValue(p, v);
return found ? v.theProperTimeTable : 0;
}
///////////////////////////////////////////////////////////////////////
inline G4EnergyLossTablesHelper G4EnergyLossTables::GetTables(
const G4ParticleDefinition* p)
{
G4EnergyLossTablesHelper r;
if (! dict.findValue(p, r)) {
G4Exception("G4EnergyLossTables::GetTables: table not found!");
exit(1);
}
return r;
}
///////////////////////////////////////////////////////////////////////
inline G4double G4EnergyLossTables::GetDEDX(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* rangeTable= t.theRangeTable;
const G4PhysicsTable* dEdxTable= t.theDEDXTable;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
G4double dEdx;
G4bool isOut;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
dEdx = sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
(*dEdxTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
dEdx = (*dEdxTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
dEdx = (*dEdxTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
G4double Charge = aParticle->GetPDGCharge() ;
G4double Chargesquare = Charge*Charge ;
return dEdx*Chargesquare;
}
inline G4double G4EnergyLossTables::GetLabTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* labtimeTable= t.theLabTimeTable;
const G4double parlowen=0.4 , ppar=0.5-parlowen ;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
G4double time;
G4bool isOut;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
time = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*labtimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
time = (*labtimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
time = (*labtimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
return time/t.theMassRatio ;
}
inline G4double G4EnergyLossTables::GetDeltaLabTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergyStart,
G4double KineticEnergyEnd,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* labtimeTable= t.theLabTimeTable;
const G4double parlowen=0.4 , ppar=0.5-parlowen ;
const G4double dToverT = 0.05 , facT = 1. -dToverT ;
G4double timestart,timeend,deltatime,dTT;
G4bool isOut;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergyStart*t.theMassRatio;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
timestart = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*labtimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
timestart = (*labtimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
timestart = (*labtimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
dTT = (KineticEnergyStart - KineticEnergyEnd)/KineticEnergyStart ;
if( dTT < dToverT )
scaledKineticEnergy = facT*KineticEnergyStart*t.theMassRatio;
else
scaledKineticEnergy = KineticEnergyEnd*t.theMassRatio;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
timeend = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*labtimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
timeend = (*labtimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
timeend = (*labtimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
deltatime = timestart - timeend ;
if( dTT < dToverT )
deltatime *= dTT/dToverT;
return deltatime/t.theMassRatio ;
}
inline G4double G4EnergyLossTables::GetProperTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* propertimeTable= t.theProperTimeTable;
const G4double parlowen=0.4 , ppar=0.5-parlowen ;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
G4double time;
G4bool isOut;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
time = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*propertimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
time = (*propertimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
time = (*propertimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
return time/t.theMassRatio ;
}
inline G4double G4EnergyLossTables::GetDeltaProperTime(
const G4ParticleDefinition *aParticle,
G4double KineticEnergyStart,
G4double KineticEnergyEnd,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* propertimeTable= t.theProperTimeTable;
const G4double parlowen=0.4 , ppar=0.5-parlowen ;
const G4double dToverT = 0.05 , facT = 1. -dToverT ;
G4double timestart,timeend,deltatime,dTT;
G4bool isOut;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergyStart*t.theMassRatio;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
timestart = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*propertimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
timestart = (*propertimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
timestart = (*propertimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
dTT = (KineticEnergyStart - KineticEnergyEnd)/KineticEnergyStart ;
if( dTT < dToverT )
scaledKineticEnergy = facT*KineticEnergyStart*t.theMassRatio;
else
scaledKineticEnergy = KineticEnergyEnd*t.theMassRatio;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
timeend = exp(ppar*log(scaledKineticEnergy/t.theLowestKineticEnergy))*
(*propertimeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
timeend = (*propertimeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
timeend = (*propertimeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
deltatime = timestart - timeend ;
if( dTT < dToverT )
deltatime *= dTT/dToverT ;
return deltatime/t.theMassRatio ;
}
inline G4double G4EnergyLossTables::GetRange(
const G4ParticleDefinition *aParticle,
G4double KineticEnergy,
G4Material *aMaterial)
{
G4EnergyLossTablesHelper t= GetTables(aParticle);
const G4PhysicsTable* rangeTable= t.theRangeTable;
const G4PhysicsTable* dEdxTable= t.theDEDXTable;
G4int materialIndex = aMaterial->GetIndex();
G4double scaledKineticEnergy = KineticEnergy*t.theMassRatio;
G4double Range;
G4bool isOut;
if (scaledKineticEnergy<t.theLowestKineticEnergy) {
Range = sqrt(scaledKineticEnergy/t.theLowestKineticEnergy)*
(*rangeTable)(materialIndex)->GetValue(
t.theLowestKineticEnergy,isOut);
} else if (scaledKineticEnergy>t.theHighestKineticEnergy) {
Range = (*rangeTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut)+
(scaledKineticEnergy-t.theHighestKineticEnergy)/
(*dEdxTable)(materialIndex)->GetValue(
t.theHighestKineticEnergy,isOut);
} else {
Range = (*rangeTable)(materialIndex)->GetValue(
scaledKineticEnergy,isOut);
}
G4double Charge = aParticle->GetPDGCharge() ;
G4double Chargesquare = Charge*Charge ;
return Range/(Chargesquare*t.theMassRatio);
}