Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4Cerenkov.cc 71478 2013-06-17 07:49:29Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
// Cerenkov Radiation Class Implementation
@@ -103,8 +103,6 @@ G4Cerenkov::G4Cerenkov(const G4String& processName, G4ProcessType type)
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created " << G4endl;
}
BuildThePhysicsTable();
}
// G4Cerenkov::G4Cerenkov(const G4Cerenkov &right)
@@ -127,6 +125,22 @@ G4Cerenkov::~G4Cerenkov()
// Methods
////////////
G4bool G4Cerenkov::IsApplicable(const G4ParticleDefinition& aParticleType)
{
G4bool result = false;
if (aParticleType.GetPDGCharge() != 0.0 &&
aParticleType.GetPDGMass() != 0.0 &&
aParticleType.GetParticleName() != "chargedgeantino" &&
!aParticleType.IsShortLived() ) { result = true; }
return result;
}
void G4Cerenkov::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (!thePhysicsTable) BuildThePhysicsTable();
}
// PostStepDoIt
// -------------
//
@@ -368,8 +382,7 @@ void G4Cerenkov::BuildThePhysicsTable()
for (G4int i=0 ; i < numOfMaterials; i++)
{
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector =
new G4PhysicsOrderedFreeVector();
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector = 0;
// Retrieve vector of refraction indices for the material
// from the material's optical properties table
@@ -381,6 +394,7 @@ void G4Cerenkov::BuildThePhysicsTable()
if (aMaterialPropertiesTable) {
aPhysicsOrderedFreeVector = new G4PhysicsOrderedFreeVector();
G4MaterialPropertyVector* theRefractionIndexVector =
aMaterialPropertiesTable->GetProperty("RINDEX");
@@ -466,8 +480,14 @@ G4double G4Cerenkov::PostStepGetPhysicalInteractionLength(
*condition = NotForced;
G4double StepLimit = DBL_MAX;
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4Material* aMaterial = aTrack.GetMaterial();
G4int materialIndex = aMaterial->GetIndex();
// If Physics Vector is not defined no Cerenkov photons
// this check avoid string comparison below
if(!(*thePhysicsTable)[materialIndex]) { return StepLimit; }
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
G4double kineticEnergy = aParticle->GetKineticEnergy();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4ForwardXrayTR.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
// G4ForwardXrayTR class -- implementation file
//
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4GammaXTRadiator.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
#include <complex>
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4RegularXTRadiator.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
#include <complex>
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4Scintillation.cc 73929 2013-09-17 08:02:54Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
// Scintillation Light Class Implementation
@@ -107,6 +107,11 @@ G4Scintillation::G4Scintillation(const G4String& processName,
scintillationByParticleType = false;
#ifdef G4DEBUG_SCINTILLATION
ScintTrackEDep = 0.;
ScintTrackYield = 0.;
#endif
theFastIntegralTable = NULL;
theSlowIntegralTable = NULL;
@@ -114,8 +119,6 @@ G4Scintillation::G4Scintillation(const G4String& processName,
G4cout << GetProcessName() << " is created " << G4endl;
}
BuildThePhysicsTable();
emSaturation = NULL;
}
@@ -139,6 +142,12 @@ G4Scintillation::~G4Scintillation()
// Methods
////////////
void G4Scintillation::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (!theFastIntegralTable || !theSlowIntegralTable) BuildThePhysicsTable();
}
// AtRestDoIt
// ----------
//
@@ -159,8 +168,8 @@ G4VParticleChange*
G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// This routine is called for each tracking step of a charged particle
// in a scintillator. A Poisson/Gauss-distributed number of photons is
// generated according to the scintillation yield formula, distributed
// in a scintillator. A Poisson/Gauss-distributed number of photons is
// generated according to the scintillation yield formula, distributed
// evenly along the track segment and uniformly into 4pi.
{
@@ -183,8 +192,8 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (!aMaterialPropertiesTable)
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
G4MaterialPropertyVector* Fast_Intensity =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
G4MaterialPropertyVector* Fast_Intensity =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
G4MaterialPropertyVector* Slow_Intensity =
aMaterialPropertiesTable->GetProperty("SLOWCOMPONENT");
@@ -196,95 +205,15 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double ScintillationYield = 0.;
// Scintillation depends on particle type, energy deposited
if (scintillationByParticleType) {
// The scintillation response is a function of the energy
// deposited by particle types.
// Get the definition of the current particle
G4ParticleDefinition *pDef = aParticle->GetDefinition();
G4MaterialPropertyVector *Scint_Yield_Vector = NULL;
ScintillationYield =
GetScintillationYieldByParticleType(aTrack, aStep);
// Obtain the G4MaterialPropertyVectory containing the
// scintillation light yield as a function of the deposited
// energy for the current particle type
// Protons
if(pDef==G4Proton::ProtonDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("PROTONSCINTILLATIONYIELD");
// Deuterons
else if(pDef==G4Deuteron::DeuteronDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("DEUTERONSCINTILLATIONYIELD");
// Tritons
else if(pDef==G4Triton::TritonDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("TRITONSCINTILLATIONYIELD");
// Alphas
else if(pDef==G4Alpha::AlphaDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ALPHASCINTILLATIONYIELD");
// Ions (particles derived from G4VIon and G4Ions)
// and recoil ions below tracking cut from neutrons after hElastic
else if(pDef->GetParticleType()== "nucleus" ||
pDef==G4Neutron::NeutronDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("IONSCINTILLATIONYIELD");
// Electrons (must also account for shell-binding energy
// attributed to gamma from standard PhotoElectricEffect)
else if(pDef==G4Electron::ElectronDefinition() ||
pDef==G4Gamma::GammaDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
// Default for particles not enumerated/listed above
else
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
// If the user has not specified yields for (p,d,t,a,carbon)
// then these unspecified particles will default to the
// electron's scintillation yield
if(!Scint_Yield_Vector){
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
}
// Throw an exception if no scintillation yield is found
if (!Scint_Yield_Vector) {
G4ExceptionDescription ed;
ed << "\nG4Scintillation::PostStepDoIt(): "
<< "Request for scintillation yield for energy deposit and particle type without correct entry in MaterialPropertiesTable\n"
<< "ScintillationByParticleType requires at minimum that ELECTRONSCINTILLATIONYIELD is set by the user\n"
<< G4endl;
G4String comments = "Missing MaterialPropertiesTable entry - No correct entry in MaterialPropertiesTable";
G4Exception("G4Scintillation::PostStepDoIt","Scint01",
FatalException,ed,comments);
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
if (verboseLevel>1) {
G4cout << "\n"
<< "Particle = " << pDef->GetParticleName() << "\n"
<< "Energy Dep. = " << TotalEnergyDeposit/MeV << "\n"
<< "Yield = "
<< Scint_Yield_Vector->Value(TotalEnergyDeposit)
<< "\n" << G4endl;
}
// Obtain the scintillation yield using the total energy
// deposited by the particle in this step.
// Units: [# scintillation photons]
ScintillationYield = Scint_Yield_Vector->
Value(TotalEnergyDeposit);
} else {
// The default linear scintillation process
} else {
ScintillationYield = aMaterialPropertiesTable->
GetConstProperty("SCINTILLATIONYIELD");
@@ -328,7 +257,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (NumPhotons <= 0)
{
// return unchanged particle and no secondaries
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
@@ -348,7 +277,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4int materialIndex = aMaterial->GetIndex();
// Retrieve the Scintillation Integral for this material
// Retrieve the Scintillation Integral for this material
// new G4PhysicsOrderedFreeVector allocated to hold CII's
G4int Num = NumPhotons;
@@ -361,7 +290,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (scnt == 1) {
if (nscnt == 1) {
if(Fast_Intensity){
if (Fast_Intensity) {
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("FASTTIMECONSTANT");
if (fFiniteRiseTime) {
@@ -369,9 +298,10 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
GetConstProperty("FASTSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theFastIntegralTable)(materialIndex));
(G4PhysicsOrderedFreeVector*)
((*theFastIntegralTable)(materialIndex));
}
if(Slow_Intensity){
if (Slow_Intensity) {
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("SLOWTIMECONSTANT");
if (fFiniteRiseTime) {
@@ -379,13 +309,14 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
GetConstProperty("SLOWSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theSlowIntegralTable)(materialIndex));
(G4PhysicsOrderedFreeVector*)
((*theSlowIntegralTable)(materialIndex));
}
}
else {
G4double YieldRatio = aMaterialPropertiesTable->
GetConstProperty("YIELDRATIO");
if ( ExcitationRatio == 1.0 ) {
if ( ExcitationRatio == 1.0 || ExcitationRatio == 0.0) {
Num = G4int (std::min(YieldRatio,1.0) * NumPhotons);
}
else {
@@ -398,7 +329,8 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
GetConstProperty("FASTSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theFastIntegralTable)(materialIndex));
(G4PhysicsOrderedFreeVector*)
((*theFastIntegralTable)(materialIndex));
}
}
else {
@@ -410,11 +342,12 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
GetConstProperty("SLOWSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theSlowIntegralTable)(materialIndex));
(G4PhysicsOrderedFreeVector*)
((*theSlowIntegralTable)(materialIndex));
}
if (!ScintillationIntegral) continue;
// Max Scintillation Integral
G4double CIImax = ScintillationIntegral->GetMaxValue();
@@ -424,7 +357,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// Determine photon energy
G4double CIIvalue = G4UniformRand()*CIImax;
G4double sampledEnergy =
G4double sampledEnergy =
ScintillationIntegral->GetEnergy(CIIvalue);
if (verboseLevel>1) {
@@ -445,14 +378,14 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double py = sint*sinp;
G4double pz = cost;
// Create photon momentum direction vector
// Create photon momentum direction vector
G4ParticleMomentum photonMomentum(px, py, pz);
// Determine polarization of new photon
// Determine polarization of new photon
G4double sx = cost*cosp;
G4double sy = cost*sinp;
G4double sy = cost*sinp;
G4double sz = -sint;
G4ThreeVector photonPolarization(sx, sy, sz);
@@ -470,7 +403,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// Generate a new photon:
G4DynamicParticle* aScintillationPhoton =
new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(),
new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(),
photonMomentum);
aScintillationPhoton->SetPolarization
(photonPolarization.x(),
@@ -496,7 +429,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// emission time distribution
if (ScintillationRiseTime==0.0) {
deltaTime = deltaTime -
deltaTime = deltaTime -
ScintillationTime * std::log( G4UniformRand() );
} else {
deltaTime = deltaTime +
@@ -508,8 +441,9 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4ThreeVector aSecondaryPosition =
x0 + rand * aStep.GetDeltaPosition();
G4Track* aSecondaryTrack =
new G4Track(aScintillationPhoton,aSecondaryTime,aSecondaryPosition);
G4Track* aSecondaryTrack = new G4Track(aScintillationPhoton,
aSecondaryTime,
aSecondaryPosition);
aSecondaryTrack->SetTouchableHandle(
aStep.GetPreStepPoint()->GetTouchableHandle());
@@ -523,7 +457,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
}
if (verboseLevel>0) {
G4cout << "\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
G4cout << "\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
@@ -538,14 +472,16 @@ void G4Scintillation::BuildThePhysicsTable()
{
if (theFastIntegralTable && theSlowIntegralTable) return;
const G4MaterialTable* theMaterialTable =
const G4MaterialTable* theMaterialTable =
G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
// create new physics table
if(!theFastIntegralTable)theFastIntegralTable = new G4PhysicsTable(numOfMaterials);
if(!theSlowIntegralTable)theSlowIntegralTable = new G4PhysicsTable(numOfMaterials);
if(!theFastIntegralTable)theFastIntegralTable =
new G4PhysicsTable(numOfMaterials);
if(!theSlowIntegralTable)theSlowIntegralTable =
new G4PhysicsTable(numOfMaterials);
// loop for materials
@@ -566,20 +502,20 @@ void G4Scintillation::BuildThePhysicsTable()
if (aMaterialPropertiesTable) {
G4MaterialPropertyVector* theFastLightVector =
G4MaterialPropertyVector* theFastLightVector =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
if (theFastLightVector) {
// Retrieve the first intensity point in vector
// of (photon energy, intensity) pairs
// of (photon energy, intensity) pairs
G4double currentIN = (*theFastLightVector)[0];
if (currentIN >= 0.0) {
// Create first (photon energy, Scintillation
// Integral pair
// Create first (photon energy, Scintillation
// Integral pair
G4double currentPM = theFastLightVector->Energy(0);
@@ -595,7 +531,7 @@ void G4Scintillation::BuildThePhysicsTable()
G4double prevIN = currentIN;
// loop over all (photon energy, intensity)
// pairs stored for this material
// pairs stored for this material
for (size_t ii = 1;
ii < theFastLightVector->GetVectorLength();
@@ -737,7 +673,7 @@ G4double G4Scintillation::sample_time(G4double tau1, G4double tau2)
// exponential distribution as envelope function: very efficient
//
G4double d = (tau1+tau2)/tau2;
// make sure the envelope function is
// make sure the envelope function is
// always larger than the bi-exponential
G4double t = -1.0*tau2*std::log(1-ran1);
G4double gg = d*single_exp(t,tau2);
@@ -745,3 +681,149 @@ G4double G4Scintillation::sample_time(G4double tau1, G4double tau2)
}
return -1.0;
}
G4double G4Scintillation::
GetScintillationYieldByParticleType(const G4Track &aTrack, const G4Step &aStep)
{
////////////////////////////////////////
// Get the scintillation yield vector //
////////////////////////////////////////
G4ParticleDefinition *pDef = aTrack.GetDynamicParticle()->GetDefinition();
G4MaterialPropertyVector *Scint_Yield_Vector = NULL;
G4MaterialPropertiesTable *aMaterialPropertiesTable
= aTrack.GetMaterial()->GetMaterialPropertiesTable();
// Get the G4MaterialPropertyVector containing the scintillation
// yield as a function of the energy deposited and particle type
// Protons
if(pDef==G4Proton::ProtonDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("PROTONSCINTILLATIONYIELD");
// Deuterons
else if(pDef==G4Deuteron::DeuteronDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("DEUTERONSCINTILLATIONYIELD");
// Tritons
else if(pDef==G4Triton::TritonDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("TRITONSCINTILLATIONYIELD");
// Alphas
else if(pDef==G4Alpha::AlphaDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ALPHASCINTILLATIONYIELD");
// Ions (particles derived from G4VIon and G4Ions) and recoil ions
// below the production cut from neutrons after hElastic
else if(pDef->GetParticleType()== "nucleus" ||
pDef==G4Neutron::NeutronDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("IONSCINTILLATIONYIELD");
// Electrons (must also account for shell-binding energy
// attributed to gamma from standard photoelectric effect)
else if(pDef==G4Electron::ElectronDefinition() ||
pDef==G4Gamma::GammaDefinition())
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
// Default for particles not enumerated/listed above
else
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
// If the user has specified none of the above particles then the
// default is the electron scintillation yield
if(!Scint_Yield_Vector)
Scint_Yield_Vector = aMaterialPropertiesTable->
GetProperty("ELECTRONSCINTILLATIONYIELD");
// Throw an exception if no scintillation yield vector is found
if (!Scint_Yield_Vector) {
G4ExceptionDescription ed;
ed << "\nG4Scintillation::PostStepDoIt(): "
<< "Request for scintillation yield for energy deposit and particle\n"
<< "type without correct entry in MaterialPropertiesTable.\n"
<< "ScintillationByParticleType requires at minimum that \n"
<< "ELECTRONSCINTILLATIONYIELD is set by the user\n"
<< G4endl;
G4String comments = "Missing MaterialPropertiesTable entry - No correct entry in MaterialPropertiesTable";
G4Exception("G4Scintillation::PostStepDoIt","Scint01",
FatalException,ed,comments);
}
///////////////////////////////////////
// Calculate the scintillation light //
///////////////////////////////////////
// To account for potential nonlinearity and scintillation photon
// density along the track, light (L) is produced according to:
//
// L_currentStep = L(PreStepKE) - L(PreStepKE - EDep)
G4double ScintillationYield = 0.;
G4double StepEnergyDeposit = aStep.GetTotalEnergyDeposit();
G4double PreStepKineticEnergy = aStep.GetPreStepPoint()->GetKineticEnergy();
if(PreStepKineticEnergy <= Scint_Yield_Vector->GetMaxEnergy()){
G4double Yield1 = Scint_Yield_Vector->Value(PreStepKineticEnergy);
G4double Yield2 = Scint_Yield_Vector->
Value(PreStepKineticEnergy - StepEnergyDeposit);
ScintillationYield = Yield1 - Yield2;
} else {
G4ExceptionDescription ed;
ed << "\nG4Scintillation::GetScintillationYieldByParticleType(): Request\n"
<< "for scintillation light yield above the available energy range\n"
<< "specifed in G4MaterialPropertiesTable. A linear interpolation\n"
<< "will be performed to compute the scintillation light yield using\n"
<< "(L_max / E_max) as the photon yield per unit energy."
<< G4endl;
G4String cmt = "\nScintillation yield may be unphysical!\n";
G4Exception("G4Scintillation::GetScintillationYieldByParticleType()",
"Scint03", JustWarning, ed, cmt);
G4double LinearYield = Scint_Yield_Vector->GetMaxValue()
/ Scint_Yield_Vector->GetMaxEnergy();
// Units: [# scintillation photons]
ScintillationYield = LinearYield * StepEnergyDeposit;
}
#ifdef G4DEBUG_SCINTILLATION
// Increment track aggregators
ScintTrackYield += ScintillationYield;
ScintTrackEDep += StepEnergyDeposit;
G4cout << "\n--- G4Scintillation::GetScintillationYieldByParticleType() ---\n"
<< "--\n"
<< "-- Name = " << aTrack.GetParticleDefinition()->GetParticleName() << "\n"
<< "-- TrackID = " << aTrack.GetTrackID() << "\n"
<< "-- ParentID = " << aTrack.GetParentID() << "\n"
<< "-- Current KE = " << aTrack.GetKineticEnergy()/MeV << " MeV\n"
<< "-- Step EDep = " << aStep.GetTotalEnergyDeposit()/MeV << " MeV\n"
<< "-- Track EDep = " << ScintTrackEDep/MeV << " MeV\n"
<< "-- Vertex KE = " << aTrack.GetVertexKineticEnergy()/MeV << " MeV\n"
<< "-- Step yield = " << ScintillationYield << " photons\n"
<< "-- Track yield = " << ScintTrackYield << " photons\n"
<< G4endl;
// The track has terminated within or has left the scintillator volume
if( (aTrack.GetTrackStatus() == fStopButAlive) or
(aStep.GetPostStepPoint()->GetStepStatus() == fGeomBoundary) ){
// Reset aggregators for the next track
ScintTrackEDep = 0.;
ScintTrackYield = 0.;
}
#endif
return ScintillationYield;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4StrawTubeXTRadiator.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
#include "G4StrawTubeXTRadiator.hh"
@@ -201,7 +201,7 @@ G4double G4StrawTubeXTRadiator::GetMediumLinearPhotoAbs(G4double omega)
omega3 = omega2*omega;
omega4 = omega2*omega2;
G4double* SandiaCof = fMediumPhotoAbsCof->GetSandiaCofForMaterial(omega);
const G4double* SandiaCof = fMediumPhotoAbsCof->GetSandiaCofForMaterial(omega);
G4double cross = SandiaCof[0]/omega + SandiaCof[1]/omega2 +
SandiaCof[2]/omega3 + SandiaCof[3]/omega4;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4SynchrotronRadiation.cc 74582 2013-10-15 12:06:25Z gcosmo $
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
@@ -46,6 +46,8 @@
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4EmProcessSubType.hh"
#include "G4DipBustGenerator.hh"
#include "G4Log.hh"
///////////////////////////////////////////////////////////////////////
//
@@ -68,7 +70,11 @@ G4SynchrotronRadiation::G4SynchrotronRadiation(const G4String& processName,
fEnergyConst = 1.5*c_light*c_light*eplus*hbar_Planck/electron_mass_c2 ;
SetProcessSubType(fSynchrotronRadiation);
verboseLevel=1;
verboseLevel = 1;
FirstTime = true;
FirstTime1 = true;
genAngle = 0;
SetAngularGenerator(new G4DipBustGenerator());
}
/////////////////////////////////////////////////////////////////////////
@@ -77,20 +83,38 @@ G4SynchrotronRadiation::G4SynchrotronRadiation(const G4String& processName,
//
G4SynchrotronRadiation::~G4SynchrotronRadiation()
{}
{
delete genAngle;
}
/////////////////////////////// METHODS /////////////////////////////////
//
void
G4SynchrotronRadiation::SetAngularGenerator(G4VEmAngularDistribution* p)
{
if(p != genAngle) {
delete genAngle;
genAngle = p;
}
}
G4bool
G4SynchrotronRadiation::IsApplicable(const G4ParticleDefinition& particle)
{
return ( ( &particle == theElectron ) || ( &particle == thePositron ));
}
/////////////////////////////////////////////////////////////////////////
//
// Production of synchrotron X-ray photon
// GEANT4 internal units.
//
G4double
G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
G4double,
G4ForceCondition* condition)
G4SynchrotronRadiation::GetMeanFreePath(const G4Track& trackData,
G4double,
G4ForceCondition* condition)
{
// gives the MeanFreePath in GEANT4 internal units
G4double MeanFreePath;
@@ -104,27 +128,25 @@ G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
G4double particleCharge = aDynamicParticle->GetDefinition()->GetPDGCharge();
if ( gamma < 1.0e3 ) MeanFreePath = DBL_MAX;
if ( gamma < 1.0e3 || 0.0 == particleCharge) { MeanFreePath = DBL_MAX; }
else
{
G4ThreeVector FieldValue;
const G4Field* pField = 0;
const G4Field* pField = 0;
G4bool fieldExertsForce = false;
G4FieldManager* fieldMgr=0;
G4bool fieldExertsForce = false;
if( (particleCharge != 0.0) )
G4FieldManager* fieldMgr =
fFieldPropagator->FindAndSetFieldManager(trackData.GetVolume());
if ( fieldMgr != 0 )
{
fieldMgr = fFieldPropagator->FindAndSetFieldManager( trackData.GetVolume() );
// If the field manager has no field, there is no field !
if ( fieldMgr != 0 )
{
// If the field manager has no field, there is no field !
fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 );
}
fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 );
}
if ( fieldExertsForce )
{
pField = fieldMgr->GetDetectorField();
@@ -143,8 +165,6 @@ G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
FieldValueVec[1],
FieldValueVec[2] );
G4ThreeVector unitMomentum = aDynamicParticle->GetMomentumDirection();
G4ThreeVector unitMcrossB = FieldValue.cross(unitMomentum);
G4double perpB = unitMcrossB.mag();
@@ -152,7 +172,6 @@ G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
if( perpB > 0.0 ) MeanFreePath = fLambdaConst/perpB;
else MeanFreePath = DBL_MAX;
static G4bool FirstTime=true;
if(verboseLevel > 0 && FirstTime)
{
G4cout << "G4SynchrotronRadiation::GetMeanFreePath :" << '\n'
@@ -160,31 +179,32 @@ G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
<< G4endl;
if(verboseLevel > 1)
{
G4ThreeVector pvec=aDynamicParticle->GetMomentum();
G4double Btot=FieldValue.getR();
G4double ptot=pvec.getR();
G4double rho= ptot / (MeV * c_light * Btot ); // full bending radius
G4double Theta=unitMomentum.theta(FieldValue); // angle between particle and field
G4cout
<< " B = " << Btot/tesla << " Tesla"
<< " perpB = " << perpB/tesla << " Tesla"
<< " Theta = " << Theta << " std::sin(Theta)=" << std::sin(Theta) << '\n'
<< " ptot = " << G4BestUnit(ptot,"Energy")
<< " rho = " << G4BestUnit(rho,"Length")
<< G4endl;
G4ThreeVector pvec = aDynamicParticle->GetMomentum();
G4double Btot = FieldValue.getR();
G4double ptot = pvec.getR();
G4double rho = ptot / (MeV * c_light * Btot );
// full bending radius
G4double Theta=unitMomentum.theta(FieldValue);
// angle between particle and field
G4cout << " B = " << Btot/tesla << " Tesla"
<< " perpB = " << perpB/tesla << " Tesla"
<< " Theta = " << Theta << " std::sin(Theta)="
<< std::sin(Theta) << '\n'
<< " ptot = " << G4BestUnit(ptot,"Energy")
<< " rho = " << G4BestUnit(rho,"Length")
<< G4endl;
}
FirstTime=false;
}
}
else MeanFreePath = DBL_MAX;
}
return MeanFreePath;
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
//
@@ -195,33 +215,30 @@ G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData,
{
aParticleChange.Initialize(trackData);
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
const G4DynamicParticle* aDynamicParticle = trackData.GetDynamicParticle();
G4double gamma = aDynamicParticle->GetTotalEnergy()/
(aDynamicParticle->GetMass() );
if(gamma <= 1.0e3 )
G4double particleCharge = aDynamicParticle->GetDefinition()->GetPDGCharge();
if(gamma <= 1.0e3 || 0.0 == particleCharge)
{
return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
}
G4double particleCharge = aDynamicParticle->GetDefinition()->GetPDGCharge();
G4ThreeVector FieldValue;
const G4Field* pField = 0;
G4FieldManager* fieldMgr=0;
G4bool fieldExertsForce = false;
G4FieldManager* fieldMgr =
fFieldPropagator->FindAndSetFieldManager(trackData.GetVolume());
if( (particleCharge != 0.0) )
if ( fieldMgr != 0 )
{
fieldMgr = fFieldPropagator->FindAndSetFieldManager( trackData.GetVolume() );
if ( fieldMgr != 0 )
{
// If the field manager has no field, there is no field !
fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 );
}
// If the field manager has no field, there is no field !
fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 );
}
if ( fieldExertsForce )
{
pField = fieldMgr->GetDetectorField();
@@ -234,8 +251,8 @@ G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData,
pField->GetFieldValue( globPosVec, FieldValueVec );
FieldValue = G4ThreeVector( FieldValueVec[0],
FieldValueVec[1],
FieldValueVec[2] );
FieldValueVec[1],
FieldValueVec[2] );
G4ThreeVector unitMomentum = aDynamicParticle->GetMomentumDirection();
G4ThreeVector unitMcrossB = FieldValue.cross(unitMomentum);
@@ -253,61 +270,21 @@ G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData,
return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
}
G4double kineticEnergy = aDynamicParticle->GetKineticEnergy();
G4ParticleMomentum
particleDirection = aDynamicParticle->GetMomentumDirection();
// M-C of its direction, simplified dipole boosted approach
// G4double Teta, fteta; // = G4UniformRand()/gamma; // Very roughly
G4double cosTheta, sinTheta, fcos, beta;
do
{
cosTheta = 1. - 2.*G4UniformRand();
fcos = (1 + cosTheta*cosTheta)*0.5;
}
while( fcos < G4UniformRand() );
beta = std::sqrt(1. - 1./(gamma*gamma));
cosTheta = (cosTheta + beta)/(1. + beta*cosTheta);
if( cosTheta > 1. ) cosTheta = 1.;
if( cosTheta < -1. ) cosTheta = -1.;
sinTheta = std::sqrt(1. - cosTheta*cosTheta );
G4double Phi = twopi * G4UniformRand();
G4double dirx = sinTheta*std::cos(Phi) ,
diry = sinTheta*std::sin(Phi) ,
dirz = cosTheta;
G4ThreeVector gammaDirection ( dirx, diry, dirz);
gammaDirection.rotateUz(particleDirection);
// polarization of new gamma
// G4double sx = std::cos(Teta)*std::cos(Phi);
// G4double sy = std::cos(Teta)*std::sin(Phi);
// G4double sz = -std::sin(Teta);
G4ThreeVector gammaDirection =
genAngle->SampleDirection(aDynamicParticle,
energyOfSR, 1, 0);
G4ThreeVector gammaPolarization = FieldValue.cross(gammaDirection);
gammaPolarization = gammaPolarization.unit();
// (sx, sy, sz);
// gammaPolarization.rotateUz(particleDirection);
// create G4DynamicParticle object for the SR photon
G4DynamicParticle* aGamma= new G4DynamicParticle ( theGamma,
gammaDirection,
energyOfSR );
gammaDirection,
energyOfSR );
aGamma->SetPolarization( gammaPolarization.x(),
gammaPolarization.y(),
gammaPolarization.z() );
gammaPolarization.y(),
gammaPolarization.z() );
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(aGamma);
@@ -315,24 +292,21 @@ G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData,
// Update the incident particle
G4double newKinEnergy = kineticEnergy - energyOfSR;
aParticleChange.ProposeLocalEnergyDeposit (0.);
if (newKinEnergy > 0.)
{
aParticleChange.ProposeMomentumDirection( particleDirection );
aParticleChange.ProposeEnergy( newKinEnergy );
aParticleChange.ProposeEnergy( newKinEnergy );
}
else
{
aParticleChange.ProposeEnergy( 0. );
aParticleChange.ProposeEnergy( 0. );
}
}
}
return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
//
@@ -340,8 +314,8 @@ G4double G4SynchrotronRadiation::InvSynFracInt(G4double x)
// direct generation
{
// from 0 to 0.7
const G4double aa1=0 ,aa2=0.7;
const G4int ncheb1=27;
static const G4double aa1=0 ,aa2=0.7;
static const G4int ncheb1=27;
static const G4double cheb1[] =
{ 1.22371665676046468821,0.108956475422163837267,0.0383328524358594396134,0.00759138369340257753721,
0.00205712048644963340914,0.000497810783280019308661,0.000130743691810302187818,0.0000338168760220395409734,
@@ -351,8 +325,8 @@ G4double G4SynchrotronRadiation::InvSynFracInt(G4double x)
1.61856011449276096e-12,4.529450993473807e-13,1.2698603951096606e-13,3.566117394511206e-14,1.00301587494091e-14,
2.82515346447219e-15,7.9680747949792e-16};
// from 0.7 to 0.9132260271183847
const G4double aa3=0.9132260271183847;
const G4int ncheb2=27;
static const G4double aa3=0.9132260271183847;
static const G4int ncheb2=27;
static const G4double cheb2[] =
{ 1.1139496701107756,0.3523967429328067,0.0713849171926623,0.01475818043595387,0.003381255637322462,
0.0008228057599452224,0.00020785506681254216,0.00005390169253706556,0.000014250571923902464,3.823880733161044e-6,
@@ -362,8 +336,8 @@ G4double G4SynchrotronRadiation::InvSynFracInt(G4double x)
6.030906040404772e-15,1.9549163926819867e-15};
// Chebyshev with exp/log scale
// a = -Log[1 - SynFracInt[1]]; b = -Log[1 - SynFracInt[7]];
const G4double aa4=2.4444485538746025480,aa5=9.3830728608909477079;
const G4int ncheb3=28;
static const G4double aa4=2.4444485538746025480,aa5=9.3830728608909477079;
static const G4int ncheb3=28;
static const G4double cheb3[] =
{ 1.2292683840435586977,0.160353449247864455879,-0.0353559911947559448721,0.00776901561223573936985,
-0.00165886451971685133259,0.000335719118906954279467,-0.0000617184951079161143187,9.23534039743246708256e-6,
@@ -372,8 +346,8 @@ G4double G4SynchrotronRadiation::InvSynFracInt(G4double x)
2.31128525568385247392e-10,-6.41796873254200220876e-11,1.74815310473323361543e-11,-4.68653536933392363045e-12,
1.24016595805520752748e-12,-3.24839432979935522159e-13,8.44601465226513952994e-14,-2.18647276044246803998e-14,
5.65407548745690689978e-15,-1.46553625917463067508e-15,3.82059606377570462276e-16,-1.00457896653436912508e-16};
const G4double aa6=33.122936966163038145;
const G4int ncheb4=27;
static const G4double aa6=33.122936966163038145;
static const G4int ncheb4=27;
static const G4double cheb4[] =
{1.69342658227676741765,0.0742766400841232319225,-0.019337880608635717358,0.00516065527473364110491,
-0.00139342012990307729473,0.000378549864052022522193,-0.000103167085583785340215,0.0000281543441271412178337,
@@ -386,30 +360,32 @@ G4double G4SynchrotronRadiation::InvSynFracInt(G4double x)
if(x<aa2) return x*x*x*Chebyshev(aa1,aa2,cheb1,ncheb1,x);
else if(x<aa3) return Chebyshev(aa2,aa3,cheb2,ncheb2,x);
else if(x<1-0.0000841363)
{ G4double y=-std::log(1-x);
{ G4double y=-G4Log(1-x);
return y*Chebyshev(aa4,aa5,cheb3,ncheb3,y);
}
else
{ G4double y=-std::log(1-x);
{ G4double y=-G4Log(1-x);
return y*Chebyshev(aa5,aa6,cheb4,ncheb4,y);
}
}
G4double G4SynchrotronRadiation::GetRandomEnergySR(G4double gamma, G4double perpB)
G4double
G4SynchrotronRadiation::GetRandomEnergySR(G4double gamma, G4double perpB)
{
G4double Ecr=fEnergyConst*gamma*gamma*perpB;
static G4bool FirstTime=true;
if(verboseLevel > 0 && FirstTime)
// static G4ThreadLocal G4bool FirstTime=true;
if(verboseLevel > 0 && FirstTime1)
{ G4double Emean=8./(15.*std::sqrt(3.))*Ecr; // mean photon energy
G4double E_rms=std::sqrt(211./675.)*Ecr; // rms of photon energy distribution
G4int prec = G4cout.precision();
G4cout << "G4SynchrotronRadiation::GetRandomEnergySR :" << '\n' << std::setprecision(4)
<< " Ecr = " << G4BestUnit(Ecr,"Energy") << '\n'
<< " Emean = " << G4BestUnit(Emean,"Energy") << '\n'
<< " E_rms = " << G4BestUnit(E_rms,"Energy") << G4endl;
FirstTime=false;
G4cout << "G4SynchrotronRadiation::GetRandomEnergySR :" << '\n'
<< std::setprecision(4)
<< " Ecr = " << G4BestUnit(Ecr,"Energy") << '\n'
<< " Emean = " << G4BestUnit(Emean,"Energy") << '\n'
<< " E_rms = " << G4BestUnit(E_rms,"Energy") << G4endl;
FirstTime1=false;
G4cout.precision(prec);
}
@@ -417,17 +393,27 @@ G4double G4SynchrotronRadiation::GetRandomEnergySR(G4double gamma, G4double perp
return energySR;
}
///////////////////////////////////////////////////////////////////////////////
//
//
void G4SynchrotronRadiation::BuildPhysicsTable(const G4ParticleDefinition& part)
void
G4SynchrotronRadiation::BuildPhysicsTable(const G4ParticleDefinition& part)
{
if(0 < verboseLevel && &part==theElectron ) PrintInfoDefinition();
}
void G4SynchrotronRadiation::PrintInfoDefinition() // not yet called, usually called from BuildPhysicsTable
///////////////////////////////////////////////////////////////////////////////
//
//
void G4SynchrotronRadiation::PrintInfoDefinition()
// not yet called, usually called from BuildPhysicsTable
{
G4String comments ="Incoherent Synchrotron Radiation\n";
G4cout << G4endl << GetProcessName() << ": " << comments
<< " good description for long magnets at all energies" << G4endl;
<< " good description for long magnets at all energies"
<< G4endl;
}
///////////////////// end of G4SynchrotronRadiation.cc
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4SynchrotronRadiationInMat.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4TransitionRadiation.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
// G4TransitionRadiation class -- implementation file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4TransparentRegXTRadiator.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
#include <complex>
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VTransitionRadiation.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
// G4VTransitionRadiation class -- implementation file
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id$
// $Id: G4VXTRenergyLoss.cc 68037 2013-03-13 14:15:08Z gcosmo $
//
// History:
// 2001-2002 R&D by V.Grichine
@@ -1091,7 +1091,7 @@ G4double G4VXTRenergyLoss::GetPlateLinearPhotoAbs(G4double omega)
omega3 = omega2*omega;
omega4 = omega2*omega2;
G4double* SandiaCof = fPlatePhotoAbsCof->GetSandiaCofForMaterial(omega);
const G4double* SandiaCof = fPlatePhotoAbsCof->GetSandiaCofForMaterial(omega);
G4double cross = SandiaCof[0]/omega + SandiaCof[1]/omega2 +
SandiaCof[2]/omega3 + SandiaCof[3]/omega4;
return cross;
@@ -1162,7 +1162,7 @@ G4double G4VXTRenergyLoss::GetGasLinearPhotoAbs(G4double omega)
omega3 = omega2*omega;
omega4 = omega2*omega2;
G4double* SandiaCof = fGasPhotoAbsCof->GetSandiaCofForMaterial(omega);
const G4double* SandiaCof = fGasPhotoAbsCof->GetSandiaCofForMaterial(omega);
G4double cross = SandiaCof[0]/omega + SandiaCof[1]/omega2 +
SandiaCof[2]/omega3 + SandiaCof[3]/omega4;
return cross;