BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLaserCompton.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 "BDSComptonEngine.hh"
19#include "BDSGlobalConstants.hh"
20#include "BDSLaserCompton.hh"
21
22#include "globals.hh"
23#include "G4Gamma.hh"
24
25#include "CLHEP/Units/PhysicalConstants.h"
26
27BDSLaserCompton::BDSLaserCompton(const G4String& processName):
28 G4VDiscreteProcess(processName),
29 laserEnergy(0.0)
30{
32 laserWavelength = globals->GetLaserwireWavelength();
33 laserDirection = globals->GetLaserwireDir();
34 comptonEngine = new BDSComptonEngine();
35}
36
37BDSLaserCompton::~BDSLaserCompton()
38{
39 delete comptonEngine;
40}
41
42G4VParticleChange* BDSLaserCompton::PostStepDoIt(const G4Track& trackData,
43 const G4Step& stepData)
44{
45 aParticleChange.Initialize(trackData);
46
47 // ensure that Laserwire can only occur once in an event
48 //G4cout << "FireLaserCompton == " << FireLaserCompton << G4endl;
49
50 if(!FireLaserCompton)
51 {return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);}
52
53 G4Material* aMaterial = trackData.GetMaterial();
54
55 if (aMaterial == BDSMaterials::Instance()->GetMaterial("LaserVac"))
56 {
57 laserWavelength = globals->GetLaserwireWavelength();
58 laserDirection = globals->GetLaserwireDir();
59
60 laserEnergy = CLHEP::twopi*CLHEP::hbarc/laserWavelength;
61
62 // point laserwire in x: P_x Py Pz E
63 G4LorentzVector Laser4mom(laserEnergy*laserDirection.unit(),laserEnergy);
64
65 const G4DynamicParticle* aDynamicParticle = trackData.GetDynamicParticle();
66
67 comptonEngine->SetIncomingElectron4Vec(aDynamicParticle->Get4Momentum());
68 comptonEngine->SetIncomingPhoton4Vec(Laser4mom);
69 comptonEngine->PerformCompton();
70
71 if(globals->GetLaserwireTrackPhotons())
72 {
73 // create G4DynamicParticle object for the Gamma
74 G4LorentzVector ScatGam = comptonEngine->GetScatteredGamma();
75 G4DynamicParticle* aGamma = new G4DynamicParticle (G4Gamma::Gamma(),
76 ScatGam.vect().unit(),// direction
77 ScatGam.e());
78
79 aParticleChange.SetNumberOfSecondaries(1);
80 aParticleChange.AddSecondary(aGamma);
81 if(!globals->GetLaserwireTrackElectrons())
82 {
83 aParticleChange.ProposeEnergy(0.);
84 aParticleChange.ProposeLocalEnergyDeposit (0.);
85 aParticleChange.ProposeTrackStatus(fStopAndKill);
86 }
87 }
88 else
89 {
90 aParticleChange.SetNumberOfSecondaries(0);
91 aParticleChange.ProposeLocalEnergyDeposit (0.);
92 }
93
94 G4double NewKinEnergy = comptonEngine->GetScatteredElectron().e()-CLHEP::electron_mass_c2;
95
96 G4LorentzVector ScatEl = comptonEngine->GetScatteredElectron();
97
98 if (NewKinEnergy > 0.)
99 {
100 aParticleChange.ProposeMomentumDirection(ScatEl.vect().unit());
101 aParticleChange.ProposeEnergy(NewKinEnergy);
102 aParticleChange.ProposeLocalEnergyDeposit (0.);
103 }
104 else
105 {
106 aParticleChange.ProposeEnergy( 0. );
107 aParticleChange.ProposeLocalEnergyDeposit (0.);
108 G4double charge= aDynamicParticle->GetCharge();
109 if (charge<0.) aParticleChange.ProposeTrackStatus(fStopAndKill);
110 else aParticleChange.ProposeTrackStatus(fStopButAlive);
111 }
112 }
113
114 FireLaserCompton = false;
115
116 return G4VDiscreteProcess::PostStepDoIt(trackData,stepData);
117}
Engine to calculate product of compton scattering process.
static BDSGlobalConstants * Instance()
Access method.
static BDSMaterials * Instance()
Singleton pattern access.