G4CrossSectionHandler.cc

Go to the documentation of this file.
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 // $Id$
00028 //
00029 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
00030 //
00031 // History:
00032 // -----------
00033 // 1  Aug 2001   MGP        Created
00034 // 19 Jul 2002   VI         Create composite data set for material
00035 // 24 Apr 2003   VI         Cut per region mfpt
00036 //
00037 // 15 Jul 2009   Nicolas A. Karakatsanis
00038 //
00039 //                           - BuildCrossSectionForMaterials method was revised in order to calculate the 
00040 //                             logarithmic values of the loaded data. 
00041 //                             It retrieves the data values from the G4EMLOW data files but, then, calculates the
00042 //                             respective log values and loads them to seperate data structures.
00043 //                             The EM data sets, initialized this way, contain both non-log and log values.
00044 //                             These initialized data sets can enhance the computing performance of data interpolation
00045 //                             operations
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 //      G4VEMDataSet* elSet = new G4EMDataSet(i,energies,data,algo1,1.,1.);
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 

Generated on Mon May 27 17:47:58 2013 for Geant4 by  doxygen 1.4.7