BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLaserPhotoDetachment.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 "BDSAuxiliaryNavigator.hh"
19#include "BDSLaserPhotoDetachment.hh"
20#include "BDSLogicalVolumeLaser.hh"
21#include "BDSLaser.hh"
22#include "BDSPhotoDetachmentEngine.hh"
23#include "BDSStep.hh"
24#include "BDSGlobalConstants.hh"
25
26#include "globals.hh"
27#include "G4AffineTransform.hh"
28#include "G4Electron.hh"
29#include "G4LogicalVolume.hh"
30#include "G4ParticleTable.hh"
31#include "G4ProcessType.hh"
32#include "G4Proton.hh"
33#include "G4Step.hh"
34#include "G4StepPoint.hh"
35#include "G4ThreeVector.hh"
36#include "G4Track.hh"
37#include "G4VTouchable.hh"
38#include "Randomize.hh"
39#include "G4TransportationManager.hh"
40#include "G4VPhysicalVolume.hh"
41#include "G4RandomDirection.hh"
42
43#include "CLHEP/Units/PhysicalConstants.h"
44#include "CLHEP/Units/SystemOfUnits.h"
45
46#include <cmath>
47
48BDSLaserPhotoDetachment::BDSLaserPhotoDetachment(const G4String& processName):
49 G4VDiscreteProcess(processName, G4ProcessType::fElectromagnetic),
50 auxNavigator(new BDSAuxiliaryNavigator()),
51 photoDetachmentEngine(new BDSPhotoDetachmentEngine())
52{;}
53
54BDSLaserPhotoDetachment::~BDSLaserPhotoDetachment()
55{
56 delete auxNavigator;
57 delete photoDetachmentEngine;
58}
59
60G4double BDSLaserPhotoDetachment::GetMeanFreePath(const G4Track& track,
61 G4double /*previousStepSize*/,
62 G4ForceCondition* forceCondition)
63{
64 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
65 if (!lv->IsExtended())
66 {// not extended so can't be a laser logical volume
67 return DBL_MAX;
68 }
69 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser*>(lv);
70 if (!lvv)
71 {// it's an extended volume but not ours (could be a crystal)
72 return DBL_MAX;
73 }
74
75 // else proceed
76 const BDSLaser* laser = lvv->Laser();
77
78 aParticleChange.Initialize(track);
79 const G4DynamicParticle* ion = track.GetDynamicParticle();
80
81 if (ion->GetCharge()==-1)
82 {
83 *forceCondition = Forced;
84 return laser->Sigma0()/10;
85 }
86 else
87 {return DBL_MAX;}
88}
89
90G4VParticleChange* BDSLaserPhotoDetachment::PostStepDoIt(const G4Track& track,
91 const G4Step& step)
92{
93 // get coordinates for photon desity calculations
94 aParticleChange.Initialize(track);
95
96 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
97 if (!lv->IsExtended()) // not extended so can't be a laser logical volume
98 {return pParticleChange;}
99
100 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser *>(lv);
101 if (!lvv) // it's an extended volume but not ours (could be a crystal)
102 {return pParticleChange;}
103
104 // else proceed
105 const BDSLaser* laser = lvv->Laser();
106
107 //G4double stepLength = step.GetStepLength();
108
109 G4DynamicParticle* ion = const_cast<G4DynamicParticle*>(track.GetDynamicParticle());
110
111 G4ThreeVector particlePositionPostStepGlobal = track.GetPosition();
112 G4ThreeVector particleDirectionMomentumGlobal = track.GetMomentumDirection();
113 const G4RotationMatrix* rot = track.GetTouchable()->GetRotation();
114 const G4AffineTransform transform = track.GetTouchable()->GetHistory()->GetTopTransform();
115 G4ThreeVector particlePositionLocal = transform.TransformPoint(particlePositionPostStepGlobal);
116 G4ThreeVector particleDirectionMomentumLocal = transform.TransformPoint(particleDirectionMomentumGlobal).unit();
117
118 // create photon
119 G4ThreeVector photonUnit(0,0,1);
120 photonUnit.transform(*rot);
121 G4double photonEnergy = (CLHEP::h_Planck*CLHEP::c_light)/laser->Wavelength();
122 G4ThreeVector photonVector = photonUnit*photonEnergy;
123 G4LorentzVector photonLorentz = G4LorentzVector(photonVector,photonEnergy);
124
125 G4double ionEnergy = ion->GetTotalEnergy();
126 G4ThreeVector ionMomentum = ion->GetMomentum();
127 G4double ionMass = ion->GetMass();
128 G4ThreeVector ionBeta = ionMomentum/ionEnergy;
129 //G4double ionGamma = ionEnergy/ionMass;
130 //G4double ionVelocity = ionBeta.mag()*CLHEP::c_light;
131 photonLorentz.boost(-ionBeta);
132 G4double photonEnergyLorentz = photonLorentz.e();
133 G4double crossSection = photoDetachmentEngine->CrossSection(photonEnergyLorentz);
134
135 G4double particleTimePostStepGlobal = track.GetGlobalTime();
136 G4double intensity =laser->Intensity(particlePositionLocal);
137 G4double timeProfile=laser->TemporalProfileGaussian(particleTimePostStepGlobal,particlePositionLocal.z());
138 G4double photonFlux = (intensity/photonEnergyLorentz)*timeProfile;
139
140 G4double ionTime = track.GetStep()->GetPreStepPoint()->GetGlobalTime();
141 G4double NeutralisationProbability = 1.0-std::exp(-crossSection*photonFlux*ionTime);
143 G4double scaleFactor = g->ScaleFactorLaser();
144 G4double randomNumber = G4UniformRand();
145
146 if((NeutralisationProbability*scaleFactor)>randomNumber)
147 {
148 // electron kinematics
149 G4ThreeVector randomDirection = G4RandomDirection();
150 G4double hydrogenMass = (CLHEP::electron_mass_c2 + CLHEP::proton_mass_c2);
151 G4double outgoingElectronEnergy = CLHEP::electron_mass_c2;
152
153 G4LorentzVector outgoingElectron;
154 outgoingElectron.setE(outgoingElectronEnergy);
155
156 // hydrogen kinematics
157
158 G4double outgoingH0Energy = ionMass+photonEnergyLorentz-outgoingElectronEnergy;
159 G4double outgoingH0Momentum = std::sqrt(outgoingH0Energy*outgoingH0Energy-hydrogenMass*hydrogenMass);
160 G4LorentzVector outgoingH0;
161 outgoingH0.setPx(-1.0*randomDirection.x()*outgoingH0Momentum);
162 outgoingH0.setPy(-1.0*randomDirection.y()*outgoingH0Momentum);
163 outgoingH0.setPz(-1.0*randomDirection.z()*outgoingH0Momentum);
164 outgoingH0.setE(outgoingH0Energy);
165
166 outgoingElectron.boost(ionBeta);
167 outgoingH0.boost(ionBeta);
168
169
170 // changes to ion to make H0
171 aParticleChange.SetNumberOfSecondaries(1);
172 aParticleChange.ProposeMass(hydrogenMass);
173 G4ThreeVector H0Momentum;
174 H0Momentum.set(outgoingH0.px(),outgoingH0.py(),outgoingH0.pz());
175 aParticleChange.ProposeMomentumDirection(H0Momentum.unit());
176 aParticleChange.ProposeCharge(0);
177 ion->RemoveElectron(1);
178 ion->SetCharge(0);
179
180 // create outgoing electron
181 G4DynamicParticle* electron = new G4DynamicParticle(G4Electron::ElectronDefinition(),
182 outgoingElectron.vect().unit(),
183 outgoingElectron.e());
184 aParticleChange.AddSecondary(electron);
185
186 aParticleChange.ProposeWeight(1.0/scaleFactor);
187
188 return G4VDiscreteProcess::PostStepDoIt(track, step);
189 }
190 else
191 {return G4VDiscreteProcess::PostStepDoIt(track, step);}
192}
193
Extra G4Navigator to get coordinate transforms.
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
Class to provide laser intensity at any point.
Definition BDSLaser.hh:35
G4double Wavelength() const
Accessor.
Definition BDSLaser.hh:63
G4double Sigma0() const
Accessor.
Definition BDSLaser.hh:67
Extended logical volume with laser definition.
const BDSLaser * Laser() const
Access the laser.