Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes
G4OpRayleigh Class Reference

#include <G4OpRayleigh.hh>

Inheritance diagram for G4OpRayleigh:
G4VDiscreteProcess G4VProcess

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 76 of file G4OpRayleigh.hh.

Constructor & Destructor Documentation

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

Definition at line 82 of file G4OpRayleigh.cc.

References fOpRayleigh, G4cout, G4endl, G4VProcess::GetProcessName(), G4VProcess::SetProcessSubType(), thePhysicsTable, and G4VProcess::verboseLevel.

83  : G4VDiscreteProcess(processName, type)
84 {
86 
87  thePhysicsTable = NULL;
88 
89  DefaultWater = false;
90 
91  if (verboseLevel>0) {
92  G4cout << GetProcessName() << " is created " << G4endl;
93  }
94 }
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
G4OpRayleigh::~G4OpRayleigh ( )

Definition at line 104 of file G4OpRayleigh.cc.

References G4PhysicsTable::clearAndDestroy(), and thePhysicsTable.

105 {
106  if (thePhysicsTable!= NULL) {
108  delete thePhysicsTable;
109  }
110 }
G4PhysicsTable * thePhysicsTable
void clearAndDestroy()

Member Function Documentation

void G4OpRayleigh::BuildPhysicsTable ( const G4ParticleDefinition aParticleType)
virtual

Reimplemented from G4VProcess.

Definition at line 116 of file G4OpRayleigh.cc.

References thePhysicsTable.

117 {
118  if (!thePhysicsTable) BuildThePhysicsTable();
119 }
G4PhysicsTable * thePhysicsTable
void G4OpRayleigh::DumpPhysicsTable ( ) const
inline

Definition at line 166 of file G4OpRayleigh.hh.

References G4PhysicsOrderedFreeVector::DumpValues(), G4PhysicsTable::entries(), thePhysicsTable, and test::v.

168 {
169  G4int PhysicsTableSize = thePhysicsTable->entries();
171 
172  for (G4int i = 0 ; i < PhysicsTableSize ; i++ )
173  {
175  v->DumpValues();
176  }
177 }
int G4int
Definition: G4Types.hh:78
G4PhysicsTable * thePhysicsTable
size_t entries() const
G4double G4OpRayleigh::GetMeanFreePath ( const G4Track aTrack,
G4double  ,
G4ForceCondition  
)
virtual

Implements G4VDiscreteProcess.

Definition at line 265 of file G4OpRayleigh.cc.

References DBL_MAX, G4Track::GetDynamicParticle(), G4Material::GetIndex(), G4Track::GetMaterial(), G4Material::GetMaterialPropertiesTable(), G4Material::GetName(), G4MaterialPropertiesTable::GetProperty(), and G4DynamicParticle::GetTotalEnergy().

268 {
269  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
270  const G4Material* aMaterial = aTrack.GetMaterial();
271 
272  G4double thePhotonEnergy = aParticle->GetTotalEnergy();
273 
274  G4double AttenuationLength = DBL_MAX;
275 
276  if (aMaterial->GetName() == "Water" && DefaultWater){
277 
278  G4bool isOutRange;
279 
280  AttenuationLength =
281  (*thePhysicsTable)(aMaterial->GetIndex())->
282  GetValue(thePhotonEnergy, isOutRange);
283  }
284  else {
285 
286  G4MaterialPropertiesTable* aMaterialPropertyTable =
287  aMaterial->GetMaterialPropertiesTable();
288 
289  if(aMaterialPropertyTable){
290  G4MaterialPropertyVector* AttenuationLengthVector =
291  aMaterialPropertyTable->GetProperty("RAYLEIGH");
292  if(AttenuationLengthVector){
293  AttenuationLength = AttenuationLengthVector ->
294  Value(thePhotonEnergy);
295  }
296  else{
297 // G4cout << "No Rayleigh scattering length specified" << G4endl;
298  }
299  }
300  else{
301 // G4cout << "No Rayleigh scattering length specified" << G4endl;
302  }
303  }
304 
305  return AttenuationLength;
306 }
G4MaterialPropertyVector * GetProperty(const char *key)
G4double GetTotalEnergy() const
const G4DynamicParticle * GetDynamicParticle() const
size_t GetIndex() const
Definition: G4Material.hh:260
const G4String & GetName() const
Definition: G4Material.hh:176
bool G4bool
Definition: G4Types.hh:79
G4Material * GetMaterial() const
G4MaterialPropertiesTable * GetMaterialPropertiesTable() const
Definition: G4Material.hh:250
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83
G4PhysicsTable * G4OpRayleigh::GetPhysicsTable ( ) const
inline

Definition at line 179 of file G4OpRayleigh.hh.

References thePhysicsTable.

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

Reimplemented from G4VProcess.

Definition at line 160 of file G4OpRayleigh.hh.

References G4OpticalPhoton::OpticalPhoton().

161 {
162  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
163 }
static G4OpticalPhoton * OpticalPhoton()
G4VParticleChange * G4OpRayleigh::PostStepDoIt ( const G4Track aTrack,
const G4Step aStep 
)
virtual

Reimplemented from G4VDiscreteProcess.

Definition at line 125 of file G4OpRayleigh.cc.

References G4VProcess::aParticleChange, CLHEP::Hep3Vector::dot(), G4cout, G4endl, G4UniformRand, G4Track::GetDynamicParticle(), G4DynamicParticle::GetMomentumDirection(), G4ParticleChange::GetMomentumDirection(), G4ParticleChange::GetPolarization(), G4DynamicParticle::GetPolarization(), G4ParticleChange::Initialize(), CLHEP::Hep3Vector::mag(), G4VDiscreteProcess::PostStepDoIt(), G4ParticleChange::ProposeMomentumDirection(), G4ParticleChange::ProposePolarization(), CLHEP::Hep3Vector::rotateUz(), CLHEP::Hep3Vector::set(), python.hepunit::twopi, CLHEP::Hep3Vector::unit(), and G4VProcess::verboseLevel.

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

Field Documentation

G4PhysicsTable* G4OpRayleigh::thePhysicsTable
protected

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