Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -16,6 +16,24 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
5 October 20: D. Sawkey (xrays-V10-06-08)
- G4Cerenkov, G4Scintillation: apply clang-format style guidelines
30 September 20: H. Wenzel (xrays-V10-06-07)
- G4Cerenkov: make GetAverageNumberOfPhotons public
28 September 20: D. Sawkey (xrays-V10-06-06)
- G4Scintillation, G4Cerenkov: remove BuildThePhysicsTable
24 September 20: D. Sawkey (xrays-V10-06-05)
- G4Scintillation: allow specifying SCINTILLATIONYIELD only (not
requiring SCINTILLATIONYIELD1) when only 1 scintillation channel present.
Same for particle specific yields.
20 July 20: D. Sawkey (xrays-V10-06-04)
- G4Cerenkov, G4Scintillation: use new G4OpticalParameters to control
simulation parameters
28 May 20: D. Sawkey (xrays-V10-06-03)
- G4Cerenkov - set verbosity levels correctly
@@ -25,7 +25,7 @@
//
//
//
//
//
////////////////////////////////////////////////////////////////////////
// Cerenkov Radiation Class Definition
////////////////////////////////////////////////////////////////////////
@@ -40,7 +40,6 @@
// 1999-10-29 add method and class descriptors
// 1997-04-09 by Peter Gumplinger
// > G4MaterialPropertiesTable; new physics/tracking scheme
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
@@ -66,21 +65,17 @@
class G4Cerenkov : public G4VProcess
{
public:
explicit G4Cerenkov(const G4String& processName = "Cerenkov",
G4ProcessType type = fElectromagnetic);
public:
explicit G4Cerenkov(const G4String& processName = "Cerenkov",
G4ProcessType type = fElectromagnetic);
~G4Cerenkov();
explicit G4Cerenkov(const G4Cerenkov &right);
explicit G4Cerenkov(const G4Cerenkov& right);
private:
G4Cerenkov& operator=(const G4Cerenkov &right) = delete;
public:
private:
G4Cerenkov& operator=(const G4Cerenkov& right) = delete;
public:
G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable', for all charged particles
// except short-lived particles.
@@ -88,43 +83,50 @@ public:
void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
// Build table at a right time
G4double GetMeanFreePath(const G4Track& aTrack,
G4double, G4ForceCondition* );
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void Initialise();
G4double GetMeanFreePath(const G4Track& aTrack, G4double, G4ForceCondition*);
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
G4double PostStepGetPhysicalInteractionLength(const G4Track& aTrack,
G4double ,
G4ForceCondition* ) override;
G4double PostStepGetPhysicalInteractionLength(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
// This is the method implementing the Cerenkov process.
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track&,
G4double ,
G4double ,
G4double& ,
G4GPILSelection*
) override { return -1.0; };
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track&, G4double, G4double, G4double&, G4GPILSelection*) override
{
return -1.0;
};
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track& ,
G4ForceCondition*
) override { return -1.0; };
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track&, G4ForceCondition*) override
{
return -1.0;
};
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4VParticleChange* AtRestDoIt(const G4Track& , const G4Step& )
override {return nullptr;};
virtual G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override
{
return nullptr;
};
virtual G4VParticleChange* AlongStepDoIt(const G4Track& , const G4Step&)
override {return nullptr;};
virtual G4VParticleChange* AlongStepDoIt(const G4Track&,
const G4Step&) override
{
return nullptr;
};
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced Cerenkov photons are tracked next. When all have
// If set, the primary particle tracking is interrupted and any
// produced Cerenkov photons are tracked next. When all have
// been tracked, the tracking of the primary resumes.
G4bool GetTrackSecondariesFirst() const;
@@ -140,7 +142,7 @@ public:
// Set the maximum number of Cerenkov photons allowed to be generated during
// a tracking step. This is an average ONLY; the actual number will vary
// around this average. If invoked, the maximum photon stack will roughly be
// of the size set. If not called, the step is not limited by the number of
// of the size set. If not called, the step is not limited by the number of
// photons generated.
G4int GetMaxNumPhotonsPerStep() const;
@@ -162,68 +164,45 @@ public:
void DumpPhysicsTable() const;
// Prints the physics table.
private:
void BuildThePhysicsTable();
G4double GetAverageNumberOfPhotons(const G4double charge,
const G4double beta,
const G4Material *aMaterial,
G4double GetAverageNumberOfPhotons(const G4double charge, const G4double beta,
const G4Material* aMaterial,
G4MaterialPropertyVector* Rindex) const;
protected:
protected:
G4PhysicsTable* thePhysicsTable;
private:
private:
G4bool fTrackSecondariesFirst;
G4double fMaxBetaChange;
G4int fMaxPhotons;
G4int fMaxPhotons;
G4bool fStackingFlag;
G4int fNumPhotons;
};
inline
G4bool G4Cerenkov::GetTrackSecondariesFirst() const
inline G4bool G4Cerenkov::GetTrackSecondariesFirst() const
{
return fTrackSecondariesFirst;
}
inline
G4double G4Cerenkov::GetMaxBetaChangePerStep() const
inline G4double G4Cerenkov::GetMaxBetaChangePerStep() const
{
return fMaxBetaChange;
}
inline
G4int G4Cerenkov::GetMaxNumPhotonsPerStep() const
{
return fMaxPhotons;
}
inline G4int G4Cerenkov::GetMaxNumPhotonsPerStep() const { return fMaxPhotons; }
inline
void G4Cerenkov::SetStackPhotons(const G4bool stackingFlag)
inline void G4Cerenkov::SetStackPhotons(const G4bool stackingFlag)
{
fStackingFlag = stackingFlag;
}
inline
G4bool G4Cerenkov::GetStackPhotons() const
{
return fStackingFlag;
}
inline G4bool G4Cerenkov::GetStackPhotons() const { return fStackingFlag; }
inline
G4int G4Cerenkov::GetNumPhotons() const
{
return fNumPhotons;
}
inline G4int G4Cerenkov::GetNumPhotons() const { return fNumPhotons; }
inline
G4PhysicsTable* G4Cerenkov::GetPhysicsTable() const
inline G4PhysicsTable* G4Cerenkov::GetPhysicsTable() const
{
return thePhysicsTable;
}
@@ -25,12 +25,12 @@
//
//
//
//
//
////////////////////////////////////////////////////////////////////////
// Scintillation Light Class Definition
// Scintillation Light Class Definition
////////////////////////////////////////////////////////////////////////
//
// File: G4Scintillation.hh
// File: G4Scintillation.hh
// Description: Discrete Process - Generation of Scintillation Photons
// Version: 1.0
// Created: 1998-11-07
@@ -47,7 +47,6 @@
// 2002-05-09 changed IsApplicable method
// 1999-10-29 add method and class descriptors
//
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
@@ -64,7 +63,7 @@
#include "G4VRestDiscreteProcess.hh"
#include "G4OpticalPhoton.hh"
#include "G4DynamicParticle.hh"
#include "G4Material.hh"
#include "G4Material.hh"
#include "G4PhysicsTable.hh"
#include "G4MaterialPropertiesTable.hh"
#include "G4PhysicsOrderedFreeVector.hh"
@@ -78,21 +77,17 @@
class G4Scintillation : public G4VRestDiscreteProcess
{
public:
explicit G4Scintillation(const G4String& processName = "Scintillation",
G4ProcessType type = fElectromagnetic);
~G4Scintillation();
public:
private:
G4Scintillation(const G4Scintillation& right) = delete;
G4Scintillation& operator=(const G4Scintillation& right) = delete;
explicit G4Scintillation(const G4String& processName = "Scintillation",
G4ProcessType type = fElectromagnetic);
~G4Scintillation();
private:
G4Scintillation(const G4Scintillation &right) = delete;
G4Scintillation& operator=(const G4Scintillation &right) = delete;
public:
// G4Scintillation Process has both PostStepDoIt (for energy
public:
// G4Scintillation Process has both PostStepDoIt (for energy
// deposition of particles in flight) and AtRestDoIt (for energy
// given to the medium by particles at rest)
@@ -103,43 +98,43 @@ public:
void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
// Build table at the right time
G4double GetMeanFreePath(const G4Track& aTrack,
G4double ,
G4ForceCondition* ) override;
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void Initialise();
G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns infinity; i. e. the process does not limit the step,
// but sets the 'StronglyForced' condition for the DoIt to be
// but sets the 'StronglyForced' condition for the DoIt to be
// invoked at every step.
G4double GetMeanLifeTime(const G4Track& aTrack,
G4ForceCondition* ) override;
G4double GetMeanLifeTime(const G4Track& aTrack, G4ForceCondition*) override;
// Returns infinity; i. e. the process does not limit the time,
// but sets the 'StronglyForced' condition for the DoIt to be
// invoked at every step.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4VParticleChange* AtRestDoIt (const G4Track& aTrack,
const G4Step& aStep) override;
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4VParticleChange* AtRestDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4double GetScintillationYieldByParticleType(const G4Track &aTrack,
const G4Step &aStep);
G4double GetScintillationYieldByParticleType(const G4Track& aTrack,
const G4Step& aStep);
// Returns the number of scintillation photons calculated when
// scintillation depends on the particle type and energy
// deposited (includes nonlinear dependendency)
// DEPRECATED: to be removed in the next major release. Use the
// following instead.
G4double GetScintillationYieldByParticleType(
const G4Track &aTrack,
const G4Step &aStep,
G4double &yield1,
G4double &yield2,
G4double &yield3);
G4double GetScintillationYieldByParticleType(const G4Track& aTrack,
const G4Step& aStep,
G4double& yield1,
G4double& yield2,
G4double& yield3);
// allow multiple time constants with scint by particle type
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced scintillation photons are tracked next. When all
// produced scintillation photons are tracked next. When all
// have been tracked, the tracking of the primary resumes.
G4bool GetTrackSecondariesFirst() const;
@@ -201,7 +196,7 @@ public:
G4EmSaturation* GetSaturation() const;
// Returns the Birks Saturation.
void SetScintillationByParticleType(const G4bool );
void SetScintillationByParticleType(const G4bool);
// Called by the user to set the scintillation yield as a function
// of energy deposited by particle type
@@ -223,7 +218,7 @@ public:
// Return the boolean for whether or not the
// G4ScintillationTrackInformation is set to the scint. photon track
void SetStackPhotons(const G4bool );
void SetStackPhotons(const G4bool);
// Call by the user to set the flag for stacking the scint. photons
G4bool GetStackPhotons() const;
@@ -235,27 +230,21 @@ public:
void DumpPhysicsTable() const;
// Prints the fast and slow scintillation integral tables.
protected:
void BuildThePhysicsTable();
// It builds either the fast or slow scintillation integral table;
// or both.
protected:
G4PhysicsTable* fIntegralTable1;
G4PhysicsTable* fIntegralTable2;
G4PhysicsTable* fIntegralTable3;
private:
G4bool fTrackSecondariesFirst;
G4bool fFiniteRiseTime;
private:
G4bool fTrackSecondariesFirst;
G4bool fFiniteRiseTime;
G4double fYieldFactor;
G4double fExcitationRatio;
G4bool fScintillationByParticleType;
G4bool fScintillationTrackInfo;
G4bool fStackingFlag;
G4int fNumPhotons;
G4bool fEnhancedTimeConstants;
G4bool fScintillationByParticleType;
G4bool fScintillationTrackInfo;
G4bool fStackingFlag;
G4int fNumPhotons;
G4bool fEnhancedTimeConstants;
#ifdef G4DEBUG_SCINTILLATION
G4double ScintTrackEDep, ScintTrackYield;
@@ -268,169 +257,137 @@ private:
G4double sample_time(G4double tau1, G4double tau2);
G4EmSaturation* fEmSaturation;
G4ParticleDefinition* opticalphoton = G4OpticalPhoton::OpticalPhotonDefinition();
G4ParticleDefinition* opticalphoton =
G4OpticalPhoton::OpticalPhotonDefinition();
};
////////////////////
// Inline methods
////////////////////
inline
void G4Scintillation::SetTrackSecondariesFirst(const G4bool state)
inline void G4Scintillation::SetTrackSecondariesFirst(const G4bool state)
{
fTrackSecondariesFirst = state;
}
inline
G4bool G4Scintillation::GetTrackSecondariesFirst() const
inline G4bool G4Scintillation::GetTrackSecondariesFirst() const
{
return fTrackSecondariesFirst;
}
inline
void G4Scintillation::SetFiniteRiseTime(const G4bool state)
inline void G4Scintillation::SetFiniteRiseTime(const G4bool state)
{
fFiniteRiseTime = state;
}
inline
G4bool G4Scintillation::GetFiniteRiseTime() const
inline G4bool G4Scintillation::GetFiniteRiseTime() const
{
return fFiniteRiseTime;
}
inline
void G4Scintillation::SetScintillationYieldFactor(const G4double yieldfactor)
inline void G4Scintillation::SetScintillationYieldFactor(
const G4double yieldfactor)
{
fYieldFactor = yieldfactor;
}
inline
G4double G4Scintillation::GetScintillationYieldFactor() const
inline G4double G4Scintillation::GetScintillationYieldFactor() const
{
return fYieldFactor;
}
inline
void G4Scintillation::SetScintillationExcitationRatio(const G4double ratio)
inline void G4Scintillation::SetScintillationExcitationRatio(
const G4double ratio)
{
fExcitationRatio = ratio;
}
inline
G4double G4Scintillation::GetScintillationExcitationRatio() const
inline G4double G4Scintillation::GetScintillationExcitationRatio() const
{
return fExcitationRatio;
}
inline
G4PhysicsTable* G4Scintillation::GetSlowIntegralTable() const
inline G4PhysicsTable* G4Scintillation::GetSlowIntegralTable() const
{
return fIntegralTable3;
}
inline
G4PhysicsTable* G4Scintillation::GetFastIntegralTable() const
inline G4PhysicsTable* G4Scintillation::GetFastIntegralTable() const
{
return fIntegralTable1;
}
inline
G4PhysicsTable* G4Scintillation::GetIntegralTable1() const
inline G4PhysicsTable* G4Scintillation::GetIntegralTable1() const
{
return fIntegralTable1;
}
inline
G4PhysicsTable* G4Scintillation::GetIntegralTable2() const
inline G4PhysicsTable* G4Scintillation::GetIntegralTable2() const
{
return fIntegralTable2;
}
inline
G4PhysicsTable* G4Scintillation::GetIntegralTable3() const
inline G4PhysicsTable* G4Scintillation::GetIntegralTable3() const
{
return fIntegralTable3;
}
inline
void G4Scintillation::AddSaturation(G4EmSaturation* sat)
inline void G4Scintillation::AddSaturation(G4EmSaturation* sat)
{
fEmSaturation = sat;
}
inline
void G4Scintillation::RemoveSaturation()
{
fEmSaturation = nullptr;
}
inline void G4Scintillation::RemoveSaturation() { fEmSaturation = nullptr; }
inline
G4EmSaturation* G4Scintillation::GetSaturation() const
inline G4EmSaturation* G4Scintillation::GetSaturation() const
{
return fEmSaturation;
}
inline
G4bool G4Scintillation::GetScintillationByParticleType() const
inline G4bool G4Scintillation::GetScintillationByParticleType() const
{
return fScintillationByParticleType;
}
inline
void G4Scintillation::SetEnhancedTimeConstants(G4bool val)
inline void G4Scintillation::SetEnhancedTimeConstants(G4bool val)
{
fEnhancedTimeConstants = val;
}
inline
G4bool G4Scintillation::GetEnhancedTimeConstants() const
inline G4bool G4Scintillation::GetEnhancedTimeConstants() const
{
return fEnhancedTimeConstants;
}
inline
void G4Scintillation::SetScintillationTrackInfo(const G4bool trackType)
inline void G4Scintillation::SetScintillationTrackInfo(const G4bool trackType)
{
fScintillationTrackInfo = trackType;
}
inline
G4bool G4Scintillation::GetScintillationTrackInfo() const
inline G4bool G4Scintillation::GetScintillationTrackInfo() const
{
return fScintillationTrackInfo;
}
inline
void G4Scintillation::SetStackPhotons(const G4bool stackingFlag)
inline void G4Scintillation::SetStackPhotons(const G4bool stackingFlag)
{
fStackingFlag = stackingFlag;
}
inline
G4bool G4Scintillation::GetStackPhotons() const
inline G4bool G4Scintillation::GetStackPhotons() const { return fStackingFlag; }
inline G4int G4Scintillation::GetNumPhotons() const { return fNumPhotons; }
inline G4double G4Scintillation::single_exp(G4double t, G4double tau2)
{
return fStackingFlag;
return std::exp(-1.0 * t / tau2) / tau2;
}
inline
G4int G4Scintillation::GetNumPhotons() const
inline G4double G4Scintillation::bi_exp(G4double t, G4double tau1,
G4double tau2)
{
return fNumPhotons;
}
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);
return std::exp(-1.0 * t / tau2) * (1 - std::exp(-1.0 * t / tau1)) / tau2 /
tau2 * (tau1 + tau2);
}
#endif /* G4Scintillation_h */
@@ -33,7 +33,7 @@
//
// Class Description:
//
// Concrete class of G4VUserTrackInformation used to store information
// Concrete class of G4VUserTrackInformation used to store information
// linked to the track generated in a scintillation process.
//
@@ -43,38 +43,48 @@
#include "G4VUserTrackInformation.hh"
// Represents the scintillation type used to create the track (opticalphoton).
enum G4ScintillationType {Fast, Medium, Slow};
enum G4ScintillationType
{
Fast,
Medium,
Slow
};
class G4ScintillationTrackInformation : public G4VUserTrackInformation
{
public:
public:
explicit G4ScintillationTrackInformation(
const G4ScintillationType& aType = Slow);
virtual ~G4ScintillationTrackInformation();
explicit G4ScintillationTrackInformation(const G4ScintillationType& aType = Slow);
virtual ~G4ScintillationTrackInformation();
// Required by G4VUserTrackInformation
void *operator new(size_t);
void operator delete(void *aScintillationTI);
// Copy Constructor/instruction
G4ScintillationTrackInformation(const G4ScintillationTrackInformation&);
G4ScintillationTrackInformation& operator=(const G4ScintillationTrackInformation&);
virtual void Print() const override;
const G4ScintillationType& GetScintillationType() const {return scintillationType;}
// Static class allowing to check if a G4VUserTrackInformation is a
// G4ScintillationTrackInformation and cast it without changing the
// pointer of the pointed data.
static G4bool IsScintillationTrackInformation(const G4VUserTrackInformation* const);
static G4ScintillationTrackInformation* Cast(const G4VUserTrackInformation* const);
private:
// Required by G4VUserTrackInformation
void* operator new(size_t);
void operator delete(void* aScintillationTI);
G4ScintillationType scintillationType;
// String given to G4VUserTrackInformation to identify this concrete class
static const G4String BaseType;
// Copy Constructor/instruction
G4ScintillationTrackInformation(const G4ScintillationTrackInformation&);
G4ScintillationTrackInformation& operator=(
const G4ScintillationTrackInformation&);
virtual void Print() const override;
const G4ScintillationType& GetScintillationType() const
{
return scintillationType;
}
// Static class allowing to check if a G4VUserTrackInformation is a
// G4ScintillationTrackInformation and cast it without changing the
// pointer of the pointed data.
static G4bool IsScintillationTrackInformation(
const G4VUserTrackInformation* const);
static G4ScintillationTrackInformation* Cast(
const G4VUserTrackInformation* const);
private:
G4ScintillationType scintillationType;
// String given to G4VUserTrackInformation to identify this concrete class
static const G4String BaseType;
};
///
@@ -84,23 +94,29 @@ class G4ScintillationTrackInformation : public G4VUserTrackInformation
#include "G4Allocator.hh"
// Forward declaration for the Allocator
class G4ScintillationTrackInformation;
class G4ScintillationTrackInformation;
#if defined G4EM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4ScintillationTrackInformation>*& aScintillationTIAllocator();
extern G4DLLEXPORT G4Allocator<G4ScintillationTrackInformation>*&
aScintillationTIAllocator();
#else
extern G4DLLIMPORT G4Allocator<G4ScintillationTrackInformation>*& aScintillationTIAllocator();
extern G4DLLIMPORT G4Allocator<G4ScintillationTrackInformation>*&
aScintillationTIAllocator();
#endif
inline void* G4ScintillationTrackInformation::operator new(size_t)
{
if (!aScintillationTIAllocator()) aScintillationTIAllocator() = new G4Allocator<G4ScintillationTrackInformation>;
return (void *) aScintillationTIAllocator()->MallocSingle();
if(!aScintillationTIAllocator())
aScintillationTIAllocator() =
new G4Allocator<G4ScintillationTrackInformation>;
return (void*) aScintillationTIAllocator()->MallocSingle();
}
inline void G4ScintillationTrackInformation::operator delete(void *aScintillationTI)
inline void G4ScintillationTrackInformation::operator delete(
void* aScintillationTI)
{
aScintillationTIAllocator()->FreeSingle((G4ScintillationTrackInformation *) aScintillationTI);
aScintillationTIAllocator()->FreeSingle(
(G4ScintillationTrackInformation*) aScintillationTI);
}
#endif // G4SCINTILLATIONTRACKINFORMATION_H
#endif // G4SCINTILLATIONTRACKINFORMATION_H
@@ -4,7 +4,7 @@
# Package: Geant4.src.G4processes.G4electromagnetic.G4xrays
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists the sources and headers of the code explicitly.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
@@ -14,35 +14,9 @@
#
#------------------------------------------------------------------------------
# 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/standard/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
@@ -56,7 +56,6 @@
// > add protection against /0
// > G4MaterialPropertiesTable; new physics/tracking scheme
//
// mail: gum@triumf.ca
//
////////////////////////////////////////////////////////////////////////
@@ -70,30 +69,30 @@
#include "G4MaterialCutsCouple.hh"
#include "G4ParticleDefinition.hh"
#include "G4OpticalParameters.hh"
#include "G4Cerenkov.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Cerenkov::G4Cerenkov(const G4String& processName, G4ProcessType type)
: G4VProcess(processName, type),
fTrackSecondariesFirst(false),
fMaxBetaChange(0.0),
fMaxPhotons(0),
fStackingFlag(true),
fNumPhotons(0)
: G4VProcess(processName, type)
, fNumPhotons(0)
{
SetProcessSubType(fCerenkov);
thePhysicsTable = nullptr;
if (verboseLevel>0) {
if(verboseLevel > 0)
{
G4cout << GetProcessName() << " is created." << G4endl;
}
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Cerenkov::~G4Cerenkov()
{
if (thePhysicsTable != nullptr) {
if(thePhysicsTable != nullptr)
{
thePhysicsTable->clearAndDestroy();
delete thePhysicsTable;
}
@@ -103,38 +102,102 @@ G4Cerenkov::~G4Cerenkov()
G4bool G4Cerenkov::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return (aParticleType.GetPDGCharge() != 0.0 &&
aParticleType.GetPDGMass() != 0.0 &&
aParticleType.GetParticleName() != "chargedgeantino" &&
!aParticleType.IsShortLived() ) ? true : false;
aParticleType.GetPDGMass() != 0.0 &&
aParticleType.GetParticleName() != "chargedgeantino" &&
!aParticleType.IsShortLived())
? true
: false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetTrackSecondariesFirst(const G4bool state)
void G4Cerenkov::Initialise()
{
fTrackSecondariesFirst = state;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetMaxBetaChangePerStep(const G4double value)
{
fMaxBetaChange = value*CLHEP::perCent;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetMaxNumPhotonsPerStep(const G4int NumPhotons)
{
fMaxPhotons = NumPhotons;
G4OpticalParameters* params = G4OpticalParameters::Instance();
SetMaxBetaChangePerStep(params->GetCerenkovMaxBetaChange());
SetMaxNumPhotonsPerStep(params->GetCerenkovMaxPhotonsPerStep());
SetTrackSecondariesFirst(params->GetCerenkovTrackSecondariesFirst());
SetStackPhotons(params->GetCerenkovStackPhotons());
SetVerboseLevel(params->GetCerenkovVerboseLevel());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::BuildPhysicsTable(const G4ParticleDefinition&)
{
if (!thePhysicsTable) BuildThePhysicsTable();
if(thePhysicsTable)
return;
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
thePhysicsTable = new G4PhysicsTable(numOfMaterials);
// loop over materials
for(G4int i = 0; i < numOfMaterials; ++i)
{
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector = 0;
// Retrieve vector of refraction indices for the material
// from the material's optical properties table
G4Material* aMaterial = (*theMaterialTable)[i];
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
if(aMaterialPropertiesTable)
{
aPhysicsOrderedFreeVector = new G4PhysicsOrderedFreeVector();
G4MaterialPropertyVector* theRefractionIndexVector =
aMaterialPropertiesTable->GetProperty(kRINDEX);
if(theRefractionIndexVector)
{
// Retrieve the first refraction index in vector
// of (photon energy, refraction index) pairs
G4double currentRI = (*theRefractionIndexVector)[0];
if(currentRI > 1.0)
{
// Create first (photon energy, Cerenkov Integral) pair
G4double currentPM = theRefractionIndexVector->Energy(0);
G4double currentCAI = 0.0;
aPhysicsOrderedFreeVector->InsertValues(currentPM, currentCAI);
// Set previous values to current ones prior to loop
G4double prevPM = currentPM;
G4double prevCAI = currentCAI;
G4double prevRI = currentRI;
// loop over all (photon energy, refraction index)
// pairs stored for this material
for(size_t ii = 1; ii < theRefractionIndexVector->GetVectorLength();
++ii)
{
currentRI = (*theRefractionIndexVector)[ii];
currentPM = theRefractionIndexVector->Energy(ii);
currentCAI = prevCAI + (currentPM - prevPM) * 0.5 *
(1.0 / (prevRI * prevRI) +
1.0 / (currentRI * currentRI));
aPhysicsOrderedFreeVector->InsertValues(currentPM, currentCAI);
prevPM = currentPM;
prevCAI = currentCAI;
prevRI = currentRI;
}
}
}
}
// The Cerenkov integral for a given material will be inserted in
// thePhysicsTable according to the position of the material in
// the material table.
thePhysicsTable->insertAt(i, aPhysicsOrderedFreeVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange*
G4Cerenkov::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4VParticleChange* G4Cerenkov::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
// This routine is called for each tracking Step of a charged particle
// in a radiator. A Poisson-distributed number of photons is generated
// according to the Cerenkov formula, distributed evenly along the track
@@ -150,43 +213,45 @@ G4Cerenkov::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
aParticleChange.Initialize(aTrack);
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4Material* aMaterial = aTrack.GetMaterial();
const G4Material* aMaterial = aTrack.GetMaterial();
G4StepPoint* pPreStepPoint = aStep.GetPreStepPoint();
G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
G4ThreeVector x0 = pPreStepPoint->GetPosition();
G4ThreeVector p0 = aStep.GetDeltaPosition().unit();
G4double t0 = pPreStepPoint->GetGlobalTime();
G4double t0 = pPreStepPoint->GetGlobalTime();
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
if (!aMaterialPropertiesTable) return pParticleChange;
G4MaterialPropertiesTable* MPT = aMaterial->GetMaterialPropertiesTable();
if(!MPT)
return pParticleChange;
G4MaterialPropertyVector* Rindex =
aMaterialPropertiesTable->GetProperty(kRINDEX);
if (!Rindex) return pParticleChange;
G4MaterialPropertyVector* Rindex = MPT->GetProperty(kRINDEX);
if(!Rindex)
return pParticleChange;
G4double charge = aParticle->GetDefinition()->GetPDGCharge();
G4double beta = (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta())*0.5;
G4double beta = (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta()) * 0.5;
//fNumPhotons = 0; // in PostStepGetPhysicalInteractionLength()
// fNumPhotons = 0; // in PostStepGetPhysicalInteractionLength()
G4double MeanNumberOfPhotons =
GetAverageNumberOfPhotons(charge,beta,aMaterial,Rindex);
G4double MeanNumberOfPhotons =
GetAverageNumberOfPhotons(charge, beta, aMaterial, Rindex);
if (MeanNumberOfPhotons <= 0.0) {
if(MeanNumberOfPhotons <= 0.0)
{
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return pParticleChange;
}
G4double step_length = aStep.GetStepLength();
MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
fNumPhotons = (G4int)G4Poisson(MeanNumberOfPhotons);
MeanNumberOfPhotons = MeanNumberOfPhotons * step_length;
fNumPhotons = (G4int) G4Poisson(MeanNumberOfPhotons);
if (fNumPhotons <= 0 || !fStackingFlag) {
// return unchanged particle and no secondaries
if(fNumPhotons <= 0 || !fStackingFlag)
{
// return unchanged particle and no secondaries
aParticleChange.SetNumberOfSecondaries(0);
return pParticleChange;
}
@@ -194,66 +259,71 @@ G4Cerenkov::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
////////////////////////////////////////////////////////////////
aParticleChange.SetNumberOfSecondaries(fNumPhotons);
if (fTrackSecondariesFirst) {
if (aTrack.GetTrackStatus() == fAlive)
aParticleChange.ProposeTrackStatus(fSuspend);
if(fTrackSecondariesFirst)
{
if(aTrack.GetTrackStatus() == fAlive)
aParticleChange.ProposeTrackStatus(fSuspend);
}
////////////////////////////////////////////////////////////////
G4double Pmin = Rindex->GetMinLowEdgeEnergy();
G4double Pmax = Rindex->GetMaxLowEdgeEnergy();
G4double dp = Pmax - Pmin;
G4double dp = Pmax - Pmin;
G4double nMax = Rindex->GetMaxValue();
G4double BetaInverse = 1./beta;
G4double nMax = Rindex->GetMaxValue();
G4double BetaInverse = 1. / beta;
G4double maxCos = BetaInverse / nMax;
G4double maxCos = BetaInverse / nMax;
G4double maxSin2 = (1.0 - maxCos) * (1.0 + maxCos);
G4double beta1 = pPreStepPoint ->GetBeta();
G4double beta1 = pPreStepPoint->GetBeta();
G4double beta2 = pPostStepPoint->GetBeta();
G4double MeanNumberOfPhotons1 =
GetAverageNumberOfPhotons(charge,beta1,aMaterial,Rindex);
GetAverageNumberOfPhotons(charge, beta1, aMaterial, Rindex);
G4double MeanNumberOfPhotons2 =
GetAverageNumberOfPhotons(charge,beta2,aMaterial,Rindex);
GetAverageNumberOfPhotons(charge, beta2, aMaterial, Rindex);
for (G4int i=0; i<fNumPhotons; ++i) {
for(G4int i = 0; i < fNumPhotons; ++i)
{
// Determine photon energy
G4double rand;
G4double sampledEnergy, sampledRI;
G4double sampledEnergy, sampledRI;
G4double cosTheta, sin2Theta;
// sample an energy
do {
rand = G4UniformRand();
sampledEnergy = Pmin + rand * dp;
sampledRI = Rindex->Value(sampledEnergy);
cosTheta = BetaInverse / sampledRI;
do
{
rand = G4UniformRand();
sampledEnergy = Pmin + rand * dp;
sampledRI = Rindex->Value(sampledEnergy);
cosTheta = BetaInverse / sampledRI;
sin2Theta = (1.0 - cosTheta)*(1.0 + cosTheta);
rand = G4UniformRand();
sin2Theta = (1.0 - cosTheta) * (1.0 + cosTheta);
rand = G4UniformRand();
// Loop checking, 07-Aug-2015, Vladimir Ivanchenko
} while (rand*maxSin2 > sin2Theta);
} while(rand * maxSin2 > sin2Theta);
// Create photon momentum direction vector. The momentum direction is still
// with respect to the coordinate system where the primary particle
// direction is aligned with the z axis
rand = G4UniformRand();
G4double phi = twopi*rand;
G4double sinPhi = std::sin(phi);
G4double cosPhi = std::cos(phi);
G4double sinTheta = std::sqrt(sin2Theta);
G4ParticleMomentum photonMomentum(sinTheta*cosPhi, sinTheta*sinPhi, cosTheta);
// direction is aligned with the z axis
rand = G4UniformRand();
G4double phi = twopi * rand;
G4double sinPhi = std::sin(phi);
G4double cosPhi = std::cos(phi);
G4double sinTheta = std::sqrt(sin2Theta);
G4ParticleMomentum photonMomentum(sinTheta * cosPhi, sinTheta * sinPhi,
cosTheta);
// Rotate momentum direction back to global reference system
// Rotate momentum direction back to global reference system
photonMomentum.rotateUz(p0);
// Determine polarization of new photon
G4ThreeVector photonPolarization(cosTheta*cosPhi, cosTheta*sinPhi, -sinTheta);
// Determine polarization of new photon
G4ThreeVector photonPolarization(cosTheta * cosPhi, cosTheta * sinPhi,
-sinTheta);
// Rotate back to original coord system
// Rotate back to original coord system
photonPolarization.rotateUz(p0);
// Generate a new photon:
@@ -265,285 +335,258 @@ G4Cerenkov::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
G4double NumberOfPhotons, N;
do {
rand = G4UniformRand();
NumberOfPhotons = MeanNumberOfPhotons1 - rand *
(MeanNumberOfPhotons1-MeanNumberOfPhotons2);
N = G4UniformRand() *
std::max(MeanNumberOfPhotons1,MeanNumberOfPhotons2);
do
{
rand = G4UniformRand();
NumberOfPhotons = MeanNumberOfPhotons1 -
rand * (MeanNumberOfPhotons1 - MeanNumberOfPhotons2);
N =
G4UniformRand() * std::max(MeanNumberOfPhotons1, MeanNumberOfPhotons2);
// Loop checking, 07-Aug-2015, Vladimir Ivanchenko
} while (N > NumberOfPhotons);
} while(N > NumberOfPhotons);
G4double delta = rand * aStep.GetStepLength();
G4double deltaTime = delta / (pPreStepPoint->GetVelocity() +
rand*(pPostStepPoint->GetVelocity() -
pPreStepPoint->GetVelocity())*0.5);
G4double deltaTime =
delta /
(pPreStepPoint->GetVelocity() +
rand * (pPostStepPoint->GetVelocity() - pPreStepPoint->GetVelocity()) *
0.5);
G4double aSecondaryTime = t0 + deltaTime;
G4double aSecondaryTime = t0 + deltaTime;
G4ThreeVector aSecondaryPosition = x0 + rand * aStep.GetDeltaPosition();
// Generate new G4Track object:
G4Track* aSecondaryTrack =
new G4Track(aCerenkovPhoton,aSecondaryTime,aSecondaryPosition);
G4Track* aSecondaryTrack =
new G4Track(aCerenkovPhoton, aSecondaryTime, aSecondaryPosition);
aSecondaryTrack->SetTouchableHandle(
aStep.GetPreStepPoint()->GetTouchableHandle());
aStep.GetPreStepPoint()->GetTouchableHandle());
aSecondaryTrack->SetParentID(aTrack.GetTrackID());
aParticleChange.AddSecondary(aSecondaryTrack);
}
if (verboseLevel>1) {
if(verboseLevel > 1)
{
G4cout << "\n Exiting from G4Cerenkov::DoIt -- NumberOfSecondaries = "
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
<< aParticleChange.GetNumberOfSecondaries() << G4endl;
}
return pParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::BuildThePhysicsTable()
void G4Cerenkov::PreparePhysicsTable(const G4ParticleDefinition&)
{
if (thePhysicsTable) return;
const G4MaterialTable* theMaterialTable=
G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
thePhysicsTable = new G4PhysicsTable(numOfMaterials);
// loop over materials
for (G4int i=0; i<numOfMaterials; ++i) {
G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector = 0;
// Retrieve vector of refraction indices for the material
// from the material's optical properties table
G4Material* aMaterial = (*theMaterialTable)[i];
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
if (aMaterialPropertiesTable) {
aPhysicsOrderedFreeVector = new G4PhysicsOrderedFreeVector();
G4MaterialPropertyVector* theRefractionIndexVector =
aMaterialPropertiesTable->GetProperty(kRINDEX);
if (theRefractionIndexVector) {
// Retrieve the first refraction index in vector
// of (photon energy, refraction index) pairs
G4double currentRI = (*theRefractionIndexVector)[0];
if (currentRI > 1.0) {
// Create first (photon energy, Cerenkov Integral) pair
G4double currentPM = theRefractionIndexVector->Energy(0);
G4double currentCAI = 0.0;
aPhysicsOrderedFreeVector->InsertValues(currentPM , currentCAI);
// Set previous values to current ones prior to loop
G4double prevPM = currentPM;
G4double prevCAI = currentCAI;
G4double prevRI = currentRI;
// loop over all (photon energy, refraction index)
// pairs stored for this material
for (size_t ii = 1;
ii < theRefractionIndexVector->GetVectorLength();
++ii) {
currentRI = (*theRefractionIndexVector)[ii];
currentPM = theRefractionIndexVector->Energy(ii);
currentCAI = prevCAI + (currentPM - prevPM) *
0.5*(1.0/(prevRI*prevRI) + 1.0/(currentRI*currentRI));
aPhysicsOrderedFreeVector->InsertValues(currentPM, currentCAI);
prevPM = currentPM;
prevCAI = currentCAI;
prevRI = currentRI;
}
}
}
}
// The Cerenkov integral for a given material will be inserted in
// thePhysicsTable according to the position of the material in
// the material table.
thePhysicsTable->insertAt(i,aPhysicsOrderedFreeVector);
}
Initialise();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4Cerenkov::GetMeanFreePath(const G4Track&,
G4double,
G4ForceCondition*)
G4double G4Cerenkov::GetMeanFreePath(const G4Track&, G4double,
G4ForceCondition*)
{
return 1.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4Cerenkov::PostStepGetPhysicalInteractionLength(
const G4Track& aTrack,
G4double,
G4ForceCondition* condition)
const G4Track& aTrack, G4double, G4ForceCondition* condition)
{
*condition = NotForced;
*condition = NotForced;
G4double StepLimit = DBL_MAX;
fNumPhotons = 0;
fNumPhotons = 0;
const G4Material* aMaterial = aTrack.GetMaterial();
G4int materialIndex = aMaterial->GetIndex();
G4int materialIndex = aMaterial->GetIndex();
// If Physics Vector is not defined no Cerenkov photons
if (!(*thePhysicsTable)[materialIndex]) { return StepLimit; }
if(!(*thePhysicsTable)[materialIndex])
{
return StepLimit;
}
const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
const G4MaterialCutsCouple* couple = aTrack.GetMaterialCutsCouple();
G4double kineticEnergy = aParticle->GetKineticEnergy();
G4double kineticEnergy = aParticle->GetKineticEnergy();
const G4ParticleDefinition* particleType = aParticle->GetDefinition();
G4double mass = particleType->GetPDGMass();
G4double mass = particleType->GetPDGMass();
G4double beta = aParticle->GetTotalMomentum() / aParticle->GetTotalEnergy();
G4double gamma = aParticle->GetTotalEnergy()/mass;
G4double gamma = aParticle->GetTotalEnergy() / mass;
G4MaterialPropertiesTable* aMaterialPropertiesTable =
aMaterial->GetMaterialPropertiesTable();
aMaterial->GetMaterialPropertiesTable();
G4MaterialPropertyVector* Rindex = nullptr;
if (aMaterialPropertiesTable)
Rindex = aMaterialPropertiesTable->GetProperty(kRINDEX);
if(aMaterialPropertiesTable)
Rindex = aMaterialPropertiesTable->GetProperty(kRINDEX);
G4double nMax;
if (Rindex) {
if(Rindex)
{
nMax = Rindex->GetMaxValue();
} else {
}
else
{
return StepLimit;
}
G4double BetaMin = 1./nMax;
if (BetaMin >= 1.) return StepLimit;
G4double BetaMin = 1. / nMax;
if(BetaMin >= 1.)
return StepLimit;
G4double GammaMin = 1./std::sqrt(1.-BetaMin*BetaMin);
if (gamma < GammaMin) return StepLimit;
G4double GammaMin = 1. / std::sqrt(1. - BetaMin * BetaMin);
if(gamma < GammaMin)
return StepLimit;
G4double kinEmin = mass*(GammaMin-1.);
G4double kinEmin = mass * (GammaMin - 1.);
G4double RangeMin =
G4LossTableManager::Instance()->GetRange(particleType, kinEmin, couple);
G4double Range =
G4LossTableManager::Instance()->GetRange(particleType, kineticEnergy, couple);
G4double Range = G4LossTableManager::Instance()->GetRange(
particleType, kineticEnergy, couple);
G4double Step = Range - RangeMin;
// If the step is smaller than 1e-16 mm, it may happen that the particle
// does not move. See bug 1992.
// 2019-03-11: change to 1e-15
if (Step < 1.e-15*mm) return StepLimit;
if (Step < StepLimit) StepLimit = Step;
if(Step < 1.e-15 * mm)
return StepLimit;
if(Step < StepLimit)
StepLimit = Step;
// If user has defined an average maximum number of photons to be generated in
// a Step, then calculate the Step length for that number of photons.
if (fMaxPhotons > 0) {
// a Step, then calculate the Step length for that number of photons.
if(fMaxPhotons > 0)
{
const G4double charge = aParticle->GetDefinition()->GetPDGCharge();
G4double MeanNumberOfPhotons =
GetAverageNumberOfPhotons(charge,beta,aMaterial,Rindex);
G4double MeanNumberOfPhotons =
GetAverageNumberOfPhotons(charge, beta, aMaterial, Rindex);
Step = 0.;
if (MeanNumberOfPhotons > 0.0) Step = fMaxPhotons / MeanNumberOfPhotons;
if (Step > 0. && Step < StepLimit) StepLimit = Step;
if(MeanNumberOfPhotons > 0.0)
Step = fMaxPhotons / MeanNumberOfPhotons;
if(Step > 0. && Step < StepLimit)
StepLimit = Step;
}
// If user has defined an maximum allowed change in beta per step
if (fMaxBetaChange > 0.) {
G4double dedx =
G4LossTableManager::Instance()->GetDEDX(particleType, kineticEnergy, couple);
if(fMaxBetaChange > 0.)
{
G4double dedx = G4LossTableManager::Instance()->GetDEDX(
particleType, kineticEnergy, couple);
G4double deltaGamma =
gamma - 1./std::sqrt(1.-beta*beta* (1.-fMaxBetaChange)* (1.-fMaxBetaChange));
gamma - 1. / std::sqrt(1. - beta * beta * (1. - fMaxBetaChange) *
(1. - fMaxBetaChange));
Step = mass * deltaGamma / dedx;
if (Step > 0. && Step < StepLimit) StepLimit = Step;
if(Step > 0. && Step < StepLimit)
StepLimit = Step;
}
*condition = StronglyForced;
return StepLimit;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double
G4Cerenkov::GetAverageNumberOfPhotons(const G4double charge,
const G4double beta,
const G4Material* aMaterial,
G4MaterialPropertyVector* Rindex) const
G4double G4Cerenkov::GetAverageNumberOfPhotons(
const G4double charge, const G4double beta, const G4Material* aMaterial,
G4MaterialPropertyVector* Rindex) const
// This routine computes the number of Cerenkov photons produced per
// GEANT4-unit (millimeter) in the current medium.
// ^^^^^^^^^^
{
const G4double Rfact = 369.81/(eV * cm);
if (beta <= 0.0) return 0.0;
G4double BetaInverse = 1./beta;
const G4double Rfact = 369.81 / (eV * cm);
if(beta <= 0.0)
return 0.0;
G4double BetaInverse = 1. / beta;
// Vectors used in computation of Cerenkov Angle Integral:
// - Refraction Indices for the current material
// - new G4PhysicsOrderedFreeVector allocated to hold CAI's
G4int materialIndex = aMaterial->GetIndex();
// Retrieve the Cerenkov Angle Integrals for this material
// Retrieve the Cerenkov Angle Integrals for this material
G4PhysicsOrderedFreeVector* CerenkovAngleIntegrals =
(G4PhysicsOrderedFreeVector*)((*thePhysicsTable)(materialIndex));
(G4PhysicsOrderedFreeVector*) ((*thePhysicsTable)(materialIndex));
if (!(CerenkovAngleIntegrals->IsFilledVectorExist())) return 0.0;
if(!(CerenkovAngleIntegrals->IsFilledVectorExist()))
return 0.0;
// Min and Max photon energies
// Min and Max photon energies
G4double Pmin = Rindex->GetMinLowEdgeEnergy();
G4double Pmax = Rindex->GetMaxLowEdgeEnergy();
// Min and Max Refraction Indices
G4double nMin = Rindex->GetMinValue();
// Min and Max Refraction Indices
G4double nMin = Rindex->GetMinValue();
G4double nMax = Rindex->GetMaxValue();
// Max Cerenkov Angle Integral
// Max Cerenkov Angle Integral
G4double CAImax = CerenkovAngleIntegrals->GetMaxValue();
G4double dp, ge;
// If n(Pmax) < 1/Beta -- no photons generated
if (nMax < BetaInverse) {
// If n(Pmax) < 1/Beta -- no photons generated
if(nMax < BetaInverse)
{
dp = 0.0;
ge = 0.0;
}
// otherwise if n(Pmin) >= 1/Beta -- photons generated
else if (nMin > BetaInverse) {
dp = Pmax - Pmin;
ge = CAImax;
}
}
// otherwise if n(Pmin) >= 1/Beta -- photons generated
else if(nMin > BetaInverse)
{
dp = Pmax - Pmin;
ge = CAImax;
}
// If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then we need to find a P such
// that the value of n(P) == 1/Beta. Interpolation is performed by the
// GetEnergy() and Value() methods of the G4MaterialPropertiesTable and
// the Value() method of G4PhysicsVector.
else {
// the Value() method of G4PhysicsVector.
else
{
Pmin = Rindex->GetEnergy(BetaInverse);
dp = Pmax - Pmin;
dp = Pmax - Pmin;
G4double CAImin = CerenkovAngleIntegrals->Value(Pmin);
ge = CAImax - CAImin;
ge = CAImax - CAImin;
if (verboseLevel>1) {
G4cout << "CAImin = " << CAImin << G4endl
<< "ge = " << ge << G4endl;
if(verboseLevel > 1)
{
G4cout << "CAImin = " << CAImin << G4endl << "ge = " << ge << G4endl;
}
}
// Calculate number of photons
G4double NumPhotons = Rfact * charge/eplus * charge/eplus *
(dp - ge * BetaInverse*BetaInverse);
return NumPhotons;
// Calculate number of photons
G4double NumPhotons = Rfact * charge / eplus * charge / eplus *
(dp - ge * BetaInverse * BetaInverse);
return NumPhotons;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetTrackSecondariesFirst(const G4bool state)
{
fTrackSecondariesFirst = state;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetMaxBetaChangePerStep(const G4double value)
{
fMaxBetaChange = value * CLHEP::perCent;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::SetMaxNumPhotonsPerStep(const G4int NumPhotons)
{
fMaxPhotons = NumPhotons;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Cerenkov::DumpPhysicsTable() const
{
G4PhysicsOrderedFreeVector *v;
for (size_t i=0 ; i<thePhysicsTable->entries(); ++i) {
v = (G4PhysicsOrderedFreeVector*)(*thePhysicsTable)[i];
v->DumpValues();
G4PhysicsOrderedFreeVector* v;
for(size_t i = 0; i < thePhysicsTable->entries(); ++i)
{
v = (G4PhysicsOrderedFreeVector*) (*thePhysicsTable)[i];
v->DumpValues();
}
}
File diff suppressed because it is too large Load Diff
@@ -32,33 +32,33 @@
G4Allocator<G4ScintillationTrackInformation>*& aScintillationTIAllocator()
{
G4ThreadLocalStatic G4Allocator<G4ScintillationTrackInformation>*
_instance = nullptr;
return _instance;
G4ThreadLocalStatic G4Allocator<G4ScintillationTrackInformation>* _instance =
nullptr;
return _instance;
}
const G4String G4ScintillationTrackInformation::BaseType = "G4ScintillationTrackInformation";
const G4String G4ScintillationTrackInformation::BaseType =
"G4ScintillationTrackInformation";
G4ScintillationTrackInformation::G4ScintillationTrackInformation(const G4ScintillationType& aType)
: G4VUserTrackInformation(BaseType),
scintillationType(aType)
{
}
G4ScintillationTrackInformation::G4ScintillationTrackInformation(
const G4ScintillationType& aType)
: G4VUserTrackInformation(BaseType)
, scintillationType(aType)
{}
G4ScintillationTrackInformation::~G4ScintillationTrackInformation()
{
}
G4ScintillationTrackInformation::~G4ScintillationTrackInformation() {}
G4ScintillationTrackInformation::G4ScintillationTrackInformation(const G4ScintillationTrackInformation& right)
: G4VUserTrackInformation(right),
scintillationType(right.scintillationType)
{
}
G4ScintillationTrackInformation::G4ScintillationTrackInformation(
const G4ScintillationTrackInformation& right)
: G4VUserTrackInformation(right)
, scintillationType(right.scintillationType)
{}
G4ScintillationTrackInformation& G4ScintillationTrackInformation::operator=(const G4ScintillationTrackInformation& right)
G4ScintillationTrackInformation& G4ScintillationTrackInformation::operator=(
const G4ScintillationTrackInformation& right)
{
G4VUserTrackInformation::operator=(right);
this->scintillationType = right.scintillationType;
this->scintillationType = right.scintillationType;
return *this;
}
@@ -67,13 +67,15 @@ void G4ScintillationTrackInformation::Print() const
G4cout << "The user track information is a scintillation" << G4endl;
}
G4bool G4ScintillationTrackInformation::IsScintillationTrackInformation(const G4VUserTrackInformation* const aTI)
G4bool G4ScintillationTrackInformation::IsScintillationTrackInformation(
const G4VUserTrackInformation* const aTI)
{
G4bool isSTI = (aTI && aTI->GetType() == BaseType.c_str());
return isSTI;
}
G4ScintillationTrackInformation* G4ScintillationTrackInformation::Cast(const G4VUserTrackInformation* const aTI)
G4ScintillationTrackInformation* G4ScintillationTrackInformation::Cast(
const G4VUserTrackInformation* const aTI)
{
G4ScintillationTrackInformation* STI = nullptr;
if(IsScintillationTrackInformation(aTI))