Import Geant4 4.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:18:25 +02:00
parent 36c080dca6
commit 921d3b1cda
3990 changed files with 185376 additions and 82884 deletions
+56 -249
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VXrayTRmodel.cc,v 1.1.4.1 2001/06/28 19:10:35 gunter Exp $
// GEANT4 tag $Name: $
// $Id: G4VXrayTRmodel.cc,v 1.5 2001/09/18 09:02:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-00 $
//
#include "G4Timer.hh"
@@ -32,6 +32,7 @@
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "globals.hh"
#include "g4std/complex"
#include "G4PhysicsTable.hh"
#include "G4PhysicsVector.hh"
#include "G4PhysicsLinearVector.hh"
@@ -88,8 +89,13 @@ G4VXrayTRmodel::G4VXrayTRmodel(G4Envelope *anEnvelope, G4double a, G4double b) :
// index of plate material
fMatIndex1 = anEnvelope->GetDaughter(0)->GetLogicalVolume()->
GetMaterial()->GetIndex() ;
G4cout<<"plate material = "<<anEnvelope->GetDaughter(0)->GetLogicalVolume()->
GetMaterial()->GetName()<<G4endl ;
// index of gas material
fMatIndex2 = anEnvelope->GetMaterial()->GetIndex() ;
G4cout<<"gas material = "<<anEnvelope->
GetMaterial()->GetName()<<G4endl ;
// plasma energy squared for plate material
@@ -161,149 +167,6 @@ G4bool G4VXrayTRmodel::ModelTrigger(const G4FastTrack& fastTrack)
return true ;
}
//////////////////////////////////////////////////////////////////////////////
//
//
void G4VXrayTRmodel::DoIt( const G4FastTrack& fastTrack ,
G4FastStep& fastStep )
{
G4int iTkin, iPlace, numOfTR, iTR, iTransfer ;
G4double energyPos, energyTR, theta, phi, dirX, dirY, dirZ ;
G4double W, W1, W2, E1, E2 ;
G4double charge = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGCharge() ;
// Now we are ready to Generate TR photons
G4double chargeSq = charge*charge ;
G4double kinEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy() ;
G4double mass = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGMass() ;
G4double gamma = 1.0 + kinEnergy/mass ;
// G4cout<<"gamma = "<<gamma<<G4endl ;
G4double massRatio = proton_mass_c2/mass ;
G4double TkinScaled = kinEnergy*massRatio ;
G4ParticleMomentum direction(fastTrack.GetPrimaryTrackLocalDirection());
G4double distance = fastTrack.GetEnvelopeSolid()->
DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
direction) ;
G4ThreeVector position = fastTrack.GetPrimaryTrackLocalPosition() +
distance*direction ;
// Set final position:
fastStep.SetPrimaryTrackFinalPosition(position);
for(iTkin=0;iTkin<fTotBin;iTkin++)
{
if(TkinScaled < fProtonEnergyVector->GetLowEdgeEnergy(iTkin)) break ;
}
iPlace = iTkin - 1 ;
// G4ParticleMomentum particleDir = fastTrack.GetPrimaryTrack()->
// GetMomentumDirection() ;
if(iTkin == 0) // Tkin is too small, neglect of TR photon generation
{
return ;
}
else // general case: Tkin between two vectors of the material
{
if(iTkin == fTotBin)
{
numOfTR = RandPoisson::shoot( (*(*fEnergyDistrTable)(iPlace))(0)*chargeSq ) ;
}
else
{
E1 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin - 1) ;
E2 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin) ;
W = 1.0/(E2 - E1) ;
W1 = (E2 - TkinScaled)*W ;
W2 = (TkinScaled - E1)*W ;
numOfTR = RandPoisson::shoot( ( (*(*fEnergyDistrTable)(iPlace))(0)*W1+
(*(*fEnergyDistrTable)(iPlace+1))(0)*W2 )
*chargeSq ) ;
}
// G4cout<<iTkin<<" mean TR number = "<<(((*(*fEnergyDistrTable)(iPlace))(0)+
// (*(*fAngleDistrTable)(iPlace))(0))*W1 +
// ((*(*fEnergyDistrTable)(iPlace + 1))(0)+
// (*(*fAngleDistrTable)(iPlace + 1))(0))*W2)
// *chargeSq*0.5<<endl ;
if( numOfTR == 0 ) // no change, return
{
return ;
}
else
{
// G4cout<<"Number of X-ray TR photons = "<<numOfTR<<endl ;
fastStep.SetNumberOfSecondaries(numOfTR);
G4double sumEnergyTR = 0.0 ;
for(iTR=0;iTR<numOfTR;iTR++)
{
// energyPos = ((*(*fEnergyDistrTable)(iPlace))(0)*W1+
// (*(*fEnergyDistrTable)(iPlace + 1))(0)*W2)*G4UniformRand() ;
// for(iTransfer=0;iTransfer<fBinTR-1;iTransfer++)
// {
// if(energyPos >= ((*(*fEnergyDistrTable)(iPlace))(iTransfer)*W1+
// (*(*fEnergyDistrTable)(iPlace + 1))(iTransfer)*W2)) break ;
// }
// energyTR = ((*fEnergyDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer))*W1+
// ((*fEnergyDistrTable)(iPlace + 1)->GetLowEdgeEnergy(iTransfer))*W2 ;
energyTR = GetXTRrandomEnergy(TkinScaled,iTkin) ;
// G4cout<<"energyTR = "<<energyTR/keV<<"keV"<<endl ;
sumEnergyTR += energyTR ;
theta = abs(G4RandGauss::shoot(0.0,pi/gamma)) ;
if( theta >= 0.1 ) theta = 0.1 ;
// G4cout<<" : theta = "<<theta<<endl ;
phi = twopi*G4UniformRand() ;
dirX = sin(theta)*cos(phi) ;
dirY = sin(theta)*sin(phi) ;
dirZ = cos(theta) ;
G4ThreeVector directionTR(dirX,dirY,dirZ) ;
directionTR.rotateUz(direction) ;
directionTR.unit() ;
G4DynamicParticle aPhotonTR(G4Gamma::Gamma(),directionTR,energyTR) ;
G4ThreeVector positionTR = fastTrack.GetPrimaryTrackLocalPosition() +
G4UniformRand()*distance*direction ;
G4double distanceTR = fastTrack.GetEnvelopeSolid()->
DistanceToOut(positionTR,directionTR) ;
positionTR = positionTR + distanceTR*directionTR ;
fastStep.CreateSecondaryTrack( aPhotonTR,
positionTR,
fastTrack.GetPrimaryTrack()->
GetGlobalTime() ) ;
}
kinEnergy -= sumEnergyTR ;
fastStep.SetPrimaryTrackFinalKineticEnergy(kinEnergy) ;
}
}
return ;
}
//////////////////////////////////////////////////////////////////////////
//
@@ -387,6 +250,27 @@ G4double G4VXrayTRmodel::GetPlateFormationZone( G4double omega ,
return cof ;
}
//////////////////////////////////////////////////////////////////////
//
// Calculates complex formation zone for plates. Omega is energy !!!
G4complex G4VXrayTRmodel::GetPlateComplexFZ( G4double omega ,
G4double gamma ,
G4double varAngle )
{
G4double cof, length,delta, real, image ;
length = 0.5*GetPlateFormationZone(omega,gamma,varAngle) ;
delta = length*GetPlateLinearPhotoAbs(omega) ;
cof = 1.0/(1.0 + delta*delta) ;
real = length*cof ;
image = real*delta ;
G4complex zone(real,image);
return zone ;
}
////////////////////////////////////////////////////////////////////////
//
// Computes matrix of Sandia photo absorption cross section coefficients for
@@ -480,6 +364,30 @@ G4double G4VXrayTRmodel::GetGasFormationZone( G4double omega ,
}
//////////////////////////////////////////////////////////////////////
//
// Calculates complex formation zone for gas gaps. Omega is energy !!!
G4complex G4VXrayTRmodel::GetGasComplexFZ( G4double omega ,
G4double gamma ,
G4double varAngle )
{
G4double cof, length,delta, real, image ;
length = 0.5*GetGasFormationZone(omega,gamma,varAngle) ;
delta = length*GetGasLinearPhotoAbs(omega) ;
cof = 1.0/(1.0 + delta*delta) ;
real = length*cof ;
image = real*delta ;
G4complex zone(real,image);
return zone ;
}
////////////////////////////////////////////////////////////////////////
//
// Computes matrix of Sandia photo absorption cross section coefficients for
@@ -581,7 +489,7 @@ void G4VXrayTRmodel::GetPlateZmuProduct()
outPlate.setf( G4std::ios::scientific, G4std::ios::floatfield );
G4int i ;
G4double omega, varAngle, gamma, result ;
G4double omega, varAngle, gamma ;
gamma = 10000. ;
varAngle = 1/gamma/gamma ;
G4cout<<"energy, keV"<<"\t"<<"Zmu for plate"<<G4endl ;
@@ -615,7 +523,7 @@ void G4VXrayTRmodel::GetGasZmuProduct()
G4std::ofstream outGas("gasZmu.dat", G4std::ios::out ) ;
outGas.setf( G4std::ios::scientific, G4std::ios::floatfield );
G4int i ;
G4double omega, varAngle, gamma, result ;
G4double omega, varAngle, gamma ;
gamma = 10000. ;
varAngle = 1/gamma/gamma ;
G4cout<<"energy, keV"<<"\t"<<"Zmu for gas"<<G4endl ;
@@ -656,107 +564,6 @@ G4VXrayTRmodel::OneBoundaryXTRNdensity( G4double energy,G4double gamma,
}
//////////////////////////////////////////////////////////////////////////
//
//
void G4VXrayTRmodel::BuildTable()
{
G4int iMat, jMat, iTkin, iTR, iPlace ;
G4double radiatorCof = 1.0 ; // for tuning of XTR yield
// fAngleDistrTable = new G4PhysicsTable(fTotBin) ;
fEnergyDistrTable = new G4PhysicsTable(fTotBin) ;
fGammaTkinCut = 0.0 ;
// setting of min/max TR energies
if(fGammaTkinCut > fTheMinEnergyTR) fMinEnergyTR = fGammaTkinCut ;
else fMinEnergyTR = fTheMinEnergyTR ;
if(fGammaTkinCut > fTheMaxEnergyTR) fMaxEnergyTR = 2.0*fGammaTkinCut ;
else fMaxEnergyTR = fTheMaxEnergyTR ;
G4cout.precision(4) ;
G4Timer timer ;
timer.Start() ;
for(iTkin=0;iTkin<fTotBin;iTkin++) // Lorentz factor loop
{
G4PhysicsLogVector* energyVector = new G4PhysicsLogVector( fMinEnergyTR,
fMaxEnergyTR,
fBinTR ) ;
fGamma = 1.0 + (fProtonEnergyVector->
GetLowEdgeEnergy(iTkin)/proton_mass_c2) ;
fMaxThetaTR = 25.0/(fGamma*fGamma) ; // theta^2
fTheMinAngle = 1.0e-6 ; // was 5.e-6, e-5, e-4
if( fMaxThetaTR > fTheMaxAngle ) fMaxThetaTR = fTheMaxAngle ;
else
{
if( fMaxThetaTR < fTheMinAngle ) fMaxThetaTR = fTheMinAngle ;
}
G4PhysicsLinearVector* angleVector = new G4PhysicsLinearVector( 0.0,
fMaxThetaTR,
fBinTR ) ;
G4double energySum = 0.0 ;
G4double angleSum = 0.0 ;
G4Integrator<G4VXrayTRmodel,G4double(G4VXrayTRmodel::*)(G4double)> integral ;
energyVector->PutValue(fBinTR-1,energySum) ;
angleVector->PutValue(fBinTR-1,angleSum) ;
for(iTR=fBinTR-2;iTR>=0;iTR--)
{
energySum += radiatorCof*fCofTR*integral.Legendre10(
this,&G4VXrayTRmodel::XTRNSpectralDensity,
energyVector->GetLowEdgeEnergy(iTR),
energyVector->GetLowEdgeEnergy(iTR+1) ) ;
// angleSum += fCofTR*integral.Legendre96(
// this,&G4VXrayTRmodel::XTRNSpectralDensity,
// angleVector->GetLowEdgeEnergy(iTR),
// angleVector->GetLowEdgeEnergy(iTR+1) ) ;
energyVector->PutValue(iTR,energySum) ;
// angleVector ->PutValue(iTR,angleSum) ;
}
G4cout<<iTkin<<"\t"
<<"fGamma = "<<fGamma<<"\t" // <<" fMaxThetaTR = "<<fMaxThetaTR
<<"sumE = "<<energySum // <<" ; sumA = "<<angleSum
<<G4endl ;
iPlace = iTkin ;
fEnergyDistrTable->insertAt(iPlace,energyVector) ;
// fAngleDistrTable->insertAt(iPlace,angleVector) ;
}
timer.Stop() ;
G4cout.precision(6) ;
G4cout<<G4endl ;
G4cout<<"total time for build X-ray TR tables = "
<<timer.GetUserElapsed()<<" s"<<G4endl ;
return ;
}
//////////////////////////////////////////////////////////////////////////
//
//
void G4VXrayTRmodel::BuildEnergyTable()
{
return ;
}
////////////////////////////////////////////////////////////////////////
//
//
void G4VXrayTRmodel::BuildAngleTable()
{
return ;
}
//////////////////////////////////////////////////////////////////////////////
//
@@ -814,7 +621,7 @@ G4double G4VXrayTRmodel::XTRNAngleDensity(G4double varAngle)
void G4VXrayTRmodel::GetNumberOfPhotons()
{
G4int iTkin ;
G4double gamma, numberE, numberA ;
G4double gamma, numberE ;
G4std::ofstream outEn("numberE.dat", G4std::ios::out ) ;
outEn.setf( G4std::ios::scientific, G4std::ios::floatfield );