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 #include "G4VCrossSectionDataSet.hh"
00043 #include "G4SystemOfUnits.hh"
00044 #include "G4CrossSectionDataSetRegistry.hh"
00045 #include "G4DynamicParticle.hh"
00046 #include "G4Material.hh"
00047 #include "G4Element.hh"
00048 #include "G4Isotope.hh"
00049 #include "G4NistManager.hh"
00050 #include "G4HadronicException.hh"
00051 #include "G4HadTmpUtil.hh"
00052 #include "Randomize.hh"
00053
00054 G4VCrossSectionDataSet::G4VCrossSectionDataSet(const G4String& nam) :
00055 verboseLevel(0),minKinEnergy(0.0),maxKinEnergy(100*TeV),name(nam)
00056 {
00057 G4CrossSectionDataSetRegistry::Instance()->Register(this);
00058 }
00059
00060 G4VCrossSectionDataSet::~G4VCrossSectionDataSet()
00061 {
00062 G4CrossSectionDataSetRegistry::Instance()->DeRegister(this);
00063 }
00064
00065 G4bool
00066 G4VCrossSectionDataSet::IsElementApplicable(const G4DynamicParticle*,
00067 G4int,
00068 const G4Material*)
00069 {
00070 return false;
00071 }
00072
00073 G4bool
00074 G4VCrossSectionDataSet::IsIsoApplicable(const G4DynamicParticle*,
00075 G4int, G4int,
00076 const G4Element*,
00077 const G4Material*)
00078 {
00079 return false;
00080 }
00081
00082 G4double
00083 G4VCrossSectionDataSet::ComputeCrossSection(const G4DynamicParticle* part,
00084 const G4Element* elm,
00085 const G4Material* mat)
00086 {
00087 G4int Z = G4lrint(elm->GetZ());
00088
00089 if (IsElementApplicable(part, Z, mat)) {
00090 return GetElementCrossSection(part, Z, mat);
00091 }
00092
00093
00094
00095
00096 G4int nIso = elm->GetNumberOfIsotopes();
00097 G4double fact = 0.0;
00098 G4double xsec = 0.0;
00099 G4Isotope* iso = 0;
00100
00101 if (0 < nIso) {
00102
00103
00104 G4IsotopeVector* isoVector = elm->GetIsotopeVector();
00105 G4double* abundVector = elm->GetRelativeAbundanceVector();
00106
00107 for (G4int j = 0; j<nIso; ++j) {
00108 iso = (*isoVector)[j];
00109 G4int A = iso->GetN();
00110 if(abundVector[j] > 0.0 && IsIsoApplicable(part, Z, A, elm, mat)) {
00111 fact += abundVector[j];
00112 xsec += abundVector[j]*GetIsoCrossSection(part, Z, A, iso, elm, mat);
00113 }
00114 }
00115
00116 } else {
00117
00118
00119 G4NistManager* nist = G4NistManager::Instance();
00120 G4int n0 = nist->GetNistFirstIsotopeN(Z);
00121 G4int nn = nist->GetNumberOfNistIsotopes(Z);
00122 for (G4int A = n0; A < n0+nn; ++A) {
00123 G4double abund = nist->GetIsotopeAbundance(Z, A);
00124 if(abund > 0.0 && IsIsoApplicable(part, Z, A, elm, mat)) {
00125 fact += abund;
00126 xsec += abund*GetIsoCrossSection(part, Z, A, iso, elm, mat);
00127 }
00128 }
00129 }
00130 if(fact > 0.0) { xsec /= fact; }
00131 return xsec;
00132 }
00133
00134 G4double
00135 G4VCrossSectionDataSet::GetElementCrossSection(const G4DynamicParticle* dynPart,
00136 G4int Z,
00137 const G4Material* mat)
00138 {
00139 G4cout << "G4VCrossSectionDataSet::GetCrossSection per element ERROR: "
00140 << " there is no cross section for "
00141 << dynPart->GetDefinition()->GetParticleName()
00142 << " E(MeV)= " << dynPart->GetKineticEnergy()/MeV;
00143 if(mat) { G4cout << " inside " << mat->GetName(); }
00144 G4cout << " for Z= " << Z << G4endl;
00145 throw G4HadronicException(__FILE__, __LINE__,
00146 "G4VCrossSectionDataSet::GetElementCrossSection is absent");
00147 return 0.0;
00148 }
00149
00150 G4double
00151 G4VCrossSectionDataSet::GetIsoCrossSection(const G4DynamicParticle* dynPart,
00152 G4int Z, G4int A,
00153 const G4Isotope*,
00154 const G4Element* elm,
00155 const G4Material* mat)
00156 {
00157 G4cout << "G4VCrossSectionDataSet::GetCrossSection per isotope ERROR: "
00158 << " there is no cross section for "
00159 << dynPart->GetDefinition()->GetParticleName()
00160 << " E(MeV)= " << dynPart->GetKineticEnergy()/MeV;
00161 if(mat) { G4cout << " inside " << mat->GetName(); }
00162 if(elm) { G4cout << " for " << elm->GetName(); }
00163 G4cout << " Z= " << Z << " A= " << A << G4endl;
00164 throw G4HadronicException(__FILE__, __LINE__,
00165 "G4VCrossSectionDataSet::GetIsoCrossSection is absent");
00166 return 0.0;
00167 }
00168
00169 G4Isotope*
00170 G4VCrossSectionDataSet::SelectIsotope(const G4Element* anElement, G4double)
00171 {
00172 G4int nIso = anElement->GetNumberOfIsotopes();
00173 G4IsotopeVector* isoVector = anElement->GetIsotopeVector();
00174 G4Isotope* iso = (*isoVector)[0];
00175
00176
00177 if(1 < nIso) {
00178 G4double* abundVector = anElement->GetRelativeAbundanceVector();
00179 G4double sum = 0.0;
00180 G4double q = G4UniformRand();
00181 for (G4int j = 0; j<nIso; ++j) {
00182 sum += abundVector[j];
00183 if(q <= sum) {
00184 iso = (*isoVector)[j];
00185 break;
00186 }
00187 }
00188 }
00189 return iso;
00190 }
00191
00192 void G4VCrossSectionDataSet::BuildPhysicsTable(const G4ParticleDefinition&)
00193 {}
00194
00195 void G4VCrossSectionDataSet::DumpPhysicsTable(const G4ParticleDefinition&)
00196 {}
00197
00198 void G4VCrossSectionDataSet::CrossSectionDescription(std::ostream& outFile) const
00199 {
00200 outFile << "The description for this cross section data set has not been written yet.\n";
00201 }