Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -0,0 +1,18 @@
#------------------------------------------------------------------------------
# CMakeLists.txt
# Module : G4xrays
# Package: Geant4.src.G4processes.G4electromagnetic.G4xrays
#
# CMakeLists.txt for building a single granular library.
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010/09/29 18:54:29 bmorgan Exp $
#
#------------------------------------------------------------------------------
if(GEANT4_BUILD_GRANULAR_LIBS)
include(Geant4MacroLibraryTargets)
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
endif()
+28 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.70 2009/07/29 23:43:27 gum Exp $
$Id: History,v 1.78 2010/11/09 21:51:07 gum Exp $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,33 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
09 November 10: P. Gumplinger (xrays-V09-03-06)
- fix coding error in G4Scintillation.cc
03 November 10: P. Gumplinger (xrays-V09-03-05)
- more corrections to G4Scintillation; now all particles are assigned the
ELECTRONSCINTILLATIONYIELD unless the user specifies otherwise
sort out where Ion and Neutron (recoil ions below tracking cut) should go
28 October 10: P. Gumplinger (xrays-V09-03-04)
- several small corrections to the previous implementation of G4Scintillation
19 October 10: P. Gumplinger (xrays-V09-03-03)
- G4Scintillation: allow for the light yield to be a function of
particle type and deposited energy in case of non-linear light
emission in scintillators. Thanks to Zach Hartwig (Department
of Nuclear Science and Engineeering - MIT)
14 October 10: V. Ivanchenko (xrays-V09-03-02)
- G4SynchrotronRadiationInMat, G4SynchrotronRadiation,
G4TransitionRadiation - added process sub-types
16 June 10: G. Cosmo (xrays-V09-03-01)
- Use mathematical functions in std namespace explicitely.
22 February 10: P. Gumplinger (xrays-V09-03-00)
- Scintillation rise time included, thanks to Martin Goettlich/DESY
29 July 09: P. Gumplinger (xrays-V09-02-00)
- Change IsApplicable for G4Cerenkov and G4Scintillation to
exclude short-lived particles.
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Scintillation.hh,v 1.16 2009/07/29 23:45:20 gum Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4Scintillation.hh,v 1.21 2010/10/28 23:29:21 gum Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
//
////////////////////////////////////////////////////////////////////////
@@ -37,7 +37,11 @@
// Version: 1.0
// Created: 1998-11-07
// Author: Peter Gumplinger
// Updated: 2005-07-28 add G4ProcessType to constructor
// Updated: 2010-10-20 Allow the scintillation yield to be a function
// of energy deposited by particle type
// Thanks to Zach Hartwig (Department of Nuclear
// Science and Engineeering - MIT)
// 2005-07-28 add G4ProcessType to constructor
// 2002-11-21 change to user G4Poisson for small MeanNumPotons
// 2002-11-07 allow for fast and slow scintillation
// 2002-11-05 make use of constant material properties
@@ -145,8 +149,15 @@ public: // With description
// produced scintillation photons are tracked next. When all
// have been tracked, the tracking of the primary resumes.
void SetFiniteRiseTime(const G4bool state);
// If set, the G4Scintillation process expects the user to have
// set the constant material property FAST/SLOWSCINTILLATIONRISETIME.
G4bool GetTrackSecondariesFirst() const;
// Returns the boolean flag for tracking secondaries first.
G4bool GetFiniteRiseTime() const;
// Returns the boolean flag for a finite scintillation rise time.
void SetScintillationYieldFactor(const G4double yieldfactor);
// Called to set the scintillation photon yield factor, needed when
@@ -174,9 +185,21 @@ public: // With description
void AddSaturation(G4EmSaturation* sat) { emSaturation = sat; }
// Adds Birks Saturation to the process.
void RemoveSaturation() { emSaturation = NULL; }
// Removes the Birks Saturation from the process.
G4EmSaturation* GetSaturation() const { return emSaturation; }
// Returns the Birks Saturation.
void SetScintillationByParticleType(const G4bool );
// Called by the user to set the scintillation yield as a function
// of energy deposited by particle type
G4bool GetScintillationByParticleType() const
{ return scintillationByParticleType; }
// Return the boolean that determines the method of scintillation
// production
void DumpPhysicsTable() const;
// Prints the fast and slow scintillation integral tables.
@@ -197,13 +220,22 @@ protected:
G4bool fTrackSecondariesFirst;
G4bool fFiniteRiseTime;
G4double YieldFactor;
G4double ExcitationRatio;
G4bool scintillationByParticleType;
private:
G4double single_exp(G4double t, G4double tau2);
G4double bi_exp(G4double t, G4double tau1, G4double tau2);
// emission time distribution when there is a finite rise time
G4double sample_time(G4double tau1, G4double tau2);
G4EmSaturation* emSaturation;
};
@@ -227,12 +259,24 @@ void G4Scintillation::SetTrackSecondariesFirst(const G4bool state)
fTrackSecondariesFirst = state;
}
inline
void G4Scintillation::SetFiniteRiseTime(const G4bool state)
{
fFiniteRiseTime = state;
}
inline
G4bool G4Scintillation::GetTrackSecondariesFirst() const
{
return fTrackSecondariesFirst;
}
inline
G4bool G4Scintillation::GetFiniteRiseTime() const
{
return fFiniteRiseTime;
}
inline
void G4Scintillation::SetScintillationYieldFactor(const G4double yieldfactor)
{
@@ -295,4 +339,16 @@ void G4Scintillation::DumpPhysicsTable() const
}
}
inline
G4double G4Scintillation::single_exp(G4double t, G4double tau2)
{
return std::exp(-1.0*t/tau2)/tau2;
}
inline
G4double G4Scintillation::bi_exp(G4double t, G4double tau1, G4double tau2)
{
return std::exp(-1.0*t/tau2)*(1-std::exp(-1.0*t/tau1))/tau2/tau2*(tau1+tau2);
}
#endif /* G4Scintillation_h */
@@ -0,0 +1,108 @@
#------------------------------------------------------------------------------
# sources.cmake
# Module : G4xrays
# Package: Geant4.src.G4processes.G4electromagnetic.G4xrays
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010/09/29 18:54:39 bmorgan Exp $
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPNumerics/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/bosons/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/barions/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/ions/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/mesons/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/leptons/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/cuts/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/electromagnetic/utils/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4xrays
HEADERS
G4Cerenkov.hh
G4ForwardXrayTR.hh
G4GammaXTRadiator.hh
G4RegularXTRadiator.hh
G4Scintillation.hh
G4StrawTubeXTRadiator.hh
G4SynchrotronRadiation.hh
G4SynchrotronRadiationInMat.hh
G4TransitionRadiation.hh
G4TransparentRegXTRadiator.hh
G4VTRModel.hh
G4VTransitionRadiation.hh
G4VXTRenergyLoss.hh
G4XTRGammaRadModel.hh
G4XTRRegularRadModel.hh
G4XTRTransparentRegRadModel.hh
SOURCES
G4Cerenkov.cc
G4ForwardXrayTR.cc
G4GammaXTRadiator.cc
G4RegularXTRadiator.cc
G4Scintillation.cc
G4StrawTubeXTRadiator.cc
G4SynchrotronRadiation.cc
G4SynchrotronRadiationInMat.cc
G4TransitionRadiation.cc
G4TransparentRegXTRadiator.cc
G4VTransitionRadiation.cc
G4VXTRenergyLoss.cc
G4XTRGammaRadModel.cc
G4XTRRegularRadModel.cc
G4XTRTransparentRegRadModel.cc
GRANULAR_DEPENDENCIES
G4baryons
G4bosons
G4cuts
G4emutils
G4geometrymng
G4globman
G4hepnumerics
G4ions
G4leptons
G4magneticfield
G4materials
G4mesons
G4navigation
G4partman
G4procman
G4track
G4volumes
GLOBAL_DEPENDENCIES
G4geometry
G4global
G4materials
G4particles
G4track
LINK_LIBRARIES
)
# List any source specific properties here
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4Cerenkov.cc,v 1.26 2008/11/14 20:16:51 gum Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Cerenkov.cc,v 1.27 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
////////////////////////////////////////////////////////////////////////
// Cerenkov Radiation Class Implementation
@@ -72,8 +72,6 @@
#include "G4Cerenkov.hh"
using namespace std;
/////////////////////////
// Class Implementation
/////////////////////////
@@ -266,14 +264,14 @@ G4Cerenkov::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
rand = G4UniformRand();
G4double phi = twopi*rand;
G4double sinPhi = sin(phi);
G4double cosPhi = cos(phi);
G4double sinPhi = std::sin(phi);
G4double cosPhi = std::cos(phi);
// calculate x,y, and z components of photon energy
// (in coord system with primary particle direction
// aligned with the z axis)
G4double sinTheta = sqrt(sin2Theta);
G4double sinTheta = std::sqrt(sin2Theta);
G4double px = sinTheta*cosPhi;
G4double py = sinTheta*sinPhi;
G4double pz = cosTheta;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4ForwardXrayTR.cc,v 1.14 2007/05/11 14:23:04 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4ForwardXrayTR.cc,v 1.15 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
// G4ForwardXrayTR class -- implementation file
@@ -84,8 +84,6 @@ G4double G4ForwardXrayTR::fPlasmaCof = 4.0*pi*fine_structure_const*
G4double G4ForwardXrayTR::fCofTR = fine_structure_const/pi ;
using namespace std;
/* ************************************************************************
@@ -410,7 +408,7 @@ void G4ForwardXrayTR::BuildXrayTRtables()
// charged particle crosses interface between two materials.
// The high energy small theta approximation is applied.
// (matter1 -> matter2)
// varAngle =2* (1 - cos(Theta)) or approximately = Theta*Theta
// varAngle =2* (1 - std::cos(Theta)) or approximately = Theta*Theta
//
G4double
@@ -451,11 +449,11 @@ G4double G4ForwardXrayTR::AngleDensity( G4double energy,
b2 = d*f ;
a4 = a2*a2 ;
b4 = b2*b2 ;
a = sqrt(a2) ;
b = sqrt(b2) ;
cof1 = c*c*(0.5/(a2*(x2 +a2)) +0.5*log(x2/(x2 +a2))/a4) ;
cof3 = d*d*(0.5/(b2*(x2 +b2)) +0.5*log(x2/(x2 +b2))/b4) ;
cof2 = -c*d*(log(x2/(x2 +b2))/b2 - log(x2/(x2 +a2))/a2)/(a2 - b2) ;
a = std::sqrt(a2) ;
b = std::sqrt(b2) ;
cof1 = c*c*(0.5/(a2*(x2 +a2)) +0.5*std::log(x2/(x2 +a2))/a4) ;
cof3 = d*d*(0.5/(b2*(x2 +b2)) +0.5*std::log(x2/(x2 +b2))/b4) ;
cof2 = -c*d*(std::log(x2/(x2 +b2))/b2 - std::log(x2/(x2 +a2))/a2)/(a2 - b2) ;
return -varAngle*(cof1 + cof2 + cof3) ;
}
@@ -502,7 +500,7 @@ G4double G4ForwardXrayTR::AngleSum( G4double varAngle1,
/////////////////////////////////////////////////////////////////////
//
// Analytical Expression for spectral density of Xray TR photons
// x = 2*(1 - cos(Theta)) ~ Theta^2
// x = 2*(1 - std::cos(Theta)) ~ Theta^2
//
G4double G4ForwardXrayTR::SpectralDensity( G4double energy,
@@ -513,7 +511,7 @@ G4double G4ForwardXrayTR::SpectralDensity( G4double energy,
+ fSigma1/(energy*energy) ;
b = 1.0/(fGamma*fGamma)
+ fSigma2/(energy*energy) ;
return ( (a + b)*log((x + b)/(x + a))/(a - b)
return ( (a + b)*std::log((x + b)/(x + a))/(a - b)
+ a/(x + a) + b/(x + b) )/energy ;
}
@@ -687,14 +685,14 @@ G4VParticleChange* G4ForwardXrayTR::PostStepDoIt(const G4Track& aTrack,
{
if(anglePos > (*(*fAngleDistrTable)(iPlace))(iTransfer)) break ;
}
theta = sqrt((*fAngleDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer-1)) ;
theta = std::sqrt((*fAngleDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer-1)) ;
// G4cout<<iTransfer<<" : theta = "<<theta<<G4endl ;
phi = twopi*G4UniformRand() ;
dirX = sin(theta)*cos(phi) ;
dirY = sin(theta)*sin(phi) ;
dirZ = cos(theta) ;
dirX = std::sin(theta)*std::cos(phi) ;
dirY = std::sin(theta)*std::sin(phi) ;
dirZ = std::cos(theta) ;
G4ThreeVector directionTR(dirX,dirY,dirZ) ;
directionTR.rotateUz(particleDir) ;
G4DynamicParticle* aPhotonTR = new G4DynamicParticle(G4Gamma::Gamma(),
@@ -762,7 +760,7 @@ G4VParticleChange* G4ForwardXrayTR::PostStepDoIt(const G4Track& aTrack,
if(anglePos > ((*(*fAngleDistrTable)(iPlace))(iTransfer)*W1+
(*(*fAngleDistrTable)(iPlace + 1))(iTransfer)*W2)) break ;
}
theta = sqrt(((*fAngleDistrTable)(iPlace)->
theta = std::sqrt(((*fAngleDistrTable)(iPlace)->
GetLowEdgeEnergy(iTransfer-1))*W1+
((*fAngleDistrTable)(iPlace + 1)->
GetLowEdgeEnergy(iTransfer-1))*W2) ;
@@ -770,9 +768,9 @@ G4VParticleChange* G4ForwardXrayTR::PostStepDoIt(const G4Track& aTrack,
// G4cout<<iTransfer<<" : theta = "<<theta<<G4endl ;
phi = twopi*G4UniformRand() ;
dirX = sin(theta)*cos(phi) ;
dirY = sin(theta)*sin(phi) ;
dirZ = cos(theta) ;
dirX = std::sin(theta)*std::cos(phi) ;
dirY = std::sin(theta)*std::sin(phi) ;
dirZ = std::cos(theta) ;
G4ThreeVector directionTR(dirX,dirY,dirZ) ;
directionTR.rotateUz(particleDir) ;
G4DynamicParticle* aPhotonTR = new G4DynamicParticle(G4Gamma::Gamma(),
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4GammaXTRadiator.cc,v 1.5 2006/06/29 19:56:07 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4GammaXTRadiator.cc,v 1.6 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
#include <complex>
@@ -35,8 +35,6 @@
#include "G4Gamma.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -94,19 +92,19 @@ G4GammaXTRadiator::GetStackFactor( G4double energy,
G4complex Ca(1.0+0.5*fPlateThick*Ma/fAlphaPlate,fPlateThick/Za/fAlphaPlate) ;
G4complex Cb(1.0+0.5*fGasThick*Mb/fAlphaGas,fGasThick/Zb/fAlphaGas) ;
G4complex Ha = pow(Ca,-fAlphaPlate) ;
G4complex Hb = pow(Cb,-fAlphaGas) ;
G4complex Ha = std::pow(Ca,-fAlphaPlate) ;
G4complex Hb = std::pow(Cb,-fAlphaGas) ;
G4complex H = Ha*Hb ;
G4complex F1 = (1.0 - Ha)*(1.0 - Hb )/(1.0 - H)
* G4double(fPlateNumber) ;
G4complex F2 = (1.0-Ha)*(1.0-Ha)*Hb/(1.0-H)/(1.0-H)
* (1.0 - pow(H,fPlateNumber)) ;
* (1.0 - std::pow(H,fPlateNumber)) ;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle) ;
result = 2.0*real(R) ;
result = 2.0*std::real(R) ;
return result ;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4RegularXTRadiator.cc,v 1.9 2006/06/29 19:56:09 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4RegularXTRadiator.cc,v 1.10 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
#include <complex>
@@ -35,8 +35,6 @@
#include "G4Gamma.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -95,19 +93,19 @@ G4RegularXTRadiator::GetStackFactor( G4double energy,
G4complex Ca(1.0+0.5*fPlateThick*Ma/fAlphaPlate,fPlateThick/Za/fAlphaPlate);
G4complex Cb(1.0+0.5*fGasThick*Mb/fAlphaGas,fGasThick/Zb/fAlphaGas);
G4complex Ha = pow(Ca,-fAlphaPlate);
G4complex Hb = pow(Cb,-fAlphaGas);
G4complex Ha = std::pow(Ca,-fAlphaPlate);
G4complex Hb = std::pow(Cb,-fAlphaGas);
G4complex H = Ha*Hb;
G4complex F1 = (1.0 - Ha)*(1.0 - Hb )/(1.0 - H)
* G4double(fPlateNumber);
G4complex F2 = (1.0-Ha)*(1.0-Ha)*Hb/(1.0-H)/(1.0-H)
* (1.0 - pow(H,fPlateNumber));
* (1.0 - std::pow(H,fPlateNumber));
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
@@ -120,22 +118,22 @@ G4RegularXTRadiator::GetStackFactor( G4double energy,
bZb = fGasThick/GetGasFormationZone(energy,gamma,varAngle);
aMa = fPlateThick*GetPlateLinearPhotoAbs(energy);
bMb = fGasThick*GetGasLinearPhotoAbs(energy);
Qa = exp(-aMa);
Qb = exp(-bMb);
Qa = std::exp(-aMa);
Qb = std::exp(-bMb);
Q = Qa*Qb;
G4complex Ha( exp(-0.5*aMa)*cos(aZa),
-exp(-0.5*aMa)*sin(aZa) );
G4complex Hb( exp(-0.5*bMb)*cos(bZb),
-exp(-0.5*bMb)*sin(bZb) );
G4complex Ha( std::exp(-0.5*aMa)*std::cos(aZa),
-std::exp(-0.5*aMa)*std::sin(aZa) );
G4complex Hb( std::exp(-0.5*bMb)*std::cos(bZb),
-std::exp(-0.5*bMb)*std::sin(bZb) );
G4complex H = Ha*Hb;
G4complex Hs = conj(H);
D = 1.0 /( (1 - sqrt(Q))*(1 - sqrt(Q)) +
4*sqrt(Q)*sin(0.5*(aZa+bZb))*sin(0.5*(aZa+bZb)) );
D = 1.0 /( (1 - std::sqrt(Q))*(1 - std::sqrt(Q)) +
4*std::sqrt(Q)*std::sin(0.5*(aZa+bZb))*std::sin(0.5*(aZa+bZb)) );
G4complex F1 = (1.0 - Ha)*(1.0 - Hb)*(1.0 - Hs)
* G4double(fPlateNumber)*D;
G4complex F2 = (1.0-Ha)*(1.0-Ha)*Hb*(1.0-Hs)*(1.0-Hs)
* (1.0 - pow(H,fPlateNumber)) * D*D;
* (1.0 - std::pow(H,fPlateNumber)) * D*D;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
@@ -148,7 +146,7 @@ G4RegularXTRadiator::GetStackFactor( G4double energy,
}
G4complex R = (2.- Ha - 1./Ha)*S + (1. - Ha)*G4double(fPlateNumber);
R *= OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
*/
}
@@ -24,19 +24,26 @@
// ********************************************************************
//
//
// $Id: G4Scintillation.cc,v 1.30 2008/10/22 01:19:11 gum Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4Scintillation.cc,v 1.38 2010/12/15 07:39:26 gunter Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
////////////////////////////////////////////////////////////////////////
// Scintillation Light Class Implementation
////////////////////////////////////////////////////////////////////////
//
// File: G4Scintillation.cc
// File: G4Scintillation.cc
// Description: RestDiscrete Process - Generation of Scintillation Photons
// Version: 1.0
// Created: 1998-11-07
// Created: 1998-11-07
// Author: Peter Gumplinger
// Updated: 2005-08-17 by Peter Gumplinger
// Updated: 2010-10-20 Allow the scintillation yield to be a function
// of energy deposited by particle type
// Thanks to Zach Hartwig (Department of Nuclear
// Science and Engineeering - MIT)
// 2010-09-22 by Peter Gumplinger
// > scintillation rise time included, thanks to
// > Martin Goettlich/DESY
// 2005-08-17 by Peter Gumplinger
// > change variable name MeanNumPhotons -> MeanNumberOfPhotons
// 2005-07-28 by Peter Gumplinger
// > add G4ProcessType to constructor
@@ -55,7 +62,7 @@
// 2000-09-18 by Peter Gumplinger
// > change: aSecondaryPosition=x0+rand*aStep.GetDeltaPosition();
// aSecondaryTrack->SetTouchable(0);
// 2001-09-17, migration of Materials to pure STL (mma)
// 2001-09-17, migration of Materials to pure STL (mma)
// 2003-06-03, V.Ivanchenko fix compilation warnings
//
// mail: gum@triumf.ca
@@ -63,14 +70,13 @@
////////////////////////////////////////////////////////////////////////
#include "G4ios.hh"
#include "G4ParticleTypes.hh"
#include "G4EmProcessSubType.hh"
#include "G4Scintillation.hh"
using namespace std;
/////////////////////////
// Class Implementation
// Class Implementation
/////////////////////////
//////////////
@@ -91,19 +97,22 @@ G4Scintillation::G4Scintillation(const G4String& processName,
{
SetProcessSubType(fScintillation);
fTrackSecondariesFirst = false;
fTrackSecondariesFirst = false;
fFiniteRiseTime = false;
YieldFactor = 1.0;
ExcitationRatio = 1.0;
scintillationByParticleType = false;
theFastIntegralTable = NULL;
theSlowIntegralTable = NULL;
if (verboseLevel>0) {
if (verboseLevel>0) {
G4cout << GetProcessName() << " is created " << G4endl;
}
}
BuildThePhysicsTable();
BuildThePhysicsTable();
emSaturation = NULL;
}
@@ -112,12 +121,12 @@ G4Scintillation::G4Scintillation(const G4String& processName,
// Destructors
////////////////
G4Scintillation::~G4Scintillation()
G4Scintillation::~G4Scintillation()
{
if (theFastIntegralTable != NULL) {
theFastIntegralTable->clearAndDestroy();
theFastIntegralTable->clearAndDestroy();
delete theFastIntegralTable;
}
}
if (theSlowIntegralTable != NULL) {
theSlowIntegralTable->clearAndDestroy();
delete theSlowIntegralTable;
@@ -158,12 +167,12 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4Material* aMaterial = aTrack.GetMaterial();
G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
G4ThreeVector x0 = pPreStepPoint->GetPosition();
G4ThreeVector x0 = pPreStepPoint->GetPosition();
G4ThreeVector p0 = aStep.GetDeltaPosition().unit();
G4double t0 = pPreStepPoint->GetGlobalTime();
G4double t0 = pPreStepPoint->GetGlobalTime();
G4double TotalEnergyDeposit = aStep.GetTotalEnergyDeposit();
@@ -172,7 +181,7 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if (!aMaterialPropertiesTable)
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
const G4MaterialPropertyVector* Fast_Intensity =
const G4MaterialPropertyVector* Fast_Intensity =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
const G4MaterialPropertyVector* Slow_Intensity =
aMaterialPropertiesTable->GetProperty("SLOWCOMPONENT");
@@ -183,9 +192,101 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4int nscnt = 1;
if (Fast_Intensity && Slow_Intensity) nscnt = 2;
G4double ScintillationYield = aMaterialPropertiesTable->
G4double ScintillationYield = 0.;
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();
const G4MaterialPropertyVector *Scint_Yield_Vector = NULL;
// 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) {
G4cerr << "\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;
G4Exception("G4Scintillation::PostStepDoIt",
"No correct entry in MaterialPropertiesTable",
FatalException,"Missing MaterialPropertiesTable entry.");
}
if (verboseLevel>1) {
G4cout << "\n"
<< "Particle = " << pDef->GetParticleName() << "\n"
<< "Energy Dep. = " << TotalEnergyDeposit/MeV << "\n"
<< "Yield = "
<< Scint_Yield_Vector->GetProperty(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->
GetProperty(TotalEnergyDeposit);
} else {
// The default linear scintillation process
ScintillationYield = aMaterialPropertiesTable->
GetConstProperty("SCINTILLATIONYIELD");
ScintillationYield *= YieldFactor;
// Units: [# scintillation photons / MeV]
ScintillationYield *= YieldFactor;
}
G4double ResolutionScale = aMaterialPropertiesTable->
GetConstProperty("RESOLUTIONSCALE");
@@ -198,18 +299,22 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double MeanNumberOfPhotons;
if (emSaturation) {
// Birk's correction via emSaturation and specifying scintillation by
// by particle type are physically mutually exclusive
if (scintillationByParticleType)
MeanNumberOfPhotons = ScintillationYield;
else if (emSaturation)
MeanNumberOfPhotons = ScintillationYield*
(emSaturation->VisibleEnergyDeposition(&aStep));
} else {
else
MeanNumberOfPhotons = ScintillationYield*TotalEnergyDeposit;
}
G4int NumPhotons;
if (MeanNumberOfPhotons > 10.)
{
G4double sigma = ResolutionScale * sqrt(MeanNumberOfPhotons);
G4double sigma = ResolutionScale * std::sqrt(MeanNumberOfPhotons);
NumPhotons = G4int(G4RandGauss::shoot(MeanNumberOfPhotons,sigma)+0.5);
}
else
@@ -217,36 +322,37 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
NumPhotons = G4int(G4Poisson(MeanNumberOfPhotons));
}
if (NumPhotons <= 0)
if (NumPhotons <= 0)
{
// return unchanged particle and no secondaries
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
aParticleChange.SetNumberOfSecondaries(0);
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
////////////////////////////////////////////////////////////////
aParticleChange.SetNumberOfSecondaries(NumPhotons);
if (fTrackSecondariesFirst) {
if (aTrack.GetTrackStatus() == fAlive )
aParticleChange.ProposeTrackStatus(fSuspend);
}
////////////////////////////////////////////////////////////////
G4int materialIndex = aMaterial->GetIndex();
////////////////////////////////////////////////////////////////
// Retrieve the Scintillation Integral for this material
// new G4PhysicsOrderedFreeVector allocated to hold CII's
aParticleChange.SetNumberOfSecondaries(NumPhotons);
if (fTrackSecondariesFirst) {
if (aTrack.GetTrackStatus() == fAlive )
aParticleChange.ProposeTrackStatus(fSuspend);
}
////////////////////////////////////////////////////////////////
G4int materialIndex = aMaterial->GetIndex();
// Retrieve the Scintillation Integral for this material
// new G4PhysicsOrderedFreeVector allocated to hold CII's
G4int Num = NumPhotons;
for (G4int scnt = 1; scnt <= nscnt; scnt++) {
G4double ScintillationTime = 0.*ns;
G4double ScintillationRiseTime = 0.*ns;
G4PhysicsOrderedFreeVector* ScintillationIntegral = NULL;
if (scnt == 1) {
@@ -254,12 +360,20 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
if(Fast_Intensity){
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("FASTTIMECONSTANT");
if (fFiniteRiseTime) {
ScintillationRiseTime = aMaterialPropertiesTable->
GetConstProperty("FASTSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theFastIntegralTable)(materialIndex));
}
if(Slow_Intensity){
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("SLOWTIMECONSTANT");
if (fFiniteRiseTime) {
ScintillationRiseTime = aMaterialPropertiesTable->
GetConstProperty("SLOWSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theSlowIntegralTable)(materialIndex));
}
@@ -268,13 +382,17 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double YieldRatio = aMaterialPropertiesTable->
GetConstProperty("YIELDRATIO");
if ( ExcitationRatio == 1.0 ) {
Num = G4int (min(YieldRatio,1.0) * NumPhotons);
Num = G4int (std::min(YieldRatio,1.0) * NumPhotons);
}
else {
Num = G4int (min(ExcitationRatio,1.0) * NumPhotons);
Num = G4int (std::min(ExcitationRatio,1.0) * NumPhotons);
}
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("FASTTIMECONSTANT");
if (fFiniteRiseTime) {
ScintillationRiseTime = aMaterialPropertiesTable->
GetConstProperty("FASTSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theFastIntegralTable)(materialIndex));
}
@@ -283,6 +401,10 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
Num = NumPhotons - Num;
ScintillationTime = aMaterialPropertiesTable->
GetConstProperty("SLOWTIMECONSTANT");
if (fFiniteRiseTime) {
ScintillationRiseTime = aMaterialPropertiesTable->
GetConstProperty("SLOWSCINTILLATIONRISETIME");
}
ScintillationIntegral =
(G4PhysicsOrderedFreeVector*)((*theSlowIntegralTable)(materialIndex));
}
@@ -291,51 +413,51 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
// Max Scintillation Integral
G4double CIImax = ScintillationIntegral->GetMaxValue();
for (G4int i = 0; i < Num; i++) {
G4double CIImax = ScintillationIntegral->GetMaxValue();
// Determine photon energy
for (G4int i = 0; i < Num; i++) {
// Determine photon energy
G4double CIIvalue = G4UniformRand()*CIImax;
G4double sampledEnergy =
G4double sampledEnergy =
ScintillationIntegral->GetEnergy(CIIvalue);
if (verboseLevel>1) {
if (verboseLevel>1) {
G4cout << "sampledEnergy = " << sampledEnergy << G4endl;
G4cout << "CIIvalue = " << CIIvalue << G4endl;
}
G4cout << "CIIvalue = " << CIIvalue << G4endl;
}
// Generate random photon direction
// Generate random photon direction
G4double cost = 1. - 2.*G4UniformRand();
G4double sint = sqrt((1.-cost)*(1.+cost));
G4double sint = std::sqrt((1.-cost)*(1.+cost));
G4double phi = twopi*G4UniformRand();
G4double sinp = sin(phi);
G4double cosp = cos(phi);
G4double phi = twopi*G4UniformRand();
G4double sinp = std::sin(phi);
G4double cosp = std::cos(phi);
G4double px = sint*cosp;
G4double py = sint*sinp;
G4double pz = cost;
G4double px = sint*cosp;
G4double py = sint*sinp;
G4double pz = cost;
// Create photon momentum direction vector
// Create photon momentum direction vector
G4ParticleMomentum photonMomentum(px, py, pz);
G4ParticleMomentum photonMomentum(px, py, pz);
// Determine polarization of new photon
// Determine polarization of new photon
G4double sx = cost*cosp;
G4double sy = cost*sinp;
G4double sz = -sint;
G4double sx = cost*cosp;
G4double sy = cost*sinp;
G4double sz = -sint;
G4ThreeVector photonPolarization(sx, sy, sz);
G4ThreeVector photonPolarization(sx, sy, sz);
G4ThreeVector perp = photonMomentum.cross(photonPolarization);
phi = twopi*G4UniformRand();
sinp = sin(phi);
cosp = cos(phi);
phi = twopi*G4UniformRand();
sinp = std::sin(phi);
cosp = std::cos(phi);
photonPolarization = cosp * photonPolarization + sinp * perp;
@@ -345,13 +467,13 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4DynamicParticle* aScintillationPhoton =
new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(),
photonMomentum);
aScintillationPhoton->SetPolarization
(photonPolarization.x(),
photonPolarization.y(),
photonPolarization.z());
photonMomentum);
aScintillationPhoton->SetPolarization
(photonPolarization.x(),
photonPolarization.y(),
photonPolarization.z());
aScintillationPhoton->SetKineticEnergy(sampledEnergy);
aScintillationPhoton->SetKineticEnergy(sampledEnergy);
// Generate new G4Track object:
@@ -368,16 +490,22 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
((pPreStepPoint->GetVelocity()+
pPostStepPoint->GetVelocity())/2.);
deltaTime = deltaTime -
ScintillationTime * log( G4UniformRand() );
// emission time distribution
if (ScintillationRiseTime==0.0) {
deltaTime = deltaTime -
ScintillationTime * std::log( G4UniformRand() );
} else {
deltaTime = deltaTime +
sample_time(ScintillationRiseTime, ScintillationTime);
}
G4double aSecondaryTime = t0 + deltaTime;
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());
@@ -385,17 +513,17 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
aSecondaryTrack->SetParentID(aTrack.GetTrackID());
aParticleChange.AddSecondary(aSecondaryTrack);
aParticleChange.AddSecondary(aSecondaryTrack);
}
}
}
if (verboseLevel>0) {
G4cout << "\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
if (verboseLevel>0) {
G4cout << "\n Exiting from G4Scintillation::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
return G4VRestDiscreteProcess::PostStepDoIt(aTrack, aStep);
}
// BuildThePhysicsTable for the scintillation process
@@ -404,95 +532,95 @@ G4Scintillation::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
void G4Scintillation::BuildThePhysicsTable()
{
if (theFastIntegralTable && theSlowIntegralTable) return;
if (theFastIntegralTable && theSlowIntegralTable) return;
const G4MaterialTable* theMaterialTable =
const G4MaterialTable* theMaterialTable =
G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
// create new physics table
// create new physics table
if(!theFastIntegralTable)theFastIntegralTable = new G4PhysicsTable(numOfMaterials);
if(!theFastIntegralTable)theFastIntegralTable = new G4PhysicsTable(numOfMaterials);
if(!theSlowIntegralTable)theSlowIntegralTable = new G4PhysicsTable(numOfMaterials);
// loop for materials
// loop for materials
for (G4int i=0 ; i < numOfMaterials; i++)
{
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector =
for (G4int i=0 ; i < numOfMaterials; i++)
{
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector =
new G4PhysicsOrderedFreeVector();
G4PhysicsOrderedFreeVector* bPhysicsOrderedFreeVector =
new G4PhysicsOrderedFreeVector();
// Retrieve vector of scintillation wavelength intensity for
// Retrieve vector of scintillation wavelength intensity for
// the material from the material's optical properties table.
G4Material* aMaterial = (*theMaterialTable)[i];
G4Material* aMaterial = (*theMaterialTable)[i];
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
if (aMaterialPropertiesTable) {
if (aMaterialPropertiesTable) {
G4MaterialPropertyVector* theFastLightVector =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
G4MaterialPropertyVector* theFastLightVector =
aMaterialPropertiesTable->GetProperty("FASTCOMPONENT");
if (theFastLightVector) {
// Retrieve the first intensity point in vector
// of (photon energy, intensity) pairs
if (theFastLightVector) {
theFastLightVector->ResetIterator();
++(*theFastLightVector); // advance to 1st entry
// Retrieve the first intensity point in vector
// of (photon energy, intensity) pairs
G4double currentIN = theFastLightVector->
GetProperty();
theFastLightVector->ResetIterator();
++(*theFastLightVector); // advance to 1st entry
if (currentIN >= 0.0) {
G4double currentIN = theFastLightVector->
GetProperty();
// Create first (photon energy, Scintillation
if (currentIN >= 0.0) {
// Create first (photon energy, Scintillation
// Integral pair
G4double currentPM = theFastLightVector->
GetPhotonEnergy();
G4double currentPM = theFastLightVector->
GetPhotonEnergy();
G4double currentCII = 0.0;
G4double currentCII = 0.0;
aPhysicsOrderedFreeVector->
InsertValues(currentPM , currentCII);
aPhysicsOrderedFreeVector->
InsertValues(currentPM , currentCII);
// Set previous values to current ones prior to loop
// Set previous values to current ones prior to loop
G4double prevPM = currentPM;
G4double prevCII = currentCII;
G4double prevIN = currentIN;
G4double prevPM = currentPM;
G4double prevCII = currentCII;
G4double prevIN = currentIN;
// loop over all (photon energy, intensity)
// pairs stored for this material
// loop over all (photon energy, intensity)
// pairs stored for this material
while(++(*theFastLightVector))
{
currentPM = theFastLightVector->
GetPhotonEnergy();
while(++(*theFastLightVector))
{
currentPM = theFastLightVector->
GetPhotonEnergy();
currentIN=theFastLightVector->
GetProperty();
currentIN = theFastLightVector->
GetProperty();
currentCII = 0.5 * (prevIN + currentIN);
currentCII = 0.5 * (prevIN + currentIN);
currentCII = prevCII +
(currentPM - prevPM) * currentCII;
currentCII = prevCII +
(currentPM - prevPM) * currentCII;
aPhysicsOrderedFreeVector->
InsertValues(currentPM, currentCII);
aPhysicsOrderedFreeVector->
InsertValues(currentPM, currentCII);
prevPM = currentPM;
prevCII = currentCII;
prevIN = currentIN;
}
prevPM = currentPM;
prevCII = currentCII;
prevIN = currentIN;
}
}
}
}
}
G4MaterialPropertyVector* theSlowLightVector =
aMaterialPropertiesTable->GetProperty("SLOWCOMPONENT");
@@ -553,16 +681,29 @@ void G4Scintillation::BuildThePhysicsTable()
}
}
}
}
// The scintillation integral(s) for a given material
// will be inserted in the table(s) according to the
// position of the material in the material table.
// The scintillation integral(s) for a given material
// will be inserted in the table(s) according to the
// position of the material in the material table.
theFastIntegralTable->insertAt(i,aPhysicsOrderedFreeVector);
theFastIntegralTable->insertAt(i,aPhysicsOrderedFreeVector);
theSlowIntegralTable->insertAt(i,bPhysicsOrderedFreeVector);
}
}
}
// Called by the user to set the scintillation yield as a function
// of energy deposited by particle type
void G4Scintillation::SetScintillationByParticleType(const G4bool scintType)
{
if (emSaturation) {
G4Exception("G4Scintillation::SetScintillationByParticleType", "Redefinition",
JustWarning, "Birks Saturation is replaced by ScintillationByParticleType!");
RemoveSaturation();
}
scintillationByParticleType = scintType;
}
// GetMeanFreePath
@@ -575,7 +716,7 @@ G4double G4Scintillation::GetMeanFreePath(const G4Track&,
{
*condition = StronglyForced;
return DBL_MAX;
return DBL_MAX;
}
@@ -591,3 +732,24 @@ G4double G4Scintillation::GetMeanLifeTime(const G4Track&,
return DBL_MAX;
}
G4double G4Scintillation::sample_time(G4double tau1, G4double tau2)
{
// tau1: rise time and tau2: decay time
while(1) {
// two random numbers
G4double ran1 = G4UniformRand();
G4double ran2 = G4UniformRand();
//
// exponential distribution as envelope function: very efficient
//
G4double d = (tau1+tau2)/tau2;
// make sure the envelope function is
// always larger than the bi-exponential
G4double t = -1.0*tau2*std::log(1-ran1);
G4double g = d*single_exp(t,tau2);
if (ran2 <= bi_exp(t,tau1,tau2)/g) return t;
}
return -1.0;
}
@@ -24,16 +24,14 @@
// ********************************************************************
//
//
// $Id: G4StrawTubeXTRadiator.cc,v 1.6 2007/09/29 17:49:34 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4StrawTubeXTRadiator.cc,v 1.7 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
#include "G4StrawTubeXTRadiator.hh"
#include "Randomize.hh"
#include "G4Gamma.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -77,7 +75,7 @@ G4StrawTubeXTRadiator::G4StrawTubeXTRadiator(G4LogicalVolume *anEnvelope,
fSigma3 = fPlasmaCof*mediumMat->GetElectronDensity();
if(verboseLevel > 0)
G4cout<<"medium plasma energy = "<<sqrt(fSigma3)/eV<<" eV"<<G4endl;
G4cout<<"medium plasma energy = "<<std::sqrt(fSigma3)/eV<<" eV"<<G4endl;
// Compute cofs for preparation of linear photo absorption in external medium
@@ -120,8 +118,8 @@ G4StrawTubeXTRadiator::GetStackFactor( G4double energy,
G4complex C2(1.0 + 0.5*fPlateThick*M2/fAlphaPlate, fPlateThick/L2/fAlphaPlate);
G4complex C3(1.0 + 0.5*fGasThick*M3/fAlphaGas, fGasThick/L3/fAlphaGas);
G4complex H2 = pow(C2,-fAlphaPlate);
G4complex H3 = pow(C3,-fAlphaGas);
G4complex H2 = std::pow(C2,-fAlphaPlate);
G4complex H3 = std::pow(C3,-fAlphaGas);
G4complex H = H2*H3;
G4complex Z1 = GetMediumComplexFZ(energy,gamma,varAngle);
@@ -133,7 +131,7 @@ G4StrawTubeXTRadiator::GetStackFactor( G4double energy,
( Z2 - Z3 )*( Z2 - Z3 )*( 1. - H3 ) +
2.*( Z1 - Z2 )*( Z2 - Z3 )*H2*( 1. - H3 ) ;
result = 2.0*real(R)*(varAngle*energy/hbarc/hbarc);
result = 2.0*std::real(R)*(varAngle*energy/hbarc/hbarc);
return result;
@@ -164,16 +162,16 @@ G4complex G4StrawTubeXTRadiator::GetMediumComplexFZ( G4double omega ,
G4double gamma ,
G4double varAngle )
{
G4double cof, length,delta, real, image;
G4double cof, length,delta, real_v, image_v;
length = 0.5*GetMediumFormationZone(omega,gamma,varAngle);
delta = length*GetMediumLinearPhotoAbs(omega);
cof = 1.0/(1.0 + delta*delta);
real = length*cof;
image = real*delta;
real_v = length*cof;
image_v = real_v*delta;
G4complex zone(real,image);
G4complex zone(real_v,image_v);
return zone;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4SynchrotronRadiation.cc,v 1.5 2006/06/29 19:56:15 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4SynchrotronRadiation.cc,v 1.8 2010/10/14 18:38:21 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
@@ -43,10 +43,8 @@
///////////////////////////////////////////////////////////////////////////
#include "G4SynchrotronRadiation.hh"
// #include "G4Integrator.hh"
#include "G4UnitsTable.hh"
using namespace std;
#include "G4EmProcessSubType.hh"
///////////////////////////////////////////////////////////////////////
//
@@ -64,9 +62,11 @@ G4SynchrotronRadiation::G4SynchrotronRadiation(const G4String& processName,
fFieldPropagator = transportMgr->GetPropagatorInField();
fLambdaConst = sqrt(3.0)*electron_mass_c2/
fLambdaConst = std::sqrt(3.0)*electron_mass_c2/
(2.5*fine_structure_const*eplus*c_light) ;
fEnergyConst = 1.5*c_light*c_light*eplus*hbar_Planck/electron_mass_c2 ;
SetProcessSubType(fSynchrotronRadiation);
verboseLevel=1;
}
@@ -76,9 +76,7 @@ G4SynchrotronRadiation::G4SynchrotronRadiation(const G4String& processName,
//
G4SynchrotronRadiation::~G4SynchrotronRadiation()
{
;
}
{}
/////////////////////////////// METHODS /////////////////////////////////
//
@@ -168,7 +166,7 @@ G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData,
G4cout
<< " B = " << Btot/tesla << " Tesla"
<< " perpB = " << perpB/tesla << " Tesla"
<< " Theta = " << Theta << " sin(Theta)=" << sin(Theta) << '\n'
<< " Theta = " << Theta << " std::sin(Theta)=" << std::sin(Theta) << '\n'
<< " ptot = " << G4BestUnit(ptot,"Energy")
<< " rho = " << G4BestUnit(rho,"Length")
<< G4endl;
@@ -261,18 +259,18 @@ G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData,
G4double Phi = twopi * G4UniformRand() ;
G4double dirx = sin(Teta)*cos(Phi) ,
diry = sin(Teta)*sin(Phi) ,
dirz = cos(Teta) ;
G4double dirx = std::sin(Teta)*std::cos(Phi) ,
diry = std::sin(Teta)*std::sin(Phi) ,
dirz = std::cos(Teta) ;
G4ThreeVector gammaDirection ( dirx, diry, dirz);
gammaDirection.rotateUz(particleDirection);
// polarization of new gamma
// G4double sx = cos(Teta)*cos(Phi);
// G4double sy = cos(Teta)*sin(Phi);
// G4double sz = -sin(Teta);
// G4double sx = std::cos(Teta)*std::cos(Phi);
// G4double sy = std::cos(Teta)*std::sin(Phi);
// G4double sz = -std::sin(Teta);
G4ThreeVector gammaPolarization = FieldValue.cross(gammaDirection);
gammaPolarization = gammaPolarization.unit();
@@ -367,11 +365,11 @@ 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=-log(1-x);
{ G4double y=-std::log(1-x);
return y*Chebyshev(aa4,aa5,cheb3,ncheb3,y);
}
else
{ G4double y=-log(1-x);
{ G4double y=-std::log(1-x);
return y*Chebyshev(aa5,aa6,cheb4,ncheb4,y);
}
}
@@ -383,8 +381,8 @@ G4double G4SynchrotronRadiation::GetRandomEnergySR(G4double gamma, G4double perp
static G4bool FirstTime=true;
if(verboseLevel > 0 && FirstTime)
{ G4double Emean=8./(15.*sqrt(3.))*Ecr; // mean photon energy
G4double E_rms=sqrt(211./675.)*Ecr; // rms of photon energy distribution
{ G4double Emean=8./(15.*std::sqrt(3.))*Ecr; // mean photon energy
G4double E_rms=std::sqrt(211./675.)*Ecr; // rms of photon energy distribution
G4cout << "G4SynchrotronRadiation::GetRandomEnergySR :" << '\n' << std::setprecision(4)
<< " Ecr = " << G4BestUnit(Ecr,"Energy") << '\n'
<< " Emean = " << G4BestUnit(Emean,"Energy") << '\n'
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4SynchrotronRadiationInMat.cc,v 1.2 2006/06/29 19:56:17 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4SynchrotronRadiationInMat.cc,v 1.5 2010/10/14 18:38:21 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
@@ -42,8 +42,7 @@
#include "G4SynchrotronRadiationInMat.hh"
#include "G4Integrator.hh"
using namespace std;
#include "G4EmProcessSubType.hh"
////////////////////////////////////////////////////////////////////
//
@@ -51,7 +50,7 @@ using namespace std;
//
const G4double
G4SynchrotronRadiationInMat::fLambdaConst = sqrt(3.0)*electron_mass_c2/
G4SynchrotronRadiationInMat::fLambdaConst = std::sqrt(3.0)*electron_mass_c2/
(2.5*fine_structure_const*eplus*c_light) ;
/////////////////////////////////////////////////////////////////////
@@ -133,6 +132,7 @@ G4SynchrotronRadiationInMat::G4SynchrotronRadiationInMat(const G4String& process
G4TransportationManager* transportMgr = G4TransportationManager::GetTransportationManager();
fFieldPropagator = transportMgr->GetPropagatorInField();
SetProcessSubType(fSynchrotronRadiation);
}
@@ -142,9 +142,7 @@ G4SynchrotronRadiationInMat::G4SynchrotronRadiationInMat(const G4String& process
//
G4SynchrotronRadiationInMat::~G4SynchrotronRadiationInMat()
{
;
}
{}
/////////////////////////////// METHODS /////////////////////////////////
@@ -316,18 +314,18 @@ G4SynchrotronRadiationInMat::PostStepDoIt(const G4Track& trackData,
G4double Phi = twopi * G4UniformRand() ;
G4double dirx = sin(Teta)*cos(Phi) ,
diry = sin(Teta)*sin(Phi) ,
dirz = cos(Teta) ;
G4double dirx = std::sin(Teta)*std::cos(Phi) ,
diry = std::sin(Teta)*std::sin(Phi) ,
dirz = std::cos(Teta) ;
G4ThreeVector gammaDirection ( dirx, diry, dirz);
gammaDirection.rotateUz(particleDirection);
// polarization of new gamma
// G4double sx = cos(Teta)*cos(Phi);
// G4double sy = cos(Teta)*sin(Phi);
// G4double sz = -sin(Teta);
// G4double sx = std::cos(Teta)*std::cos(Phi);
// G4double sy = std::cos(Teta)*std::sin(Phi);
// G4double sz = -std::sin(Teta);
G4ThreeVector gammaPolarization = FieldValue.cross(gammaDirection);
gammaPolarization = gammaPolarization.unit();
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TransitionRadiation.cc,v 1.7 2006/06/29 19:56:19 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TransitionRadiation.cc,v 1.10 2010/10/14 18:38:21 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
// G4TransitionRadiation class -- implementation file
@@ -41,15 +41,10 @@
#include <cmath>
// #include "G4ios.hh"
// #include <fstream.h>
// #include <stdlib.h>
#include "G4TransitionRadiation.hh"
#include "G4Material.hh"
// Init gamma array
#include "G4EmProcessSubType.hh"
// Local constants
@@ -57,7 +52,6 @@ const G4int G4TransitionRadiation::fSympsonNumber = 100 ;
const G4int G4TransitionRadiation::fGammaNumber = 15 ;
const G4int G4TransitionRadiation::fPointNumber = 100 ;
using namespace std;
///////////////////////////////////////////////////////////////////////
//
@@ -68,6 +62,7 @@ G4TransitionRadiation::
G4TransitionRadiation( const G4String& processName, G4ProcessType type )
: G4VDiscreteProcess(processName, type)
{
SetProcessSubType(fTransitionRadiation);
// fMatIndex1 = pMat1->GetIndex() ;
// fMatIndex2 = pMat2->GetIndex() ;
}
@@ -78,15 +73,13 @@ G4TransitionRadiation( const G4String& processName, G4ProcessType type )
//
G4TransitionRadiation::~G4TransitionRadiation()
{
;
}
{}
///////////////////////////////////////////////////////////////////
//
// Sympson integral of TR spectral-angle density over energy between
// the limits energy 1 and energy2 at fixed varAngle = 1 - cos(Theta)
// the limits energy 1 and energy2 at fixed varAngle = 1 - std::cos(Theta)
G4double
G4TransitionRadiation::IntegralOverEnergy( G4double energy1,
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4TransparentRegXTRadiator.cc,v 1.11 2007/09/29 17:49:34 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TransparentRegXTRadiator.cc,v 1.12 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
#include <complex>
@@ -35,8 +35,6 @@
#include "G4Integrator.hh"
#include "G4Gamma.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -112,26 +110,26 @@ G4double G4TransparentRegXTRadiator::SpectralXTRdEdx(G4double energy)
{
tmp = pi*fPlateThick*(k + cof2)/(fPlateThick + fGasThick);
result = (k - cof1)*(k - cof1)*(k + cof2)*(k + cof2);
// tmp = sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
// tmp = std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
if( k == kMin && kMin == G4int(cofMin) )
{
sum += 0.5*sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
sum += 0.5*std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
else
{
sum += sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
sum += std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
if(verboseLevel > 2)
{
G4cout<<"k = "<<k<<"; tmp = "<<sin(tmp)*sin(tmp)*abs(k-cofMin)/result
G4cout<<"k = "<<k<<"; tmp = "<<std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result
<<"; sum = "<<sum<<G4endl;
}
}
result = 4*( cof1 + cof2 )*( cof1 + cof2 )*sum/energy;
// result *= ( 1 - exp(-0.5*fPlateNumber*sigma) )/( 1 - exp(-0.5*sigma) );
// result *= ( 1 - std::exp(-0.5*fPlateNumber*sigma) )/( 1 - std::exp(-0.5*sigma) );
// fPlateNumber;
result *= fPlateNumber; // *exp(-0.5*fPlateNumber*sigma);
// +1-exp(-0.5*fPlateNumber*sigma);
result *= fPlateNumber; // *std::exp(-0.5*fPlateNumber*sigma);
// +1-std::exp(-0.5*fPlateNumber*sigma);
/*
fEnergy = energy;
// G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral;
@@ -173,17 +171,17 @@ G4TransparentRegXTRadiator::GetStackFactor( G4double energy,
G4complex Ca(1.0+0.5*fPlateThick*Ma/fAlphaPlate,fPlateThick/Za/fAlphaPlate);
G4complex Cb(1.0+0.5*fGasThick*Mb/fAlphaGas,fGasThick/Zb/fAlphaGas);
G4complex Ha = pow(Ca,-fAlphaPlate);
G4complex Hb = pow(Cb,-fAlphaGas);
G4complex Ha = std::pow(Ca,-fAlphaPlate);
G4complex Hb = std::pow(Cb,-fAlphaGas);
G4complex H = Ha*Hb;
G4complex F1 = (1.0 - Ha)*(1.0 - Hb )/(1.0 - H)
* G4double(fPlateNumber) ;
G4complex F2 = (1.0-Ha)*(1.0-Ha)*Hb/(1.0-H)/(1.0-H)
* (1.0 - exp(-0.5*fPlateNumber*sigma)) ;
// *(1.0 - pow(H,fPlateNumber)) ;
* (1.0 - std::exp(-0.5*fPlateNumber*sigma)) ;
// *(1.0 - std::pow(H,fPlateNumber)) ;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
// G4complex R = F2*OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
*/
// numerically unstable result
@@ -195,23 +193,23 @@ G4TransparentRegXTRadiator::GetStackFactor( G4double energy,
aMa = fPlateThick*GetPlateLinearPhotoAbs(energy);
bMb = fGasThick*GetGasLinearPhotoAbs(energy);
sigma = aMa*fPlateThick + bMb*fGasThick;
Qa = exp(-0.5*aMa);
Qb = exp(-0.5*bMb);
Qa = std::exp(-0.5*aMa);
Qb = std::exp(-0.5*bMb);
Q = Qa*Qb;
G4complex Ha( Qa*cos(aZa), -Qa*sin(aZa) );
G4complex Hb( Qb*cos(bZb), -Qb*sin(bZb) );
G4complex Ha( Qa*std::cos(aZa), -Qa*std::sin(aZa) );
G4complex Hb( Qb*std::cos(bZb), -Qb*std::sin(bZb) );
G4complex H = Ha*Hb;
G4complex Hs = conj(H);
D = 1.0 /( (1 - Q)*(1 - Q) +
4*Q*sin(0.5*(aZa + bZb))*sin(0.5*(aZa + bZb)) );
4*Q*std::sin(0.5*(aZa + bZb))*std::sin(0.5*(aZa + bZb)) );
G4complex F1 = (1.0 - Ha)*(1.0 - Hb)*(1.0 - Hs)
* G4double(fPlateNumber)*D;
G4complex F2 = (1.0 - Ha)*(1.0 - Ha)*Hb*(1.0 - Hs)*(1.0 - Hs)
// * (1.0 - pow(H,fPlateNumber)) * D*D;
* (1.0 - exp(-0.5*fPlateNumber*sigma)) * D*D;
// * (1.0 - std::pow(H,fPlateNumber)) * D*D;
* (1.0 - std::exp(-0.5*fPlateNumber*sigma)) * D*D;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VTransitionRadiation.cc,v 1.5 2006/06/29 19:56:23 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VTransitionRadiation.cc,v 1.6 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
// G4VTransitionRadiation class -- implementation file
@@ -45,14 +45,12 @@
///////////////////////////////////////////////////////////////////////
using namespace std;
G4VTransitionRadiation::G4VTransitionRadiation( const G4String& processName,
G4ProcessType type )
: G4VDiscreteProcess(processName, type),
nSteps(0),
gammaMin(100),
cosDThetaMax(cos(0.1))
cosDThetaMax(std::cos(0.1))
{
Clear();
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4VXTRenergyLoss.cc,v 1.44 2007/09/29 17:49:34 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4VXTRenergyLoss.cc,v 1.45 2010/06/16 15:34:15 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
// History:
// 2001-2002 R&D by V.Grichine
@@ -54,8 +54,6 @@
#include "G4PhysicsFreeVector.hh"
#include "G4PhysicsLinearVector.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -141,13 +139,13 @@ G4VXTRenergyLoss::G4VXTRenergyLoss(G4LogicalVolume *anEnvelope,
fSigma1 = fPlasmaCof*foilMat->GetElectronDensity() ;
// fSigma1 = (20.9*eV)*(20.9*eV) ;
if(verboseLevel > 0)
G4cout<<"plate plasma energy = "<<sqrt(fSigma1)/eV<<" eV"<<G4endl ;
G4cout<<"plate plasma energy = "<<std::sqrt(fSigma1)/eV<<" eV"<<G4endl ;
// plasma energy squared for gas material
fSigma2 = fPlasmaCof*gasMat->GetElectronDensity() ;
if(verboseLevel > 0)
G4cout<<"gas plasma energy = "<<sqrt(fSigma2)/eV<<" eV"<<G4endl ;
G4cout<<"gas plasma energy = "<<std::sqrt(fSigma2)/eV<<" eV"<<G4endl ;
// Compute cofs for preparation of linear photo absorption
@@ -202,7 +200,7 @@ G4double G4VXTRenergyLoss::GetMeanFreePath(const G4Track& aTrack,
G4cout<<" gamma = "<<gamma<<"; fGamma = "<<fGamma<<G4endl;
}
if ( fabs( gamma - fGamma ) < 0.05*gamma ) lambda = fLambda;
if ( std::fabs( gamma - fGamma ) < 0.05*gamma ) lambda = fLambda;
else
{
charge = aParticle->GetDefinition()->GetPDGCharge();
@@ -494,22 +492,22 @@ G4PhysicsFreeVector* G4VXTRenergyLoss::GetAngleVector(G4double energy, G4int n)
result = (k - cof1)*(k - cof1)*(k + cof2)*(k + cof2);
tmp = sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
tmp = std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
if( k == kMin && kMin == G4int(cofMin) )
{
angleSum += 0.5*tmp; // 0.5*sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
angleSum += 0.5*tmp; // 0.5*std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
else
{
angleSum += tmp; // sin(tmp)*sin(tmp)*abs(k-cofMin)/result;
angleSum += tmp; // std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
theta = abs(k-cofMin)*cofPHC/energy/(fPlateThick + fGasThick);
theta = std::abs(k-cofMin)*cofPHC/energy/(fPlateThick + fGasThick);
if(verboseLevel > 2)
{
G4cout<<"iTheta = "<<iTheta<<"; k = "<<k<<"; theta = "
<<std::sqrt(theta)*fGamma<<"; tmp = "
<<tmp // sin(tmp)*sin(tmp)*abs(k-cofMin)/result
<<tmp // std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result
<<"; angleSum = "<<angleSum<<G4endl;
}
angleVector->PutValue( iTheta, theta, angleSum );
@@ -696,12 +694,12 @@ G4VParticleChange* G4VXTRenergyLoss::PostStepDoIt( const G4Track& aTrack,
}
if (fAngleRadDistr)
{
// theta = fabs(G4RandGauss::shoot(0.0,pi/gamma));
// theta = std::fabs(G4RandGauss::shoot(0.0,pi/gamma));
theta2 = GetRandomAngle(energyTR,iTkin);
if(theta2 > 0.) theta = std::sqrt(theta2);
else theta = theta2;
}
else theta = fabs(G4RandGauss::shoot(0.0,pi/gamma));
else theta = std::fabs(G4RandGauss::shoot(0.0,pi/gamma));
if( theta >= 0.1 ) theta = 0.1;
@@ -709,9 +707,9 @@ G4VParticleChange* G4VXTRenergyLoss::PostStepDoIt( const G4Track& aTrack,
phi = twopi*G4UniformRand();
dirX = sin(theta)*cos(phi);
dirY = sin(theta)*sin(phi);
dirZ = cos(theta);
dirX = std::sin(theta)*std::cos(phi);
dirY = std::sin(theta)*std::sin(phi);
dirZ = std::cos(theta);
G4ThreeVector directionTR(dirX,dirY,dirZ);
directionTR.rotateUz(direction);
@@ -761,7 +759,7 @@ G4VParticleChange* G4VXTRenergyLoss::PostStepDoIt( const G4Track& aTrack,
// charged particle crosses interface between two materials.
// The high energy small theta approximation is applied.
// (matter1 -> matter2, or 2->1)
// varAngle =2* (1 - cos(theta)) or approximately = theta*theta
// varAngle =2* (1 - std::cos(theta)) or approximately = theta*theta
//
G4complex G4VXTRenergyLoss::OneInterfaceXTRdEdx( G4double energy,
@@ -849,7 +847,7 @@ G4double G4VXTRenergyLoss::AngleXTRdEdx(G4double varAngle)
// G4cout<<"cof1 = "<<cof1<<"; cof2 = "<<cof2<<"; cofPHC = "<<cofPHC<<G4endl;
cofMin = sqrt(cof1*cof2);
cofMin = std::sqrt(cof1*cof2);
cofMin /= cofPHC;
kMin = G4int(cofMin);
@@ -862,7 +860,7 @@ G4double G4VXTRenergyLoss::AngleXTRdEdx(G4double varAngle)
for( k = kMin; k <= kMax; k++ )
{
tmp1 = cofPHC*k;
tmp2 = sqrt(tmp1*tmp1-cof1*cof2);
tmp2 = std::sqrt(tmp1*tmp1-cof1*cof2);
energy1 = (tmp1+tmp2)/cof1;
energy2 = (tmp1-tmp2)/cof1;
@@ -873,13 +871,13 @@ G4double G4VXTRenergyLoss::AngleXTRdEdx(G4double varAngle)
if (energy1 > fTheMaxEnergyTR || energy1 < fTheMinEnergyTR) continue;
tmp1 = ( energy1*energy1*(1./fGamma/fGamma + varAngle) + fSigma1 )
* fPlateThick/(4*hbarc*energy1);
tmp2 = sin(tmp1);
tmp2 = std::sin(tmp1);
tmp = energy1*tmp2*tmp2;
tmp2 = fPlateThick/(4*tmp1);
tmp1 = hbarc*energy1/( energy1*energy1*(1./fGamma/fGamma + varAngle) + fSigma2 );
tmp *= (tmp1-tmp2)*(tmp1-tmp2);
tmp1 = cof1/(4*hbarc) - cof2/(4*hbarc*energy1*energy1);
tmp2 = abs(tmp1);
tmp2 = std::abs(tmp1);
if(tmp2 > 0.) tmp /= tmp2;
else continue;
}
@@ -888,13 +886,13 @@ G4double G4VXTRenergyLoss::AngleXTRdEdx(G4double varAngle)
if (energy2 > fTheMaxEnergyTR || energy2 < fTheMinEnergyTR) continue;
tmp1 = ( energy2*energy2*(1./fGamma/fGamma + varAngle) + fSigma1 )
* fPlateThick/(4*hbarc*energy2);
tmp2 = sin(tmp1);
tmp2 = std::sin(tmp1);
tmp = energy2*tmp2*tmp2;
tmp2 = fPlateThick/(4*tmp1);
tmp1 = hbarc*energy2/( energy2*energy2*(1./fGamma/fGamma + varAngle) + fSigma2 );
tmp *= (tmp1-tmp2)*(tmp1-tmp2);
tmp1 = cof1/(4*hbarc) - cof2/(4*hbarc*energy2*energy2);
tmp2 = abs(tmp1);
tmp2 = std::abs(tmp1);
if(tmp2 > 0.) tmp /= tmp2;
else continue;
}
@@ -939,16 +937,16 @@ G4complex G4VXTRenergyLoss::GetPlateComplexFZ( G4double omega ,
G4double gamma ,
G4double varAngle )
{
G4double cof, length,delta, real, image ;
G4double cof, length,delta, real_v, image_v ;
length = 0.5*GetPlateFormationZone(omega,gamma,varAngle) ;
delta = length*GetPlateLinearPhotoAbs(omega) ;
cof = 1.0/(1.0 + delta*delta) ;
real = length*cof ;
image = real*delta ;
real_v = length*cof ;
image_v = real_v*delta ;
G4complex zone(real,image);
G4complex zone(real_v,image_v);
return zone ;
}
@@ -1012,16 +1010,16 @@ G4complex G4VXTRenergyLoss::GetGasComplexFZ( G4double omega ,
G4double gamma ,
G4double varAngle )
{
G4double cof, length,delta, real, image ;
G4double cof, length,delta, real_v, image_v ;
length = 0.5*GetGasFormationZone(omega,gamma,varAngle) ;
delta = length*GetGasLinearPhotoAbs(omega) ;
cof = 1.0/(1.0 + delta*delta) ;
real = length*cof ;
image = real*delta ;
real_v = length*cof ;
image_v = real_v*delta ;
G4complex zone(real,image);
G4complex zone(real_v,image_v);
return zone ;
}
@@ -1079,8 +1077,8 @@ G4double G4VXTRenergyLoss::GetPlateZmuProduct( G4double omega ,
void G4VXTRenergyLoss::GetPlateZmuProduct()
{
ofstream outPlate("plateZmu.dat", ios::out ) ;
outPlate.setf( ios::scientific, ios::floatfield );
std::ofstream outPlate("plateZmu.dat", std::ios::out ) ;
outPlate.setf( std::ios::scientific, std::ios::floatfield );
G4int i ;
G4double omega, varAngle, gamma ;
@@ -1117,8 +1115,8 @@ G4double G4VXTRenergyLoss::GetGasZmuProduct( G4double omega ,
void G4VXTRenergyLoss::GetGasZmuProduct()
{
ofstream outGas("gasZmu.dat", ios::out ) ;
outGas.setf( ios::scientific, ios::floatfield );
std::ofstream outGas("gasZmu.dat", std::ios::out ) ;
outGas.setf( std::ios::scientific, std::ios::floatfield );
G4int i ;
G4double omega, varAngle, gamma ;
gamma = 10000. ;
@@ -1208,7 +1206,7 @@ G4double G4VXTRenergyLoss::GetComptonPerAtom(G4double GammaEnergy, G4double Z)
G4double T0 = 15.0*keV;
if (Z < 1.5) T0 = 40.0*keV;
G4double X = max(GammaEnergy, T0) / electron_mass_c2;
G4double X = std::max(GammaEnergy, T0) / electron_mass_c2;
CrossSection = p1Z*std::log(1.+2.*X)/X
+ (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X);
@@ -1218,13 +1216,13 @@ G4double G4VXTRenergyLoss::GetComptonPerAtom(G4double GammaEnergy, G4double Z)
{
G4double dT0 = 1.*keV;
X = (T0+dT0) / electron_mass_c2 ;
G4double sigma = p1Z*log(1.+2*X)/X
G4double sigma = p1Z*std::log(1.+2*X)/X
+ (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X);
G4double c1 = -T0*(sigma-CrossSection)/(CrossSection*dT0);
G4double c2 = 0.150;
if (Z > 1.5) c2 = 0.375-0.0556*log(Z);
G4double y = log(GammaEnergy/T0);
CrossSection *= exp(-y*(c1+c2*y));
if (Z > 1.5) c2 = 0.375-0.0556*std::log(Z);
G4double y = std::log(GammaEnergy/T0);
CrossSection *= std::exp(-y*(c1+c2*y));
}
// G4cout << "e= " << GammaEnergy << " Z= " << Z << " cross= " << CrossSection << G4endl;
return CrossSection;
@@ -1238,7 +1236,7 @@ G4double G4VXTRenergyLoss::GetComptonPerAtom(G4double GammaEnergy, G4double Z)
// charged particle crosses interface between two materials.
// The high energy small theta approximation is applied.
// (matter1 -> matter2, or 2->1)
// varAngle =2* (1 - cos(theta)) or approximately = theta*theta
// varAngle =2* (1 - std::cos(theta)) or approximately = theta*theta
//
G4double
@@ -1325,11 +1323,11 @@ void G4VXTRenergyLoss::GetNumberOfPhotons()
G4int iTkin ;
G4double gamma, numberE ;
ofstream outEn("numberE.dat", ios::out ) ;
outEn.setf( ios::scientific, ios::floatfield );
std::ofstream outEn("numberE.dat", std::ios::out ) ;
outEn.setf( std::ios::scientific, std::ios::floatfield );
ofstream outAng("numberAng.dat", ios::out ) ;
outAng.setf( ios::scientific, ios::floatfield );
std::ofstream outAng("numberAng.dat", std::ios::out ) ;
outAng.setf( std::ios::scientific, std::ios::floatfield );
for(iTkin=0;iTkin<fTotBin;iTkin++) // Lorentz factor loop
{
@@ -32,8 +32,6 @@
#include "G4Integrator.hh"
#include "G4Gamma.hh"
using namespace std;
////////////////////////////////////////////////////////////////////////////
//
// Constructor, destructor
@@ -120,16 +118,16 @@ G4double G4XTRTransparentRegRadModel::SpectralXTRdEdx(G4double energy)
if( k == kMin && kMin == G4int(cofMin) )
{
sum += 0.5*sin(tmp)*sin(tmp)*std::abs(k-cofMin)/result;
sum += 0.5*std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
else
{
sum += sin(tmp)*sin(tmp)*std::abs(k-cofMin)/result;
sum += std::sin(tmp)*std::sin(tmp)*std::abs(k-cofMin)/result;
}
// G4cout<<"k = "<<k<<"; sum = "<<sum<<G4endl;
}
result = 4.*( cof1 + cof2 )*( cof1 + cof2 )*sum/energy;
result *= ( 1. - exp(-fPlateNumber*sigma) )/( 1. - exp(-sigma) );
result *= ( 1. - std::exp(-fPlateNumber*sigma) )/( 1. - std::exp(-sigma) );
return result;
}
@@ -158,17 +156,17 @@ G4XTRTransparentRegRadModel::GetStackFactor( G4double energy,
G4complex Ca(1.0+0.5*fPlateThick*Ma/fAlphaPlate,fPlateThick/Za/fAlphaPlate);
G4complex Cb(1.0+0.5*fGasThick*Mb/fAlphaGas,fGasThick/Zb/fAlphaGas);
G4complex Ha = pow(Ca,-fAlphaPlate);
G4complex Hb = pow(Cb,-fAlphaGas);
G4complex Ha = std::pow(Ca,-fAlphaPlate);
G4complex Hb = std::pow(Cb,-fAlphaGas);
G4complex H = Ha*Hb;
G4complex F1 = (1.0 - Ha)*(1.0 - Hb )/(1.0 - H)
* G4double(fPlateNumber) ;
G4complex F2 = (1.0-Ha)*(1.0-Ha)*Hb/(1.0-H)/(1.0-H)
* (1.0 - exp(-0.5*fPlateNumber*sigma)) ;
// *(1.0 - pow(H,fPlateNumber)) ;
* (1.0 - std::exp(-0.5*fPlateNumber*sigma)) ;
// *(1.0 - std::pow(H,fPlateNumber)) ;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
// G4complex R = F2*OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
*/
// numerically unstable result
@@ -180,23 +178,23 @@ G4XTRTransparentRegRadModel::GetStackFactor( G4double energy,
aMa = fPlateThick*GetPlateLinearPhotoAbs(energy);
bMb = fGasThick*GetGasLinearPhotoAbs(energy);
sigma = aMa*fPlateThick + bMb*fGasThick;
Qa = exp(-0.5*aMa);
Qb = exp(-0.5*bMb);
Qa = std::exp(-0.5*aMa);
Qb = std::exp(-0.5*bMb);
Q = Qa*Qb;
G4complex Ha( Qa*cos(aZa), -Qa*sin(aZa) );
G4complex Hb( Qb*cos(bZb), -Qb*sin(bZb) );
G4complex Ha( Qa*std::cos(aZa), -Qa*std::sin(aZa) );
G4complex Hb( Qb*std::cos(bZb), -Qb*std::sin(bZb) );
G4complex H = Ha*Hb;
G4complex Hs = conj(H);
D = 1.0 /( (1 - Q)*(1 - Q) +
4*Q*sin(0.5*(aZa + bZb))*sin(0.5*(aZa + bZb)) );
4*Q*std::sin(0.5*(aZa + bZb))*std::sin(0.5*(aZa + bZb)) );
G4complex F1 = (1.0 - Ha)*(1.0 - Hb)*(1.0 - Hs)
* G4double(fPlateNumber)*D;
G4complex F2 = (1.0 - Ha)*(1.0 - Ha)*Hb*(1.0 - Hs)*(1.0 - Hs)
// * (1.0 - pow(H,fPlateNumber)) * D*D;
* (1.0 - exp(-0.5*fPlateNumber*sigma)) * D*D;
// * (1.0 - std::pow(H,fPlateNumber)) * D*D;
* (1.0 - std::exp(-0.5*fPlateNumber*sigma)) * D*D;
G4complex R = (F1 + F2)*OneInterfaceXTRdEdx(energy,gamma,varAngle);
result = 2.0*real(R);
result = 2.0*std::real(R);
return result;
}