65 :
G4VEmModel(nam),fParticleChange(0),fParticle(0),
66 isInitialised(false),energyGrid(0),
67 XSTableElectron(0),XSTablePositron(0),fPenelopeFSHelper(0),
68 fPenelopeAngular(0),fLocalTable(false)
71 fIntrinsicLowEnergyLimit = 100.0*eV;
72 fIntrinsicHighEnergyLimit = 100.0*GeV;
103 if (fPenelopeFSHelper)
104 delete fPenelopeFSHelper;
107 if (fPenelopeAngular)
108 delete fPenelopeAngular;
116 if (verboseLevel > 3)
117 G4cout <<
"Calling G4PenelopeBremsstrahlungModel::Initialise()" <<
G4endl;
124 if (!fPenelopeFSHelper)
126 if (!fPenelopeAngular)
132 if (fPenelopeAngular)
137 nBins = std::max(nBins,(
size_t)100);
143 XSTableElectron =
new
145 XSTablePositron =
new
159 BuildXSTable(theMat,theCuts.at(i));
164 if (verboseLevel > 2) {
165 G4cout <<
"Penelope Bremsstrahlung model v2008 is initialized " <<
G4endl
173 if(isInitialised)
return;
175 isInitialised =
true;
182 if (verboseLevel > 3)
183 G4cout <<
"Calling G4PenelopeBremsstrahlungModel::InitialiseLocal()" <<
G4endl;
196 energyGrid = theModel->energyGrid;
197 XSTableElectron = theModel->XSTableElectron;
198 XSTablePositron = theModel->XSTablePositron;
199 fPenelopeFSHelper = theModel->fPenelopeFSHelper;
204 if (!fPenelopeAngular)
207 if (fPenelopeAngular)
222 nBins = theModel->nBins;
225 verboseLevel = theModel->verboseLevel;
240 if (verboseLevel > 3)
241 G4cout <<
"Calling CrossSectionPerVolume() of G4PenelopeBremsstrahlungModel" <<
G4endl;
256 if (verboseLevel > 3)
257 G4cout <<
"Material " << material->
GetName() <<
" has " << atPerMol <<
258 "atoms per molecule" <<
G4endl;
262 moleculeDensity = atomDensity/atPerMol;
264 G4double crossPerVolume = crossPerMolecule*moleculeDensity;
266 if (verboseLevel > 2)
269 G4cout <<
"Mean free path for gamma emission > " << cutEnergy/keV <<
" keV at " <<
270 energy/keV <<
" keV = " << (1./crossPerVolume)/mm <<
" mm" <<
G4endl;
273 return crossPerVolume;
288 G4cout <<
"*** G4PenelopeBremsstrahlungModel -- WARNING ***" <<
G4endl;
289 G4cout <<
"Penelope Bremsstrahlung model v2008 does not calculate cross section _per atom_ " <<
G4endl;
290 G4cout <<
"so the result is always zero. For physics values, please invoke " <<
G4endl;
291 G4cout <<
"GetCrossSectionPerVolume() or GetMeanFreePath() via the G4EmCalculator" <<
G4endl;
302 if (verboseLevel > 3)
303 G4cout <<
"Calling ComputeDEDX() of G4PenelopeBremsstrahlungModel" <<
G4endl;
317 moleculeDensity = atomDensity/atPerMol;
319 G4double sPowerPerVolume = sPowerPerMolecule*moleculeDensity;
321 if (verboseLevel > 2)
324 G4cout <<
"Stopping power < " << cutEnergy/keV <<
" keV at " <<
325 kineticEnergy/keV <<
" keV = " <<
326 sPowerPerVolume/(keV/mm) <<
" keV/mm" <<
G4endl;
328 return sPowerPerVolume;
339 if (verboseLevel > 3)
340 G4cout <<
"Calling SampleSecondaries() of G4PenelopeBremsstrahlungModel" <<
G4endl;
345 if (kineticEnergy <= fIntrinsicLowEnergyLimit)
357 if (kineticEnergy < cutG)
360 if (verboseLevel > 3)
361 G4cout <<
"Going to sample gamma energy for: " <<material->
GetName() <<
" " <<
362 "energy = " << kineticEnergy/keV <<
", cut = " << cutG/keV <<
G4endl;
368 if (verboseLevel > 3)
369 G4cout <<
"Sampled gamma energy: " << gammaEnergy/keV <<
" keV" <<
G4endl;
374 fPenelopeAngular->
SampleDirection(aDynamicParticle,gammaEnergy,0,material);
376 if (verboseLevel > 3)
379 G4double residualPrimaryEnergy = kineticEnergy-gammaEnergy;
380 if (residualPrimaryEnergy < 0)
383 gammaEnergy += residualPrimaryEnergy;
384 residualPrimaryEnergy = 0.0;
388 G4ThreeVector particleDirection1 = initialMomentum - gammaEnergy*gammaDirection1;
389 particleDirection1 = particleDirection1.
unit();
392 if (residualPrimaryEnergy > 0.)
406 fvect->push_back(theGamma);
408 if (verboseLevel > 1)
410 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
411 G4cout <<
"Energy balance from G4PenelopeBremsstrahlung" <<
G4endl;
412 G4cout <<
"Incoming primary energy: " << kineticEnergy/keV <<
" keV" <<
G4endl;
413 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
414 G4cout <<
"Outgoing primary energy: " << residualPrimaryEnergy/keV <<
" keV" <<
G4endl;
415 G4cout <<
"Bremsstrahlung photon " << gammaEnergy/keV <<
" keV" <<
G4endl;
416 G4cout <<
"Total final state: " << (residualPrimaryEnergy+gammaEnergy)/keV
418 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
421 if (verboseLevel > 0)
423 G4double energyDiff = std::fabs(residualPrimaryEnergy+gammaEnergy-kineticEnergy);
424 if (energyDiff > 0.05*keV)
425 G4cout <<
"Warning from G4PenelopeBremsstrahlung: problem with energy conservation: "
427 (residualPrimaryEnergy+gammaEnergy)/keV <<
428 " keV (final) vs. " <<
429 kineticEnergy/keV <<
" keV (initial)" <<
G4endl;
436void G4PenelopeBremsstrahlungModel::ClearTables()
440 G4Exception(
"G4PenelopeBremsstrahlungModel::ClearTables()",
445 for (
auto& item : (*XSTableElectron))
447 delete XSTableElectron;
448 XSTableElectron =
nullptr;
452 for (
auto& item : (*XSTablePositron))
454 delete XSTablePositron;
455 XSTablePositron =
nullptr;
461 if (fPenelopeFSHelper)
464 if (verboseLevel > 2)
465 G4cout <<
"G4PenelopeBremsstrahlungModel: cleared tables" <<
G4endl;
475 return fIntrinsicLowEnergyLimit;
484 G4Exception(
"G4PenelopeBremsstrahlungModel::BuildXSTable()",
488 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
491 if (XSTableElectron->count(theKey) && XSTablePositron->count(theKey))
499 if (verboseLevel > 2)
501 G4cout <<
"G4PenelopeBremsstrahlungModel: going to build cross section table " <<
G4endl;
502 G4cout <<
"for e+/e- in " << mat->
GetName() <<
" for Ecut(gamma)= " <<
503 cut/keV <<
" keV " <<
G4endl;
510 ed <<
"Energy Grid looks not initialized" <<
G4endl;
512 G4Exception(
"G4PenelopeBremsstrahlungModel::BuildXSTable()",
523 for (
size_t bin=0;bin<nBins;bin++)
531 ((
energy+electron_mass_c2)*(energy+electron_mass_c2)/
538 size_t nBinsX = fPenelopeFSHelper->
GetNBinsX();
541 for (
size_t ix=0;ix<nBinsX;ix++)
544 G4double val = (*table)[ix]->Value(logene);
545 tempData[ix] =
G4Exp(val);
549 if (restrictedCut <= 1)
557 if (restrictedCut <=1)
575 G4double posCorrection = GetPositronXSCorrection(mat,energy);
585 XSTableElectron->insert(std::make_pair(theKey,XSEntry));
586 XSTablePositron->insert(std::make_pair(theKey,XSEntry2));
603 G4Exception(
"G4PenelopeBremsstrahlungModel::GetCrossSectionTableForCouple()",
612 if (!XSTableElectron)
616 G4String excep =
"The Cross Section Table for e- was not initialized correctly!";
617 G4Exception(
"G4PenelopeBremsstrahlungModel::GetCrossSectionTableForCouple()",
620 XSTableElectron =
new
626 if (!fPenelopeFSHelper)
629 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
630 if (XSTableElectron->count(theKey))
631 return XSTableElectron->find(theKey)->second;
636 if (verboseLevel > 0)
640 ed <<
"Unable to find e- table for " << mat->
GetName() <<
" at Ecut(gamma)= "
641 << cut/keV <<
" keV " <<
G4endl;
642 ed <<
"This can happen only in Unit Tests or via G4EmCalculator" <<
G4endl;
643 G4Exception(
"G4PenelopeBremsstrahlungModel::GetCrossSectionTableForCouple()",
647 G4AutoLock lock(&PenelopeBremsstrahlungModelMutex);
649 BuildXSTable(mat,cut);
652 return XSTableElectron->find(theKey)->second;
660 if (!XSTablePositron)
662 G4String excep =
"The Cross Section Table for e+ was not initialized correctly!";
663 G4Exception(
"G4PenelopeBremsstrahlungModel::GetCrossSectionTableForCouple()",
666 XSTablePositron =
new
672 if (!fPenelopeFSHelper)
675 std::pair<const G4Material*,G4double> theKey = std::make_pair(mat,cut);
676 if (XSTablePositron->count(theKey))
677 return XSTablePositron->find(theKey)->second;
682 if (verboseLevel > 0)
686 ed <<
"Unable to find e+ table for " << mat->
GetName() <<
" at Ecut(gamma)= "
687 << cut/keV <<
" keV " <<
G4endl;
688 ed <<
"This can happen only in Unit Tests or via G4EmCalculator" <<
G4endl;
689 G4Exception(
"G4PenelopeBremsstrahlungModel::GetCrossSectionTableForCouple()",
693 G4AutoLock lock(&PenelopeBremsstrahlungModelMutex);
695 BuildXSTable(mat,cut);
698 return XSTablePositron->find(theKey)->second;
719 (3.1516e-2-t*(7.7446e-3-t*(1.0595e-3-t*
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
G4double G4Log(G4double x)
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
G4ThreeVector GetMomentum() const
static G4Electron * Electron()
const G4Material * GetMaterial() const
G4double GetTotNbOfAtomsPerVolume() const
const G4String & GetName() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
const G4String & GetParticleName() const
G4ThreeVector & SampleDirection(const G4DynamicParticle *dp, G4double out_energy, G4int Z, const G4Material *mat=0)
Samples the direction of the outgoing photon (in global coordinates).
void PrepareTables(const G4Material *material, G4bool isMaster)
Reserved for Master Model.
void BuildScaledXSTable(const G4Material *material, G4double cut, G4bool isMaster)
G4double GetEffectiveZSquared(const G4Material *mat) const
const G4PhysicsTable * GetScaledXSTable(const G4Material *, const G4double cut) const
void ClearTables(G4bool isMaster=true)
Reserved for the master model: they build and handle tables.
G4double SampleGammaEnergy(G4double energy, const G4Material *, const G4double cut) const
G4double GetMomentumIntegral(G4double *y, G4double up, G4int momOrder) const
virtual G4double CrossSectionPerVolume(const G4Material *material, const G4ParticleDefinition *theParticle, G4double kineticEnergy, G4double cutEnergy, G4double maxEnergy=DBL_MAX)
virtual G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy)
const G4ParticleDefinition * fParticle
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
virtual G4double MinEnergyCut(const G4ParticleDefinition *, const G4MaterialCutsCouple *)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *theParticle, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
G4PenelopeBremsstrahlungModel(const G4ParticleDefinition *p=0, const G4String &processName="PenBrem")
G4ParticleChangeForLoss * fParticleChange
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *)
virtual ~G4PenelopeBremsstrahlungModel()
G4double GetSoftStoppingPower(G4double energy) const
Returns the total stopping power due to soft collisions.
G4double GetHardCrossSection(G4double energy) const
Returns hard cross section at the given energy.
void AddCrossSectionPoint(size_t binNumber, G4double energy, G4double XH0, G4double XH1, G4double XH2, G4double XS0, G4double XS1, G4double XS2)
G4double GetAtomsPerMolecule(const G4Material *)
Returns the total number of atoms per molecule.
static G4PenelopeOscillatorManager * GetOscillatorManager()
G4double GetLowEdgeEnergy(std::size_t binNumber) const
std::size_t GetVectorLength() const
static G4Positron * Positron()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
void SetHighEnergyLimit(G4double)
G4double LowEnergyLimit() const
G4double HighEnergyLimit() const
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
void SetDeexcitationFlag(G4bool val)
G4ParticleChangeForLoss * GetParticleChangeForLoss()
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
G4double energy(const ThreeVector &p, const G4double m)