Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -6,6 +6,36 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-11-11 Gabriele Cosmo (fastsimchanneling-V11-02-04)
- Fixed compilation warnings on macOS/XCode for implicit type conversions
in G4CoherentPairProduction.
## 2024-10-22 Alexei Sytov (fastsimchanneling-V11-02-03)
- Added new process G4CoherentPairProduction for the simulation
of coherent pair production by high energy gamma in an oriented crystal.
IMPORTANT: it works as a G4VDiscreteProcess, not as a parameterisation.
IMPORTANT: it uses G4ChannelingFastSimCrystalData.
- sources.cmake updated accordingly
## 2024-09-17 Vladimir Ivanchenko (fastsimchanneling-V11-02-02)
- G4VChannelingFastSimCrystalData - fixed Coverity warning
## 2024-08-30 Alexei Sytov (fastsimchanneling-V11-02-01)
- Considerable updates;
- Semantic errors were corrected in G4BaierKatkov::RadIntegral and
in G4VChannelingFastSimCrystalData::CoulombElectronScattering;
- New model of ionization losses for e+- has been implemented ionization
G4VChannelingFastSimCrystalData with some updates in
G4ChannelingFastSimModel and G4ChannelingFastSimCrystalData;
some bugs concerning particles of higher charges were corrected;
- G4ChannelingFastSimCrystalData was updated to be compatible with
new channeling dataset: G4CHANNELINGDATA. An option to use a custom
input file was also added.
- Some new get functions were added.
## 2024-07-17 Vladimir Ivanchenko (fastsimchanneling-V11-02-00)
- G4VChannelingFastSimCrystalData - fixed Coverity warning
## 2023-10-23 Alexei Sytov (fastsimchanneling-V11-01-04)
- G4Log replaced std::log
- some small issues were fixed to comply with the Geant4 guidelines
@@ -23,7 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paterno (modifications & testing)
// On the base of the CRYSTALRAD realization of the Baier-Katkov integral:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
#ifndef G4BaierKatkov_h
#define G4BaierKatkov_h 1
@@ -113,7 +117,7 @@ public:
///number of steps in a trajectory small piece before
///the next call of the radiation integral
void SetNSmallTrajectorySteps(G4double nSmallTrajectorySteps)
void SetNSmallTrajectorySteps(G4int nSmallTrajectorySteps)
{fNSmallTrajectorySteps = nSmallTrajectorySteps;}
///reinitialize intermediate integrals fFa, fSs, fSc, fSsx, fSsy, fScx, fScy;
@@ -259,7 +263,7 @@ private:
//in sampling, y-plane
G4double fParamPhotonAngleY=1.e-3*CLHEP::rad; //a parameter radiated photon
//sampling distribution, y-plane
G4double fRadiationAngleFactor = 1.; // number of radiation angles 1/gamma:
G4double fRadiationAngleFactor = 4.; // number of radiation angles 1/gamma:
// more fRadiationAngleFactor =>
// higher fParamPhotonAngleX and Y
@@ -23,7 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
#ifndef G4ChannelingFastSimCrystalData_h
#define G4ChannelingFastSimCrystalData_h 1
@@ -60,7 +61,9 @@ public:
///find and upload crystal lattice input files, calculate all the basic values
///(to do only once)
void SetMaterialProperties(const G4Material* crystal, const G4String &lattice);
void SetMaterialProperties(const G4Material* crystal,
const G4String &lattice,
const G4String &filePath);
///calculate the coordinates in the co-rotating reference system
///within a channel (periodic cell)
@@ -88,6 +91,10 @@ public:
///auxialiary function to transform the horizontal angle
G4double AngleXShift(G4double z){return fMiscutAngle + z*fCurv;}
///get channel width in x and y
G4double GetChannelWidthX(){return fDx;}
G4double GetChannelWidthY(){return fDy;}
private:
///variables
@@ -23,6 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
#ifndef G4ChannelingFastSimInterpolation_h
#define G4ChannelingFastSimInterpolation_h
@@ -23,6 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
// On the base of the CRYSTALRAD realization of channeling model:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
#ifndef G4ChannelingFastSimModel_h
#define G4ChannelingFastSimModel_h 1
@@ -63,7 +67,13 @@ public:
void DoIt(const G4FastTrack&, G4FastStep&) override;
///special functions
void Input(const G4Material* crystal, const G4String &lattice);
void Input(const G4Material* crystal,
const G4String &lattice)
{Input(crystal,lattice,"");}
void Input(const G4Material* crystal,
const G4String &lattice,
const G4String &filePath);
void RadiationModelActivate();
@@ -80,11 +90,16 @@ public:
void SetLindhardAngleNumberHighLimit(G4double angleNumber, const G4String& particleName)
{fLindhardAngleNumberHighLimit[particleTable->FindParticle(particleName)->
GetParticleDefinitionID()]=angleNumber;}
void SetHighAngleLimit(G4double anglemax, const G4String& particleName)
{fHighAngleLimit[particleTable->FindParticle(particleName)->
GetParticleDefinitionID()] = anglemax;}
void SetDefaultLowKineticEnergyLimit(G4double ekinetic)
{fDefaultLowEnergyLimit=ekinetic;}
void SetDefaultLindhardAngleNumberHighLimit(G4double angleNumber)
{fDefaultLindhardAngleNumberHighLimit=angleNumber;}
void SetDefaultHighAngleLimit(G4double anglemax)
{fDefaultHighAngleLimit=anglemax;}
/// get the maximal number of photons that can be produced per fastStep
@@ -93,15 +108,6 @@ public:
{fMaxPhotonsProducedPerStep=nPhotons;}
///get cuts
G4double GetLowKineticEnergyLimit(const G4String& particleName)
{return GetLowKineticEnergyLimit(particleTable->
FindParticle(particleName)->
GetParticleDefinitionID());}
G4double GetLindhardAngleNumberHighLimit(const G4String& particleName)
{return GetLindhardAngleNumberHighLimit(particleTable->
FindParticle(particleName)->
GetParticleDefinitionID());}
//the same functions but using particleDefinitionID (needed for faster model execution)
G4double GetLowKineticEnergyLimit(G4int particleDefinitionID)
{return (fLowEnergyLimit.count(particleDefinitionID) == 1)
? fLowEnergyLimit[particleDefinitionID]
@@ -110,6 +116,10 @@ public:
{return (fLindhardAngleNumberHighLimit.count(particleDefinitionID) == 1)
? fLindhardAngleNumberHighLimit[particleDefinitionID]
: fDefaultLindhardAngleNumberHighLimit;}
G4double GetHighAngleLimit(G4int particleDefinitionID)
{return (fHighAngleLimit.count(particleDefinitionID) == 1)
? fHighAngleLimit[particleDefinitionID]
: fDefaultHighAngleLimit;}
/// get the maximal number of photons that can be produced per fastStep
G4int GetMaxPhotonsProducedPerStep(){return fMaxPhotonsProducedPerStep;}
@@ -124,12 +134,15 @@ private:
///flag of radiation model
G4bool fRad = false;
/// maps of cuts
/// maps of cuts (angular cuts are chosen as std::max of
/// fHighAngleLimit and calculated Lindhard angle)
std::unordered_map<G4int, G4double> fLowEnergyLimit;
std::unordered_map<G4int, G4double> fLindhardAngleNumberHighLimit;
std::unordered_map<G4int, G4double> fHighAngleLimit;
G4double fDefaultLowEnergyLimit = 200*CLHEP::MeV;
G4double fDefaultLindhardAngleNumberHighLimit = 100.;
G4double fDefaultHighAngleLimit = 0.;
/// the maximal number of photons that can be produced per fastStep
G4int fMaxPhotonsProducedPerStep=1000.;
@@ -0,0 +1,192 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paterno (testing)
// Using the key points of G4BaierKatkov and developments of V.V. Tikhomirov,
// partially described in L. Bandiera et al. Eur. Phys. J. C 82, 699 (2022)
#ifndef G4CoherentPairProduction_h
#define G4CoherentPairProduction_h 1
#include "G4VDiscreteProcess.hh"
#include <vector>
#include <CLHEP/Units/SystemOfUnits.h>
#include <CLHEP/Units/PhysicalConstants.h>
#include <CLHEP/Vector/TwoVector.h>
#include "G4ChannelingFastSimCrystalData.hh"
#include "G4LogicalVolume.hh"
#include "G4ParticleTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
class G4CoherentPairProduction : public G4VDiscreteProcess
{
public:
G4CoherentPairProduction(const G4String& processName = "cpp",
G4ProcessType aType = fElectromagnetic);
~G4CoherentPairProduction() = default;
G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&) override;
G4bool IsApplicable(const G4ParticleDefinition& aPD) override
{
return(aPD.GetParticleName() == "gamma");
}
// print documentation in html format
void ProcessDescription(std::ostream&) const override;
///special functions
void Input(const G4Material* crystal,
const G4String &lattice)
{Input(crystal,lattice,"");}
void Input(const G4Material* crystal,
const G4String &lattice,
const G4String &filePath);
// an option to use crystal data already created outside this class
void Input(const G4ChannelingFastSimCrystalData* crystalData);
///activate incoherent scattering
///(standard gamma conversion should be switched off in physics list)
void ActivateIncoherentScattering(){fIncoherentScattering = true;}
G4ChannelingFastSimCrystalData* GetCrystalData() {return fCrystalData;}
///get cuts
// minimal energy for non-zero cross section
G4double ModelMinPrimaryEnergy() { return fLowEnergyLimit;}
G4double GetHighAngleLimit() {return fHighAngleLimit;}
G4double GetPPKineticEnergyCut() {return fPPKineticEnergyCut;}
/// get the number of pairs in sampling of Baier-Katkov Integral
/// (MC integration by e+- energy and angles <=> e+- momentum)
G4int GetSamplingPairsNumber(){return fNMCPairs;}
/// get the number of particle angles 1/gamma in pair production
/// defining the width of the angular distribution of pair sampling
/// in the Baier-Katkov Integral
G4double GetChargeParticleAngleFactor(){return fChargeParticleAngleFactor;}
/// get number of trajectory steps of a single particle (e- or e+)
G4double GetNTrajectorySteps(){return fNTrajectorySteps;}
/// get effective radiation length
/// (due to coherent process of pair production)
/// simulated for the current photon
G4double GetEffectiveLrad(){return fEffectiveLrad;}
///get the name of G4Region in which the model is applicable
G4String GetG4RegionName() {return fG4RegionName;}
///set cuts
void SetLowEnergyLimit(G4double energy){fLowEnergyLimit=energy;}
void SetHighAngleLimit(G4double angle) {fHighAngleLimit=angle;}
void SetPPKineticEnergyCut(G4double kineticEnergyCut) {fPPKineticEnergyCut=kineticEnergyCut;}
/// set the number of pairs in sampling of Baier-Katkov Integral
/// (MC integration by e+- energy and angles <=> e+- momentum)
void SetSamplingPairsNumber(G4int nPairs){fNMCPairs = nPairs;}
/// set the number of particle angles 1/gamma in pair production
/// defining the width of the angular distribution of pair sampling
/// in the Baier-Katkov Integral
void SetChargeParticleAngleFactor(G4double chargeParticleAngleFactor)
{fChargeParticleAngleFactor = chargeParticleAngleFactor;}
/// set number of trajectory steps of a single particle (e- or e+)
void SetNTrajectorySteps(G4int nTrajectorySteps)
{fNTrajectorySteps = nTrajectorySteps;}
///set the name of G4Region in which the model is applicable
void SetG4RegionName(const G4String& nameG4Region){fG4RegionName=nameG4Region;}
G4double GetMeanFreePath(const G4Track& aTrack,
G4double,
G4ForceCondition* condition) override;
private:
G4int FindVectorIndex(std::vector<G4double> &myvector, G4double value);
G4ChannelingFastSimCrystalData* fCrystalData{nullptr};
//collection of etotal
std::vector <CLHEP::Hep2Vector> fullVectorEtotal;
//collection of x
std::vector <CLHEP::Hep2Vector> fullVectorX;
//collection of y
std::vector <CLHEP::Hep2Vector> fullVectorY;
//collection of tx
std::vector <CLHEP::Hep2Vector> fullVectorTX;
//collection of tx
std::vector <CLHEP::Hep2Vector> fullVectorTY;
//the vector of the discrete CDF of the production of sampling e+e- pairs
//(in reality per distance along the photon direction)
std::vector <G4double> fPairProductionCDFdz;
G4double fLowEnergyLimit = 1*CLHEP::GeV;
G4double fHighAngleLimit = 50*CLHEP::mrad;
///minimal kinetic energy of a charged particle produced
G4double fPPKineticEnergyCut = 1*CLHEP::MeV;
///Monte Carlo statistics of e+- pair sampling in Baier-Katkov for 1 photon
G4int fNMCPairs = 150;
G4double fChargeParticleAngleFactor = 4; // number of particle angles 1/gamma:
// more fChargeParticleAngleFactor => higher paramParticleAngle
///number of trajectory steps of a single particle (e- or e+)
G4int fNTrajectorySteps=250;
///effective radiation length (due to coherent process of pair production)
G4double fEffectiveLrad = 0.;
///the name of G4Region in which the model is applicable
G4String fG4RegionName = "Crystal";
///charged particle mass
const G4double fMass = CLHEP::electron_mass_c2;
///flag of simulation of incoherent scattering
G4bool fIncoherentScattering = false;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
@@ -23,7 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
// On the base of the CRYSTALRAD realization of scattering model:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
#ifndef G4VChannelingFastSimCrystalData_h
#define G4VChannelingFastSimCrystalData_h 1
@@ -81,7 +84,7 @@ public:
//don't put it =0, otherwise division on 0 in CoulombAtomicScattering
///Calculate the value of the Lindhard angle (!!! the value for a straight crystal)
G4double GetLindhardAngle(G4double etotal, G4double mass);
G4double GetLindhardAngle(G4double etotal, G4double mass, G4double charge);
///Calculate the value of the Lindhard angle (!!! the value for a straight crystal)
G4double GetLindhardAngle();//return the Lindhard angle value calculated in
//SetParticleProperties
@@ -90,7 +93,7 @@ public:
///reduced value for overbarrier particles)
G4double GetSimulationStep(G4double tx,G4double ty);
///Calculate maximal simulation step (standard value for channeling particles)
G4double GetMaxSimulationStep(G4double etotal, G4double mass);
G4double GetMaxSimulationStep(G4double etotal, G4double mass, G4double charge);
///get particle velocity/c
G4double GetBeta(){return fBeta;}
@@ -119,7 +122,8 @@ public:
///find and upload crystal lattice input files, calculate all the basic values
///(to do only once)
virtual void SetMaterialProperties(const G4Material* crystal,
const G4String &lattice) = 0;
const G4String &lattice,
const G4String &filePath) = 0;
///set geometry parameters from current logical volume
void SetGeometryParameters(const G4LogicalVolume *crystallogic);
@@ -153,7 +157,7 @@ public:
void SetParticleProperties(G4double etotal,
G4double mp,
G4double charge,
G4bool ifhadron);
const G4String& particleName);
///calculate the coordinates in the co-rotating reference system
///within a channel (periodic cell)
@@ -280,6 +284,7 @@ protected:
G4double fK3=0;//a useful coefficient, fK3=2.*pi*alpha*hdc/electron_mass_c2/(fPV)**2
std::vector <G4double> fKD; //a useful coefficient for dE/dx
std::vector <G4double> fLogPlasmaEdI0; //item of delta-correction of ionization loss
///coefficients for multiple scattering suppression
std::vector <G4double> fPu11;//a useful coefficient for exponent containing u1
@@ -324,7 +329,7 @@ private:
G4double fTmax=0; // max ionization losses
///particle properties flags
G4bool fHadron=false;//=true (for hadrons); =false (for leptons)
G4String fParticleName = "";
G4double fZ2=0; //particle charge
};
@@ -8,12 +8,14 @@ geant4_add_module(G4channeling
G4ChannelingFastSimInterpolation.hh
G4ChannelingFastSimModel.hh
G4VChannelingFastSimCrystalData.hh
G4CoherentPairProduction.hh
SOURCES
G4BaierKatkov.cc
G4ChannelingFastSimCrystalData.cc
G4ChannelingFastSimInterpolation.cc
G4ChannelingFastSimModel.cc
G4VChannelingFastSimCrystalData.cc)
G4VChannelingFastSimCrystalData.cc
G4CoherentPairProduction.cc)
geant4_module_link_libraries(G4channeling
PUBLIC
@@ -24,6 +26,9 @@ geant4_add_module(G4channeling
G4parameterisation
G4track
G4partman
G4procman
PRIVATE
G4bosons
G4navigation)
G4navigation
G4leptons
G4emutils)
@@ -23,6 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paterno (modifications & testing)
// On the base of the CRYSTALRAD realization of the Baier-Katkov integral:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
#include "G4BaierKatkov.hh"
@@ -446,7 +450,7 @@ G4double G4BaierKatkov::RadIntegral(G4double etotal, G4double mass,
G4double coefNorm = CLHEP::fine_structure_const/(8*(CLHEP::pi2))*coefNormLogdNMC;
G4double e2pluseprime2 = 0.;//e2pluseprime2 =e2+eprime2
G4double coefNormom2deprime2 = 0.; //coefNormom2deprime2 = coefNorm*om2/eprime2;
G4double gammaInverse2om = 0.; //gammaInverse2*om
G4double gammaInverse2om2 = 0.; //gammaInverse2*om*om
std::size_t nmctotal = fPhotonEnergyInIntegral.size();
for (std::size_t j=0;j<nmctotal;j++)
@@ -459,7 +463,7 @@ G4double G4BaierKatkov::RadIntegral(G4double etotal, G4double mass,
omprime=etotal*om/eprime;//om'=(E*om/E')
omprimed2=omprime/2;
coefNormom2deprime2 = coefNorm*om*om/eprime2;
gammaInverse2om = gammaInverse2*om;
gammaInverse2om2 = gammaInverse2*om*om;
for(std::size_t k=kmin;k<nparts;k++)
{
@@ -506,7 +510,7 @@ G4double G4BaierKatkov::RadIntegral(G4double etotal, G4double mass,
//updating the total radiation probability along the trajectory
totalRadiationProbabilityPhj = coefNormom2deprime2*fPhotonAngleNormCoef[j]*
(i2*e2pluseprime2+j2*gammaInverse2om);
(i2*e2pluseprime2+j2*gammaInverse2om2);
fTotalRadiationProbabilityAlongTrajectory[k] += totalRadiationProbabilityPhj;
}
@@ -23,6 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
#include "G4ChannelingFastSimCrystalData.hh"
#include "G4SystemOfUnits.hh"
@@ -35,8 +37,10 @@ G4ChannelingFastSimCrystalData::G4ChannelingFastSimCrystalData()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ChannelingFastSimCrystalData::SetMaterialProperties(const G4Material *crystal,
const G4String &lattice)
void G4ChannelingFastSimCrystalData::SetMaterialProperties(
const G4Material *crystal,
const G4String &lattice,
const G4String &filePath)
{
G4String filename=crystal->GetName(); //input file
filename.erase(0,3);
@@ -46,9 +50,9 @@ void G4ChannelingFastSimCrystalData::SetMaterialProperties(const G4Material *cry
G4cout <<
"======================================================================="
<< G4endl;
G4cout <<
"====== Crystal lattice data ========"
<< G4endl;
G4cout <<
"====== Crystal lattice data ========"
<< G4endl;
G4cout <<
"======================================================================="
<< G4endl;
@@ -74,6 +78,18 @@ void G4ChannelingFastSimCrystalData::SetMaterialProperties(const G4Material *cry
//input file:
filename = filename + lattice.substr(1,(lattice.length())-2) + ".dat";
if(filePath=="")
{
//standard file path if another one is not set
filename = "/" + filename;
filename = G4FindDataDir("G4CHANNELINGDATA") + filename;
}
else
{
//custom file path
filename = filePath + filename;
}
fNelements=(G4int)crystal->GetNumberOfElements();
for(G4int i=0; i<fNelements; i++)
{
@@ -87,6 +103,17 @@ void G4ChannelingFastSimCrystalData::SetMaterialProperties(const G4Material *cry
std::ifstream vfilein;
vfilein.open(filename);
//check if the input file was found, otherwise return an exception
if(!vfilein.is_open())
{
G4String outputMessage="Input file " +
filename +
" is not found!";
G4Exception("SetMaterialProperties",
"001",
FatalException,
outputMessage);
}
//read nuclear concentration
for(G4int i=0; i<fNelements; i++)
@@ -275,6 +302,8 @@ void G4ChannelingFastSimCrystalData::SetMaterialProperties(const G4Material *cry
fK40.push_back(3.76*std::pow(CLHEP::fine_structure_const*fZ1[i],2.));
fKD.push_back(fK30*fZ1[i]*fN0[i]);
fLogPlasmaEdI0.push_back(G4Log((crystal->GetIonisation()->GetPlasmaEnergy())/fI0[i]));
}
fBB.resize(fNelements);
@@ -23,6 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
/// \file G4ChannelingFastSimInterpolation.cc
/// \brief Implementation of the G4ChannelingFastSimInterpolation class
@@ -23,7 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file B107FastSim/src/G4ChannelingFastSimModel.cc
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
// On the base of the CRYSTALRAD realization of channeling model:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
/// \file G4ChannelingFastSimModel.cc
/// \brief Implementation of the G4ChannelingFastSimModel class
//
//
@@ -101,12 +106,15 @@ G4bool G4ChannelingFastSimModel::ModelTrigger(const G4FastTrack& fastTrack)
//particle mass
G4double mass = fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetPDGMass();
//particle total energy
G4double etotal = fastTrack.GetPrimaryTrack()->GetTotalEnergy();
G4double etotal = mass + ekinetic;
//particle charge
G4double charge = fastTrack.GetPrimaryTrack()->
GetParticleDefinition()->GetPDGCharge();
//Particle position
G4ThreeVector xyz0 = fastTrack.GetPrimaryTrackLocalPosition();
//Step estimate
G4double dz0 = fCrystalData->GetMaxSimulationStep(etotal,mass);
G4double dz0 = fCrystalData->GetMaxSimulationStep(etotal,mass,charge);
xyz0 += 2*dz0*momentumDirection;//overestimated particle shift on the next step
//in channeling
@@ -117,8 +125,12 @@ G4bool G4ChannelingFastSimModel::ModelTrigger(const G4FastTrack& fastTrack)
Inside(xyz0)==kInside) &&
momentumDirection.z()>0. &&
std::abs(angle) <
GetLindhardAngleNumberHighLimit(particleDefinitionID) *
fCrystalData->GetLindhardAngle(etotal,mass);
std::max(
GetLindhardAngleNumberHighLimit(particleDefinitionID) *
fCrystalData->GetLindhardAngle(etotal,
mass,
charge),
GetHighAngleLimit(particleDefinitionID));
}
return modelTrigger;
@@ -132,7 +144,10 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
G4double etotal;//particle total energy
G4double etotalPreStep;//etotal at the previous step
G4double etotalToSetParticleProperties;//etotal value at which
//SetParticleProperties is called
//SetParticleProperties is calculated
G4double ekinetic = 0;//kinetic energy
G4double eDeposited = 0.;//deposited energy along the trajectory
G4double elossAccum = 0;// accumulate local energy loss (not radiation)
G4double mass; //particle mass
G4double charge;//particle charge
G4double tGlobal; //global time
@@ -151,6 +166,7 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
G4ThreeVector scatteringAnglesAndEnergyLoss;//output of scattering functions
G4double lindhardAngleNumberHighLimit0; //current high limit of the angle expressed in
//[Lindhard angle] units
G4double highAngleLimit0; //current absolute high limit of the angle expressed
//coordinates in Runge-Kutta calculations
G4double x1=0.,x2=0.,x3=0.,x4=0.,y1=0.,y2=0.,y3=0.,y4=0.;
@@ -179,20 +195,21 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
fBaierKatkov->ResetRadIntegral();//to avoid any memory from the previous trajectory
}
etotal = fastTrack.GetPrimaryTrack()->GetTotalEnergy();
mass = fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetPDGMass();
etotal = mass + fastTrack.GetPrimaryTrack()->GetKineticEnergy();
charge = fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetPDGCharge();
// we need to distunguish only charge particles, either leptons or hadrons
G4bool hadron =
fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetLeptonNumber()==0;
G4String particleName =
fastTrack.GetPrimaryTrack()->GetParticleDefinition()->GetParticleName();
lindhardAngleNumberHighLimit0 =
GetLindhardAngleNumberHighLimit(fastTrack.GetPrimaryTrack()->
GetParticleDefinition()->GetParticleDefinitionID());
highAngleLimit0 = GetHighAngleLimit(fastTrack.GetPrimaryTrack()->
GetParticleDefinition()->GetParticleDefinitionID());
//set fCrystalData parameters depending on the particle parameters
fCrystalData->SetParticleProperties(etotal, mass, charge, hadron);
fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
//global time
tGlobal = fastTrack.GetPrimaryTrack()->GetGlobalTime();
@@ -324,7 +341,7 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
CoulombAtomicScattering(effectiveStep,momentumDirectionStep,i);
//Amorphous part of ionization energy losses
etotal-=fCrystalData->IonizationLosses(momentumDirectionStep, i);
elossAccum += fCrystalData->IonizationLosses(momentumDirectionStep, i);
}
//electron scattering and coherent part of ionization energy losses
scatteringAnglesAndEnergyLoss += fCrystalData->CoulombElectronScattering(
@@ -333,13 +350,13 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
momentumDirectionStep);
tx += scatteringAnglesAndEnergyLoss.x();
ty += scatteringAnglesAndEnergyLoss.y();
etotal -= scatteringAnglesAndEnergyLoss.z();
elossAccum += scatteringAnglesAndEnergyLoss.z();
// recalculate the energy depended parameters
//(only if the energy decreased enough, not at each step)
if (etotalToSetParticleProperties>etotal)
{
fCrystalData->SetParticleProperties(etotal, mass, charge, hadron);
fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
etotalToSetParticleProperties = etotal*0.999;
}
@@ -359,14 +376,18 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
{
//if the angle w.r.t. the planes is too high
if (std::abs(tx) >=
lindhardAngleNumberHighLimit0*fCrystalData->GetLindhardAngle())
std::max(lindhardAngleNumberHighLimit0*
fCrystalData->GetLindhardAngle(),
highAngleLimit0))
{inCrystal = false;}//escape the cycle
}
else if (fCrystalData->GetModel()==2) //2D model, field of axes
{
//if the angle w.r.t. the axes is too high
if (std::sqrt(tx*tx+ty*ty) >= lindhardAngleNumberHighLimit0*
fCrystalData->GetLindhardAngle())
if (std::sqrt(tx*tx+ty*ty) >=
std::max(lindhardAngleNumberHighLimit0*
fCrystalData->GetLindhardAngle(),
highAngleLimit0))
{inCrystal = false;}//escape the cycle
}
@@ -403,7 +424,7 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
fBaierKatkov->GeneratePhoton(fastStep);
//particle energy was changed
fCrystalData->SetParticleProperties(etotal, mass, charge, hadron);
fCrystalData->SetParticleProperties(etotal, mass, charge, particleName);
//coordinates in the co-rotating reference system within a channel
xyz = fCrystalData->CoordinatesFromBoxToLattice(xyz0);
@@ -416,6 +437,25 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
ty = ty0;
}
}
else
{
//we calculate deposited energy and energy losses ONLY in absence
//of radiation otherwise we do it only at the end of model
etotal -= elossAccum;
eDeposited += elossAccum;
elossAccum=0;
ekinetic = etotal-mass;
if(ekinetic<1*keV)
{
G4cout << "Warning in G4ChannelingFastSimModel: " <<
ekinetic << "<" << 1*keV << " !" << G4endl;
eDeposited-=(1*keV-ekinetic);
ekinetic = 1*keV;
G4cout << "Setting deposited energy=" <<
eDeposited << " & ekinetic=" << ekinetic << G4endl;
etotal = mass+ekinetic;
}
}
//precise check if the particle is escaping the volume
if (crystallogic->GetSolid()->
@@ -458,10 +498,25 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
fastStep.ProposePrimaryTrackFinalTime(tGlobal);
//set final position
fastStep.ProposePrimaryTrackFinalPosition(xyz0);
//set deposited energy (due to ionization)
etotal -= elossAccum;
eDeposited += elossAccum;
ekinetic = etotal-mass;
if(ekinetic<1*keV)
{
G4cout << "Warning in G4ChannelingFastSimModel: " <<
ekinetic << "<" << 1*keV << " !" << G4endl;
eDeposited-=(1*keV-ekinetic);
ekinetic = 1*keV;
G4cout << "Setting deposited energy=" <<
eDeposited << " & ekinetic=" << ekinetic << G4endl;
}
fastStep.ProposeTotalEnergyDeposited(eDeposited);
//set final kinetic energy
fastStep.ProposePrimaryTrackFinalKineticEnergy(etotal-
fastTrack.GetPrimaryTrack()->
GetParticleDefinition()->GetPDGMass());
fastStep.ProposePrimaryTrackFinalKineticEnergy(ekinetic);
//set final momentum direction
G4double momentumDirectionZ =
1./std::sqrt(1.+std::pow(std::tan(tx0),2)+std::pow(std::tan(ty0),2));
@@ -473,14 +528,16 @@ void G4ChannelingFastSimModel::DoIt(const G4FastTrack& fastTrack,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4ChannelingFastSimModel::Input(const G4Material *crystal, const G4String &lattice)
void G4ChannelingFastSimModel::Input(const G4Material *crystal,
const G4String &lattice,
const G4String &filePath)
{
//initializing the class with containing all
//the crystal material and crystal lattice data and
//Channeling scattering and ionization processes
fCrystalData = new G4ChannelingFastSimCrystalData();
//setting all the crystal material and lattice data
fCrystalData->SetMaterialProperties(crystal,lattice);
fCrystalData->SetMaterialProperties(crystal,lattice,filePath);
//setting default low energy cuts for kinetic energy
SetLowKineticEnergyLimit(1*GeV,"proton");
@@ -0,0 +1,692 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paterno (testing)
// Using the key points of G4BaierKatkov and developments of V.V. Tikhomirov,
// partially described in L. Bandiera et al. Eur. Phys. J. C 82, 699 (2022)
#include "G4CoherentPairProduction.hh"
#include "Randomize.hh"
#include "G4TouchableHistory.hh"
#include "G4TouchableHandle.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4EmProcessSubType.hh"
#include "G4TransportationManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4CoherentPairProduction::G4CoherentPairProduction(const G4String& aName,
G4ProcessType):
G4VDiscreteProcess(aName)
{
SetProcessSubType(fCoherentPairProduction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4CoherentPairProduction::GetMeanFreePath(const G4Track& aTrack,
G4double,
G4ForceCondition* condition)
{
//current logical volume
G4LogicalVolume* crystallogic;
//momentum direction and coordinates (see comments below)
G4ThreeVector momentumDirectionGamma,xyzGamma0,xyzGamma;
//angle of the photon in the local reference system of the volume
G4double txGamma0 = 0, tyGamma0 = 0;
*condition = NotForced;
//model activation
G4bool modelTrigger = false;
//photon energy
G4double eGamma = aTrack.GetTotalEnergy();
//energy cut, at the beginning, to not check everything else
if(eGamma > ModelMinPrimaryEnergy())
{
//current logical volume
crystallogic = aTrack.GetVolume()->GetLogicalVolume();
//the model works only in the G4Region fG4RegionName
if(crystallogic->GetRegion()->GetName()==fG4RegionName)
{
fCrystalData->SetGeometryParameters(crystallogic);
//the momentum direction of the photon in the local reference system of the volume
momentumDirectionGamma =
(aTrack.GetTouchableHandle()->GetHistory()->
GetTopTransform().NetRotation().inverse())*aTrack.GetMomentumDirection();
//the coordinates of the photon in the local reference system of the volume
xyzGamma0 =
aTrack.GetTouchableHandle()->GetHistory()->
GetTopTransform().TransformPoint(aTrack.GetPosition());
// the coordinates of the photon in the co-rotating reference system within
//a channel (elementary periodic cell)
xyzGamma = fCrystalData->CoordinatesFromBoxToLattice(xyzGamma0);
//angle of the photon in the local reference system of the volume
//(!!! ONLY FORWARD DIRECTION, momentumDirectionGamma.getZ()>0,
txGamma0 = std::atan(momentumDirectionGamma.x()/momentumDirectionGamma.z());
tyGamma0 = std::atan(momentumDirectionGamma.y()/momentumDirectionGamma.z());
//recalculate angle into the lattice reference system
G4double angle = fCrystalData->AngleXFromBoxToLattice(txGamma0,xyzGamma.z());
if (fCrystalData->GetModel()==2)
{
angle = std::sqrt(angle*angle+tyGamma0*tyGamma0);
}
//Applies the parameterisation not at the last step, only forward local direction
//above low energy limit and below angular limit
modelTrigger = (momentumDirectionGamma.z()>0. &&
std::abs(angle) < GetHighAngleLimit());
}
}
if(modelTrigger)
{
//execute the model
G4double x=0.,y=0.,z=0.;// the coordinates of charged particles
//in the co-rotating reference system within
//a channel (elementary periodic cell)
G4double tx0=0.,ty0=0.; // the angles of charged particles
// in the local reference system of the volume
G4double txPreStep0=0.,tyPreStep0=0.; // the same as tx0, ty0 before the step
// in the co-rotating reference system within
//a channel (elementary periodic cell)
G4ThreeVector scatteringAnglesAndEnergyLoss;//output of scattering functions
//coordinates in Runge-Kutta calculations
G4double x1=0.,x2=0.,x3=0.,x4=0.,y1=0.,y2=0.,y3=0.,y4=0.;
//angles in Runge-Kutta calculations
G4double tx1=0.,tx2=0.,tx3=0.,tx4=0.,ty1=0.,ty2=0.,ty3=0.,ty4=0.;
//variables in Runge-Kutta calculations
G4double kvx1=0.,kvx2=0.,kvx3=0.,kvx4=0.,kvy1=0.,kvy2=0.,kvy3=0.,kvy4=0.;
//simulation step along z (internal step of the model) and its parts
G4double dz=0.,dzd3=0.,dzd8=0.;//dzd3 = dz/3; dzd8 = dz/8;
//simulation step along the momentum direction
G4double momentumDirectionStep;
//effective simulation step (taking into account nuclear density along the trajectory)
G4double effectiveStep=0.;
// Baier-Katkov variables
G4double dzMeV=0.; //step in MeV^-1
G4double axt=0.,ayt=0.; //charged particle accelerations
G4double vxin=0.,vyin=0.;//the angles vs the photon (with incoherent scattering)
G4double vxno=0.,vyno=0.;//the angles vs the photon (without incoherent scattering)
G4double dzmod=0.;
G4double fa1=0.,faseBefore=0.,faseBeforedz=0.,faseBeforedzd2=0.;
G4double faseAfter=0.,fa2dfaseBefore2=0.;
G4double skJ=0, skIx=0., skIy=0.;
G4double sinfa1=0.,cosfa1=0.;
//2-vector is needed for an initial parameter collection of 1 pair
//vector of 2-vectors is an initial parameter collection of all sampling pair
//collection of etotal for a single pair
CLHEP::Hep2Vector twoVectorEtotal(0.,0.);
//collection of x for a single pair
CLHEP::Hep2Vector twoVectorX(0.,0.);
//collection of y for a single pair
CLHEP::Hep2Vector twoVectorY(0.,0.);
//collection of tx for a single pair
CLHEP::Hep2Vector twoVectorTX(0.,0.);
//collection of tx for a single pair
CLHEP::Hep2Vector twoVectorTY(0.,0.);
fullVectorEtotal.clear();
fullVectorX.clear();
fullVectorY.clear();
fullVectorTX.clear();
fullVectorTY.clear();
fPairProductionCDFdz.clear();
fPairProductionCDFdz.push_back(0.);//0th element equal to 0
const G4double charge[2] = {-1.,1.}; //particle charge
const G4String particleName[2] = {"e-", "e+"};
// the coordinates of a charged particle in the reference system within
//a channel (elementary periodic cell)
G4ThreeVector xyzparticle = xyzGamma;//changed below
//the idea of pair production simulation is analogical to radiation in G4BaierKatkov
//since the matrix element of these processes is the same => we solve inverse problem
//to radiation: sample the pairs, calculate their trajectories and then calculate the
//probabilities using Baier-Katkov analogically to radiation
//cycle by sampling e+- pairs
for(G4int i=0; i<fNMCPairs;i++)
{
//pair energy uniform sampling
G4double etotal = fMass + fPPKineticEnergyCut +
G4UniformRand()*(eGamma-2*(fMass+fPPKineticEnergyCut));//particle
//total energy
G4double phi = CLHEP::twopi*G4UniformRand();//necessary for pair kinematics
//the probability of the production of the current pair (will be simulated)
//per distance
G4double probabilityPPdz = 0.;
//cycle e- and e+ within single pair
for(G4int j=0; j<2;j++)
{
if(j==1){etotal=eGamma-etotal;} //2nd particle energy
twoVectorEtotal[j]=etotal;
//Baier-Katkov input
//intermediate variables to reduce calculations (the same names as in G4BaierKatkov)
G4double e2 = etotal*etotal;
G4double gammaInverse2 = fMass*fMass/(etotal*etotal);// 1/gamma^2
//normalization coefficient
G4double coefNorm = CLHEP::fine_structure_const/(8*(CLHEP::pi2))/(2.*fNMCPairs);
//G4double phi = CLHEP::twopi*G4UniformRand();//necessary for pair kinematics
G4double om = eGamma;
G4double eprime=om-etotal; //E'=omega-E
G4double eprime2 = eprime*eprime;
G4double e2pluseprime2 =e2+eprime2;
G4double omprime=etotal*om/eprime;//om'=E*om/(om-E)
G4double omprimed2=omprime/2;
//difference vs G4BaierKatkov: om -> etotal
G4double coefNorme2deprime2 = coefNorm*e2/eprime2; //e2/om/om;//e2/eprime2;
G4double gammaInverse2om = gammaInverse2*om*om;
//initialize intermediate integrals with zeros
G4double fa=0.,ss=0.,sc=0.,ssx=0.,ssy=0.,scx=0.,scy=0.;
//End of Baier-Katkov input
G4bool fbreak = false;//flag of the trajectory cycle break
//set fCrystalData parameters depending on the particle parameters
fCrystalData->SetParticleProperties(etotal, fMass,
charge[j], particleName[j]);
//needed just to setup the correct value of channel No in the crystal
//since later it may be changed during the trajectory calculation
fCrystalData->CoordinatesFromBoxToLattice(xyzGamma0);
//coordinate sampling: random x and y due to coordinate uncertainty
//in the interaction point
if(j==0)
{
x = fCrystalData->GetChannelWidthX()*G4UniformRand();
y = fCrystalData->GetChannelWidthY()*G4UniformRand();
}
else
{
x=twoVectorX[0];
y=twoVectorY[0];
}
twoVectorX[j] = x;
twoVectorY[j] = y;
//definite z as a coordinate of the photon (uncertainty of the
//interaction point is taking into account later by simulation
//of the position of pair production)
z = xyzGamma.z();
//angles of the photon in the co-rotating reference system within a channel =>
//angular distribution center
G4double tx = fCrystalData->AngleXFromBoxToLattice(txGamma0,z);
G4double ty = tyGamma0;
G4double momentumDirectionZGamma = 1./
std::sqrt(1.+std::pow(std::tan(tx),2)+
std::pow(std::tan(ty),2));
//angle sampling: depends on angular range within a particle trajectory
//defined by the Lindhard angle and on the angle of radiation proportional
//to 1/gamma
//range of MC integration on angles
G4double paramParticleAngle = fChargeParticleAngleFactor*fMass/etotal;
G4double axangle=0.;
if (fCrystalData->GetModel()==1)//1D model (only angle vs plane matters)
{
axangle = std::abs(tx);
}
else if (fCrystalData->GetModel()==2)//2D model
{
axangle = std::sqrt(tx*tx+ty*ty);
}
if(axangle>fCrystalData->GetLindhardAngle()+DBL_EPSILON)
{
paramParticleAngle+=axangle
-std::sqrt(axangle*axangle
-fCrystalData->GetLindhardAngle()
*fCrystalData->GetLindhardAngle());
}
else
{
paramParticleAngle+=fCrystalData->GetLindhardAngle();
}
//ONLY forward direction
if (paramParticleAngle>CLHEP::halfpi-DBL_EPSILON){paramParticleAngle=CLHEP::halfpi;}
G4double rho=1.;
G4double rhocut=CLHEP::halfpi/paramParticleAngle;//radial angular cut of
//the distribution
G4double norm=std::atan(rhocut*rhocut)*
CLHEP::pi*paramParticleAngle*paramParticleAngle;
//distribution with long tails (useful to not exclude particle angles
//after a strong single scattering)
//at ellipsescale < 1 => half of statistics
do
{
rho = std::sqrt(std::tan(CLHEP::halfpi*G4UniformRand()));
}
while (rho>rhocut);
//normalization coefficient for intergration on angles of charged particles
G4double angleNormCoef = (1.+rho*rho*rho*rho)*norm;
tx+=charge[j]*paramParticleAngle*rho*std::cos(phi);
twoVectorTX[j] = tx;
ty+=charge[j]*paramParticleAngle*rho*std::sin(phi);
twoVectorTY[j] = ty;
G4double zalongGamma = 0;//necessary for renormalization of PP probability
//depending on the trajectory length along Gamma direction
//starting the trajectory
//here we don't care about the boundaries of the crystal volume
//the trajectory is very short and the pair production probability obtained
//in Baier-Katkov will be extrapolated to the real step inside the crystal volume
for(G4int k=0; k<fNTrajectorySteps;k++)
{
//back to the local reference system of the volume
txPreStep0 = fCrystalData->AngleXFromLatticeToBox(tx,z);
tyPreStep0 = ty;
dz = fCrystalData->GetSimulationStep(tx,ty);
dzd3=dz/3;
dzd8=dz/8;
//trajectory calculation:
//Runge-Cutt "3/8"
//fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ() is due to dependence
//of the radius on x; GetCurv gets 1/R for the central ("central plane/axis")
//first step
kvx1=fCrystalData->Ex(x,y);
x1=x+tx*dzd3;
tx1=tx+(kvx1-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dzd3;
if (fCrystalData->GetModel()==2)
{
kvy1=fCrystalData->Ey(x,y);
y1=y+ty*dzd3;
ty1=ty+kvy1*dzd3;
}
//second step
kvx2=fCrystalData->Ex(x1,y1);
x2=x-tx*dzd3+tx1*dz;
tx2=tx-(kvx1-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dzd3+
(kvx2-fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dz;
if (fCrystalData->GetModel()==2)
{
kvy2=fCrystalData->Ey(x1,y1);
y2=y-ty*dzd3+ty1*dz;
ty2=ty-kvy1*dzd3+kvy2*dz;
}
//third step
kvx3=fCrystalData->Ex(x2,y2);
x3=x+(tx-tx1+tx2)*dz;
tx3=tx+(kvx1-kvx2+kvx3-
fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ())*dz;
if (fCrystalData->GetModel()==2)
{
kvy3=fCrystalData->Ey(x2,y2);
y3=y+(ty-ty1+ty2)*dz;
ty3=ty+(kvy1-kvy2+kvy3)*dz;
}
//fourth step
kvx4=fCrystalData->Ex(x3,y3);
x4=x+(tx+3.*tx1+3.*tx2+tx3)*dzd8;
tx4=tx+(kvx1+3.*kvx2+3.*kvx3+kvx4)*dzd8-
fCrystalData->GetCurv(z)*fCrystalData->GetCorrectionZ()*dz;
if (fCrystalData->GetModel()==2)
{
kvy4=fCrystalData->Ey(x3,y3);
y4=y+(ty+3.*ty1+3.*ty2+ty3)*dzd8;
ty4=ty+(kvy1+3.*kvy2+3.*kvy3+kvy4)*dzd8;
}
else
{
y4 =y+ty*dz;
ty4=ty;
}
x=x4;
tx=tx4;
y=y4;
ty=ty4;
z+=dz*fCrystalData->GetCorrectionZ();//motion along the z coordinate
//("central plane/axis", no current plane/axis)
xyzparticle = fCrystalData->ChannelChange(x,y,z);
x=xyzparticle.x();
y=xyzparticle.y();
z=xyzparticle.z();
momentumDirectionStep =
dz*std::sqrt(1+std::pow(std::tan(tx),2)+std::pow(std::tan(ty),2));
zalongGamma += dz/momentumDirectionZGamma;
//default scattering and energy loss 0
scatteringAnglesAndEnergyLoss.set(0.,0.,0.);
if(fIncoherentScattering)
{
//calculate separately for each element of the crystal
for (G4int ii = 0; ii < fCrystalData->GetNelements(); ii++)
{
//effective step taking into account nuclear density along the trajectory
effectiveStep = momentumDirectionStep*
fCrystalData->NuclearDensity(x,y,ii);
//Coulomb scattering on screened atomic potential
//(both multiple and single)
scatteringAnglesAndEnergyLoss +=
fCrystalData->CoulombAtomicScattering(effectiveStep,
momentumDirectionStep,
ii);
}
//electron scattering and coherent part of ionization energy losses
scatteringAnglesAndEnergyLoss += fCrystalData->CoulombElectronScattering(
fCrystalData->MinIonizationEnergy(x,y),
fCrystalData->ElectronDensity(x,y),
momentumDirectionStep);
tx += scatteringAnglesAndEnergyLoss.x();
ty += scatteringAnglesAndEnergyLoss.y();
}
//To avoid backward direction
if(std::abs(tx)>CLHEP::halfpi-DBL_EPSILON||
std::abs(ty)>CLHEP::halfpi-DBL_EPSILON)
{
G4cout << "Warning: particle angle is beyond +-pi/2 range => "
"skipping the calculation of its probability" << G4endl;
fbreak = true;
break;
}
//**********Baier-Katkov start
//back to the local reference system of the volume
tx0 = fCrystalData->AngleXFromLatticeToBox(tx,z);
ty0 = ty;
dzMeV=momentumDirectionStep/CLHEP::hbarc;// in MeV^-1
// accelerations
axt=(tx0-scatteringAnglesAndEnergyLoss.x()-txPreStep0)/dzMeV;
ayt=(ty0-scatteringAnglesAndEnergyLoss.y()-tyPreStep0)/dzMeV;
//the angles vs the photon (with incoherent scattering)
vxin = tx0-txGamma0;
vyin = ty0-tyGamma0;
//the angles vs the photon (without incoherent scattering)
vxno = vxin-scatteringAnglesAndEnergyLoss.x();
vyno = vyin-scatteringAnglesAndEnergyLoss.y();
//phase difference before scattering
faseBefore=omprimed2*(gammaInverse2+vxno*vxno+vyno*vyno);//phi' t<ti//MeV
faseBeforedz = faseBefore*dzMeV;
faseBeforedzd2 = faseBeforedz/2.;
fa+=faseBeforedz; //
fa1=fa-faseBeforedzd2;//
dzmod=2*std::sin(faseBeforedzd2)/faseBefore;//MeV^-1
//phi''/faseBefore^2
fa2dfaseBefore2 = omprime*(axt*vxno+ayt*vyno)/(faseBefore*faseBefore);
//phase difference after scattering
faseAfter=omprimed2*(gammaInverse2+vxin*vxin+vyin*vyin);//phi' ti+O//MeV
skJ=1/faseAfter-1/faseBefore-fa2dfaseBefore2*dzmod;//MeV^-1
skIx=vxin/faseAfter-vxno/faseBefore+dzmod*(axt/faseBefore-
vxno*fa2dfaseBefore2);
skIy=vyin/faseAfter-vyno/faseBefore+dzmod*(ayt/faseBefore-
vyno*fa2dfaseBefore2);
sinfa1 = std::sin(fa1);
cosfa1 = std::cos(fa1);
ss+=sinfa1*skJ;//sum sin integral J of BK
sc+=cosfa1*skJ;//sum cos integral J of BK
ssx+=sinfa1*skIx;// sum sin integral Ix of BK
ssy+=sinfa1*skIy;// sum sin integral Iy of BK
scx+=cosfa1*skIx;// sum cos integral Ix of BK
scy+=cosfa1*skIy;// sum cos integral Iy of BK
}
//only of the trajectory cycle was not broken
if(!fbreak)
{
G4double i2=ssx*ssx+scx*scx+ssy*ssy+scy*scy;//MeV^-2
G4double j2=ss*ss+sc*sc;//MeV^-2
probabilityPPdz += coefNorme2deprime2*angleNormCoef*
(i2*e2pluseprime2+j2*gammaInverse2om)/zalongGamma;
}
}
//filling the CDF of probabilities of the production of sampling pairs
fPairProductionCDFdz.push_back(fPairProductionCDFdz[i]+probabilityPPdz);
//**********Baier-Katkov end
//accumulation of initial parameters of sampling pairs
fullVectorEtotal.push_back(twoVectorEtotal);
fullVectorX.push_back(twoVectorX);
fullVectorY.push_back(twoVectorY);
fullVectorTX.push_back(twoVectorTX);
fullVectorTY.push_back(twoVectorTY);
}
//photon mean free path
//fPairProductionCDFdz.back() = full pair production probability
//simulated for the current photon along photon direction
G4double lMeanFreePath = 1/fPairProductionCDFdz.back();
fEffectiveLrad = 7.*lMeanFreePath/9.;//only for scoring purpose
return lMeanFreePath;
}
else
{
//dummy process, does not occur
return DBL_MAX;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VParticleChange* G4CoherentPairProduction::PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep)
{
//example with no physical sense
aParticleChange.Initialize(aTrack);
//G4LogicalVolume* aLV = aTrack.GetVolume()->GetLogicalVolume();
const G4ParticleDefinition* chargedParticleDefinition[2] =
{G4Electron::Electron(),G4Positron::Positron()};
// the coordinates of the photon in the local reference system of the volume
G4ThreeVector xyzGamma0 =
aTrack.GetTouchableHandle()->GetHistory()->
GetTopTransform().TransformPoint(aTrack.GetPosition());
// the coordinates of the photon in the co-rotating reference system within
//a channel (elementary periodic cell)
G4ThreeVector xyzGamma = fCrystalData->CoordinatesFromBoxToLattice(xyzGamma0);
//global time
G4double tGlobalGamma = aTrack.GetGlobalTime();
G4double ksi1 = G4UniformRand()*fPairProductionCDFdz.back();
//randomly choosing the pair to be produced from the sampling list
//according to the probabilities calculated in the Baier-Katkov integral
G4int ipair = FindVectorIndex(fPairProductionCDFdz,ksi1)-1;//index of
//a pair produced
// the coordinates of a charged particle in the reference system within
//a channel (elementary periodic cell)
G4ThreeVector xyzparticle;
//cycle e- and e+ within single pair
for(G4int j=0; j<2;j++)
{
xyzparticle.set(fullVectorX[ipair][j],fullVectorY[ipair][j],xyzGamma.z());
//in the local reference system of the volume
G4ThreeVector newParticleCoordinateXYZ =
fCrystalData->CoordinatesFromLatticeToBox(xyzparticle);
//the same in the global reference system
newParticleCoordinateXYZ =
aTrack.GetTouchableHandle()->GetHistory()->
GetTopTransform().Inverse().TransformPoint(newParticleCoordinateXYZ);
//back to the local reference system of the volume
G4double tx0 = fCrystalData->AngleXFromLatticeToBox(fullVectorTX[ipair][j],xyzGamma.z());
G4double ty0 = fullVectorTY[ipair][j];
G4double momentumDirectionZ = 1./
std::sqrt(1.+std::pow(std::tan(tx0),2)+
std::pow(std::tan(ty0),2));
//momentum direction vector of the charged particle produced
//in the local reference system of the volume
G4ThreeVector momentumDirectionParticle = G4ThreeVector(momentumDirectionZ*std::tan(tx0),
momentumDirectionZ*std::tan(ty0),
momentumDirectionZ);
//the same in the global reference system
momentumDirectionParticle =
(aTrack.GetTouchableHandle()->GetHistory()->GetTopTransform().NetRotation()) *
momentumDirectionParticle;
G4DynamicParticle* chargedParticle =
new G4DynamicParticle(chargedParticleDefinition[j],
momentumDirectionParticle,
fullVectorEtotal[ipair][j]-fMass);
// Create the track for the secondary particle
G4Track* secondaryTrack = new G4Track(chargedParticle,
tGlobalGamma,
newParticleCoordinateXYZ);
secondaryTrack->SetTouchableHandle(aStep.GetPostStepPoint()->GetTouchableHandle());
secondaryTrack->SetParentID(aTrack.GetTrackID());
//generation of a secondary charged particle
aParticleChange.AddSecondary(secondaryTrack);
}
//killing the photon
aParticleChange.ProposeTrackStatus(fStopAndKill);
return &aParticleChange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4int G4CoherentPairProduction::FindVectorIndex(std::vector<G4double> &myvector, G4double value)
{
auto iteratorbegin = myvector.begin();
auto iteratorend = myvector.end();
//vector index (for non precise values lower_bound gives upper value)
auto loweriterator = std::lower_bound(iteratorbegin, iteratorend, value);
//return the index of the vector element
return (G4int)std::distance(iteratorbegin, loweriterator);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4CoherentPairProduction::Input(const G4Material *crystal,
const G4String &lattice,
const G4String &filePath)
{
//initializing the class with containing all
//the crystal material and crystal lattice data and
//Channeling scattering and ionization processes
fCrystalData = new G4ChannelingFastSimCrystalData();
//setting all the crystal material and lattice data
fCrystalData->SetMaterialProperties(crystal,lattice,filePath);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4CoherentPairProduction::Input(const G4ChannelingFastSimCrystalData *crystalData)
{
//setting the class with containing all
//the crystal material and crystal lattice data and
//Channeling scattering and ionization processes
//fCrystalData = new G4ChannelingFastSimCrystalData();
fCrystalData = const_cast<G4ChannelingFastSimCrystalData*>(crystalData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4CoherentPairProduction::ProcessDescription(std::ostream& out) const
{
out << " Coherent pair production";
G4VDiscreteProcess::ProcessDescription(out);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,6 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Alexei Sytov
// Co-author: Gianfranco Paternò (modifications & testing)
// On the base of the CRYSTALRAD realization of scattering model:
// A. I. Sytov, V. V. Tikhomirov, and L. Bandiera PRAB 22, 064601 (2019)
#include "G4VChannelingFastSimCrystalData.hh"
#include "G4SystemOfUnits.hh"
@@ -210,19 +214,19 @@ void G4VChannelingFastSimCrystalData::SetCUParameters(
void G4VChannelingFastSimCrystalData::SetParticleProperties(G4double etotal,
G4double mass,
G4double charge,
G4bool ifhadron)
const G4String& particleName)
{
G4double teta1;
fZ2=charge;
G4double zz22=fZ2*fZ2;
fHadron=ifhadron;
fParticleName=particleName;
// particle momentum and energy
G4double t=etotal*etotal-mass*mass; // economy of operations
fPz=std::sqrt(t); // momentum of particle
fPV=t/etotal; // pv
fBeta=fPz/etotal; // velocity/c
fTetaL = std::sqrt(fVmax2/fPV); //Lindhard angle
fTetaL = std::sqrt(std::abs(fZ2)*fVmax2/fPV); //Lindhard angle
fChannelingStep = fChangeStep/fTetaL; //standard simulation step
// Energy losses
@@ -233,6 +237,8 @@ void G4VChannelingFastSimCrystalData::SetParticleProperties(G4double etotal,
fTmax = fMe2Gamma*fGamma*fV2/
(CLHEP::electron_mass_c2/mass*CLHEP::electron_mass_c2/mass +
1. + fMe2Gamma/mass);
// max ionization losses for electrons
if(fParticleName=="e-"){fTmax/=2;}
for(G4int i=0; i<fNelements; i++)
{
@@ -262,24 +268,23 @@ void G4VChannelingFastSimCrystalData::SetParticleProperties(G4double etotal,
fTetamax2[i]=tetamax*tetamax;
fTetamax12[i]=fTeta12[i]+fTetamax2[i];
// a cofficient in a formula for scattering (for high speed of simulation)
// fK2=(fZ2*alpha*hdc)**2*4.*pi*fN0*(fZ1/fPV)**2
// fK3=(fZ2*alpha*hdc)**2*4.*pi*fN0/(fPV)**2
// a coefficient in a formula for scattering (for high speed of simulation)
// fK2=(fZ2)**2*alphahbarc2*4.*pi*fN0*(fZ1/fPV)**2
fK2[i]=fK20[i]*zz22/fPV/fPV;
}
// nuclear diffractive scattering angle
//tetaQEL=1./sqrt(2.*(9.26-4.94/sqrt(fPz/GeV)+0.28*log(fPz/GeV)));
fK3=fK30/fV2;
// fK3=(fZ2)**2*alphahbarc2*pi/electron_mass_c2/(fV2)**2
fK3=fK30*zz22/fV2;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VChannelingFastSimCrystalData::GetLindhardAngle(G4double etotal, G4double mass)
G4double G4VChannelingFastSimCrystalData::GetLindhardAngle(G4double etotal,
G4double mass,
G4double charge)
{
G4double pv0 = etotal-mass*mass/etotal;
return std::sqrt(2*fVmax/pv0); //Calculate the value of the Lindhard angle
return std::sqrt(2*std::abs(charge)*fVmax/pv0); //Calculate the value of the Lindhard angle
//(!!! the value for a straight crystal)
}
@@ -313,7 +318,8 @@ G4double G4VChannelingFastSimCrystalData::GetSimulationStep(G4double tx,G4double
}
else
{
simulationstep = fChangeStep/angle;
simulationstep = fChangeStep;
if (angle > 0.0) { simulationstep /= angle; }
}
return simulationstep;
@@ -322,10 +328,11 @@ G4double G4VChannelingFastSimCrystalData::GetSimulationStep(G4double tx,G4double
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4VChannelingFastSimCrystalData::GetMaxSimulationStep(G4double etotal,
G4double mass)
G4double mass,
G4double charge)
{
//standard value of step for channeling particles which is the maximal possible step
return fChangeStep/GetLindhardAngle(etotal, mass);
return fChangeStep/GetLindhardAngle(etotal, mass, charge);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -479,11 +486,14 @@ G4ThreeVector G4VChannelingFastSimCrystalData::CoulombElectronScattering(
G4double e1=eMinIonization/(1.-ksi*(1.-eMinIonization/fTmax));
// scattering angle
G4double t=std::sqrt(e1*(e1+2.*CLHEP::electron_mass_c2))/fPz;
G4double t=0;
if(fTmax-e1>DBL_EPSILON) //to be sure e1<fTmax
{
t=std::sqrt(2.*CLHEP::electron_mass_c2*e1*(1-e1/fTmax))/fPz;
}
// energy losses
if (fHadron) {eloss=e1;} // we don't calculate ionization losses for e+-
eloss=e1;
ksi=G4UniformRand();
tx+=t*std::cos(CLHEP::twopi*ksi);
@@ -507,11 +517,33 @@ G4ThreeVector G4VChannelingFastSimCrystalData::CoulombElectronScattering(
G4double G4VChannelingFastSimCrystalData::IonizationLosses(G4double dz,
G4int ielement)
{
//amorphous part of ionization losses
G4double elosses = 0.;
if (fHadron) {elosses=fKD[ielement]/fV2*
(G4Log(fMe2Gamma*fV2/fI0[ielement]/fGamma) - fV2)*dz;}
return elosses;
}
// 1/2 already taken into account in fKD
G4double loge = G4Log(fMe2Gamma*fGamma*fV2/fI0[ielement]);
G4double delta= 2*(G4Log(fBeta*fGamma)+fLogPlasmaEdI0[ielement]-0.5);
if(delta<0){delta=0;}
loge-=delta;
if(fParticleName=="e-")
{
loge+=(-G4Log(2.) + 1
-(2*fGamma - 1)/fGamma/fGamma*G4Log(2.) +
1/8*((fGamma - 1)/fGamma)*((fGamma - 1)/fGamma));
}
else if(fParticleName=="e+")
{
loge+=(-fV2/12*(11 + 14/(fGamma + 1) + 10/(fGamma + 1)/(fGamma + 1) +
4/(fGamma + 1)/(fGamma + 1)/(fGamma + 1)));
}
else
{
loge-=fV2;
}
elosses=fZ2*fZ2*fKD[ielement]/fV2*loge*dz;
return elosses;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....