00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "G4VLowEnergyDiscretePhotonProcess.hh"
00045
00046 #include "G4PhysicalConstants.hh"
00047 #include "G4SystemOfUnits.hh"
00048 #include "G4String.hh"
00049 #include "G4CrossSectionHandler.hh"
00050 #include "G4CompositeEMDataSet.hh"
00051 #include "G4Gamma.hh"
00052 #include "G4Track.hh"
00053 #include "G4DynamicParticle.hh"
00054 #include "G4ThreeVector.hh"
00055 #include "Randomize.hh"
00056
00057 G4VLowEnergyDiscretePhotonProcess :: G4VLowEnergyDiscretePhotonProcess(const G4String& processName,
00058 const G4String& aCrossSectionFileName,
00059 const G4String& aScatterFileName,
00060 G4VDataSetAlgorithm* aScatterInterpolation,
00061 G4double aLowEnergyLimit,
00062 G4double aHighEnergyLimit)
00063 :
00064 G4VLowEnergyTestableDiscreteProcess(processName),
00065 lowEnergyLimit(aLowEnergyLimit),
00066 highEnergyLimit(aHighEnergyLimit),
00067 crossSectionFileName(aCrossSectionFileName),
00068 meanFreePathTable(0)
00069 {
00070 crossSectionHandler = new G4CrossSectionHandler();
00071 scatterFunctionData = new G4CompositeEMDataSet(aScatterInterpolation, 1., 1.);
00072 scatterFunctionData->LoadData(aScatterFileName);
00073
00074 if (verboseLevel > 0)
00075 {
00076 G4cout << GetProcessName() << " is created " << G4endl
00077 << "Energy range: "
00078 << lowEnergyLimit / keV << " keV - "
00079 << highEnergyLimit / GeV << " GeV"
00080 << G4endl;
00081 }
00082 }
00083
00084
00085
00086 G4VLowEnergyDiscretePhotonProcess::~G4VLowEnergyDiscretePhotonProcess(void)
00087 {
00088 if (meanFreePathTable)
00089 delete meanFreePathTable;
00090
00091 delete crossSectionHandler;
00092 delete scatterFunctionData;
00093 }
00094
00095
00096
00097
00098
00099 G4bool G4VLowEnergyDiscretePhotonProcess::IsApplicable(const G4ParticleDefinition& particleDefinition)
00100 {
00101 return (&particleDefinition)==G4Gamma::Gamma();
00102 }
00103
00104
00105
00106 void G4VLowEnergyDiscretePhotonProcess::BuildPhysicsTable(const G4ParticleDefinition& )
00107 {
00108 crossSectionHandler->Clear();
00109 crossSectionHandler->LoadData(crossSectionFileName);
00110
00111 if (meanFreePathTable)
00112 delete meanFreePathTable;
00113 meanFreePathTable=crossSectionHandler->BuildMeanFreePathForMaterials();
00114 }
00115
00116
00117
00118
00119
00120 G4double G4VLowEnergyDiscretePhotonProcess::GetMeanFreePath(const G4Track& aTrack, G4double , G4ForceCondition* )
00121 {
00122 G4double photonEnergy;
00123 photonEnergy = aTrack.GetDynamicParticle()->GetKineticEnergy();
00124
00125 if (photonEnergy < lowEnergyLimit)
00126 return DBL_MAX;
00127
00128 if (photonEnergy > highEnergyLimit)
00129 photonEnergy=highEnergyLimit;
00130
00131 size_t materialIndex;
00132 materialIndex = aTrack.GetMaterialCutsCouple()->GetIndex();
00133
00134 return meanFreePathTable->FindValue(photonEnergy, materialIndex);
00135 }
00136
00137
00138
00139
00140
00141 G4ThreeVector G4VLowEnergyDiscretePhotonProcess::GetPhotonPolarization(const G4DynamicParticle& photon)
00142 {
00143 G4ThreeVector photonMomentumDirection;
00144 G4ThreeVector photonPolarization;
00145
00146 photonPolarization = photon.GetPolarization();
00147 photonMomentumDirection = photon.GetMomentumDirection();
00148
00149 if ((!photonPolarization.isOrthogonal(photonMomentumDirection, 1e-6)) || photonPolarization.mag()==0.)
00150 {
00151
00152
00153
00154 G4ThreeVector e1(photonMomentumDirection.orthogonal().unit());
00155 G4ThreeVector e2(photonMomentumDirection.cross(e1).unit());
00156
00157 G4double angle(G4UniformRand() * twopi);
00158
00159 e1*=std::cos(angle);
00160 e2*=std::sin(angle);
00161
00162 photonPolarization=e1+e2;
00163 }
00164 else if (photonPolarization.howOrthogonal(photonMomentumDirection) != 0.)
00165 {
00166
00167
00168
00169 photonPolarization=photonPolarization.perpPart(photonMomentumDirection);
00170 }
00171
00172 return photonPolarization.unit();
00173 }