Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointAlongStepWeightCorrection.cc,v 1.5 2009/11/23 09:02:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointAlongStepWeightCorrection.cc,v 1.6 2010/09/03 14:33:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointAlongStepWeightCorrection.hh"
#include "G4Step.hh"
@@ -89,11 +89,7 @@ G4VParticleChange* G4AdjointAlongStepWeightCorrection::AlongStepDoIt(const G4Tra
//When the new weight is 0 it will be later on consider as nan by G4.
//Therefore we do put a lower limit of 1.e-300. for new_weight
//Correction by L.Desorgher on 15 July 2009
#ifdef WIN32
if (!!_isnan(new_weight) || new_weight==0){
#else
if (std::isnan(new_weight) || new_weight==0){
#endif
if (new_weight==0 || (new_weight<=0 && new_weight>0)){
//G4cout<<new_weight<<'\t'<<weight_correction<<'\t'<<track.GetWeight()<<G4endl;
new_weight=1.e-300;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointBremsstrahlungModel.cc,v 1.5 2009/12/16 17:50:01 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointBremsstrahlungModel.cc,v 1.6 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointBremsstrahlungModel.hh"
#include "G4AdjointCSManager.hh"
@@ -50,6 +50,11 @@ G4AdjointBremsstrahlungModel::G4AdjointBremsstrahlungModel():
theDirectStdBremModel = new G4eBremsstrahlungModel(G4Electron::Electron(),"TheDirecteBremModel");
theDirectEMModel=theDirectStdBremModel;
theEmModelManagerForFwdModels = new G4EmModelManager();
isDirectModelInitialised = false;
G4VEmFluctuationModel* f=0;
G4Region* r=0;
theEmModelManagerForFwdModels->AddEmModel(1, theDirectStdBremModel, f, r);
// theDirectPenelopeBremModel =0;
SetApplyCutInRange(true);
@@ -277,11 +282,11 @@ G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecond(con
G4double kinEnergyProj, // kinetic energy of the primary particle before the interaction
G4double kinEnergyProd // kinetic energy of the secondary particle
)
{/*if (UsePenelopeModel && !isPenelopeModelInitialised) {
theEmModelManagerForFwdModels->Initialise(G4Electron::Electron(),G4Gamma::Gamma(),1.,0);
isPenelopeModelInitialised =true;
}
*/
{if (!isDirectModelInitialised) {
theEmModelManagerForFwdModels->Initialise(G4Electron::Electron(),G4Gamma::Gamma(),1.,0);
isDirectModelInitialised =true;
}
return DiffCrossSectionPerVolumePrimToSecondApproximated2(aMaterial,
kinEnergyProj,
kinEnergyProd);
@@ -304,8 +309,8 @@ G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecondAppr
//In this approximation we consider that the secondary gammas are sampled with 1/Egamma energy distribution
//This is what is applied in the discrete standard model before the rejection test that make a cooerction
//The application of the same rejection function is not possble here.
//This is what is applied in the discrete standard model before the rejection test that make a correction
//The application of the same rejection function is not possible here.
//The differentiation of the CS over Ecut does not produce neither a good differential CS. That is due to the
// fact that in the discrete model the differential CS and the integrated CS are both fitted but separatly and
// therefore do not allow a correct numerical differentiation of the integrated CS to get the differential one.
@@ -364,11 +369,10 @@ G4double G4AdjointBremsstrahlungModel::DiffCrossSectionPerVolumePrimToSecondAppr
G4double G4AdjointBremsstrahlungModel::AdjointCrossSection(const G4MaterialCutsCouple* aCouple,
G4double primEnergy,
G4bool IsScatProjToProjCase)
{/* if (UsePenelopeModel && !isPenelopeModelInitialised) {
{ if (!isDirectModelInitialised) {
theEmModelManagerForFwdModels->Initialise(G4Electron::Electron(),G4Gamma::Gamma(),1.,0);
isPenelopeModelInitialised =true;
isDirectModelInitialised =true;
}
*/
if (UseMatrix) return G4VEmAdjointModel::AdjointCrossSection(aCouple,primEnergy,IsScatProjToProjCase);
DefineCurrentMaterial(aCouple);
G4double Cross=0.;
@@ -388,7 +392,15 @@ G4double G4AdjointBremsstrahlungModel::AdjointCrossSection(const G4MaterialCutsC
return Cross;
}
G4double G4AdjointBremsstrahlungModel::GetAdjointCrossSection(const G4MaterialCutsCouple* aCouple,
G4double primEnergy,
G4bool IsScatProjToProjCase)
{
return AdjointCrossSection(aCouple, primEnergy,IsScatProjToProjCase);
lastCZ=theDirectEMModel->CrossSectionPerVolume(aCouple->GetMaterial(),theDirectPrimaryPartDef,100.*MeV,100.*MeV/std::exp(1.));//this give the constant above
return G4VEmAdjointModel::GetAdjointCrossSection(aCouple, primEnergy,IsScatProjToProjCase);
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointCSManager.cc,v 1.5 2009/11/20 10:31:20 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointCSManager.cc,v 1.6 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointCSManager.hh"
#include "G4AdjointCSMatrix.hh"
@@ -67,6 +67,7 @@ G4AdjointCSManager* G4AdjointCSManager::GetAdjointCSManager()
//
G4AdjointCSManager::G4AdjointCSManager()
{ CrossSectionMatrixesAreBuilt=false;
TotalSigmaTableAreBuilt=false;
theTotalForwardSigmaTableVector.clear();
theTotalAdjointSigmaTableVector.clear();
listOfForwardEmProcess.clear();
@@ -76,9 +77,11 @@ G4AdjointCSManager::G4AdjointCSManager()
EminForAdjSigmaTables.clear();
EkinofFwdSigmaMax.clear();
EkinofAdjSigmaMax.clear();
listSigmaTableForAdjointModelScatProjToProj.clear();
listSigmaTableForAdjointModelProdToProj.clear();
Tmin=0.1*keV;
Tmax=100.*TeV;
nbins=360; //probably this should be decrease, that was choosen to avoid error in the CS value closed to CS jump.(For example at Tcut)
nbins=320; //probably this should be decrease, that was choosen to avoid error in the CS value closed to CS jump.(For example at Tcut)
RegisterAdjointParticle(G4AdjointElectron::AdjointElectron());
RegisterAdjointParticle(G4AdjointGamma::AdjointGamma());
@@ -106,8 +109,12 @@ G4AdjointCSManager::~G4AdjointCSManager()
}
///////////////////////////////////////////////////////
//
void G4AdjointCSManager::RegisterEmAdjointModel(G4VEmAdjointModel* aModel)
size_t G4AdjointCSManager::RegisterEmAdjointModel(G4VEmAdjointModel* aModel)
{listOfAdjointEMModel.push_back(aModel);
listSigmaTableForAdjointModelScatProjToProj.push_back(new G4PhysicsTable);
listSigmaTableForAdjointModelProdToProj.push_back(new G4PhysicsTable);
return listOfAdjointEMModel.size() -1;
}
///////////////////////////////////////////////////////
//
@@ -249,8 +256,24 @@ void G4AdjointCSManager::BuildCrossSectionMatrices()
///////////////////////////////////////////////////////
//
void G4AdjointCSManager::BuildTotalSigmaTables()
{
{ if (TotalSigmaTableAreBuilt) return;
const G4ProductionCutsTable* theCoupleTable= G4ProductionCutsTable::GetProductionCutsTable();
//Prepare the Sigma table for all AdjointEMModel, will be filled later on
for (size_t i=0; i<listOfAdjointEMModel.size();i++){
listSigmaTableForAdjointModelScatProjToProj[i]->clearAndDestroy();
listSigmaTableForAdjointModelProdToProj[i]->clearAndDestroy();
for (size_t j=0;j<theCoupleTable->GetTableSize();j++){
listSigmaTableForAdjointModelScatProjToProj[i]->push_back(new G4PhysicsLogVector(Tmin, Tmax, nbins));
listSigmaTableForAdjointModelProdToProj[i]->push_back(new G4PhysicsLogVector(Tmin, Tmax, nbins));
}
}
for (size_t i=0;i<theListOfAdjointParticlesInAction.size();i++){
G4ParticleDefinition* thePartDef = theListOfAdjointParticlesInAction[i];
DefineCurrentParticle(thePartDef);
@@ -333,10 +356,10 @@ void G4AdjointCSManager::BuildTotalSigmaTables()
e_sigma_max =0.;
ind=0;
G4PhysicsVector* aVector1 = new G4PhysicsLogVector(Tmin, Tmax, nbins);
for(size_t l=0; l<aVector->GetVectorLength(); l++) {
G4double e=aVector->GetLowEdgeEnergy(l);
for(eindex=0; eindex<aVector->GetVectorLength(); eindex++) {
G4double e=aVector->GetLowEdgeEnergy(eindex);
G4double totCS =ComputeTotalAdjointCS(couple,thePartDef,e*0.9999999/massRatio); //massRatio needed for ions
aVector1->PutValue(l,totCS);
aVector1->PutValue(eindex,totCS);
if (totCS>sigma_max){
sigma_max=totCS;
e_sigma_max = e;
@@ -357,6 +380,7 @@ void G4AdjointCSManager::BuildTotalSigmaTables()
}
}
TotalSigmaTableAreBuilt =true;
}
///////////////////////////////////////////////////////
@@ -382,7 +406,15 @@ G4double G4AdjointCSManager::GetTotalForwardCS(G4ParticleDefinition* aPartDef, G
}
///////////////////////////////////////////////////////
//
G4double G4AdjointCSManager::GetAdjointSigma(G4double Ekin_nuc, size_t index_model,G4bool is_scat_proj_to_proj,
const G4MaterialCutsCouple* aCouple)
{ DefineCurrentMaterial(aCouple);
G4bool b;
if (is_scat_proj_to_proj) return (((*listSigmaTableForAdjointModelScatProjToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
else return (((*listSigmaTableForAdjointModelProdToProj[index_model])[currentMatIndex])->GetValue(Ekin_nuc, b));
}
///////////////////////////////////////////////////////
//
void G4AdjointCSManager::GetEminForTotalCS(G4ParticleDefinition* aPartDef,
@@ -655,6 +687,7 @@ G4double G4AdjointCSManager::ComputeTotalAdjointCS(const G4MaterialCutsCouple* a
std::vector<G4double> CS_Vs_Element;
G4double CS;
for (size_t i=0; i<listOfAdjointEMModel.size();i++){
G4double Tlow=0;
@@ -673,20 +706,28 @@ G4double G4AdjointCSManager::ComputeTotalAdjointCS(const G4MaterialCutsCouple* a
}
if ( Ekin<=listOfAdjointEMModel[i]->GetHighEnergyLimit() && Ekin>=listOfAdjointEMModel[i]->GetLowEnergyLimit()){
if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectPrimaryParticleDefinition()){
TotalCS += ComputeAdjointCS(currentMaterial,
CS=ComputeAdjointCS(currentMaterial,
listOfAdjointEMModel[i],
Ekin, Tlow,true,CS_Vs_Element);
Ekin, Tlow,true,CS_Vs_Element);
TotalCS += CS;
(*listSigmaTableForAdjointModelScatProjToProj[i])[currentMatIndex]->PutValue(eindex,CS);
}
if (aPartDef == listOfAdjointEMModel[i]->GetAdjointEquivalentOfDirectSecondaryParticleDefinition()){
TotalCS += ComputeAdjointCS(currentMaterial,
CS = ComputeAdjointCS(currentMaterial,
listOfAdjointEMModel[i],
Ekin, Tlow,false, CS_Vs_Element);
TotalCS += CS;
(*listSigmaTableForAdjointModelProdToProj[i])[currentMatIndex]->PutValue(eindex,CS);
}
}
else {
(*listSigmaTableForAdjointModelScatProjToProj[i])[currentMatIndex]->PutValue(eindex,0.);
(*listSigmaTableForAdjointModelProdToProj[i])[currentMatIndex]->PutValue(eindex,0.);
}
}
return TotalCS;
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointComptonModel.cc,v 1.6 2009/12/16 17:50:03 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointComptonModel.cc,v 1.7 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointComptonModel.hh"
#include "G4AdjointCSManager.hh"
@@ -45,7 +45,7 @@ G4AdjointComptonModel::G4AdjointComptonModel():
G4VEmAdjointModel("AdjointCompton")
{ SetApplyCutInRange(false);
SetUseMatrix(true);
SetUseMatrix(false);
SetUseMatrixPerElement(true);
SetUseOnlyOneMatrixForAllElements(true);
theAdjEquivOfDirectPrimPartDef =G4AdjointGamma::AdjointGamma();
@@ -170,6 +170,7 @@ void G4AdjointComptonModel::RapidSampleSecondaries(const G4Track& aTrack,
}
G4double diffCSUsed=currentMaterial->GetElectronDensity()*twopi_mc2_rcl2;
G4double gammaE1=0.;
G4double gammaE2=0.;
@@ -380,15 +381,15 @@ G4double G4AdjointComptonModel::AdjointCrossSection(const G4MaterialCutsCouple*
DefineCurrentMaterial(aCouple);
G4double Cross=0.;
G4double Emax_proj =0.;
G4double Emin_proj =0.;
float Cross=0.;
float Emax_proj =0.;
float Emin_proj =0.;
if (!IsScatProjToProjCase ){
Emax_proj = GetSecondAdjEnergyMaxForProdToProjCase(primEnergy);
Emin_proj = GetSecondAdjEnergyMinForProdToProjCase(primEnergy);
if (Emax_proj>Emin_proj ){
Cross= std::log((Emax_proj-primEnergy)*Emin_proj/Emax_proj/(Emin_proj-primEnergy))
*(1.+2.*std::log(1.+electron_mass_c2/primEnergy));
Cross= std::log((Emax_proj-float (primEnergy))*Emin_proj/Emax_proj/(Emin_proj-primEnergy))
*(1.+2.*std::log(float(1.+electron_mass_c2/primEnergy)));
}
}
else {
@@ -404,5 +405,13 @@ G4double G4AdjointComptonModel::AdjointCrossSection(const G4MaterialCutsCouple*
Cross*=currentMaterial->GetElectronDensity()*twopi_mc2_rcl2;
lastCS=Cross;
return Cross;
return double(Cross);
}
////////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointComptonModel::GetAdjointCrossSection(const G4MaterialCutsCouple* aCouple,
G4double primEnergy,
G4bool IsScatProjToProjCase)
{ return AdjointCrossSection(aCouple, primEnergy,IsScatProjToProjCase);
//return G4VEmAdjointModel::GetAdjointCrossSection(aCouple, primEnergy,IsScatProjToProjCase);
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointIonIonisationModel.cc,v 1.2 2009/11/20 10:31:20 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointIonIonisationModel.cc,v 1.3 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointIonIonisationModel.hh"
#include "G4AdjointCSManager.hh"
@@ -314,6 +314,7 @@ void G4AdjointIonIonisationModel::DefineProjectileProperty()
mass = theDirectPrimaryPartDef->GetPDGMass();
massRatio= G4GenericIon::GenericIon()->GetPDGMass()/mass;
mass_ratio_projectile = massRatio;
spin = theDirectPrimaryPartDef->GetPDGSpin();
G4double q = theDirectPrimaryPartDef->GetPDGCharge()/eplus;
chargeSquare = q*q;
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointPhotoElectricModel.cc,v 1.5 2009/12/16 17:50:05 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointPhotoElectricModel.cc,v 1.6 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointPhotoElectricModel.hh"
#include "G4AdjointCSManager.hh"
@@ -214,6 +214,14 @@ G4double G4AdjointPhotoElectricModel::AdjointCrossSection(const G4MaterialCutsCo
////////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointPhotoElectricModel::GetAdjointCrossSection(const G4MaterialCutsCouple* aCouple,
G4double electronEnergy,
G4bool IsScatProjToProjCase)
{ return AdjointCrossSection(aCouple,electronEnergy,IsScatProjToProjCase);
}
////////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointPhotoElectricModel::AdjointCrossSectionPerAtom(const G4Element* anElement,G4double electronEnergy)
{
G4int nShells = anElement->GetNbOfAtomicShells();
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointhIonisationModel.cc,v 1.3 2009/12/16 17:50:07 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointhIonisationModel.cc,v 1.4 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4AdjointhIonisationModel.hh"
#include "G4AdjointCSManager.hh"
@@ -203,9 +203,9 @@ void G4AdjointhIonisationModel::RapidSampleSecondaries(const G4Track& aTrack,
G4double t1=adjointPrimKinEnergy*(1./diff1-1./diff2);
G4double t2=adjointPrimKinEnergy*(1./Emin-1./Emax);
G4double f31=diff1/Emin;
G4double f32=diff2/Emax/f31;
G4double t3=2.*std::log(f32);
/*G4double f31=diff1/Emin;
G4double f32=diff2/Emax/f31;*/
G4double t3=2.*std::log(Emax/Emin);
G4double sum_t=t1+t2+t3;
newCS=newCS*sum_t/adjointPrimKinEnergy/adjointPrimKinEnergy;
G4double t=G4UniformRand()*sum_t;
@@ -219,7 +219,7 @@ void G4AdjointhIonisationModel::RapidSampleSecondaries(const G4Track& aTrack,
projectileKinEnergy =1./(1./Emin-q);
}
else {
projectileKinEnergy=adjointPrimKinEnergy/(1.-f31*std::pow(f32,G4UniformRand()));
projectileKinEnergy=Emin*std::pow(Emax/Emin,G4UniformRand());
}
eEnergy=projectileKinEnergy-adjointPrimKinEnergy;
@@ -414,6 +414,7 @@ void G4AdjointhIonisationModel::DefineProjectileProperty()
}
mass = theDirectPrimaryPartDef->GetPDGMass();
mass_ratio_projectile = proton_mass_c2/theDirectPrimaryPartDef->GetPDGMass();;
spin = theDirectPrimaryPartDef->GetPDGSpin();
G4double q = theDirectPrimaryPartDef->GetPDGCharge()/eplus;
chargeSquare = q*q;
@@ -469,7 +470,8 @@ G4double G4AdjointhIonisationModel::AdjointCrossSection(const G4MaterialCutsCoup
G4double diff1=Emin_proj-primEnergy;
G4double diff2=Emax_proj-primEnergy;
G4double t1=(1./diff1+1./Emin_proj-1./diff2-1./Emax_proj)/primEnergy;
G4double t2=2.*std::log(diff2*Emin_proj/Emax_proj/diff1)/primEnergy/primEnergy;
//G4double t2=2.*std::log(diff2*Emin_proj/Emax_proj/diff1)/primEnergy/primEnergy;
G4double t2=2.*std::log(Emax_proj/Emin_proj)/primEnergy/primEnergy;
Cross*=(t1+t2);
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointhMultipleScattering.cc,v 1.2 2009/11/20 10:31:20 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4AdjointhMultipleScattering.cc,v 1.3 2010/04/12 18:57:15 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
@@ -42,7 +42,6 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4AdjointhMultipleScattering.hh"
#include "G4UrbanMscModel.hh"
#include "G4UrbanMscModel90.hh"
#include "G4MscStepLimitType.hh"
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ContinuousGainOfEnergy.cc,v 1.4 2009/11/20 10:31:20 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4ContinuousGainOfEnergy.cc,v 1.5 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4ContinuousGainOfEnergy.hh"
#include "G4Step.hh"
@@ -136,15 +136,14 @@ G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
*dynParticle = *(track.GetDynamicParticle());
dynParticle->SetDefinition(theDirectPartDef);
G4double Tkin = dynParticle->GetKineticEnergy();
G4double Tkin1=Tkin*0.001;
size_t n=1;
if (is_integral ) n=10;
n=1;
G4double dlength= length/n;
for (size_t i=0;i<n;i++) {
G4double factor_dE=1.;
if (Tkin != preStepKinEnergy && IsIon) {
if (Tkin != preStepKinEnergy && IsIon) {
chargeSqRatio = currentModel->GetChargeSquareRatio(theDirectPartDef,currentMaterial,Tkin);
theDirectEnergyLossProcess->SetDynamicMassCharge(massRatio,chargeSqRatio);
@@ -152,9 +151,7 @@ G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
G4double r = theDirectEnergyLossProcess->GetRange(Tkin, currentCouple);
if( dlength <= linLossLimit * r ) {
degain = DEDX_before*dlength;
G4double degain1 = dlength*theDirectEnergyLossProcess->GetDEDX(Tkin1, currentCouple);
factor_dE=1.+(degain1-degain)/(Tkin1-Tkin);
degain = DEDX_before*dlength;
}
else {
G4double x = r + dlength;
@@ -172,10 +169,7 @@ G4VParticleChange* G4ContinuousGainOfEnergy::AlongStepDoIt(const G4Track& track,
}
}
G4double r1 = theDirectEnergyLossProcess->GetRange(Tkin1, currentCouple);
G4double x1 = r1 + dlength;
G4double E1 = theDirectEnergyLossProcess->GetKineticEnergy(x1,currentCouple);
factor_dE=(E1-E)/(Tkin1-Tkin);
degain=E-Tkin;
@@ -279,7 +273,7 @@ G4double G4ContinuousGainOfEnergy::GetContinuousStepLimit(const G4Track& track,
maxE=std::min(emax_model*1.001,maxE);
G4double r = theDirectEnergyLossProcess->GetRange(preStepKinEnergy, currentCouple);
preStepRange = theDirectEnergyLossProcess->GetRange(preStepKinEnergy, currentCouple);
if (IsIon) {
G4double chargeSqRatioAtEmax = currentModel->GetChargeSquareRatio(theDirectPartDef,currentMaterial,maxE);
@@ -292,8 +286,8 @@ G4double G4ContinuousGainOfEnergy::GetContinuousStepLimit(const G4Track& track,
x=r1-r;
x=std::max(r1-r,0.001*mm);
x=r1-preStepRange;
x=std::max(r1-preStepRange,0.001*mm);
return x;
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VAdjointReverseReaction.cc,v 1.2 2009/11/20 10:31:20 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VAdjointReverseReaction.cc,v 1.3 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4VAdjointReverseReaction.hh"
#include "G4AdjointCSManager.hh"
@@ -108,9 +108,11 @@ G4double G4VAdjointReverseReaction::GetMeanFreePath(const G4Track& track,
{ *condition = NotForced;
G4double preStepKinEnergy = track.GetKineticEnergy();
G4double Sigma =
theAdjointEMModel->AdjointCrossSection(track.GetMaterialCutsCouple(),preStepKinEnergy,IsScatProjToProjCase);
/*G4double Sigma =
theAdjointEMModel->AdjointCrossSection(track.GetMaterialCutsCouple(),preStepKinEnergy,IsScatProjToProjCase);*/
G4double Sigma =
theAdjointEMModel->GetAdjointCrossSection(track.GetMaterialCutsCouple(),preStepKinEnergy,IsScatProjToProjCase);
G4double fwd_TotCS;
Sigma *= theAdjointCSManager->GetCrossSectionCorrection(track.GetDefinition(),preStepKinEnergy,track.GetMaterialCutsCouple(),IsFwdCSUsed, fwd_TotCS);
//G4cout<<fwd_TotCS<<G4endl;
@@ -135,4 +137,3 @@ G4double G4VAdjointReverseReaction::GetMeanFreePath(const G4Track& track,
return mean_free_path;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VEmAdjointModel.cc,v 1.5 2009/12/16 17:50:09 gunter Exp $
// GEANT4 tag $Name: geant4-09-03 $
// $Id: G4VEmAdjointModel.cc,v 1.6 2010/11/11 11:51:56 ldesorgh Exp $
// GEANT4 tag $Name: geant4-09-04 $
//
#include "G4VEmAdjointModel.hh"
#include "G4AdjointCSManager.hh"
@@ -32,6 +32,8 @@
#include "G4TrackStatus.hh"
#include "G4ParticleChange.hh"
#include "G4AdjointElectron.hh"
#include "G4AdjointGamma.hh"
#include "G4AdjointPositron.hh"
#include "G4AdjointInterpolator.hh"
#include "G4PhysicsTable.hh"
@@ -41,9 +43,11 @@ G4VEmAdjointModel::G4VEmAdjointModel(const G4String& nam):
name(nam)
// lowLimit(0.1*keV), highLimit(100.0*TeV), fluc(0), name(nam), pParticleChange(0)
{
G4AdjointCSManager::GetAdjointCSManager()->RegisterEmAdjointModel(this);
model_index = G4AdjointCSManager::GetAdjointCSManager()->RegisterEmAdjointModel(this);
second_part_of_same_type =false;
theDirectEMModel=0;
mass_ratio_product=1.;
mass_ratio_projectile=1.;
}
////////////////////////////////////////////////////////////////////////////////
//
@@ -73,7 +77,49 @@ G4double G4VEmAdjointModel::AdjointCrossSection(const G4MaterialCutsCouple* aCou
return lastCS;
}
}
////////////////////////////////////////////////////////////////////////////////
//
G4double G4VEmAdjointModel::GetAdjointCrossSection(const G4MaterialCutsCouple* aCouple,
G4double primEnergy,
G4bool IsScatProjToProjCase)
{
return AdjointCrossSection(aCouple, primEnergy,
IsScatProjToProjCase);
//To continue
DefineCurrentMaterial(aCouple);
preStepEnergy=primEnergy;
if (IsScatProjToProjCase){
G4double ekin=primEnergy*mass_ratio_projectile;
lastCS = G4AdjointCSManager::GetAdjointCSManager()->GetAdjointSigma(ekin, model_index,true, aCouple);
lastAdjointCSForScatProjToProjCase = lastCS;
//G4cout<<ekin<<std::endl;
}
else {
G4double ekin=primEnergy*mass_ratio_product;
lastCS = G4AdjointCSManager::GetAdjointCSManager()->GetAdjointSigma(ekin, model_index,false, aCouple);
lastAdjointCSForProdToProjCase = lastCS;
//G4cout<<ekin<<std::endl;
}
/* G4double ratio=lastCS;
G4cout<<"Model name"<<name;
G4cout<<" LastCS Get "<<lastCS;
G4cout<<" Energy "<<primEnergy;*/
/*G4double lastCS1 = AdjointCrossSection(aCouple,
primEnergy,
IsScatProjToProjCase);
if (lastCS1 >0) {
G4double ratio=lastCS/lastCS1;
G4double diff = std::abs(1-ratio)*100.;
if (diff >1) G4cout<<primEnergy <<" diff"<<diff<<'\t'<<lastCS<<'\t'<<lastCS1<<'\t'<<name<<'\t'<<IsScatProjToProjCase<<std::endl;
}
//G4cout<<" LastCS Compute "<<lastCS1<<std::endl;
*/
return lastCS;
}
////////////////////////////////////////////////////////////////////////////////
//
//General implementation correct for energy loss process, for the photoelectric and compton scattering the method should be redefine
@@ -601,10 +647,10 @@ void G4VEmAdjointModel::CorrectPostStepWeight(G4ParticleChange* fParticleChange,
lastCS=lastAdjointCSForScatProjToProjCase;
if ( !IsScatProjToProjCase) lastCS=lastAdjointCSForProdToProjCase;
if (adjointPrimKinEnergy !=preStepEnergy){ //Is that in all cases needed???
if ((adjointPrimKinEnergy-preStepEnergy)/preStepEnergy>0.001){ //Is that in all cases needed???
G4double post_stepCS=AdjointCrossSection(currentCouple, adjointPrimKinEnergy
,IsScatProjToProjCase );
w_corr*=post_stepCS/lastCS;
if (post_stepCS>0 && lastCS>0) w_corr*=post_stepCS/lastCS;
}
new_weight*=w_corr;
@@ -654,36 +700,18 @@ void G4VEmAdjointModel::DefineCurrentMaterial(const G4MaterialCutsCouple* coupl
currentCoupleIndex = couple->GetIndex();
currentMaterialIndex = currentMaterial->GetIndex();
size_t idx=56;
currentTcutForDirectPrim =0.00000000001;
if (theAdjEquivOfDirectPrimPartDef) {
if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_gamma") idx = 0;
else if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_e-") idx = 1;
else if (theAdjEquivOfDirectPrimPartDef->GetParticleName() == "adj_e+") idx = 2;
currentTcutForDirectSecond =0.00000000001;
if (theAdjEquivOfDirectSecondPartDef) {
if (theAdjEquivOfDirectSecondPartDef == G4AdjointGamma::AdjointGamma()) idx = 0;
else if (theAdjEquivOfDirectSecondPartDef == G4AdjointElectron::AdjointElectron()) idx = 1;
else if (theAdjEquivOfDirectSecondPartDef == G4AdjointPositron::AdjointPositron()) idx = 2;
if (idx <56){
const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
currentTcutForDirectPrim=(*aVec)[currentCoupleIndex];
currentTcutForDirectSecond=(*aVec)[currentCoupleIndex];
}
}
currentTcutForDirectSecond =0.00000000001;
if (theAdjEquivOfDirectPrimPartDef == theAdjEquivOfDirectSecondPartDef) {
currentTcutForDirectSecond = currentTcutForDirectPrim;
}
else {
if (theAdjEquivOfDirectSecondPartDef){
if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_gamma") idx = 0;
else if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_e-") idx = 1;
else if (theAdjEquivOfDirectSecondPartDef->GetParticleName() == "adj_e+") idx = 2;
const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
currentTcutForDirectSecond=(*aVec)[currentCoupleIndex];
if (idx <56){
const std::vector<G4double>* aVec = G4ProductionCutsTable::GetProductionCutsTable()->GetEnergyCutsVector(idx);
currentTcutForDirectPrim=(*aVec)[currentCoupleIndex];
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////