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
00045
00046
00047
00048
00049 #include "G4CrossSectionHandler.hh"
00050 #include "G4VDataSetAlgorithm.hh"
00051 #include "G4VEMDataSet.hh"
00052 #include "G4EMDataSet.hh"
00053 #include "G4CompositeEMDataSet.hh"
00054 #include "G4ShellEMDataSet.hh"
00055 #include "G4ProductionCutsTable.hh"
00056 #include "G4Material.hh"
00057 #include "G4Element.hh"
00058 #include "Randomize.hh"
00059 #include <map>
00060 #include <vector>
00061
00062 #include "G4LogLogInterpolation.hh"
00063
00064 G4CrossSectionHandler::G4CrossSectionHandler()
00065 { }
00066
00067 G4CrossSectionHandler::~G4CrossSectionHandler()
00068 { }
00069
00070 std::vector<G4VEMDataSet*>*
00071 G4CrossSectionHandler::BuildCrossSectionsForMaterials(const G4DataVector& energyVector,
00072 const G4DataVector*)
00073 {
00074 G4DataVector* energies;
00075 G4DataVector* data;
00076
00077 G4DataVector* log_energies;
00078 G4DataVector* log_data;
00079
00080 std::vector<G4VEMDataSet*>* matCrossSections = new std::vector<G4VEMDataSet*>;
00081
00082 const G4ProductionCutsTable* theCoupleTable=
00083 G4ProductionCutsTable::GetProductionCutsTable();
00084 size_t numOfCouples = theCoupleTable->GetTableSize();
00085
00086 size_t nOfBins = energyVector.size();
00087 const G4VDataSetAlgorithm* interpolationAlgo = CreateInterpolation();
00088
00089 for (size_t mLocal=0; mLocal<numOfCouples; mLocal++)
00090 {
00091 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(mLocal);
00092 const G4Material* material= couple->GetMaterial();
00093 G4int nElements = material->GetNumberOfElements();
00094 const G4ElementVector* elementVector = material->GetElementVector();
00095 const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
00096
00097 G4VDataSetAlgorithm* algo = interpolationAlgo->Clone();
00098
00099 G4VEMDataSet* setForMat = new G4CompositeEMDataSet(algo,1.,1.);
00100
00101 for (G4int i=0; i<nElements; i++) {
00102
00103 G4int Z = (G4int) (*elementVector)[i]->GetZ();
00104 G4double density = nAtomsPerVolume[i];
00105
00106 energies = new G4DataVector;
00107 data = new G4DataVector;
00108
00109 log_energies = new G4DataVector;
00110 log_data = new G4DataVector;
00111
00112
00113 for (size_t bin=0; bin<nOfBins; bin++)
00114 {
00115 G4double e = energyVector[bin];
00116 energies->push_back(e);
00117 if (e==0.) e=1e-300;
00118 log_energies->push_back(std::log10(e));
00119 G4double cross = density*FindValue(Z,e);
00120 data->push_back(cross);
00121 if (cross==0.) cross=1e-300;
00122 log_data->push_back(std::log10(cross));
00123 }
00124
00125 G4VDataSetAlgorithm* algo1 = interpolationAlgo->Clone();
00126
00127
00128
00129 G4VEMDataSet* elSet = new G4EMDataSet(i,energies,data,log_energies,log_data,algo1,1.,1.);
00130
00131 setForMat->AddComponent(elSet);
00132 }
00133
00134 matCrossSections->push_back(setForMat);
00135 }
00136 delete interpolationAlgo;
00137 return matCrossSections;
00138 }
00139