Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4XrayReflection Class Reference

#include <G4XrayReflection.hh>

+ Inheritance diagram for G4XrayReflection:

Public Member Functions

 G4XrayReflection (const G4String &processName="XrayReflection", G4ProcessType type=fElectromagnetic)
 
 ~G4XrayReflection () override=default
 
G4double GetMeanFreePath (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override
 
G4VParticleChangePostStepDoIt (const G4Track &track, const G4Step &Step) override
 
G4bool IsApplicable (const G4ParticleDefinition &) override
 
void BuildPhysicsTable (const G4ParticleDefinition &) override
 
void ProcessDescription (std::ostream &) const override
 
void DumpInfo () const override
 
void SetSurfaceRoughness (const G4double value)
 
G4double Reflectivity (const G4double GamEner, const G4double SinIncidentAngle, const G4Material *theMat) const
 
G4int ReadHenkeXrayData (std::string ElName, std::vector< G4double > &Ephot, std::vector< G4double > &f1, std::vector< G4double > &f2)
 
void SaveHenkeDataAsMaterialProperty ()
 
- Public Member Functions inherited from G4VDiscreteProcess
 G4VDiscreteProcess (const G4String &aName, G4ProcessType aType=fNotDefined)
 
 G4VDiscreteProcess (G4VDiscreteProcess &)
 
virtual ~G4VDiscreteProcess ()
 
G4VDiscreteProcessoperator= (const G4VDiscreteProcess &)=delete
 
virtual G4double PostStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual G4double AlongStepGetPhysicalInteractionLength (const G4Track &, G4double, G4double, G4double &, G4GPILSelection *)
 
virtual G4double AtRestGetPhysicalInteractionLength (const G4Track &, G4ForceCondition *)
 
virtual G4VParticleChangeAtRestDoIt (const G4Track &, const G4Step &)
 
virtual G4VParticleChangeAlongStepDoIt (const G4Track &, const G4Step &)
 
virtual G4double GetCrossSection (const G4double, const G4MaterialCutsCouple *)
 
virtual G4double MinPrimaryEnergy (const G4ParticleDefinition *, const G4Material *)
 
- Public Member Functions inherited from G4VProcess
 G4VProcess (const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
 
 G4VProcess (const G4VProcess &right)
 
virtual ~G4VProcess ()
 
G4VProcessoperator= (const G4VProcess &)=delete
 
G4bool operator== (const G4VProcess &right) const
 
G4bool operator!= (const G4VProcess &right) const
 
G4double GetCurrentInteractionLength () const
 
void SetPILfactor (G4double value)
 
G4double GetPILfactor () const
 
G4double AlongStepGPIL (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
 
G4double AtRestGPIL (const G4Track &track, G4ForceCondition *condition)
 
G4double PostStepGPIL (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual void PreparePhysicsTable (const G4ParticleDefinition &)
 
virtual G4bool StorePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
virtual G4bool RetrievePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
const G4StringGetPhysicsTableFileName (const G4ParticleDefinition *, const G4String &directory, const G4String &tableName, G4bool ascii=false)
 
const G4StringGetProcessName () const
 
G4ProcessType GetProcessType () const
 
void SetProcessType (G4ProcessType)
 
G4int GetProcessSubType () const
 
void SetProcessSubType (G4int)
 
virtual const G4VProcessGetCreatorProcess () const
 
virtual void StartTracking (G4Track *)
 
virtual void EndTracking ()
 
virtual void SetProcessManager (const G4ProcessManager *)
 
virtual const G4ProcessManagerGetProcessManager ()
 
virtual void ResetNumberOfInteractionLengthLeft ()
 
G4double GetNumberOfInteractionLengthLeft () const
 
G4double GetTotalNumberOfInteractionLengthTraversed () const
 
G4bool isAtRestDoItIsEnabled () const
 
G4bool isAlongStepDoItIsEnabled () const
 
G4bool isPostStepDoItIsEnabled () const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 
virtual void SetMasterProcess (G4VProcess *masterP)
 
const G4VProcessGetMasterProcess () const
 
virtual void BuildWorkerPhysicsTable (const G4ParticleDefinition &part)
 
virtual void PrepareWorkerPhysicsTable (const G4ParticleDefinition &)
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VProcess
static const G4StringGetProcessTypeName (G4ProcessType)
 
- Protected Member Functions inherited from G4VDiscreteProcess
- Protected Member Functions inherited from G4VProcess
void SubtractNumberOfInteractionLengthLeft (G4double prevStepSize)
 
void ClearNumberOfInteractionLengthLeft ()
 
- Protected Attributes inherited from G4VProcess
const G4ProcessManageraProcessManager = nullptr
 
G4VParticleChangepParticleChange = nullptr
 
G4ParticleChange aParticleChange
 
G4double theNumberOfInteractionLengthLeft = -1.0
 
G4double currentInteractionLength = -1.0
 
G4double theInitialNumberOfInteractionLength = -1.0
 
G4String theProcessName
 
G4String thePhysicsTableFileName
 
G4ProcessType theProcessType = fNotDefined
 
G4int theProcessSubType = -1
 
G4double thePILfactor = 1.0
 
G4int verboseLevel = 0
 
G4bool enableAtRestDoIt = true
 
G4bool enableAlongStepDoIt = true
 
G4bool enablePostStepDoIt = true
 

Detailed Description

Definition at line 46 of file G4XrayReflection.hh.

Constructor & Destructor Documentation

◆ G4XrayReflection()

G4XrayReflection::G4XrayReflection ( const G4String & processName = "XrayReflection",
G4ProcessType type = fElectromagnetic )
explicit

Definition at line 49 of file G4XrayReflection.cc.

◆ ~G4XrayReflection()

G4XrayReflection::~G4XrayReflection ( )
overridedefault

Member Function Documentation

◆ BuildPhysicsTable()

void G4XrayReflection::BuildPhysicsTable ( const G4ParticleDefinition & part)
overridevirtual

Reimplemented from G4VProcess.

Definition at line 197 of file G4XrayReflection.cc.

198{
200
201 if (GetVerboseLevel() > 2)
202 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
203 << std::right << std::setw(4) << __LINE__
204 << " is gamma=" << (&part == G4Gamma::Definition())
205 << " fSurfaceRoughness=" << G4BestUnit(fSurfaceRoughness, "Length") << G4endl;
206}
#define G4BestUnit(a, b)
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
static G4Gamma * Definition()
Definition G4Gamma.cc:43
G4int GetVerboseLevel() const
void ProcessDescription(std::ostream &) const override

◆ DumpInfo()

void G4XrayReflection::DumpInfo ( ) const
inlineoverridevirtual

Reimplemented from G4VProcess.

Definition at line 62 of file G4XrayReflection.hh.

◆ GetMeanFreePath()

G4double G4XrayReflection::GetMeanFreePath ( const G4Track & track,
G4double previousStepSize,
G4ForceCondition * condition )
overridevirtual

Implements G4VDiscreteProcess.

Definition at line 110 of file G4XrayReflection.cc.

112{
114 G4double GamEner = aTrack.GetDynamicParticle()->GetTotalEnergy();
115 if (GamEner < 30. * eV || GamEner > 30. * keV)
116 return DBL_MAX; // do nothing below and above the limits
117
118 if (GetVerboseLevel() > 2)
119 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
120 << std::right << std::setw(4) << __LINE__ << " GamEner=" << GamEner / keV
121 << " keV previousStepSize=" << previousStepSize
122 << " TrackLength=" << aTrack.GetTrackLength() << " StepLength=" << aTrack.GetStepLength()
123 << G4endl;
124
125 G4double MeanFreePath = DBL_MAX; // by default no reflection
126 G4VPhysicalVolume* Volume = aTrack.GetVolume();
127 if (fLastVolume && Volume != fLastVolume && aTrack.GetTrackLength() > 0) { // at a boundary
128 const G4Material* theLastMat = fLastVolume->GetLogicalVolume()->GetMaterial();
129 const G4Material* theMat = Volume->GetLogicalVolume()->GetMaterial();
130
131 G4double last_density = theLastMat->GetDensity();
132 G4double density = theMat->GetDensity();
133 if (density > last_density) { // density has increased
134 G4Navigator* theNavigator =
136 G4bool valid = false;
137 G4ThreeVector theSurfaceNormal =
138 theNavigator->GetGlobalExitNormal(aTrack.GetPosition(), &valid);
139 if (valid) fSurfaceNormal = theSurfaceNormal;
140 G4double SinIncidentAngle =
141 aTrack.GetDynamicParticle()->GetMomentumDirection() * fSurfaceNormal;
142 if (G4UniformRand() < Reflectivity(GamEner, SinIncidentAngle, theMat)) {
143 MeanFreePath = 0;
144 }
145 G4ThreeVector Position = aTrack.GetPosition(); // only for info
146 const G4VSolid* LastSolid_Volume = fLastVolume->GetLogicalVolume()->GetSolid(); // for info
147 if (GetVerboseLevel() > 1 && MeanFreePath == 0)
148 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
149 << std::right << std::setw(4) << __LINE__
150 << " trigger reflection SinIncidentAngle=" << SinIncidentAngle
151 << " at z=" << Position.getZ() / meter << " m" << G4endl;
152 else if (GetVerboseLevel() > 2)
153 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
154 << std::right << std::setw(4) << __LINE__ << " volume has changed "
155 << " last logical volume name =" << fLastVolume->GetLogicalVolume()->GetName()
156 << " last logical volume material name =" << theLastMat->GetName()
157 << " last density=" << last_density << " part/cm3 ? "
158 << " logical volume name =" << Volume->GetLogicalVolume()->GetName()
159 << " logical volume material name =" << theMat->GetName() << " density=" << density
160 << " part/cm3 ? "
161 << " LastSolid_Volume->Inside(Position)=" << LastSolid_Volume->Inside(Position)
162 << " sin(IncidentAngle)=" << SinIncidentAngle << " MeanFreePath=" << MeanFreePath
163 << G4endl;
164 }
165 }
166 fLastVolume = Volume;
167 return MeanFreePath;
168}
G4double condition(const G4ErrorSymMatrix &m)
@ NotForced
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
#define G4UniformRand()
Definition Randomize.hh:52
G4VSolid * GetSolid() const
G4Material * GetMaterial() const
const G4String & GetName() const
G4double GetDensity() const
const G4String & GetName() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
G4LogicalVolume * GetLogicalVolume() const
virtual EInside Inside(const G4ThreeVector &p) const =0
G4double Reflectivity(const G4double GamEner, const G4double SinIncidentAngle, const G4Material *theMat) const
#define DBL_MAX
Definition templates.hh:62

◆ IsApplicable()

G4bool G4XrayReflection::IsApplicable ( const G4ParticleDefinition & particle)
overridevirtual

Reimplemented from G4VProcess.

Definition at line 59 of file G4XrayReflection.cc.

60{
61 return (&particle == G4Gamma::Gamma()); // apply only to gamma
62}
static G4Gamma * Gamma()
Definition G4Gamma.cc:81

◆ PostStepDoIt()

G4VParticleChange * G4XrayReflection::PostStepDoIt ( const G4Track & track,
const G4Step & Step )
overridevirtual

Reimplemented from G4VDiscreteProcess.

Definition at line 172 of file G4XrayReflection.cc.

173{
174 aParticleChange.Initialize(aTrack); // copy the current position to the changed particle
175 G4ThreeVector PhotDir = aTrack.GetDynamicParticle()->GetMomentumDirection();
176 G4ThreeVector para_part = (PhotDir * fSurfaceNormal) * fSurfaceNormal;
177 G4ThreeVector photon_reflected = PhotDir - 2 * para_part; // invert the parallel component
178 if (GetVerboseLevel() > 1)
179 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
180 << std::right << std::setw(4) << __LINE__ << " fSurfaceNormal=" << fSurfaceNormal
181 << " StepLength=" << aStep.GetStepLength() << " PhotDir=" << PhotDir
182 << " photon_reflected=" << photon_reflected << " para_part=" << para_part
183 << " aParticleChange.GetTrackStatus()=" << aParticleChange.GetTrackStatus()
184 << G4endl;
185
187 fStopAndKill); // needed when working with primary gamma to get rid of
188 // primary
189 auto ReflectedPhoton = new G4DynamicParticle(G4Gamma::Gamma(), photon_reflected,
190 aTrack.GetDynamicParticle()->GetTotalEnergy());
191 aParticleChange.AddSecondary(ReflectedPhoton);
192 return &aParticleChange;
193}
@ fStopAndKill
void AddSecondary(G4Track *aSecondary)
void Initialize(const G4Track &) override
void ProposeTrackStatus(G4TrackStatus status)
G4TrackStatus GetTrackStatus() const
G4ParticleChange aParticleChange

◆ ProcessDescription()

void G4XrayReflection::ProcessDescription ( std::ostream & out) const
overridevirtual

Reimplemented from G4VProcess.

Definition at line 210 of file G4XrayReflection.cc.

211{
213 out << '\n' << GetProcessName() << ": Gamma specular reflection for energies > 30 eV.\n";
214}
const G4String & GetProcessName() const
G4bool IsMasterThread()

Referenced by BuildPhysicsTable(), and DumpInfo().

◆ ReadHenkeXrayData()

G4int G4XrayReflection::ReadHenkeXrayData ( std::string ElName,
std::vector< G4double > & Ephot,
std::vector< G4double > & f1,
std::vector< G4double > & f2 )

Definition at line 218 of file G4XrayReflection.cc.

220{
221 std::transform(ElName.begin(), ElName.end(), ElName.begin(),
222 ::tolower); // henke_physical_reference uses lower case filanames
223 const G4String DataDir = G4EmParameters::Instance()->GetDirLEDATA() + "/XRayReflection_data/";
224 const G4String InpFname = DataDir + ElName + ".nff";
225 std::ifstream infile(InpFname);
226 if (!infile.is_open()) {
227 G4cout << "ReadHenkeXrayReflData " << InpFname << " not found" << G4endl;
228 return 1; // failure
229 }
230 std::vector<std::string> VarName(3);
231 infile >> VarName[0] >> VarName[1] >> VarName[2];
232 if (GetVerboseLevel())
233 G4cout << "ReadHenkeXrayData variable names " << VarName[0] << " " << VarName[1] << " "
234 << VarName[2] << G4endl;
235 G4double E_eV_i, f1_i, f2_i;
236 Ephot.resize(0);
237 f1.resize(0);
238 f2.resize(0);
239 for (;;) {
240 infile >> E_eV_i >> f1_i >> f2_i;
241 if (infile.eof()) break;
242 Ephot.push_back(E_eV_i * eV);
243 f1.push_back(f1_i);
244 f2.push_back(f2_i);
245 }
246 return 0; // success
247}
static G4EmParameters * Instance()
const G4String & GetDirLEDATA() const

Referenced by SaveHenkeDataAsMaterialProperty().

◆ Reflectivity()

G4double G4XrayReflection::Reflectivity ( const G4double GamEner,
const G4double SinIncidentAngle,
const G4Material * theMat ) const

Definition at line 66 of file G4XrayReflection.cc.

68{
69 G4double theReflectivity = 0;
70 const G4MaterialPropertiesTable* theMatProp = theMat->GetMaterialPropertiesTable();
71 if (SinIncidentAngle < 0.9 && theMatProp != nullptr)
72 { // avoid perpendicular refl. at straight entry and require
73 // data available
74 G4MaterialPropertyVector* RealIndex = theMatProp->GetProperty(kREALRINDEX);
76 if (nullptr == RealIndex || nullptr == ImagIndex) { return theReflectivity; }
77 const G4double delta = RealIndex->Value(GamEner);
78 const G4double beta = ImagIndex->Value(GamEner);
79 const G4double sin2 = std::pow(SinIncidentAngle, 2);
80 const G4double rho2 =
81 0.5 * (sin2 - 2 * delta + std::sqrt(std::pow(sin2 - 2 * delta, 2) + 4 * beta * beta));
82 const G4double rho = std::sqrt(rho2);
83 const G4double Refl_sigma = (rho2 * std::pow(SinIncidentAngle - rho, 2) + std::pow(beta, 2))
84 / (rho2 * std::pow(SinIncidentAngle + rho, 2) + std::pow(beta, 2));
85 const G4double coscot = std::sqrt(1 - sin2) / SinIncidentAngle;
86 const G4double pi_over_sigma = (rho2 * std::pow(rho - coscot, 2) + std::pow(beta, 2))
87 / (rho2 * std::pow(rho + coscot, 2) + std::pow(beta, 2));
88 const G4double Refl_pi = Refl_sigma * pi_over_sigma;
89 theReflectivity = 0.5 * (Refl_sigma + Refl_pi); // unpolarized
90 G4double RoughAtten = 1;
91 if (fSurfaceRoughness > 0) {
92 G4double kiz = SinIncidentAngle * GamEner / CLHEP::hbarc;
93 G4double kjz = SinIncidentAngle * (1 - delta) * GamEner / CLHEP::hbarc;
94 RoughAtten = G4Exp(-2 * kiz * kjz * fSurfaceRoughness * fSurfaceRoughness); // Nevot–Croce
95 theReflectivity *= RoughAtten;
96 }
97 if (GetVerboseLevel() > 1)
98 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
99 << std::right << std::setw(4) << __LINE__ << " GamEner=" << GamEner
100 << " fSurfaceRoughness=" << G4BestUnit(fSurfaceRoughness, "Length")
101 << " RoughAtten=" << RoughAtten << " SinIncidentAngle=" << SinIncidentAngle
102 << " delta=" << delta << " beta=" << beta << " Refl_sigma=" << Refl_sigma
103 << " Refl_pi=" << Refl_pi << " theReflectivity=" << theReflectivity << G4endl;
104 }
105 return theReflectivity;
106}
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition G4Exp.hh:180
G4MaterialPropertyVector * GetProperty(const char *key) const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
G4double Value(const G4double energy, std::size_t &lastidx) const

Referenced by GetMeanFreePath().

◆ SaveHenkeDataAsMaterialProperty()

void G4XrayReflection::SaveHenkeDataAsMaterialProperty ( )

Definition at line 251 of file G4XrayReflection.cc.

252{
253 // loop through the material table and load set up MaterialPropertiesTable
254 // with Henke data used to calculate the reflection
255 auto materialTable = G4Material::GetMaterialTable();
256 for (auto a_material : *materialTable) {
257 auto N = a_material->GetTotNbOfAtomsPerVolume();
258 if (GetVerboseLevel() > 2)
259 if (GetVerboseLevel() > 2)
260 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
261 << std::right << std::setw(4) << __LINE__ << " " << a_material->GetName()
262 << " NbOfAtomsPerVolume()=" << N
263 << " NumberOfElements()=" << a_material->GetNumberOfElements() << G4endl;
264 // calculate the reflectivity from input data. Implemented for dense
265 // materials of a single element
266 if (a_material->GetNumberOfElements() == 1 && a_material->GetDensity() > 1) {
267 G4double factor = N * CLHEP::classic_electr_radius / CLHEP::twopi;
268 std::vector<G4double> Ephot, f1, f2;
269 const G4Element* theElement = a_material->GetElement(0);
270 G4int iret = ReadHenkeXrayData(theElement->GetName(), Ephot, f1, f2);
271 if (iret) {
272 if (GetVerboseLevel() > 2)
273 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
274 << std::right << std::setw(4) << __LINE__ << " no Henke data found for "
275 << a_material->GetName() << " " << theElement->GetName() << G4endl;
276 }
277 else {
278 std::vector<G4double> RealIndex(Ephot.size()), ImagIndex(Ephot.size());
279 for (std::size_t i = 0; i < Ephot.size(); ++i) {
280 G4double lambda = CLHEP::twopi * CLHEP::hbarc / Ephot[i];
281 G4double lambda_sqr = lambda * lambda;
282 RealIndex[i] = fmax(0, factor * lambda_sqr * f1[i]); // delta or 1-RealIndex
283 ImagIndex[i] = factor * lambda_sqr * f2[i]; // beta or -ImagIndex
284 if (GetVerboseLevel() > 2)
285 G4cout << "Ephot=" << std::setw(10) << Ephot[i] / eV << " eV delta=" << std::setw(10)
286 << RealIndex[i] << " beta=" << std::setw(10) << ImagIndex[i] << G4endl;
287 } // photon energy
288 G4MaterialPropertiesTable* proptab = a_material->GetMaterialPropertiesTable();
289 if(proptab == nullptr) {
290 proptab = new G4MaterialPropertiesTable();
291 a_material->SetMaterialPropertiesTable(proptab);
292 }
293 proptab->AddProperty("REALRINDEX", Ephot, RealIndex); // 1-RealIndex
294 proptab->AddProperty("IMAGINARYRINDEX", Ephot, ImagIndex);
295 if (GetVerboseLevel() > 2)
296 G4cout << std::left << std::setw(12) << __FILE__ << " " << __FUNCTION__ << " line "
297 << std::right << std::setw(4) << __LINE__ << " " << a_material->GetName()
298 << " " << theElement->GetName()
299 << " reflection data saved in PropertiesTable" << G4endl;
300 } // data found
301 }
302 }
303}
int G4int
Definition G4Types.hh:85
const G4String & GetName() const
Definition G4Element.hh:115
static G4Element * GetElement(const G4String &name, G4bool warning=true)
Definition G4Element.cc:397
G4MaterialPropertyVector * AddProperty(const G4String &key, const std::vector< G4double > &photonEnergies, const std::vector< G4double > &propertyValues, G4bool createNewKey=false, G4bool spline=false)
static G4MaterialTable * GetMaterialTable()
G4int ReadHenkeXrayData(std::string ElName, std::vector< G4double > &Ephot, std::vector< G4double > &f1, std::vector< G4double > &f2)
#define N
Definition crc32.c:57

Referenced by G4XrayReflection().

◆ SetSurfaceRoughness()

void G4XrayReflection::SetSurfaceRoughness ( const G4double value)

Definition at line 307 of file G4XrayReflection.cc.

308{
309 fSurfaceRoughness = value;
310}

The documentation for this class was generated from the following files: