Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PolarizationMessenger.cc 68046 2013-03-13 14:31:38Z gcosmo $
// $Id: G4PolarizationMessenger.cc 81375 2014-05-27 13:08:40Z gcosmo $
//
//
// GEANT4 Class file
@@ -76,7 +76,6 @@ G4PolarizationMessenger::G4PolarizationMessenger(G4PolarizationManager * polMgr)
optActivateCmd->SetParameterName("flag",true);
optActivateCmd->SetDefaultValue(true);
volumeDirectory = new G4UIdirectory("/polarization/volume/");
volumeDirectory->SetGuidance("Status control commands of registered polarized logical volumes.");
@@ -111,13 +110,23 @@ G4PolarizationMessenger::G4PolarizationMessenger(G4PolarizationManager * polMgr)
testPolarizationTransformationCmd->SetGuidance("checks definition of particle reference frame and corresponding translation routines");
testPolarizationTransformationCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
testInteractionFrameCmd = new G4UIcmdWithoutParameter("/polarization/test/interactionFrame",this);
testInteractionFrameCmd->SetGuidance("checks definition of interaction frame");
testInteractionFrameCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed);
}
G4PolarizationMessenger::~G4PolarizationMessenger()
{
delete verboseCmd;
delete testInteractionFrameCmd;
delete testPolarizationTransformationCmd;
delete testDirectory;
delete setPolarizationCmd;
delete printVolumeListCmd;
delete volumeDirectory;
delete optActivateCmd;
delete managerDirectory;
delete polarizationDirectory;
}
void G4PolarizationMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PolarizedCompton.cc 76244 2013-11-08 11:12:59Z gcosmo $
// $Id: G4PolarizedCompton.cc 85018 2014-10-23 09:51:37Z gcosmo $
//
//
// File name: G4PolarizedCompton
@@ -64,23 +64,26 @@
#include "G4PhysicsTableHelper.hh"
#include "G4KleinNishinaCompton.hh"
#include "G4PolarizedComptonModel.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4PhysicsTable* G4PolarizedCompton::theAsymmetryTable = 0;
G4PolarizedCompton::G4PolarizedCompton(const G4String& processName,
G4ProcessType type):
G4VEmProcess (processName, type),
buildAsymmetryTable(true),
useAsymmetryTable(true),
isInitialised(false),
selectedModel(0),
mType(10),
theAsymmetryTable(NULL)
mType(10)
{
SetLambdaBinning(90);
SetMinKinEnergy(0.1*keV);
SetMaxKinEnergy(100.0*GeV);
SetStartFromNullFlag(true);
SetBuildTableFlag(true);
SetSecondaryParticle(G4Electron::Electron());
SetProcessSubType(fComptonScattering);
SetMinKinEnergyPrim(1*MeV);
SetSplineFlag(true);
emModel = 0;
}
@@ -88,9 +91,7 @@ G4PolarizedCompton::G4PolarizedCompton(const G4String& processName,
G4PolarizedCompton::~G4PolarizedCompton()
{
if (theAsymmetryTable) {
delete theAsymmetryTable;
}
delete theAsymmetryTable;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -99,16 +100,16 @@ void G4PolarizedCompton::InitialiseProcess(const G4ParticleDefinition*)
{
if(!isInitialised) {
isInitialised = true;
SetBuildTableFlag(true);
SetSecondaryParticle(G4Electron::Electron());
G4double emin = MinKinEnergy();
G4double emax = MaxKinEnergy();
emModel = new G4PolarizedComptonModel();
if(0 == mType) selectedModel = new G4KleinNishinaCompton();
else if(10 == mType) selectedModel = emModel;
selectedModel->SetLowEnergyLimit(emin);
selectedModel->SetHighEnergyLimit(emax);
AddEmModel(1, selectedModel);
if(0 == mType) {
if(!EmModel(1)) { SetEmModel(new G4KleinNishinaCompton(), 1); }
} else {
emModel = new G4PolarizedComptonModel();
SetEmModel(emModel, 1);
}
G4EmParameters* param = G4EmParameters::Instance();
EmModel(1)->SetLowEnergyLimit(param->MinKinEnergy());
EmModel(1)->SetHighEnergyLimit(param->MaxKinEnergy());
AddEmModel(1, EmModel(1));
}
}
@@ -118,7 +119,7 @@ void G4PolarizedCompton::PrintInfo()
{
G4cout << " Total cross sections has a good parametrisation"
<< " from 10 KeV to (100/Z) GeV"
<< "\n Sampling according " << selectedModel->GetName() << " model"
<< "\n Sampling according " << EmModel(1)->GetName() << " model"
<< G4endl;
}
@@ -126,15 +127,11 @@ void G4PolarizedCompton::PrintInfo()
void G4PolarizedCompton::SetModel(const G4String& ss)
{
if(ss == "Klein-Nishina") mType = 0;
if(ss == "Polarized-Compton") mType = 10;
if(ss == "Klein-Nishina") { mType = 0; }
if(ss == "Polarized-Compton") { mType = 10; }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4PolarizedCompton::GetMeanFreePath(
const G4Track& aTrack,
@@ -144,66 +141,64 @@ G4double G4PolarizedCompton::GetMeanFreePath(
// *** get unploarised mean free path from lambda table ***
G4double mfp = G4VEmProcess::GetMeanFreePath(aTrack, previousStepSize, condition);
if (theAsymmetryTable && useAsymmetryTable) {
// *** get asymmetry, if target is polarized ***
const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle();
const G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
const G4StokesVector GammaPolarization = aTrack.GetPolarization();
const G4ParticleMomentum GammaDirection0 = aDynamicGamma->GetMomentumDirection();
if (theAsymmetryTable && useAsymmetryTable) {
// *** get asymmetry, if target is polarized ***
const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle();
const G4double GammaEnergy = aDynamicGamma->GetKineticEnergy();
const G4StokesVector GammaPolarization = aTrack.GetPolarization();
const G4ParticleMomentum GammaDirection0 = aDynamicGamma->GetMomentumDirection();
G4Material* aMaterial = aTrack.GetMaterial();
G4VPhysicalVolume* aPVolume = aTrack.GetVolume();
G4LogicalVolume* aLVolume = aPVolume->GetLogicalVolume();
G4Material* aMaterial = aTrack.GetMaterial();
G4VPhysicalVolume* aPVolume = aTrack.GetVolume();
G4LogicalVolume* aLVolume = aPVolume->GetLogicalVolume();
// G4Material* bMaterial = aLVolume->GetMaterial();
G4PolarizationManager * polarizationManger = G4PolarizationManager::GetInstance();
// G4Material* bMaterial = aLVolume->GetMaterial();
G4PolarizationManager * polarizationManger = G4PolarizationManager::GetInstance();
const G4bool VolumeIsPolarized = polarizationManger->IsPolarized(aLVolume);
G4StokesVector ElectronPolarization = polarizationManger->GetVolumePolarization(aLVolume);
if (!VolumeIsPolarized || mfp == DBL_MAX) return mfp;
G4bool VolumeIsPolarized = polarizationManger->IsPolarized(aLVolume);
G4StokesVector ElectronPolarization = polarizationManger->GetVolumePolarization(aLVolume);
if (verboseLevel>=2) {
G4cout << " Mom " << GammaDirection0 << G4endl;
G4cout << " Polarization " << GammaPolarization << G4endl;
G4cout << " MaterialPol. " << ElectronPolarization << G4endl;
G4cout << " Phys. Volume " << aPVolume->GetName() << G4endl;
G4cout << " Log. Volume " << aLVolume->GetName() << G4endl;
G4cout << " Material " << aMaterial << G4endl;
}
G4int midx= CurrentMaterialCutsCoupleIndex();
G4PhysicsVector * aVector=(*theAsymmetryTable)(midx);
if (!VolumeIsPolarized || mfp == DBL_MAX) return mfp;
G4double asymmetry=0;
if (aVector) {
G4bool isOutRange;
asymmetry = aVector->GetValue(GammaEnergy, isOutRange);
} else {
G4cout << " MaterialIndex " << midx << " is out of range \n";
asymmetry=0;
}
if (verboseLevel>=2) {
// we have to determine angle between particle motion
// and target polarisation here
// circ pol * Vec(ElectronPol)*Vec(PhotonMomentum)
// both vectors in global reference frame
G4cout << " Mom " << GammaDirection0 << G4endl;
G4cout << " Polarization " << GammaPolarization << G4endl;
G4cout << " MaterialPol. " << ElectronPolarization << G4endl;
G4cout << " Phys. Volume " << aPVolume->GetName() << G4endl;
G4cout << " Log. Volume " << aLVolume->GetName() << G4endl;
G4cout << " Material " << aMaterial << G4endl;
}
G4int midx= CurrentMaterialCutsCoupleIndex();
G4PhysicsVector * aVector=(*theAsymmetryTable)(midx);
G4double pol=ElectronPolarization*GammaDirection0;
G4double asymmetry=0;
if (aVector) {
asymmetry = aVector->Value(GammaEnergy);
} else {
G4cout << " MaterialIndex " << midx << " is out of range \n";
asymmetry=0;
}
// we have to determine angle between particle motion
// and target polarisation here
// circ pol * Vec(ElectronPol)*Vec(PhotonMomentum)
// both vectors in global reference frame
G4double polProduct = GammaPolarization.p3() * pol;
mfp *= 1. / ( 1. + polProduct * asymmetry );
G4double pol=ElectronPolarization*GammaDirection0;
G4double polProduct = GammaPolarization.p3() * pol;
mfp *= 1. / ( 1. + polProduct * asymmetry );
if (verboseLevel>=2) {
G4cout << " MeanFreePath: " << mfp / mm << " mm " << G4endl;
G4cout << " Asymmetry: " << asymmetry << G4endl;
G4cout << " PolProduct: " << polProduct << G4endl;
}
}
if (verboseLevel>=2) {
G4cout << " MeanFreePath: " << mfp / mm << " mm " << G4endl;
G4cout << " Asymmetry: " << asymmetry << G4endl;
G4cout << " PolProduct: " << polProduct << G4endl;
}
}
return mfp;
return mfp;
}
G4double G4PolarizedCompton::PostStepGetPhysicalInteractionLength(
@@ -249,8 +244,7 @@ G4double G4PolarizedCompton::PostStepGetPhysicalInteractionLength(
G4double asymmetry=0;
if (aVector) {
G4bool isOutRange;
asymmetry = aVector->GetValue(GammaEnergy, isOutRange);
asymmetry = aVector->Value(GammaEnergy);
} else {
G4cout << " MaterialIndex " << midx << " is out of range \n";
asymmetry=0;
@@ -281,8 +275,17 @@ G4double G4PolarizedCompton::PostStepGetPhysicalInteractionLength(
void G4PolarizedCompton::PreparePhysicsTable(const G4ParticleDefinition& part)
{
G4VEmProcess::PreparePhysicsTable(part);
if(buildAsymmetryTable)
theAsymmetryTable = G4PhysicsTableHelper::PreparePhysicsTable(theAsymmetryTable);
if(buildAsymmetryTable && emModel) {
G4bool isMaster = true;
const G4PolarizedCompton* masterProcess =
static_cast<const G4PolarizedCompton*>(GetMasterProcess());
if(masterProcess && masterProcess != this) { isMaster = false; }
if(isMaster) {
theAsymmetryTable =
G4PhysicsTableHelper::PreparePhysicsTable(theAsymmetryTable);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -292,8 +295,13 @@ void G4PolarizedCompton::BuildPhysicsTable(const G4ParticleDefinition& part)
{
// *** build (unpolarized) cross section tables (Lambda)
G4VEmProcess::BuildPhysicsTable(part);
if(buildAsymmetryTable)
BuildAsymmetryTable(part);
if(buildAsymmetryTable && emModel) {
G4bool isMaster = true;
const G4PolarizedCompton* masterProcess =
static_cast<const G4PolarizedCompton*>(GetMasterProcess());
if(masterProcess && masterProcess != this) { isMaster = false; }
if(isMaster) { BuildAsymmetryTable(part); }
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -305,37 +313,47 @@ void G4PolarizedCompton::BuildAsymmetryTable(const G4ParticleDefinition& part)
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if(!theAsymmetryTable) { return; }
G4int nbins = LambdaBinning();
G4double emin = MinKinEnergy();
G4double emax = MaxKinEnergy();
G4PhysicsLogVector* aVector = 0;
G4PhysicsLogVector* bVector = 0;
for(size_t i=0; i<numOfCouples; ++i) {
if (!theAsymmetryTable) break;
if (theAsymmetryTable->GetFlag(i)) {
// create physics vector and fill it
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
// use same parameters as for lambda
G4PhysicsVector* aVector = LambdaPhysicsVector(couple);
// modelManager->FillLambdaVector(aVector, couple, startFromNull);
for (G4int j = 0 ; j < LambdaBinning() ; ++j ) {
G4double lowEdgeEnergy = aVector->GetLowEdgeEnergy(j);
G4double tasm=0.;
G4double asym = ComputeAsymmetry(lowEdgeEnergy, couple, part, 0., tasm);
aVector->PutValue(j,asym);
if(!aVector) {
aVector = new G4PhysicsLogVector(emin, emax, nbins);
aVector->SetSpline(true);
bVector = aVector;
} else {
bVector = new G4PhysicsLogVector(*aVector);
}
G4PhysicsTableHelper::SetPhysicsVector(theAsymmetryTable, i, aVector);
for (G4int j = 0; j <= nbins; ++j ) {
G4double energy = bVector->Energy(j);
G4double tasm=0.;
G4double asym = ComputeAsymmetry(energy, couple, part, 0., tasm);
bVector->PutValue(j,asym);
}
G4PhysicsTableHelper::SetPhysicsVector(theAsymmetryTable, i, bVector);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4PolarizedCompton::ComputeAsymmetry(G4double energy,
const G4MaterialCutsCouple* couple,
const G4ParticleDefinition& aParticle,
G4double cut,
G4double & tAsymmetry)
const G4MaterialCutsCouple* couple,
const G4ParticleDefinition& aParticle,
G4double cut,
G4double & tAsymmetry)
{
G4double lAsymmetry = 0.0;
tAsymmetry=0;
@@ -357,8 +375,8 @@ G4double G4PolarizedCompton::ComputeAsymmetry(G4double energy,
G4double sigma0=emModel->CrossSection(couple,&aParticle,energy,cut,energy);
// determine assymmetries
if (sigma0>0.) {
lAsymmetry=sigma2/sigma0-1.;
if (sigma0 > 0.) {
lAsymmetry = sigma2/sigma0-1.;
}
return lAsymmetry;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PolarizedComptonModel.cc 68046 2013-03-13 14:31:38Z gcosmo $
// $Id: G4PolarizedComptonModel.cc 82755 2014-07-08 14:07:29Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -65,39 +65,37 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PolarizedComptonModel::G4PolarizedComptonModel(const G4ParticleDefinition*,
const G4String& nam)
const G4String& nam)
: G4KleinNishinaCompton(0,nam),
verboseLevel(0)
{
crossSectionCalculator=new G4PolarizedComptonCrossSection();
crossSectionCalculator = new G4PolarizedComptonCrossSection();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4PolarizedComptonModel::~G4PolarizedComptonModel()
{
if (crossSectionCalculator) delete crossSectionCalculator;
delete crossSectionCalculator;
}
G4double G4PolarizedComptonModel::ComputeAsymmetryPerAtom
(G4double gammaEnergy, G4double /*Z*/)
{
G4double asymmetry = 0.0 ;
G4double asymmetry = 0.0 ;
G4double k0 = gammaEnergy / electron_mass_c2 ;
G4double k1 = 1 + 2*k0 ;
G4double k0 = gammaEnergy / electron_mass_c2 ;
G4double k1 = 1 + 2*k0 ;
asymmetry = -k0;
asymmetry *= (k0 + 1.)*sqr(k1)*std::log(k1) - 2.*k0*(5.*sqr(k0) + 4.*k0 + 1.);
asymmetry /= ((k0 - 2.)*k0 -2.)*sqr(k1)*std::log(k1) + 2.*k0*(k0*(k0 + 1.)*(k0 + 8.) + 2.);
asymmetry = -k0;
asymmetry *= (k0 + 1.)*sqr(k1)*std::log(k1) - 2.*k0*(5.*sqr(k0) + 4.*k0 + 1.);
asymmetry /= ((k0 - 2.)*k0 -2.)*sqr(k1)*std::log(k1) + 2.*k0*(k0*(k0 + 1.)*(k0 + 8.) + 2.);
// G4cout<<"energy = "<<GammaEnergy<<" asymmetry = "<<asymmetry<<"\t\t GAM = "<<k0<<G4endl;
if (asymmetry>1.) G4cout<<"ERROR in G4PolarizedComptonModel::ComputeAsymmetryPerAtom"<<G4endl;
// G4cout<<"energy = "<<GammaEnergy<<" asymmetry = "<<asymmetry<<"\t\t GAM = "<<k0<<G4endl;
if (asymmetry>1.) G4cout<<"ERROR in G4PolarizedComptonModel::ComputeAsymmetryPerAtom"<<G4endl;
return asymmetry;
return asymmetry;
}
@@ -113,39 +111,43 @@ G4double G4PolarizedComptonModel::ComputeCrossSectionPerAtom(
G4KleinNishinaCompton::ComputeCrossSectionPerAtom(pd,kinEnergy,
Z,A,cut,emax);
G4double polzz = theBeamPolarization.p3()*theTargetPolarization.z();
if (polzz!=0) {
G4double asym=ComputeAsymmetryPerAtom(kinEnergy, Z);
if (polzz > 0.0) {
G4double asym = ComputeAsymmetryPerAtom(kinEnergy, Z);
xs*=(1.+polzz*asym);
}
return xs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>* fvect,
const G4MaterialCutsCouple*,
const G4DynamicParticle* aDynamicGamma,
G4double,
G4double)
void G4PolarizedComptonModel::SampleSecondaries(
std::vector<G4DynamicParticle*>* fvect,
const G4MaterialCutsCouple*,
const G4DynamicParticle* aDynamicGamma,
G4double, G4double)
{
// do nothing below the threshold
if(aDynamicGamma->GetKineticEnergy() <= LowEnergyLimit()) { return; }
const G4Track * aTrack = fParticleChange->GetCurrentTrack();
G4VPhysicalVolume* aPVolume = aTrack->GetVolume();
G4LogicalVolume* aLVolume = aPVolume->GetLogicalVolume();
if (verboseLevel>=1)
if (verboseLevel >= 1) {
G4cout<<"G4PolarizedComptonModel::SampleSecondaries in "
<< aLVolume->GetName() <<G4endl;
G4PolarizationManager * polarizationManager = G4PolarizationManager::GetInstance();
}
G4PolarizationManager * polarizationManager =
G4PolarizationManager::GetInstance();
// obtain polarization of the beam
theBeamPolarization = aDynamicGamma->GetPolarization();
theBeamPolarization.SetPhoton();
// obtain polarization of the media
const G4bool targetIsPolarized = polarizationManager->IsPolarized(aLVolume);
theTargetPolarization = polarizationManager->GetVolumePolarization(aLVolume);
G4bool targetIsPolarized = polarizationManager->IsPolarized(aLVolume);
theTargetPolarization =
polarizationManager->GetVolumePolarization(aLVolume);
// if beam is linear polarized or target is transversely polarized
// determine the angle to x-axis
@@ -155,10 +157,11 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
// transfere theTargetPolarization
// into the gamma frame (problem electron is at rest)
if (targetIsPolarized)
if (targetIsPolarized) {
theTargetPolarization.rotateUz(gamDirection0);
// The scattered gamma energy is sampled according to Klein - Nishina formula.
}
// The scattered gamma energy is sampled according to
// Klein - Nishina formula.
// The random number techniques of Butcher & Messel are used
// (Nuc Phys 20(1960),15).
// Note : Effects due to binding of atomic electrons are negliged.
@@ -166,7 +169,6 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
G4double gamEnergy0 = aDynamicGamma->GetKineticEnergy();
G4double E0_m = gamEnergy0 / electron_mass_c2 ;
//
// sample the energy rate of the scattered gamma
//
@@ -178,8 +180,15 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
G4double alpha1 = - std::log(eps0);
G4double alpha2 = 0.5*(1.- epsilon0sq);
G4double polarization = theBeamPolarization.p3()*theTargetPolarization.p3();
G4double polarization =
theBeamPolarization.p3()*theTargetPolarization.p3();
G4int nloop = 0;
do {
++nloop;
// false interaction if too many iterations
if(nloop > 1000) { return; }
if ( alpha1/(alpha1+alpha2) > G4UniformRand() ) {
epsilon = std::exp(-alpha1*G4UniformRand()); // epsilon0**r
epsilonsq = epsilon*epsilon;
@@ -187,21 +196,22 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
} else {
epsilonsq = epsilon0sq + (1.- epsilon0sq)*G4UniformRand();
epsilon = std::sqrt(epsilonsq);
};
}
onecost = (1.- epsilon)/(epsilon*E0_m);
sint2 = onecost*(2.-onecost);
G4double gdiced = 2.*(1./epsilon+epsilon);
G4double gdist = 1./epsilon + epsilon - sint2
- polarization*(1./epsilon-epsilon)*(1.-onecost);
greject = gdist/gdiced;
if (greject>1) G4cout<<"ERROR in PolarizedComptonScattering::PostStepDoIt\n"
<<" costh rejection does not work properly: "<<greject<<G4endl;
if (greject>1) {
G4cout<<"ERROR in PolarizedComptonScattering::PostStepDoIt\n"
<<" costh rejection does not work properly: "<<greject
<<G4endl;
}
} while (greject < G4UniformRand());
//
@@ -212,26 +222,32 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
G4double sinTeta = std::sqrt (sint2);
G4double Phi;
do {
Phi = twopi * G4UniformRand();
G4double gdiced = 1./epsilon + epsilon - sint2
++nloop;
// false interaction if too many iterations
if(nloop > 1000) { return; }
Phi = twopi * G4UniformRand();
G4double gdiced = 1./epsilon + epsilon - sint2
+ std::abs(theBeamPolarization.p3())*
( std::abs((1./epsilon-epsilon)*cosTeta*theTargetPolarization.p3())
+(1.-epsilon)*sinTeta*(std::sqrt(sqr(theTargetPolarization.p1())
+ sqr(theTargetPolarization.p2()))))
+sint2*(std::sqrt(sqr(theBeamPolarization.p1()) + sqr(theBeamPolarization.p2())));
+sint2*(std::sqrt(sqr(theBeamPolarization.p1()) +
sqr(theBeamPolarization.p2())));
G4double gdist = 1./epsilon + epsilon - sint2
G4double gdist = 1./epsilon + epsilon - sint2
+ theBeamPolarization.p3()*
((1./epsilon-epsilon)*cosTeta*theTargetPolarization.p3()
+(1.-epsilon)*sinTeta*(std::cos(Phi)*theTargetPolarization.p1()+
std::sin(Phi)*theTargetPolarization.p2()))
-sint2*(std::cos(2.*Phi)*theBeamPolarization.p1()
+std::sin(2.*Phi)*theBeamPolarization.p2());
greject = gdist/gdiced;
if (greject>1.+1.e-10 || greject<0) G4cout<<"ERROR in PolarizedComptonScattering::PostStepDoIt\n"
<<" phi rejection does not work properly: "<<greject<<G4endl;
greject = gdist/gdiced;
if (greject>1.+1.e-10 || greject<0) {
G4cout<<"ERROR in PolarizedComptonScattering::PostStepDoIt\n"
<<" phi rejection does not work properly: "<<greject<<G4endl;
}
if (greject<1.e-3) {
G4cout<<"ERROR in PolarizedComptonScattering::PostStepDoIt\n"
<<" phi rejection does not work properly: "<<greject<<"\n";
@@ -241,7 +257,8 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
}
} while (greject < G4UniformRand());
G4double dirx = sinTeta*std::cos(Phi), diry = sinTeta*std::sin(Phi), dirz = cosTeta;
G4double dirx = sinTeta*std::cos(Phi), diry = sinTeta*std::sin(Phi),
dirz = cosTeta;
//
// update G4VParticleChange for the scattered gamma
@@ -250,72 +267,56 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
G4ThreeVector gamDirection1 ( dirx,diry,dirz );
gamDirection1.rotateUz(gamDirection0);
G4double gamEnergy1 = epsilon*gamEnergy0;
fParticleChange->SetProposedKineticEnergy(gamEnergy1);
if(gamEnergy1 > lowestGammaEnergy) {
G4double edep = 0.0;
if(gamEnergy1 > lowestSecondaryEnergy) {
fParticleChange->ProposeMomentumDirection(gamDirection1);
fParticleChange->SetProposedKineticEnergy(gamEnergy1);
} else {
fParticleChange->ProposeTrackStatus(fStopAndKill);
gamEnergy1 += fParticleChange->GetLocalEnergyDeposit();
fParticleChange->ProposeLocalEnergyDeposit(gamEnergy1);
fParticleChange->SetProposedKineticEnergy(0.0);
edep = gamEnergy1;
}
//
// kinematic of the scattered electron
//
G4double eKinEnergy = gamEnergy0 - gamEnergy1;
G4ThreeVector eDirection = gamEnergy0*gamDirection0 - gamEnergy1*gamDirection1;
eDirection = eDirection.unit();
//
// calculate Stokesvector of final state photon and electron
//
G4ThreeVector nInteractionFrame;
if((gamEnergy1 > lowestGammaEnergy) ||
(eKinEnergy > DBL_MIN)) {
G4ThreeVector nInteractionFrame =
G4PolarizationHelper::GetFrame(gamDirection1,gamDirection0);
// determine interaction plane
// nInteractionFrame =
// G4PolarizationHelper::GetFrame(gamDirection1,eDirection);
if (gamEnergy1 > lowestGammaEnergy)
nInteractionFrame = G4PolarizationHelper::GetFrame(gamDirection1,gamDirection0);
else
nInteractionFrame = G4PolarizationHelper::GetFrame(gamDirection0, eDirection);
// transfere theBeamPolarization and theTargetPolarization
// into the interaction frame (note electron is in gamma frame)
if (verboseLevel>=1) {
G4cout << "========================================\n";
G4cout << " nInteractionFrame = " <<nInteractionFrame<<"\n";
G4cout << " GammaDirection0 = " <<gamDirection0<<"\n";
G4cout << " gammaPolarization = " <<theBeamPolarization<<"\n";
G4cout << " electronPolarization = " <<theTargetPolarization<<"\n";
}
theBeamPolarization.InvRotateAz(nInteractionFrame,gamDirection0);
theTargetPolarization.InvRotateAz(nInteractionFrame,gamDirection0);
if (verboseLevel>=1) {
G4cout << "----------------------------------------\n";
G4cout << " gammaPolarization = " <<theBeamPolarization<<"\n";
G4cout << " electronPolarization = " <<theTargetPolarization<<"\n";
G4cout << "----------------------------------------\n";
}
// initialize the polarization transfer matrix
crossSectionCalculator->Initialize(epsilon,E0_m,0.,
theBeamPolarization,
theTargetPolarization,2);
// transfere theBeamPolarization and theTargetPolarization
// into the interaction frame (note electron is in gamma frame)
if (verboseLevel>=1) {
G4cout << "========================================\n";
G4cout << " nInteractionFrame = " <<nInteractionFrame<<"\n";
G4cout << " GammaDirection0 = " <<gamDirection0<<"\n";
G4cout << " gammaPolarization = " <<theBeamPolarization<<"\n";
G4cout << " electronPolarization = " <<theTargetPolarization<<"\n";
}
// if(eKinEnergy > DBL_MIN)
{
theBeamPolarization.InvRotateAz(nInteractionFrame,gamDirection0);
theTargetPolarization.InvRotateAz(nInteractionFrame,gamDirection0);
if (verboseLevel>=1) {
G4cout << "----------------------------------------\n";
G4cout << " gammaPolarization = " <<theBeamPolarization<<"\n";
G4cout << " electronPolarization = " <<theTargetPolarization<<"\n";
G4cout << "----------------------------------------\n";
}
// initialize the polarization transfer matrix
crossSectionCalculator->Initialize(epsilon,E0_m,0.,
theBeamPolarization,
theTargetPolarization,2);
if(gamEnergy1 > lowestSecondaryEnergy) {
// in interaction frame
// calculate polarization transfer to the photon (in interaction plane)
finalGammaPolarization = crossSectionCalculator->GetPol2();
if (verboseLevel>=1) G4cout << " gammaPolarization1 = " <<finalGammaPolarization<<"\n";
if (verboseLevel>=1) {
G4cout << " gammaPolarization1 = " <<finalGammaPolarization<<"\n";
}
finalGammaPolarization.SetPhoton();
// translate polarization into particle reference frame
@@ -325,7 +326,8 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
if (finalGammaPolarization.mag() > 1.+1.e-8){
G4cout<<"ERROR in Polarizaed Compton Scattering !"<<G4endl;
G4cout<<"Polarization of final photon more than 100%"<<G4endl;
G4cout<<finalGammaPolarization<<" mag = "<<finalGammaPolarization.mag()<<G4endl;
G4cout<<finalGammaPolarization<<" mag = "
<<finalGammaPolarization.mag()<<G4endl;
}
if (verboseLevel>=1) {
G4cout << " gammaPolarization1 = " <<finalGammaPolarization<<"\n";
@@ -333,37 +335,50 @@ void G4PolarizedComptonModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
}
}
// if (ElecKineEnergy > fminimalEnergy) {
{
finalElectronPolarization = crossSectionCalculator->GetPol3();
if (verboseLevel>=1)
G4cout << " electronPolarization1 = " <<finalElectronPolarization<<"\n";
//
// kinematic of the scattered electron
//
G4double eKinEnergy = gamEnergy0 - gamEnergy1;
if (eKinEnergy > lowestSecondaryEnergy) {
G4ThreeVector eDirection =
gamEnergy0*gamDirection0 - gamEnergy1*gamDirection1;
eDirection = eDirection.unit();
finalElectronPolarization = crossSectionCalculator->GetPol3();
if (verboseLevel>=1) {
G4cout << " electronPolarization1 = "
<<finalElectronPolarization<<"\n";
}
// transfer into particle reference frame
finalElectronPolarization.RotateAz(nInteractionFrame,eDirection);
if (verboseLevel>=1) {
G4cout << " electronPolarization1 = " <<finalElectronPolarization<<"\n";
G4cout << " electronPolarization1 = "
<<finalElectronPolarization<<"\n";
G4cout << " ElecDirection = " <<eDirection<<"\n";
}
}
if (verboseLevel>=1)
G4cout << "========================================\n";
if(eKinEnergy > DBL_MIN) {
// create G4DynamicParticle object for the electron.
G4DynamicParticle* aElectron = new G4DynamicParticle(theElectron,eDirection,eKinEnergy);
G4DynamicParticle* aElectron =
new G4DynamicParticle(theElectron,eDirection,eKinEnergy);
//store polarization vector
if (finalElectronPolarization.mag() > 1.+1.e-8){
G4cout<<"ERROR in Polarizaed Compton Scattering !"<<G4endl;
G4cout<<"Polarization of final electron more than 100%"<<G4endl;
G4cout<<finalElectronPolarization<<" mag = "<<finalElectronPolarization.mag()<<G4endl;
G4cout<<finalElectronPolarization<<" mag = "
<<finalElectronPolarization.mag()<<G4endl;
}
aElectron->SetPolarization(finalElectronPolarization.p1(),
finalElectronPolarization.p2(),
finalElectronPolarization.p3());
fvect->push_back(aElectron);
} else {
edep += eKinEnergy;
}
// energy balance
if(edep > 0.0) {
fParticleChange->ProposeLocalEnergyDeposit(edep);
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PolarizedGammaConversion.cc 68046 2013-03-13 14:31:38Z gcosmo $
// $Id: G4PolarizedGammaConversion.cc 85018 2014-10-23 09:51:37Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -45,6 +45,7 @@
#include "G4SystemOfUnits.hh"
#include "G4PolarizedGammaConversionModel.hh"
#include "G4Electron.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -52,10 +53,12 @@ G4PolarizedGammaConversion::G4PolarizedGammaConversion(const G4String& processNa
G4ProcessType type):G4VEmProcess (processName, type),
isInitialised(false)
{
SetLambdaBinning(100);
SetMinKinEnergy(2.0*electron_mass_c2);
SetMaxKinEnergy(100.0*GeV);
SetLambdaBinning(220);
//SetMaxKinEnergy(100.0*GeV);
SetProcessSubType(fGammaConversion);
SetBuildTableFlag(true);
SetSecondaryParticle(G4Electron::Electron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -69,28 +72,19 @@ void G4PolarizedGammaConversion::InitialiseProcess(const G4ParticleDefinition*)
{
if(!isInitialised) {
isInitialised = true;
// SetVerboseLevel(1);
SetBuildTableFlag(true);
SetSecondaryParticle(G4Electron::Electron());
G4double emin = std::max(MinKinEnergy(), 2.0*electron_mass_c2);
SetMinKinEnergy(emin);
G4double emax = MaxKinEnergy();
// G4VEmModel* model = new G4BetheHeitlerModel();
G4VEmModel* model = new G4PolarizedGammaConversionModel();
model->SetLowEnergyLimit(emin);
model->SetHighEnergyLimit(emax);
AddEmModel(1, model);
G4EmParameters* param = G4EmParameters::Instance();
G4double emin = std::max(param->MinKinEnergy(), 2*electron_mass_c2);
G4double emax = param->MaxKinEnergy();
if(!EmModel(1)) { SetEmModel(new G4PolarizedGammaConversionModel(), 1); }
EmModel(1)->SetLowEnergyLimit(emin);
EmModel(1)->SetHighEnergyLimit(emax);
AddEmModel(1, EmModel(1));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4PolarizedGammaConversion::PrintInfo()
{
G4cout << " Total cross sections has a good parametrisation"
<< " from 1.5 MeV to 100 GeV for all Z;"
<< "\n sampling secondary e+e- according to the polarized compton cross section"
<< G4endl;
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4PolarizedPhotoElectricEffect.cc 68046 2013-03-13 14:31:38Z gcosmo $
// $Id: G4PolarizedPhotoElectricEffect.cc 85018 2014-10-23 09:51:37Z gcosmo $
//
//
//------------------ G4PolarizedPhotoElectricEffect physics process --
@@ -36,6 +36,7 @@
#include "G4PolarizedPhotoElectricEffect.hh"
#include "G4PolarizedPEEffectModel.hh"
#include "G4Electron.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -45,6 +46,8 @@ G4PolarizedPhotoElectricEffect::G4PolarizedPhotoElectricEffect(const G4String& p
G4ProcessType type):G4VEmProcess (processName, type),
isInitialised(false)
{
SetBuildTableFlag(false);
SetSecondaryParticle(G4Electron::Electron());
SetProcessSubType(fPhotoElectricEffect);
}
@@ -59,11 +62,10 @@ void G4PolarizedPhotoElectricEffect::InitialiseProcess(const G4ParticleDefinitio
{
if(!isInitialised) {
isInitialised = true;
SetBuildTableFlag(false);
SetSecondaryParticle(G4Electron::Electron());
if(!EmModel()) SetEmModel(new G4PolarizedPEEffectModel);
EmModel()->SetLowEnergyLimit(MinKinEnergy());
EmModel()->SetHighEnergyLimit(MaxKinEnergy());
G4EmParameters* param = G4EmParameters::Instance();
EmModel()->SetLowEnergyLimit(param->MinKinEnergy());
EmModel()->SetHighEnergyLimit(param->MaxKinEnergy());
AddEmModel(1, EmModel());
}
}
@@ -71,12 +73,7 @@ void G4PolarizedPhotoElectricEffect::InitialiseProcess(const G4ParticleDefinitio
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4PolarizedPhotoElectricEffect::PrintInfo()
{
G4cout
<< " Total cross sections from Sandia parametrisation. "
<< "\n Sampling according " << EmModel()->GetName() << " model"
<< G4endl;
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif // NOIONIZATIONAS
@@ -23,14 +23,14 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ePolarizedBremsstrahlung.cc 68046 2013-03-13 14:31:38Z gcosmo $
// $Id: G4ePolarizedBremsstrahlung.cc 85018 2014-10-23 09:51:37Z gcosmo $
//
// -------------------------------------------------------------------
//
// GEANT4 Class file
//
//
// File name: G4eBremsstrahlung
// File name: G4ePolarizedBremsstrahlung
//
// Author: Karim Laihem
//
@@ -54,6 +54,7 @@
#include "G4ProductionCutsTable.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -62,8 +63,9 @@ G4ePolarizedBremsstrahlung::G4ePolarizedBremsstrahlung(const G4String& name):
{}
void G4ePolarizedBremsstrahlung::InitialiseEnergyLossProcess(const G4ParticleDefinition*,
const G4ParticleDefinition*)
void G4ePolarizedBremsstrahlung::InitialiseEnergyLossProcess(
const G4ParticleDefinition*,
const G4ParticleDefinition*)
{
if(!isInitialised) {
isInitialised = true;
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ePolarizedIonisation.cc 76472 2013-11-11 10:34:07Z gcosmo $
// $Id: G4ePolarizedIonisation.cc 85018 2014-10-23 09:51:37Z gcosmo $
// -------------------------------------------------------------------
//
// GEANT4 Class file
@@ -61,6 +61,7 @@
#include "G4PolarizationManager.hh"
#include "G4PolarizationHelper.hh"
#include "G4StokesVector.hh"
#include "G4EmParameters.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -73,14 +74,8 @@ G4ePolarizedIonisation::G4ePolarizedIonisation(const G4String& name)
theTransverseAsymmetryTable(NULL)
{
verboseLevel=0;
// SetDEDXBinning(120);
// SetLambdaBinning(120);
// numBinAsymmetryTable=78;
// SetMinKinEnergy(0.1*keV);
// SetMaxKinEnergy(100.0*TeV);
// PrintInfoDefinition();
SetProcessSubType(fIonisation);
SetSecondaryParticle(theElectron);
flucModel = 0;
emModel = 0;
}
@@ -101,18 +96,16 @@ void G4ePolarizedIonisation::InitialiseEnergyLossProcess(
{
if(!isInitialised) {
if(part == G4Positron::Positron()) isElectron = false;
SetSecondaryParticle(theElectron);
if(part == G4Positron::Positron()) { isElectron = false; }
if (!FluctModel()) { SetFluctModel(new G4UniversalFluctuation()); }
flucModel = FluctModel();
flucModel = new G4UniversalFluctuation();
//flucModel = new G4BohrFluctuations();
// G4VEmModel* em = new G4MollerBhabhaModel();
emModel = new G4PolarizedMollerBhabhaModel;
emModel->SetLowEnergyLimit(MinKinEnergy());
emModel->SetHighEnergyLimit(MaxKinEnergy());
emModel = new G4PolarizedMollerBhabhaModel();
SetEmModel(emModel, 1);
G4EmParameters* param = G4EmParameters::Instance();
emModel->SetLowEnergyLimit(param->MinKinEnergy());
emModel->SetHighEnergyLimit(param->MaxKinEnergy());
AddEmModel(1, emModel, flucModel);
isInitialised = true;
@@ -122,11 +115,7 @@ void G4ePolarizedIonisation::InitialiseEnergyLossProcess(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4ePolarizedIonisation::PrintInfo()
{
G4cout << " Delta cross sections from Moller+Bhabha, "
<< "good description from 1 KeV to 100 GeV."
<< G4endl;
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....