Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpMieHG.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27////////////////////////////////////////////////////////////////////////
28//
29// File G4OpMieHG.hh
30// Description: Discrete Process -- Mie Scattering of Optical Photons
31// Created: 2010-07-03
32// Author: Xin Qian
33// Based on work from Vlasios Vasileiou
34//
35// This subroutine will mimic the Mie scattering based on
36// Henyey-Greenstein phase function
37// Forward and backward angles are treated separately.
38//
39////////////////////////////////////////////////////////////////////////
40
41#include "G4OpMieHG.hh"
44#include "G4OpProcessSubType.hh"
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 : G4VDiscreteProcess(processName, type)
49{
50 Initialise();
51 if(verboseLevel > 0)
52 {
53 G4cout << GetProcessName() << " is created " << G4endl;
54 }
56}
57
58//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59G4OpMieHG::~G4OpMieHG() = default;
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
67//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69{
70 SetVerboseLevel(G4OpticalParameters::Instance()->GetMieVerboseLevel());
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 const G4Step& aStep)
76{
78
79 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
80 const G4MaterialPropertiesTable* MPT =
82
84
85 if(verboseLevel > 1)
86 {
87 G4cout << "OpMie Scattering Photon!" << G4endl
88 << " Old Momentum Direction: " << aParticle->GetMomentumDirection()
89 << G4endl
90 << " MIE Old Polarization: " << aParticle->GetPolarization()
91 << G4endl;
92 }
93
94 G4double gg;
95 G4int direction;
96 if(G4UniformRand() <= forwardRatio)
97 {
99 direction = 1;
100 }
101 else
102 {
104 direction = -1;
105 }
106
108
109 // sample the direction
110 G4double theta;
111 if(gg != 0.)
112 {
113 theta = std::acos(2. * r * (1. + gg) * (1. + gg) * (1. - gg + gg * r) /
114 ((1. - gg + 2. * gg * r) * (1. - gg + 2. * gg * r)) -
115 1.);
116 }
117 else
118 {
119 theta = std::acos(2. * r - 1.);
120 }
121 G4double phi = G4UniformRand() * twopi;
122
123 if(direction == -1)
124 theta = pi - theta; // backward scattering
125
126 G4ThreeVector newMomDir, oldMomDir;
127 G4ThreeVector newPol, oldPol;
128
129 G4double sinth = std::sin(theta);
130 newMomDir.set(sinth * std::cos(phi), sinth * std::sin(phi), std::cos(theta));
131 oldMomDir = aParticle->GetMomentumDirection();
132 newMomDir.rotateUz(oldMomDir);
133 newMomDir = newMomDir.unit();
134
135 oldPol = aParticle->GetPolarization();
136 newPol = newMomDir - oldPol / newMomDir.dot(oldPol);
137 newPol = newPol.unit();
138
139 if(newPol.mag() == 0.)
140 {
141 r = G4UniformRand() * twopi;
142 newPol.set(std::cos(r), std::sin(r), 0.);
143 newPol.rotateUz(newMomDir);
144 }
145 else
146 {
147 // There are two directions perpendicular to new momentum direction
148 if(G4UniformRand() < 0.5)
149 newPol = -newPol;
150 }
151
154
155 if(verboseLevel > 1)
156 {
157 G4cout << "OpMie New Polarization: " << newPol << G4endl
158 << " Polarization Change: " << *(aParticleChange.GetPolarization())
159 << G4endl << " New Momentum Direction: " << newMomDir << G4endl
160 << " Momentum Change: " << *(aParticleChange.GetMomentumDirection())
161 << G4endl;
162 }
163
164 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
165}
166
167//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170{
171 G4double attLength = DBL_MAX;
174 if(MPT)
175 {
177 if(attVector)
178 {
179 attLength = attVector->Value(
180 aTrack.GetDynamicParticle()->GetTotalEnergy(), idx_mie);
181 }
182 }
183 return attLength;
184}
185
186//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ForceCondition
G4ProcessType
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
#define G4UniformRand()
Definition Randomize.hh:52
Hep3Vector unit() const
double dot(const Hep3Vector &) const
double mag() const
void set(double x, double y, double z)
Hep3Vector & rotateUz(const Hep3Vector &)
const G4ThreeVector & GetMomentumDirection() const
G4double GetTotalEnergy() const
const G4ThreeVector & GetPolarization() const
G4double GetConstProperty(const G4String &key) const
G4MaterialPropertyVector * GetProperty(const char *key) const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
virtual G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override
Definition G4OpMieHG.cc:168
G4OpMieHG(const G4String &processName="OpMieHG", G4ProcessType type=fOptical)
Definition G4OpMieHG.cc:47
virtual void PreparePhysicsTable(const G4ParticleDefinition &) override
Definition G4OpMieHG.cc:62
void SetVerboseLevel(G4int)
Definition G4OpMieHG.cc:187
virtual void Initialise()
Definition G4OpMieHG.cc:68
virtual G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
Definition G4OpMieHG.cc:74
virtual ~G4OpMieHG()
static G4OpticalParameters * Instance()
void ProposePolarization(G4double Px, G4double Py, G4double Pz)
const G4ThreeVector * GetPolarization() const
void Initialize(const G4Track &) override
const G4ThreeVector * GetMomentumDirection() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4double Value(const G4double energy, std::size_t &lastidx) const
G4Material * GetMaterial() const
const G4DynamicParticle * GetDynamicParticle() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)
G4ParticleChange aParticleChange
G4int verboseLevel
void SetProcessSubType(G4int)
const G4String & GetProcessName() const
#define DBL_MAX
Definition templates.hh:62