67 :
G4VEmModel(nam),fParticleChange(0),fParticle(0),
68 isInitialised(false),fAtomDeexcitation(0),logAtomicShellXS(0),fLocalTable(false)
70 fIntrinsicLowEnergyLimit = 100.0*
eV;
71 fIntrinsicHighEnergyLimit = 100.0*
GeV;
99 std::map <G4int,G4PhysicsTable*>::iterator i;
100 if (logAtomicShellXS)
102 for (i=logAtomicShellXS->begin();i != logAtomicShellXS->end();i++)
109 delete logAtomicShellXS;
118 if (verboseLevel > 3)
119 G4cout <<
"Calling G4PenelopePhotoElectricModel::Initialise()" <<
G4endl;
121 SetParticle(particle);
128 if (!logAtomicShellXS)
129 logAtomicShellXS =
new std::map<G4int,G4PhysicsTable*>;
142 G4int iZ = (
G4int) theElementVector->at(j)->GetZ();
144 if (!logAtomicShellXS->count(iZ))
154 if (!fAtomDeexcitation)
157 G4cout <<
"WARNING from G4PenelopePhotoElectricModel " <<
G4endl;
158 G4cout <<
"Atomic de-excitation module is not instantiated, so there will not be ";
160 G4cout <<
"Please make sure this is intended" <<
G4endl;
163 if (verboseLevel > 0) {
164 G4cout <<
"Penelope Photo-Electric model v2008 is initialized " << G4endl
171 if(isInitialised)
return;
173 isInitialised =
true;
180 if (verboseLevel > 3)
181 G4cout <<
"Calling G4PenelopePhotoElectricModel::InitialiseLocal()" <<
G4endl;
195 logAtomicShellXS = theModel->logAtomicShellXS;
198 verboseLevel = theModel->verboseLevel;
216 if (verboseLevel > 3)
217 G4cout <<
"Calling ComputeCrossSectionPerAtom() of G4PenelopePhotoElectricModel" <<
G4endl;
223 if (!logAtomicShellXS)
228 logAtomicShellXS =
new std::map<G4int,G4PhysicsTable*>;
232 if (!logAtomicShellXS->count(iZ))
237 ed <<
"Unable to retrieve the shell cross section table for Z=" << iZ <<
G4endl;
238 ed <<
"This can happen only in Unit Tests or via G4EmCalculator" <<
G4endl;
239 G4Exception(
"G4PenelopePhotoElectricModel::ComputeCrossSectionPerAtom()",
242 G4AutoLock lock(&PenelopePhotoElectricModelMutex);
255 G4Exception(
"G4PenelopePhotoElectricModel::ComputeCrossSectionPerAtom()",
257 "Unable to retrieve the total cross section table");
262 cross = std::exp(logXS);
264 if (verboseLevel > 2)
265 G4cout <<
"Photoelectric cross section at " << energy/
MeV <<
" MeV for Z=" << Z <<
292 if (verboseLevel > 3)
293 G4cout <<
"Calling SamplingSecondaries() of G4PenelopePhotoElectricModel" <<
G4endl;
301 if (photonEnergy <= fIntrinsicLowEnergyLimit)
310 if (verboseLevel > 2)
317 if (verboseLevel > 2)
326 size_t shellIndex = SelectRandomShell(Z,photonEnergy);
328 if (verboseLevel > 2)
329 G4cout <<
"Selected shell " << shellIndex <<
" of element " << anElement->
GetName() <<
G4endl;
340 size_t numberOfShells = (size_t) transitionManager->
NumberOfShells(Z);
341 if (shellIndex >= numberOfShells)
342 shellIndex = numberOfShells-1;
354 bindingEnergy = 0.*
eV;
365 if (eKineticEnergy > 0.)
369 cosTheta = SampleElectronDirection(eKineticEnergy);
370 G4double sinTheta = std::sqrt(1-cosTheta*cosTheta);
372 G4double dirx = sinTheta * std::cos(phi);
373 G4double diry = sinTheta * std::sin(phi);
376 electronDirection.
rotateUz(photonDirection);
380 fvect->push_back(electron);
383 bindingEnergy = photonEnergy;
392 if (fAtomDeexcitation && shellIndex<9)
397 size_t nBefore = fvect->size();
399 size_t nAfter = fvect->size();
401 if (nAfter > nBefore)
403 for (
size_t j=nBefore;j<nAfter;j++)
405 G4double itsEnergy = ((*fvect)[j])->GetKineticEnergy();
406 bindingEnergy -= itsEnergy;
408 energyInFluorescence += itsEnergy;
410 energyInAuger += itsEnergy;
419 if (localEnergyDeposit < 0)
422 <<
"G4PenelopePhotoElectricModel::SampleSecondaries() - Negative energy deposit"
424 localEnergyDeposit = 0;
429 if (verboseLevel > 1)
431 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
432 G4cout <<
"Energy balance from G4PenelopePhotoElectric" <<
G4endl;
433 G4cout <<
"Selected shell: " << WriteTargetShell(shellIndex) <<
" of element " <<
435 G4cout <<
"Incoming photon energy: " << photonEnergy/
keV <<
" keV" <<
G4endl;
436 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
438 G4cout <<
"Outgoing electron " << eKineticEnergy/
keV <<
" keV" <<
G4endl;
439 if (energyInFluorescence)
440 G4cout <<
"Fluorescence x-rays: " << energyInFluorescence/
keV <<
" keV" <<
G4endl;
442 G4cout <<
"Auger electrons: " << energyInAuger/
keV <<
" keV" <<
G4endl;
443 G4cout <<
"Local energy deposit " << localEnergyDeposit/
keV <<
" keV" <<
G4endl;
444 G4cout <<
"Total final state: " <<
445 (eKineticEnergy+energyInFluorescence+localEnergyDeposit+energyInAuger)/
keV <<
447 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
449 if (verboseLevel > 0)
452 std::fabs(eKineticEnergy+energyInFluorescence+localEnergyDeposit+energyInAuger-photonEnergy);
453 if (energyDiff > 0.05*
keV)
455 G4cout <<
"Warning from G4PenelopePhotoElectric: problem with energy conservation: " <<
456 (eKineticEnergy+energyInFluorescence+localEnergyDeposit+energyInAuger)/
keV
457 <<
" keV (final) vs. " <<
458 photonEnergy/
keV <<
" keV (initial)" << G4endl;
459 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
460 G4cout <<
"Energy balance from G4PenelopePhotoElectric" <<
G4endl;
461 G4cout <<
"Selected shell: " << WriteTargetShell(shellIndex) <<
" of element " <<
463 G4cout <<
"Incoming photon energy: " << photonEnergy/
keV <<
" keV" <<
G4endl;
464 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
466 G4cout <<
"Outgoing electron " << eKineticEnergy/
keV <<
" keV" <<
G4endl;
467 if (energyInFluorescence)
468 G4cout <<
"Fluorescence x-rays: " << energyInFluorescence/
keV <<
" keV" <<
G4endl;
470 G4cout <<
"Auger electrons: " << energyInAuger/
keV <<
" keV" <<
G4endl;
471 G4cout <<
"Local energy deposit " << localEnergyDeposit/
keV <<
" keV" <<
G4endl;
472 G4cout <<
"Total final state: " <<
473 (eKineticEnergy+energyInFluorescence+localEnergyDeposit+energyInAuger)/
keV <<
475 G4cout <<
"-----------------------------------------------------------" <<
G4endl;
485 if (energy>1*
GeV)
return costheta;
492 G4double beta = std::sqrt((gamma2-1.0)/gamma2);
497 G4double a1 = 0.5*beta*gamma*(gamma-1.0)*(gamma-2.0);
509 tsam = 2.0*ac * (2.0*rand + a2*std::sqrt(rand)) / (a2*a2 - 4.0*rand);
510 gtr = (2.0 - tsam) * (a1 + 1.0/(ac+tsam));
520 void G4PenelopePhotoElectricModel::ReadDataFile(
G4int Z)
524 G4Exception(
"G4PenelopePhotoElectricModel::ReadDataFile()",
527 if (verboseLevel > 2)
529 G4cout <<
"G4PenelopePhotoElectricModel::ReadDataFile()" <<
G4endl;
530 G4cout <<
"Going to read PhotoElectric data files for Z=" << Z <<
G4endl;
533 char* path = getenv(
"G4LEDATA");
536 G4String excep =
"G4PenelopePhotoElectricModel - G4LEDATA environment variable not set!";
537 G4Exception(
"G4PenelopePhotoElectricModel::ReadDataFile()",
545 std::ostringstream ost;
547 ost << path <<
"/penelope/photoelectric/pdgph" << Z <<
".p08";
549 ost << path <<
"/penelope/photoelectric/pdgph0" << Z <<
".p08";
550 std::ifstream
file(ost.str().c_str());
553 G4String excep =
"G4PenelopePhotoElectricModel - data file " +
G4String(ost.str()) +
" not found!";
554 G4Exception(
"G4PenelopePhotoElectricModel::ReadDataFile()",
561 while( getline(
file, line) )
568 file.open(ost.str().c_str());
572 file >> readZ >> nShells;
574 if (verboseLevel > 3)
575 G4cout <<
"Element Z=" << Z <<
" , nShells = " << nShells <<
G4endl;
578 if (readZ != Z || nShells <= 0 || nShells > 50)
581 ed <<
"Corrupted data file for Z=" << Z <<
G4endl;
582 G4Exception(
"G4PenelopePhotoElectricModel::ReadDataFile()",
594 for (
size_t i=0;i<nShells+1;i++)
598 for (k=0;k<ndata && !
file.eof();k++)
606 for (
size_t i=0;i<nShells+1;i++)
611 if (aValue < 1e-40*
cm2)
613 theVec->
PutValue(k,logene,std::log(aValue));
617 if (verboseLevel > 2)
619 G4cout <<
"G4PenelopePhotoElectricModel: read " << k <<
" points for element Z = "
623 logAtomicShellXS->insert(std::make_pair(Z,thePhysicsTable));
635 G4Exception(
"G4PenelopePhotoElectricModel::GetNumberOfShellXS()",
639 if (!logAtomicShellXS->count(Z))
642 if (!logAtomicShellXS->count(Z))
645 ed <<
"Cannot find shell cross section data for Z=" << Z <<
G4endl;
646 G4Exception(
"G4PenelopePhotoElectricModel::GetNumberOfShellXS()",
650 size_t nEntries = logAtomicShellXS->find(Z)->second->entries();
661 if (shellID >= entries)
663 G4cout <<
"Element Z=" << Z <<
" has data for " << entries <<
" shells only" <<
G4endl;
664 G4cout <<
"so shellID should be from 0 to " << entries-1 <<
G4endl;
674 G4Exception(
"G4PenelopePhotoElectricModel::GetShellCrossSection()",
676 "Unable to retrieve the total cross section table");
682 if (cross < 2e-40*cm2) cross = 0;
688 G4String G4PenelopePhotoElectricModel::WriteTargetShell(
size_t shellID)
693 else if (shellID == 1)
695 else if (shellID == 2)
697 else if (shellID == 3)
699 else if (shellID == 4)
701 else if (shellID == 5)
703 else if (shellID == 6)
705 else if (shellID == 7)
707 else if (shellID == 8)
724 size_t G4PenelopePhotoElectricModel::SelectRandomShell(
G4int Z,
G4double energy)
726 G4double logEnergy = std::log(energy);
729 if (!logAtomicShellXS->count(Z))
732 ed <<
"Cannot find shell cross section data for Z=" << Z <<
G4endl;
733 G4Exception(
"G4PenelopePhotoElectricModel::SelectRandomShell()",
755 for (
size_t k=1;k<theTable->
entries();k++)
760 G4double partialXS = std::exp(logXSLocal);
G4double LowEnergyLimit() const
G4bool CheckDeexcitationActiveRegion(G4int coupleIndex)
static G4LossTableManager * Instance()
G4int NumberOfShells(G4int Z) const
std::vector< G4Element * > G4ElementVector
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
std::ostringstream G4ExceptionDescription
G4double GetKineticEnergy() const
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
G4double HighEnergyLimit() const
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
G4ParticleChangeForGamma * fParticleChange
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
const G4String & GetName() const
G4double GetShellCrossSection(G4int Z, size_t shellID, G4double energy)
void push_back(G4PhysicsVector *)
static G4Electron * Definition()
G4double BindingEnergy() const
G4PenelopePhotoElectricModel(const G4ParticleDefinition *p=0, const G4String &processName="PenPhotoElec")
const G4ElementVector * GetElementVector() const
#define G4MUTEX_INITIALIZER
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetHighEnergyLimit(G4double)
G4GLOB_DLL std::ostream G4cout
size_t GetTableSize() const
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
std::ostream & tab(std::ostream &)
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
std::vector< G4EmElementSelector * > * GetElementSelectors()
G4double Value(G4double theEnergy, size_t &lastidx) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4ProductionCutsTable * GetProductionCutsTable()
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
virtual ~G4PenelopePhotoElectricModel()
const G4ParticleDefinition * fParticle
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
static G4Electron * Electron()
void SetProposedKineticEnergy(G4double proposedKinEnergy)
size_t GetNumberOfElements() const
G4VAtomDeexcitation * AtomDeexcitation()
void ProposeTrackStatus(G4TrackStatus status)
const G4String & GetName() const
size_t GetNumberOfShellXS(G4int)
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
void SetDeexcitationFlag(G4bool val)
G4double bindingEnergy(G4int A, G4int Z)
static G4AtomicTransitionManager * Instance()
G4AtomicShell * Shell(G4int Z, size_t shellIndex) const
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
static G4Gamma * Definition()
const G4Material * GetMaterial() const
static G4Gamma * GammaDefinition()