BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPhysicsXrayReflection.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "G4Version.hh"
19#if G4VERSION_NUMBER > 1119
20
21#include "BDSDebug.hh"
22#include "BDSGlobalConstants.hh"
23#include "BDSPhysicsXrayReflection.hh"
24
25#include "G4AutoDelete.hh"
26#include "G4Gamma.hh"
27#include "G4ParticleDefinition.hh"
28#include "G4XrayReflection.hh"
29
30#if G4VERSION_NUMBER < 1129
31#include "G4ProcessManager.hh"
32#else
33#include "G4PhysicsListHelper.hh"
34#endif
35
36BDSPhysicsXrayReflection::BDSPhysicsXrayReflection(G4double surfaceRoughnessIn):
37 G4VPhysicsConstructor("BDSPhysicsXrayReflection"),
38 surfaceRoughness(surfaceRoughnessIn)
39{
40 G4cout << __METHOD_NAME__ << "surface roughness: " << surfaceRoughness / CLHEP::nm << " nm" << G4endl;
41}
42
43BDSPhysicsXrayReflection::~BDSPhysicsXrayReflection()
44{;}
45
47{
48 G4Gamma::Gamma();
49}
50
52{
53 if (Activated())
54 {return;}
55
56 G4XrayReflection* reflection = new G4XrayReflection();
57 reflection->SetSurfaceRoughness(surfaceRoughness);
58 G4AutoDelete::Register(reflection);
59
60#if G4VERSION_NUMBER > 1129
61 G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
62#endif
63
64 auto aParticleIterator = GetParticleIterator();
65 aParticleIterator->reset();
66
67 while( (*aParticleIterator)() )
68 {
69 G4ParticleDefinition* particle = aParticleIterator->value();
70 G4String particleName = particle->GetParticleName();
71 if (particleName == "gamma")
72 {
73#if G4VERSION_NUMBER < 1129
74 particle->GetProcessManager()->AddDiscreteProcess(reflection);
75#else
76 ph->RegisterProcess(reflection, particle);
77#endif
78 break;
79 }
80 }
82}
83
84#endif
virtual void ConstructParticle()
Construct gammas.
virtual void ConstructProcess()
Construct and attach the processes to the relevant particles.
G4bool Activated() const
Get whether this instance has been activated.
void SetActivated()
Flag this instance as activated for later querying.