Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpRayleigh Class Reference

#include <G4OpRayleigh.hh>

Inheritance diagram for G4OpRayleigh:
Collaboration diagram for G4OpRayleigh:

Public Member Functions

 G4OpRayleigh (const G4String &processName="OpRayleigh", G4ProcessType type=fOptical)
 
 ~G4OpRayleigh ()
 
G4bool IsApplicable (const G4ParticleDefinition &aParticleType)
 
void BuildPhysicsTable (const G4ParticleDefinition &aParticleType)
 
G4double GetMeanFreePath (const G4Track &aTrack, G4double, G4ForceCondition *)
 
G4VParticleChangePostStepDoIt (const G4Track &aTrack, const G4Step &aStep)
 
G4PhysicsTableGetPhysicsTable () const
 
void DumpPhysicsTable () const
 
- Public Member Functions inherited from G4VDiscreteProcess
 G4VDiscreteProcess (const G4String &, G4ProcessType aType=fNotDefined)
 
 G4VDiscreteProcess (G4VDiscreteProcess &)
 
virtual ~G4VDiscreteProcess ()
 
virtual G4double PostStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual G4double AlongStepGetPhysicalInteractionLength (const G4Track &, G4double, G4double, G4double &, G4GPILSelection *)
 
virtual G4double AtRestGetPhysicalInteractionLength (const G4Track &, G4ForceCondition *)
 
virtual G4VParticleChangeAtRestDoIt (const G4Track &, const G4Step &)
 
virtual G4VParticleChangeAlongStepDoIt (const G4Track &, const G4Step &)
 
- Public Member Functions inherited from G4VProcess
 G4VProcess (const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
 
 G4VProcess (const G4VProcess &right)
 
virtual ~G4VProcess ()
 
G4int operator== (const G4VProcess &right) const
 
G4int operator!= (const G4VProcess &right) const
 
G4double GetCurrentInteractionLength () const
 
void SetPILfactor (G4double value)
 
G4double GetPILfactor () const
 
G4double AlongStepGPIL (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
 
G4double AtRestGPIL (const G4Track &track, G4ForceCondition *condition)
 
G4double PostStepGPIL (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual void PreparePhysicsTable (const G4ParticleDefinition &)
 
virtual G4bool StorePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
virtual G4bool RetrievePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
const G4StringGetPhysicsTableFileName (const G4ParticleDefinition *, const G4String &directory, const G4String &tableName, G4bool ascii=false)
 
const G4StringGetProcessName () const
 
G4ProcessType GetProcessType () const
 
void SetProcessType (G4ProcessType)
 
G4int GetProcessSubType () const
 
void SetProcessSubType (G4int)
 
virtual void StartTracking (G4Track *)
 
virtual void EndTracking ()
 
virtual void SetProcessManager (const G4ProcessManager *)
 
virtual const G4ProcessManagerGetProcessManager ()
 
virtual void ResetNumberOfInteractionLengthLeft ()
 
G4double GetNumberOfInteractionLengthLeft () const
 
G4double GetTotalNumberOfInteractionLengthTraversed () const
 
G4bool isAtRestDoItIsEnabled () const
 
G4bool isAlongStepDoItIsEnabled () const
 
G4bool isPostStepDoItIsEnabled () const
 
virtual void DumpInfo () const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 
virtual void SetMasterProcess (G4VProcess *masterP)
 
const G4VProcessGetMasterProcess () const
 
virtual void BuildWorkerPhysicsTable (const G4ParticleDefinition &part)
 
virtual void PrepareWorkerPhysicsTable (const G4ParticleDefinition &)
 

Protected Attributes

G4PhysicsTablethePhysicsTable
 
- Protected Attributes inherited from G4VProcess
const G4ProcessManageraProcessManager
 
G4VParticleChangepParticleChange
 
G4ParticleChange aParticleChange
 
G4double theNumberOfInteractionLengthLeft
 
G4double currentInteractionLength
 
G4double theInitialNumberOfInteractionLength
 
G4String theProcessName
 
G4String thePhysicsTableFileName
 
G4ProcessType theProcessType
 
G4int theProcessSubType
 
G4double thePILfactor
 
G4bool enableAtRestDoIt
 
G4bool enableAlongStepDoIt
 
G4bool enablePostStepDoIt
 
G4int verboseLevel
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VProcess
static const G4StringGetProcessTypeName (G4ProcessType)
 
- Protected Member Functions inherited from G4VProcess
void SubtractNumberOfInteractionLengthLeft (G4double previousStepSize)
 
void ClearNumberOfInteractionLengthLeft ()
 

Detailed Description

Definition at line 77 of file G4OpRayleigh.hh.

Constructor & Destructor Documentation

G4OpRayleigh::G4OpRayleigh ( const G4String processName = "OpRayleigh",
G4ProcessType  type = fOptical 
)

Definition at line 88 of file G4OpRayleigh.cc.

89  : G4VDiscreteProcess(processName, type)
90 {
92 
93  thePhysicsTable = NULL;
94 
95  if (verboseLevel>0) {
96  G4cout << GetProcessName() << " is created " << G4endl;
97  }
98 }
G4int verboseLevel
Definition: G4VProcess.hh:368
G4PhysicsTable * thePhysicsTable
G4GLOB_DLL std::ostream G4cout
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4OpRayleigh::~G4OpRayleigh ( )

Definition at line 108 of file G4OpRayleigh.cc.

109 {
110  if (thePhysicsTable) {
112  delete thePhysicsTable;
113  }
114 }
G4PhysicsTable * thePhysicsTable
void clearAndDestroy()

Here is the call graph for this function:

Member Function Documentation

void G4OpRayleigh::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)
virtual

Reimplemented from G4VProcess.

Definition at line 217 of file G4OpRayleigh.cc.

218 {
219  if (thePhysicsTable) {
221  delete thePhysicsTable;
222  thePhysicsTable = NULL;
223  }
224 
225  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
226  const G4int numOfMaterials = G4Material::GetNumberOfMaterials();
227 
228  thePhysicsTable = new G4PhysicsTable( numOfMaterials );
229 
230  for( G4int iMaterial = 0; iMaterial < numOfMaterials; iMaterial++ )
231  {
232  G4Material* material = (*theMaterialTable)[iMaterial];
233  G4MaterialPropertiesTable* materialProperties =
234  material->GetMaterialPropertiesTable();
235  G4PhysicsOrderedFreeVector* rayleigh = NULL;
236  if ( materialProperties != NULL ) {
237  rayleigh = materialProperties->GetProperty( "RAYLEIGH" );
238  if ( rayleigh == NULL ) rayleigh =
239  CalculateRayleighMeanFreePaths( material );
240  }
241  thePhysicsTable->insertAt( iMaterial, rayleigh );
242  }
243 }
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
int G4int
Definition: G4Types.hh:78
G4PhysicsTable * thePhysicsTable
string material
Definition: eplot.py:19
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:594
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:252
void insertAt(size_t, G4PhysicsVector *)
G4MaterialPropertyVector * GetProperty(const char *key)
void clearAndDestroy()

Here is the call graph for this function:

void G4OpRayleigh::DumpPhysicsTable ( ) const
inline

Definition at line 167 of file G4OpRayleigh.hh.

169 {
170  G4int PhysicsTableSize = thePhysicsTable->entries();
172 
173  for (G4int i = 0 ; i < PhysicsTableSize ; i++ )
174  {
176  v->DumpValues();
177  }
178 }
void DumpValues(G4double unitE=1.0, G4double unitV=1.0) const
int G4int
Definition: G4Types.hh:78
G4PhysicsTable * thePhysicsTable
tuple v
Definition: test.py:18
size_t entries() const

Here is the call graph for this function:

G4double G4OpRayleigh::GetMeanFreePath ( const G4Track aTrack,
G4double  ,
G4ForceCondition  
)
virtual

Implements G4VDiscreteProcess.

Definition at line 248 of file G4OpRayleigh.cc.

251 {
252  const G4DynamicParticle* particle = aTrack.GetDynamicParticle();
253  const G4double photonMomentum = particle->GetTotalMomentum();
254  const G4Material* material = aTrack.GetMaterial();
255 
256  G4PhysicsOrderedFreeVector* rayleigh =
257  static_cast<G4PhysicsOrderedFreeVector*>
258  ((*thePhysicsTable)(material->GetIndex()));
259 
260  G4double rsLength = DBL_MAX;
261  if( rayleigh != NULL ) rsLength = rayleigh->Value( photonMomentum );
262  return rsLength;
263 }
const G4DynamicParticle * GetDynamicParticle() const
size_t GetIndex() const
Definition: G4Material.hh:262
G4double GetTotalMomentum() const
string material
Definition: eplot.py:19
G4double Value(G4double theEnergy, size_t &lastidx) const
G4Material * GetMaterial() const
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83

Here is the call graph for this function:

G4PhysicsTable * G4OpRayleigh::GetPhysicsTable ( ) const
inline

Definition at line 180 of file G4OpRayleigh.hh.

181 {
182  return thePhysicsTable;
183 }
G4PhysicsTable * thePhysicsTable
G4bool G4OpRayleigh::IsApplicable ( const G4ParticleDefinition aParticleType)
inlinevirtual

Reimplemented from G4VProcess.

Definition at line 161 of file G4OpRayleigh.hh.

162 {
163  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
164 }
static G4OpticalPhoton * OpticalPhoton()

Here is the call graph for this function:

G4VParticleChange * G4OpRayleigh::PostStepDoIt ( const G4Track aTrack,
const G4Step aStep 
)
virtual

Reimplemented from G4VDiscreteProcess.

Definition at line 124 of file G4OpRayleigh.cc.

125 {
126  aParticleChange.Initialize(aTrack);
127 
128  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
129 
130  if (verboseLevel>0) {
131  G4cout << "Scattering Photon!" << G4endl;
132  G4cout << "Old Momentum Direction: "
133  << aParticle->GetMomentumDirection() << G4endl;
134  G4cout << "Old Polarization: "
135  << aParticle->GetPolarization() << G4endl;
136  }
137 
138  G4double cosTheta;
139  G4ThreeVector OldMomentumDirection, NewMomentumDirection;
140  G4ThreeVector OldPolarization, NewPolarization;
141 
142  G4double rand, constant;
143  G4double CosTheta, SinTheta, SinPhi, CosPhi, unit_x, unit_y, unit_z;
144 
145  do {
146  // Try to simulate the scattered photon momentum direction
147  // w.r.t. the initial photon momentum direction
148 
149  CosTheta = G4UniformRand();
150  SinTheta = std::sqrt(1.-CosTheta*CosTheta);
151  // consider for the angle 90-180 degrees
152  if (G4UniformRand() < 0.5) CosTheta = -CosTheta;
153 
154  // simulate the phi angle
155  rand = twopi*G4UniformRand();
156  SinPhi = std::sin(rand);
157  CosPhi = std::cos(rand);
158 
159  // start constructing the new momentum direction
160  unit_x = SinTheta * CosPhi;
161  unit_y = SinTheta * SinPhi;
162  unit_z = CosTheta;
163  NewMomentumDirection.set (unit_x,unit_y,unit_z);
164 
165  // Rotate the new momentum direction into global reference system
166  OldMomentumDirection = aParticle->GetMomentumDirection();
167  OldMomentumDirection = OldMomentumDirection.unit();
168  NewMomentumDirection.rotateUz(OldMomentumDirection);
169  NewMomentumDirection = NewMomentumDirection.unit();
170 
171  // calculate the new polarization direction
172  // The new polarization needs to be in the same plane as the new
173  // momentum direction and the old polarization direction
174  OldPolarization = aParticle->GetPolarization();
175  constant = -NewMomentumDirection.dot(OldPolarization);
176 
177  NewPolarization = OldPolarization + constant*NewMomentumDirection;
178  NewPolarization = NewPolarization.unit();
179 
180  // There is a corner case, where the Newmomentum direction
181  // is the same as oldpolariztion direction:
182  // random generate the azimuthal angle w.r.t. Newmomentum direction
183  if (NewPolarization.mag() == 0.) {
184  rand = G4UniformRand()*twopi;
185  NewPolarization.set(std::cos(rand),std::sin(rand),0.);
186  NewPolarization.rotateUz(NewMomentumDirection);
187  } else {
188  // There are two directions which are perpendicular
189  // to the new momentum direction
190  if (G4UniformRand() < 0.5) NewPolarization = -NewPolarization;
191  }
192 
193  // simulate according to the distribution cos^2(theta)
194  cosTheta = NewPolarization.dot(OldPolarization);
195  // Loop checking, 13-Aug-2015, Peter Gumplinger
196  } while (std::pow(cosTheta,2) < G4UniformRand());
197 
198  aParticleChange.ProposePolarization(NewPolarization);
199  aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
200 
201  if (verboseLevel>0) {
202  G4cout << "New Polarization: "
203  << NewPolarization << G4endl;
204  G4cout << "Polarization Change: "
205  << *(aParticleChange.GetPolarization()) << G4endl;
206  G4cout << "New Momentum Direction: "
207  << NewMomentumDirection << G4endl;
208  G4cout << "Momentum Change: "
209  << *(aParticleChange.GetMomentumDirection()) << G4endl;
210  }
211 
212  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
213 }
void set(double x, double y, double z)
G4int verboseLevel
Definition: G4VProcess.hh:368
const G4DynamicParticle * GetDynamicParticle() const
double dot(const Hep3Vector &) const
void ProposePolarization(G4double Px, G4double Py, G4double Pz)
const G4ThreeVector * GetMomentumDirection() const
static constexpr double twopi
Definition: G4SIunits.hh:76
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
const G4ThreeVector & GetMomentumDirection() const
Hep3Vector & rotateUz(const Hep3Vector &)
Definition: ThreeVector.cc:38
virtual void Initialize(const G4Track &)
Hep3Vector unit() const
const G4ThreeVector & GetPolarization() const
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
#define G4endl
Definition: G4ios.hh:61
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
double G4double
Definition: G4Types.hh:76
const G4ThreeVector * GetPolarization() const
double mag() const
virtual G4VParticleChange * PostStepDoIt(const G4Track &, const G4Step &)

Here is the call graph for this function:

Member Data Documentation

G4PhysicsTable* G4OpRayleigh::thePhysicsTable
protected

Definition at line 148 of file G4OpRayleigh.hh.


The documentation for this class was generated from the following files: