BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLaserIonExcitation.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 "BDSElectronQuantumLevel.hh"
20#include "BDSGlobalConstants.hh"
21#include "BDSIonExcitationEngine.hh"
22#include "BDSLaserIonExcitation.hh"
23#include "BDSLogicalVolumeLaser.hh"
24#include "BDSLaser.hh"
25#include "BDSStep.hh"
26#include "BDSUserTrackInformation.hh"
27
28#include "globals.hh"
29#include "G4AffineTransform.hh"
30#include "G4Electron.hh"
31#include "G4DecayProducts.hh"
32#include "G4Hydrogen.hh"
33#include "G4LogicalVolume.hh"
34#include "G4ParticleTable.hh"
35#include "G4ProcessType.hh"
36#include "G4Proton.hh"
37#include "G4Step.hh"
38#include "G4StepPoint.hh"
39#include "G4ThreeVector.hh"
40#include "G4Track.hh"
41#include "G4VTouchable.hh"
42#include "Randomize.hh"
43#include "G4TransportationManager.hh"
44#include "G4VPhysicalVolume.hh"
45#include "BDSElectronOccupancy.hh"
46
47#include "CLHEP/Units/PhysicalConstants.h"
48#include "CLHEP/Units/SystemOfUnits.h"
49
50#include <cmath>
51#include <limits>
52
53BDSLaserIonExcitation::BDSLaserIonExcitation(const G4String& processName):
54 G4VDiscreteProcess(processName, G4ProcessType::fUserDefined),
55 auxNavigator(new BDSAuxiliaryNavigator())
56{;}
57
58BDSLaserIonExcitation::~BDSLaserIonExcitation()
59{
60 delete auxNavigator;
61}
62
63G4double BDSLaserIonExcitation::GetMeanFreePath(const G4Track& track,
64 G4double /*previousStepSize*/,
65 G4ForceCondition* forceCondition)
66{
67 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
68 BDSUserTrackInformation* trackInfo = dynamic_cast<BDSUserTrackInformation*>(track.GetUserInformation());
69
70 if (!lv->IsExtended())
71 {// not extended so can't be a laser logical volume
72 return std::numeric_limits<double>::max();
73 }
74 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser*>(lv);
75 if (!lvv)
76 {// it's an extended volume but not ours (could be a crystal)
77 return std::numeric_limits<double>::max();
78 }
79 G4bool excited = trackInfo->GetElectronOccupancy()->StatePopulated(2,1,0.5);
80 if(excited)
81 {// its already in the excited state cannot be excited again
82 return std::numeric_limits<double>::max();
83 }
84
85 const BDSLaser* laser = lvv->Laser();
86 aParticleChange.Initialize(track);
87
88 *forceCondition = Forced;
89 return laser->Sigma0()/10;
90}
91
92G4VParticleChange* BDSLaserIonExcitation::PostStepDoIt(const G4Track& track,
93 const G4Step& step)
94{
95 // get coordinates for photon desity calculations
96 aParticleChange.Initialize(track);
97 //copied from mfp to access laser instance is clearly incorrect!
98
99 G4LogicalVolume* lv = track.GetVolume()->GetLogicalVolume();
100 if (!lv->IsExtended())// not extended so can't be a laser logical volume
101 {return pParticleChange;}
102
103 BDSLogicalVolumeLaser* lvv = dynamic_cast<BDSLogicalVolumeLaser *>(lv);
104 if (!lvv) // it's an extended volume but not ours (could be a crystal)
105 {return pParticleChange;}
106 // else proceed
107
108 const BDSLaser* laser = lvv->Laser();
109 G4double stepLength = step.GetStepLength();
110 G4DynamicParticle* ion = const_cast<G4DynamicParticle*>(track.GetDynamicParticle());
111
112 G4ThreeVector particlePositionGlobal = track.GetPosition();
113 G4ThreeVector particleDirectionMomentumGlobal = track.GetMomentumDirection();
114 const G4RotationMatrix* rot = track.GetTouchable()->GetRotation();
115 const G4AffineTransform transform = track.GetTouchable()->GetHistory()->GetTopTransform();
116 G4ThreeVector particlePositionLocal = transform.TransformPoint(particlePositionGlobal);
117 G4ThreeVector particleDirectionMomentumLocal = transform.TransformPoint(particleDirectionMomentumGlobal).unit();
118
119 BDSIonExcitationEngine* ionExcitationEngine = new BDSIonExcitationEngine();
120 // create photon
121 // photon vector in laser frame coordinates
122 G4ThreeVector photonUnit(0, 0, 1);
123 //translate into lab frame coordinates
124 G4double photonE = (CLHEP::h_Planck * CLHEP::c_light) / laser->Wavelength();
125 G4ThreeVector photonVector = photonUnit * photonE;
126 photonVector.transform(*rot);
127 G4LorentzVector photonLorentz = G4LorentzVector(photonVector, photonE);
128
129 G4double ionEnergy = ion->GetTotalEnergy();
130 G4ThreeVector ionMomentum = ion->GetMomentum();
131 G4ThreeVector ionBeta = ionMomentum / ionEnergy;
132 G4double ionVelocity = ionBeta.mag() * CLHEP::c_light;
133 photonLorentz.boost(-ionBeta);
134 G4double photonEnergy = photonLorentz.e();
135 G4double crossSection = ionExcitationEngine->CrossSection(photonEnergy);
136 G4double particleGlobalTime = track.GetGlobalTime();
137 G4double photonFlux = (laser->Intensity(particlePositionLocal)*laser->TemporalProfileGaussian(particleGlobalTime,particlePositionLocal.z()))/photonEnergy;
138 G4LorentzVector ion4Vector = ion->Get4Momentum();
139 ion4Vector.boost(-ionBeta);
140
141 G4double ionTime = (stepLength / ionVelocity);
142 G4double excitationProbability = 1.0 - std::exp(-crossSection * photonFlux * ionTime);
144 G4double scaleFactor = g->ScaleFactorLaser();
145 G4double randomNumber = G4UniformRand();
146
147 if ((excitationProbability * scaleFactor) > randomNumber)
148 {
149 BDSUserTrackInformation* userInfo = dynamic_cast<BDSUserTrackInformation*>(track.GetUserInformation());
150 userInfo->GetElectronOccupancy()->RemoveElectrons(2,0,0.5,1);
151 userInfo->GetElectronOccupancy()->AddElectrons(2,1,0.5,1);
152 userInfo->GetElectronOccupancy()->SetTimeOfExciation(ion->GetProperTime(),2,1,(1/2));
153 // Kinematics
154 ionExcitationEngine->setIncomingGamma(photonLorentz);
155 ionExcitationEngine->setIncomingIon(ion4Vector);
156 ionExcitationEngine->PhotonAbsorption(ionBeta);
157 G4LorentzVector scatteredIon = ionExcitationEngine->GetScatteredIonAbsorption();
158
159 G4LorentzVector IonLorentz = G4LorentzVector(scatteredIon.vect().unit(),scatteredIon.e());
160
161 aParticleChange.ProposeEnergy(scatteredIon.e());
162 aParticleChange.ProposeMomentumDirection(IonLorentz.getX(),IonLorentz.getY(),IonLorentz.getZ());
163 aParticleChange.ProposeWeight(scaleFactor);
164 }
165
166 delete ionExcitationEngine;
167
168 return G4VDiscreteProcess::PostStepDoIt(track,step);
169}
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.