00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 00027 template <class IsoIsoCrossSectionType> 00028 G4ElementIsoCrossSections<IsoIsoCrossSectionType>:: 00029 G4ElementIsoCrossSections() 00030 { 00031 nIsotopes = 0; 00032 crossSectionBuffer = 0.0; 00033 theData = NULL; 00034 G4cout << "WARNING: G4ElementIsoCrossSections is deprecated and will be removed with Geant4 version 10" 00035 << G4endl; 00036 } 00037 00038 template <class IsoIsoCrossSectionType> 00039 G4ElementIsoCrossSections<IsoIsoCrossSectionType>:: 00040 ~G4ElementIsoCrossSections() 00041 { 00042 for(G4int i=0; i<nIsotopes; i++) 00043 { 00044 delete theData[i]; 00045 } 00046 delete [] theData; 00047 } 00048 00049 template <class IsoIsoCrossSectionType> 00050 void G4ElementIsoCrossSections<IsoIsoCrossSectionType>:: 00051 Init(const G4Element * anElement) 00052 { 00053 G4int Z = G4int(anElement->GetZ()+0.001); 00054 nIsotopes = anElement->GetNumberOfIsotopes(); 00055 G4bool useIsotopesFromElement = true; 00056 if( nIsotopes == 0 ) 00057 { 00058 nIsotopes += theStableOnes.GetNumberOfIsotopes(Z); 00059 useIsotopesFromElement = false; 00060 } 00061 theData = new IsoIsoCrossSectionType * [nIsotopes]; 00062 if(useIsotopesFromElement) 00063 { 00064 for (G4int i=0; i<nIsotopes; i++) 00065 { 00066 G4int A = anElement->GetIsotope(i)->GetN(); 00067 G4double frac = anElement->GetRelativeAbundanceVector()[i]/CLHEP::perCent; 00068 theData[i] = new IsoIsoCrossSectionType; 00069 theData[i]->Init(A, Z, frac); 00070 } 00071 } 00072 else 00073 { 00074 G4int first = theStableOnes.GetFirstIsotope(Z); 00075 for(G4int i=0; i<theStableOnes.GetNumberOfIsotopes(Z); i++) 00076 { 00077 G4int A = theStableOnes.GetIsotopeNucleonCount(first+i); 00078 G4double frac = theStableOnes.GetAbundance(first+i); 00079 theData[i] = new IsoIsoCrossSectionType; 00080 theData[i]->Init(A, Z, frac); 00081 } 00082 } 00083 } 00084 00085 template <class IsoIsoCrossSectionType> 00086 G4double G4ElementIsoCrossSections<IsoIsoCrossSectionType>:: 00087 GetCrossSection(G4double anEnergy) 00088 { 00089 G4double result = 0; 00090 for(G4int i=0; i<nIsotopes; i++) 00091 { 00092 result += theData[i]->GetCrossSection(anEnergy); // this is already weighted with relative abundance 00093 } 00094 crossSectionBuffer = result; 00095 return result; 00096 } 00097 00098 template <class IsoIsoCrossSectionType> 00099 G4IsoResult * G4ElementIsoCrossSections<IsoIsoCrossSectionType>:: 00100 GetProductIsotope(G4double anEnergy) 00101 { 00102 G4double running = 0; 00103 G4int index(0); 00104 G4double random = G4UniformRand(); 00105 for(G4int i=0; i<nIsotopes; i++) 00106 { 00107 running += theData[i]->GetCrossSection(anEnergy); 00108 index = i; 00109 if(running/crossSectionBuffer > random) break; 00110 } 00111 G4String result = theData[index]->GetProductIsotope(anEnergy); 00112 G4Nucleus nucleus(theData[index]->GetA(), theData[index]->GetZ()); 00113 G4IsoResult * theResult = new G4IsoResult(result, nucleus); 00114 return theResult; 00115 } 00116 00117