Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -59,7 +59,8 @@ public:
of the radiation type you are interested in
CAUTION: do ResetRadIntegral() before the start of a new trajectory
1) change some model defaults if necessary (SetSinglePhotonRadiationProbabilityLimit,
1) change some model defaults if necessary
(SetSinglePhotonRadiationProbabilityLimit,
SetNSmallTrajectorySteps, SetSpectrumEnergyRange)
2) call DoRadiation at each step of your trajectory
3) if DoRadiation returns TRUE, this means that a photon is produced (not added
@@ -98,7 +99,8 @@ public:
const G4ThreeVector& GetParticleNewCoordinateXYZ(){return fNewParticleCoordinateXYZ;}
///get photon energies (x-value in spectrum)
const std::vector<G4double>& GetPhotonEnergyInSpectrum(){return fPhotonEnergyInSpectrum;}
const std::vector<G4double>& GetPhotonEnergyInSpectrum()
{return fPhotonEnergyInSpectrum;}
///get fTotalSpectrum after finishing the trajectory part with DoRadiation
const std::vector<G4double>& GetTotalSpectrum(){return fTotalSpectrum;}
@@ -121,7 +123,12 @@ public:
///setting the number of photons in sampling of Baier-Katkov Integral
///(MC integration by photon energy and angles <=> photon momentum)
void SetSamplingPhotonsNumber(G4double nPhotons){fNMCPhotons = nPhotons;}
void SetSamplingPhotonsNumber(G4int nPhotons){fNMCPhotons = nPhotons;}
///setting the number of radiation angles 1/gamma, defining the width of
///the angular distribution of photon sampling in the Baier-Katkov Integral
void SetRadiationAngleFactor(G4double radiationAngleFactor)
{fRadiationAngleFactor = radiationAngleFactor;}
///CAUTION, the bins width is logarithmic
///Do not worry if the maximal energy > particle energy.
@@ -142,6 +149,16 @@ public:
fMaxPhotonEnergy,
nbin);}
/// Increase the statistic of virtual photons in a certain energy region
/// CAUTION! : don't do it before SetSpectrumEnergyRange or SetMinPhotonEnergy
void AddStatisticsInPhotonEnergyRegion(G4double emin, G4double emax,
G4int timesPhotonStatistics);
/// Virtual collimator masks the selection of photon angles in fTotalSpectrum
/// Virtual collimator doesn't influence on Geant4 simulations.
void SetVirtualCollimator(G4double virtualCollimatorAngularDiameter)
{fVirtualCollimatorAngularDiameter=virtualCollimatorAngularDiameter;}
/// add the new elements of the trajectory, calculate radiation in a crystal
/// see complete description in G4BaierKatkov::DoRadiation
/// calls RadIntegral and all the necessary functions
@@ -196,14 +213,14 @@ private:
G4int FindVectorIndex(std::vector<G4double> &myvector, G4double value);
G4double fTotalRadiationProbability = 0.;
G4double fSinglePhotonRadiationProbabilityLimit=0.05;//Maximal radiation
G4double fSinglePhotonRadiationProbabilityLimit=0.25;//Maximal radiation
//probability to preserve single photon radiation
//number of steps in a trajectory piece before the next call of the radiation integral
G4int fNSmallTrajectorySteps=1000;
G4int fNSmallTrajectorySteps=10000;
///trajectory element No (the first element of the array feeded in RadIntegral)
G4int fImin0 = 0;
///number of Monte Carlo points of integration on photon angles
///Monte Carlo statistics of photon sampling in Baier-Katkov with 1 trajectory
G4int fNMCPhotons =150;
///the number of bins in photon spectrum
G4int fNBinsSpectrum = 110;
@@ -218,6 +235,14 @@ private:
G4double fLogEdEmin = 1.; // = log(E/fMinPhotonEnergy), the same as fLogEmaxdEmin
// but with the particle energy as the maximal limit
G4double fVirtualCollimatorAngularDiameter=1.;//default, infinite angle
std::vector<G4bool> fInsideVirtualCollimator;
///data of the phootn energy range with additional statistics
std::vector<G4double> fLogAddRangeEmindEmin;//=G4Log(emin/fMinPhotonEnergy)
std::vector<G4double> fLogAddRangeEmaxdEmin;//=G4Log(emax/fMinPhotonEnergy)
std::vector<G4int> fTimesPhotonStatistics;
///number of trajectories
//(at each of the Baier-Katkov Integral is calculated for the same photons)
G4int fItrajectories = 0;
@@ -234,6 +259,9 @@ 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:
// more fRadiationAngleFactor =>
// higher fParamPhotonAngleX and Y
///new particle parameters (the parameters at the point of radiation emission)
G4double fNewParticleEnergy=0;
@@ -277,14 +305,14 @@ private:
std::vector<G4int> fNPhotonsPerBin; //number of photons per spectrum bin
//(accumulating during total run)
std::vector<G4double> fSpectrum; //spectrum normalized by the total radiation probability
//of one particle at one call of RadIntegral
std::vector<G4double> fSpectrum; //spectrum normalized by the total
//radiation probability of one particle at one call of RadIntegral
std::vector<std::vector<G4double>> fAccumSpectrum; //accumulate Spectrum during
//the part of a trajectory
std::vector<G4double> fAccumTotalSpectrum; //spectrum normalized by the total radiation
//probability summed
std::vector<G4double> fAccumTotalSpectrum; //spectrum normalized by the total
//radiation probability summed
//for all the particles (is not divided
//of one particle number fNPhotonsPerBin)
@@ -295,8 +323,8 @@ private:
//multiplied by the number of trajectories
//(fItrajectories)
std::vector<G4double> fImax0; //trajectory element numbers at the end of each small piece
//G4double just for security of some operations
std::vector<G4double> fImax0; //trajectory element numbers at the end of each
//small piece; G4double just for security of some operations
///total radiation probability along this trajectory
std::vector<G4double> fTotalRadiationProbabilityAlongTrajectory;
};
@@ -77,11 +77,13 @@ public:
///calculate the horizontal angle in the co-rotating reference system
///within a channel (periodic cell)
///(connected with crystal planes/axes either bent or straight)
G4double AngleXFromBoxToLattice(G4double tx, G4double z){return tx-AngleXShift(z);}
G4double AngleXFromBoxToLattice(G4double tx, G4double z)
{return tx-AngleXShift(z)-GetCUtetax(z);}
///calculate the horizontal angle in the Box reference system
///(connected with the bounding box of the volume)
G4double AngleXFromLatticeToBox(G4double tx, G4double z){return tx+AngleXShift(z);}
G4double AngleXFromLatticeToBox(G4double tx, G4double z)
{return tx+AngleXShift(z)+GetCUtetax(z);}
///auxialiary function to transform the horizontal angle
G4double AngleXShift(G4double z){return fMiscutAngle + z*fCurv;}
@@ -99,7 +101,8 @@ private:
//inside the box; =0 in the case of planes
///values related to the crystal lattice
G4int fNpointsx=0,fNpointsy=0;// number of horizontal and vertical nodes of interpolation
G4int fNpointsx=0,fNpointsy=0;// number of horizontal and vertical nodes of
// interpolation
G4double fDx=0, fDy=0;// channel (periodic cell)
//horizontal and vertical dimensions
@@ -72,9 +72,9 @@ private:
G4double Spline1D(G4double xx);
G4double Spline2D(G4double xx, G4double yy);// cubic spline of 2-variable function
G4double fDx=0, fDy=0; //channel width and height
G4double fStepi=0, fStepj=0; //interpolation steps in x and y, respectively
G4double fStepi2=0; //=fStepi*fStepi
G4double fDx=0., fDy=0.; //channel width and height
G4double fStepi=0., fStepj=0.; //interpolation steps in x and y, respectively
G4double fStepi2=0.; //=fStepi*fStepi
G4int nPointsx=0, nPointsy=0; //number of interpolation nodes in x and y, respectively
std::vector <G4double> fAI;
@@ -107,7 +107,14 @@ public:
G4double GetMiscutAngle(){return fMiscutAngle;}
///get crystal curvature
G4double GetCurv(){return fCurv;}
///for crystalline undulator the curvature is a function, otherwise it's a constant
G4double GetCurv(G4double z){return fCU ? -fCUK2*GetCUx(z) : fCurv;}
///get crystalline undulator wave function
G4double GetCUx(G4double z){return fCUAmplitude*std::cos(fCUK*z+fCUPhase);}
///get crystalline undulator wave 1st derivative function
G4double GetCUtetax(G4double z){
return fCU ? -fCUAmplitudeK*std::sin(fCUK*z+fCUPhase) : 0;}
///find and upload crystal lattice input files, calculate all the basic values
///(to do only once)
@@ -128,6 +135,19 @@ public:
///otherwise geometry routines may be unstable
void SetMiscutAngle(G4double tetam, const G4LogicalVolume *crystallogic);
///set crystalline undulator parameters: amplitude, period and phase
/// (default: all 3 value = 0)
/// function to use in Detector Construction
void SetCrystallineUndulatorParameters(G4double amplitude,
G4double period,
G4double phase,
const G4LogicalVolume *crystallogic);
///set crystalline undulator parameters (internal function of the model)
///for convenience we put amplitude, period and phase in a G4ThreeVector
void SetCUParameters(const G4ThreeVector &amplitudePeriodPhase,
const G4LogicalVolume *crystallogic);
///recalculate all the important values
///(to do both at the trajectory start and after energy loss)
void SetParticleProperties(G4double etotal,
@@ -145,8 +165,7 @@ public:
virtual G4ThreeVector CoordinatesFromLatticeToBox(const G4ThreeVector &pos) = 0;
///change the channel if necessary, recalculate x o y
virtual G4ThreeVector ChannelChange(G4double& x, G4double& y,
G4double& z) = 0;
virtual G4ThreeVector ChannelChange(G4double& x, G4double& y, G4double& z) = 0;
///return correction of the longitudinal coordinate
/// (along current plane/axis vs "central plane/axis")
@@ -215,6 +234,14 @@ protected:
//(along current plane/axis vs "central plane/axis"), 1 is default value
//(for "central plane/axis" or a straight crystal)
G4bool fCU = false;//flag of crystalline undulator geometry
//(periodically bent crystal)
G4double fCUAmplitude=0.; //Amplitude of a crystalline undulator
G4double fCUK=0.; //2*pi/period of a crystalline undulator
G4double fCUPhase=0.;//Phase of a crystalline undulator
G4double fCUAmplitudeK=0.;//fCUAmplitude*fCUK
G4double fCUK2=0.; //fCUK^2
///values related to the crystal lattice
G4int fNelements=1;//number of nuclear elements in a crystal
G4int iModel=1;// model type (iModel=1 for interplanar potential,
@@ -278,6 +305,10 @@ private:
std::unordered_map<G4int, G4double> fMapMiscutAngle;//the map fMiscutAngle
//for different logical volumes
std::unordered_map<G4int, G4ThreeVector> fMapCUAmplitudePeriodPhase;//the map of
//AmplitudePeriodPhase
//for different logical volumes
G4double fChannelingStep=0;// simulation step under the channeling conditions =
//channeling oscillation length/fNsteps
// channeling oscillation length: Biryukov book Eq. (1.24)