92 buildLambdaTable(true),
95 theLambdaTablePrim(0),
100 startFromNull(false),
110 minKinEnergy = 0.1*keV;
111 maxKinEnergy = 10.0*TeV;
119 polarAngleLimit = 0.0;
128 secParticles.reserve(5);
147 <<
" " <<
this <<
" " << theLambdaTable <<
G4endl;
152 delete theLambdaTable;
154 if(theLambdaTablePrim) {
156 delete theLambdaTablePrim;
165void G4VEmProcess::Clear()
186 modelManager->
AddEmModel(order, p, fm, region);
196 G4cout <<
"### G4VEmProcess::SetModel is obsolete method and will be "
197 <<
"removed for the next release." <<
G4endl;
200 G4int n = emModels.size();
201 if(index >= n) {
for(
G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
210 G4cout <<
"### G4VEmProcess::Model is obsolete method and will be "
211 <<
"removed for the next release." <<
G4endl;
215 if(index >= 0 && index <
G4int(emModels.size())) { p = emModels[index]; }
223 G4int n = emModels.size();
224 if(index >= n) {
for(
G4int i=n; i<=index; ++i) {emModels.push_back(0);} }
233 if(index >= 0 && index <
G4int(emModels.size())) { p = emModels[index]; }
249 return modelManager->
GetModel(idx, ver);
262 if(pname !=
"deuteron" && pname !=
"triton" &&
263 pname !=
"alpha" && pname !=
"He3" &&
264 pname !=
"alpha+" && pname !=
"helium" &&
265 pname !=
"hydrogen") {
272 G4cout <<
"G4VEmProcess::PreparePhysicsTable() for "
284 if(particle == &part) {
292 theEnergyOfCrossSectionMax.resize(n, 0.0);
293 theCrossSectionMax.resize(n,
DBL_MAX);
297 for(
G4int i=0; i<numberOfModels; ++i) {
299 if(0 == i) { currentModel = mod; }
307 theCuts = modelManager->
Initialise(particle,secondaryParticle,
314 if(buildLambdaTable){
319 if(minKinEnergyPrim < maxKinEnergy){
340 G4cout <<
"G4VEmProcess::BuildPhysicsTable() for "
342 <<
" and particle " << num
343 <<
" buildLambdaTable= " << buildLambdaTable
349 if(buildLambdaTable || minKinEnergyPrim < maxKinEnergy) {
356 num ==
"e+" || num ==
"mu+" ||
357 num ==
"mu-" || num ==
"proton"||
358 num ==
"pi+" || num ==
"pi-" ||
359 num ==
"kaon+" || num ==
"kaon-" ||
360 num ==
"alpha" || num ==
"anti_proton" ||
361 num ==
"GenericIon")))
368 G4cout <<
"G4VEmProcess::BuildPhysicsTable() done for "
370 <<
" and particle " << num
377void G4VEmProcess::BuildLambdaTable()
380 G4cout <<
"G4EmProcess::BuildLambdaTable() for process "
400 if(startFromNull || minKinEnergyPrim < maxKinEnergy ) {
401 scale = std::log(maxKinEnergy/minKinEnergy);
402 if(minKinEnergyPrim < maxKinEnergy) { emax1 = minKinEnergyPrim; }
405 for(
size_t i=0; i<numOfCouples; ++i) {
414 if(buildLambdaTable) {
415 delete (*theLambdaTable)[i];
417 G4bool startNull = startFromNull;
419 if(startFromNull || minKinEnergyPrim < maxKinEnergy) {
421 if(emin < minKinEnergy) {
426 if(emax <= emin) { emax = 2*emin; }
428 G4lrint(nLambdaBins*std::log(emax/emin)/scale);
429 if(bin < 3) { bin = 3; }
433 }
else if(!bVector) {
446 if(minKinEnergyPrim < maxKinEnergy) {
447 delete (*theLambdaTablePrim)[i];
452 G4lrint(nLambdaBins*std::log(maxKinEnergy/minKinEnergyPrim)/scale);
453 if(bin < 3) { bin = 3; }
456 bVectorPrim = aVectorPrim;
470 if(buildLambdaTable) { FindLambdaMax(); }
473 G4cout <<
"Lambda table is built for "
486 if(integral) {
G4cout <<
", integral: 1 "; }
487 if(applyCuts) {
G4cout <<
", applyCuts: 1 "; }
489 if(biasFactor != 1.0) {
G4cout <<
" BiasingFactor= " << biasFactor; }
491 if(buildLambdaTable) {
492 size_t length = theLambdaTable->
length();
493 for(
size_t i=0; i<length; ++i) {
496 G4cout <<
" Lambda table from "
508 if(minKinEnergyPrim < maxKinEnergy) {
509 size_t length = theLambdaTablePrim->
length();
510 for(
size_t i=0; i<length; ++i) {
513 G4cout <<
" LambdaPrime table from "
529 G4cout <<
" LambdaTable address= " << theLambdaTable <<
G4endl;
530 if(theLambdaTable) {
G4cout << (*theLambdaTable) <<
G4endl; }
569 if(!currentModel->
IsActive(preStepKinEnergy)) {
return x; }
575 return biasManager->
GetStepLimit(currentCoupleIndex, previousStepSize);
581 if(preStepKinEnergy < mfpKinEnergy) {
582 if (integral) { ComputeIntegralLambda(preStepKinEnergy); }
583 else { preStepLambda = GetCurrentLambda(preStepKinEnergy); }
586 if(preStepLambda <= 0.0) {
593 if(preStepLambda > 0.0) {
616 G4cout <<
"G4VEmProcess::PostStepGetPhysicalInteractionLength ";
619 <<
" in Material " << currentMaterial->
GetName()
620 <<
" Ekin(MeV)= " << preStepKinEnergy/MeV
623 <<
" InteractionLength= " << x/cm <<
"[cm] " <<
G4endl;
660 <<
" E(MeV)= " << finalT/MeV
661 <<
" preLambda= " << preStepLambda <<
" < "
662 << lx <<
" (postLambda) "
678 weight /= biasFactor;
693 secParticles.clear();
697 (*theCuts)[currentCoupleIndex]);
706 eloss, currentCoupleIndex,
707 (*theCuts)[currentCoupleIndex],
717 G4int num = secParticles.size();
723 for (
G4int i=0; i<num; ++i) {
724 if (secParticles[i]) {
731 if (e < (*theCutsGamma)[currentCoupleIndex]) { good =
false; }
733 }
else if (p == theElectron) {
734 if (e < (*theCutsElectron)[currentCoupleIndex]) { good =
false; }
736 }
else if (p == thePositron) {
737 if (electron_mass_c2 < (*theCutsGamma)[currentCoupleIndex] &&
738 e < (*theCutsPositron)[currentCoupleIndex]) {
740 e += 2.0*electron_mass_c2;
780 if ( theLambdaTable && part == particle) {
788 <<
" in the directory <" << directory
791 G4cout <<
"Fail to store Physics Table for "
794 <<
" in the directory <" << directory
798 if ( theLambdaTablePrim && part == particle) {
806 <<
" in the directory <" << directory
809 G4cout <<
"Fail to store Physics Table Prim for "
812 <<
" in the directory <" << directory
826 G4cout <<
"G4VEmProcess::RetrievePhysicsTable() for "
832 if((!buildLambdaTable && minKinEnergyPrim > maxKinEnergy)
833 || particle != part) {
return yes; }
838 if(buildLambdaTable) {
844 G4cout <<
"Lambda table for " << particleName
845 <<
" is Retrieved from <"
850 size_t n = theLambdaTable->
length();
851 for(
size_t i=0; i<n; ++i) {
852 if((* theLambdaTable)[i]) {
853 (* theLambdaTable)[i]->SetSpline(
true);
859 G4cout <<
"Lambda table for " << particleName <<
" in file <"
860 << filename <<
"> is not exist"
865 if(minKinEnergyPrim < maxKinEnergy) {
871 G4cout <<
"Lambda table prim for " << particleName
872 <<
" is Retrieved from <"
877 size_t n = theLambdaTablePrim->
length();
878 for(
size_t i=0; i<n; ++i) {
879 if((* theLambdaTablePrim)[i]) {
880 (* theLambdaTablePrim)[i]->SetSpline(
true);
886 G4cout <<
"Lambda table prim for " << particleName <<
" in file <"
887 << filename <<
"> is not exist"
903 DefineMaterial(couple);
906 cross = (*theDensityFactor)[currentCoupleIndex]*
907 (((*theLambdaTable)[basedCoupleIndex])->Value(kineticEnergy));
911 currentParticle,kineticEnergy);
914 if(cross < 0.0) { cross = 0.0; }
935 if(0.0 < preStepLambda) { x = 1.0/preStepLambda; }
956void G4VEmProcess::FindLambdaMax()
959 G4cout <<
"### G4VEmProcess::FindLambdaMax: "
963 size_t n = theLambdaTable->
length();
970 for (i=0; i<
n; ++i) {
971 pv = (*theLambdaTable)[i];
977 for (
size_t j=0; j<nb; ++j) {
986 theEnergyOfCrossSectionMax[i] = emax;
987 theCrossSectionMax[i] = smax;
990 <<
" Max CS at i= " << i <<
" emax(MeV)= " << emax/MeV
991 <<
" lambda= " << smax <<
G4endl;
996 for (i=0; i<
n; ++i) {
997 pv = (*theLambdaTable)[i];
999 G4int j = (*theDensityIdx)[i];
1000 theEnergyOfCrossSectionMax[i] = theEnergyOfCrossSectionMax[j];
1001 theCrossSectionMax[i] = (*theDensityFactor)[i]*theCrossSectionMax[j];
1034 G4cout <<
"### SetCrossSectionBiasingFactor: for "
1037 <<
" biasFactor= " << f <<
" weightFlag= " << flag
1051 G4cout <<
"### ActivateForcedInteraction: for "
1054 <<
" length(mm)= " << length/mm
1055 <<
" in G4Region <" << r
1056 <<
"> weightFlag= " << flag
1070 if (0.0 <= factor) {
1079 G4cout <<
"### ActivateSecondaryBiasing: for "
1081 <<
" factor= " << factor
1082 <<
" in G4Region <" << region
1083 <<
"> energyLimit(MeV)= " << energyLimit/MeV
1093 nLambdaBins =
G4lrint(nLambdaBins*std::log(maxKinEnergy/e)
1094 /std::log(maxKinEnergy/minKinEnergy));
1102 nLambdaBins =
G4lrint(nLambdaBins*std::log(e/minKinEnergy)
1103 /std::log(maxKinEnergy/minKinEnergy));
G4double condition(const G4ErrorSymMatrix &m)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4DLLIMPORT std::ostream G4cout
const G4ParticleDefinition * GetParticleDefinition() const
G4double GetKineticEnergy() const
static G4Electron * Electron()
G4bool ForcedInteractionRegion(G4int coupleIdx)
G4double ApplySecondaryBiasing(std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForGamma *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
void ActivateSecondaryBiasing(const G4String ®ion, G4double factor, G4double energyLimit)
void ResetForcedInteraction()
void Initialise(const G4ParticleDefinition &part, const G4String &procName, G4int verbose)
void ActivateForcedInteraction(G4double length=0.0, const G4String &r="")
G4bool SecondaryBiasingRegion(G4int coupleIdx)
G4double GetStepLimit(G4int coupleIdx, G4double previousStep)
void UpdateEmModel(const G4String &, G4double, G4double)
void AddEmModel(G4int, G4VEmModel *, G4VEmFluctuationModel *, const G4Region *)
G4int NumberOfModels() const
void SetFluoFlag(G4bool val)
void DumpModelList(G4int verb)
G4VEmModel * GetModel(G4int, G4bool ver=false)
void FillLambdaVector(G4PhysicsVector *, const G4MaterialCutsCouple *, G4bool startFromNull=true, G4EmTableType t=fRestricted)
const G4DataVector * Initialise(const G4ParticleDefinition *, const G4ParticleDefinition *, G4double, G4int)
static G4GenericIon * GenericIon()
const std::vector< G4double > * GetDensityFactors()
void InitialiseBaseMaterials(G4PhysicsTable *table)
const std::vector< G4int > * GetCoupleIndexes()
G4bool GetFlag(size_t idx) const
static G4LossTableManager * Instance()
G4LossTableBuilder * GetTableBuilder()
G4VAtomDeexcitation * AtomDeexcitation()
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
const G4Material * GetMaterial() const
const G4String & GetName() const
void InitializeForPostStep(const G4Track &)
G4double GetProposedKineticEnergy() const
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleType() const
const G4String & GetParticleName() const
const G4String & GetParticleSubType() const
static void SetPhysicsVector(G4PhysicsTable *physTable, size_t idx, G4PhysicsVector *vec)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
static G4bool RetrievePhysicsTable(G4PhysicsTable *physTable, const G4String &fileName, G4bool ascii)
G4bool StorePhysicsTable(const G4String &filename, G4bool ascii=false)
size_t GetVectorLength() const
G4double GetMaxEnergy() const
G4double Energy(size_t index) const
void FillSecondDerivatives()
static G4Positron * Positron()
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
size_t GetTableSize() const
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double GetSafety() const
G4StepPoint * GetPostStepPoint() const
G4TrackStatus GetTrackStatus() const
const G4ParticleDefinition * GetParticleDefinition() const
void SetWeight(G4double aValue)
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4double GetGlobalTime() const
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
G4double GetKineticEnergy() const
G4int GetParentID() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
G4bool IsActive(G4double kinEnergy)
void SetPolarAngleLimit(G4double)
void SetHighEnergyLimit(G4double)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
const G4Element * GetCurrentElement() const
G4double HighEnergyLimit() const
void SetParticleChange(G4VParticleChange *, G4VEmFluctuationModel *f=0)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin=0.0, G4double tmax=DBL_MAX)=0
G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
G4VEmModel * GetModelByIndex(G4int idx=0, G4bool ver=false)
G4double MeanFreePath(const G4Track &track)
void StartTracking(G4Track *)
G4PhysicsVector * LambdaPhysicsVector(const G4MaterialCutsCouple *)
virtual void PrintInfo()=0
G4VEmProcess(const G4String &name, G4ProcessType type=fElectromagnetic)
void AddEmModel(G4int, G4VEmModel *, const G4Region *region=0)
virtual G4double MinPrimaryEnergy(const G4ParticleDefinition *, const G4Material *)
G4double ComputeCrossSectionPerAtom(G4double kineticEnergy, G4double Z, G4double A=0., G4double cut=0.0)
void SetMinKinEnergy(G4double e)
G4VEmModel * SelectModel(G4double &kinEnergy, size_t index)
G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
void SetCrossSectionBiasingFactor(G4double f, G4bool flag=true)
void SetEmModel(G4VEmModel *, G4int index=1)
virtual void InitialiseProcess(const G4ParticleDefinition *)=0
G4VEmModel * EmModel(G4int index=1)
G4double GetLambda(G4double &kinEnergy, const G4MaterialCutsCouple *couple)
void PrintInfoDefinition()
void UpdateEmModel(const G4String &, G4double, G4double)
G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
void BuildPhysicsTable(const G4ParticleDefinition &)
G4double CrossSectionPerVolume(G4double kineticEnergy, const G4MaterialCutsCouple *couple)
void PreparePhysicsTable(const G4ParticleDefinition &)
void ActivateForcedInteraction(G4double length=0.0, const G4String &r="", G4bool flag=true)
G4VEmModel * Model(G4int index=1)
void ActivateSecondaryBiasing(const G4String ®ion, G4double factor, G4double energyLimit)
G4ParticleChangeForGamma fParticleChange
G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &directory, G4bool ascii)
void SetParticle(const G4ParticleDefinition *p)
void SetMaxKinEnergy(G4double e)
const G4Element * GetCurrentElement() const
void SetModel(G4VEmModel *, G4int index=1)
G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4double GetParentWeight() const
void ProposeTrackStatus(G4TrackStatus status)
void ProposeWeight(G4double finalWeight)
G4double GetLocalEnergyDeposit() const
void AddSecondary(G4Track *aSecondary)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetNumberOfSecondaries(G4int totSecondaries)
G4TrackStatus GetTrackStatus() const
G4double currentInteractionLength
void SetVerboseLevel(G4int value)
virtual void ResetNumberOfInteractionLengthLeft()
void ClearNumberOfInteractionLengthLeft()
G4double theNumberOfInteractionLengthLeft
G4VParticleChange * pParticleChange
G4int GetProcessSubType() const
const G4String & GetPhysicsTableFileName(const G4ParticleDefinition *, const G4String &directory, const G4String &tableName, G4bool ascii=false)
const G4String & GetProcessName() const