Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:07

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
0029 //
0030 // History:
0031 // -----------
0032 // 1  Aug 2001   MGP        Created
0033 // 19 Jul 2002   VI         Create composite data set for material
0034 // 24 Apr 2003   VI         Cut per region mfpt
0035 //
0036 // -------------------------------------------------------------------
0037 
0038 #include "G4RDCrossSectionHandler.hh"
0039 #include "G4RDVDataSetAlgorithm.hh"
0040 #include "G4RDVEMDataSet.hh"
0041 #include "G4RDEMDataSet.hh"
0042 #include "G4RDCompositeEMDataSet.hh"
0043 #include "G4RDShellEMDataSet.hh"
0044 #include "G4ProductionCutsTable.hh"
0045 #include "G4Material.hh"
0046 #include "G4Element.hh"
0047 #include "Randomize.hh"
0048 #include <map>
0049 #include <vector>
0050 
0051 #include "G4RDLogLogInterpolation.hh"
0052 
0053 G4RDCrossSectionHandler::G4RDCrossSectionHandler()
0054 { }
0055 
0056 G4RDCrossSectionHandler::~G4RDCrossSectionHandler()
0057 { }
0058 
0059 std::vector<G4RDVEMDataSet*>*
0060 G4RDCrossSectionHandler::BuildCrossSectionsForMaterials(const G4DataVector& energyVector,
0061                               const G4DataVector*)
0062 {
0063   G4DataVector* energies;
0064   G4DataVector* data;
0065 
0066   std::vector<G4RDVEMDataSet*>* matCrossSections = new std::vector<G4RDVEMDataSet*>;
0067 
0068   const G4ProductionCutsTable* theCoupleTable=
0069         G4ProductionCutsTable::GetProductionCutsTable();
0070   size_t numOfCouples = theCoupleTable->GetTableSize();
0071 
0072   size_t nOfBins = energyVector.size();
0073   const G4RDVDataSetAlgorithm* interpolationAlgo = CreateInterpolation();
0074 
0075   for (size_t m=0; m<numOfCouples; m++)
0076     {
0077       const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(m);
0078       const G4Material* material= couple->GetMaterial();
0079       G4int nElements = material->GetNumberOfElements();
0080       const G4ElementVector* elementVector = material->GetElementVector();
0081       const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
0082 
0083       G4RDVDataSetAlgorithm* algo = interpolationAlgo->Clone();
0084 
0085       G4RDVEMDataSet* setForMat = new G4RDCompositeEMDataSet(algo,1.,1.);
0086 
0087       for (G4int i=0; i<nElements; i++) {
0088  
0089         G4int Z = (G4int) (*elementVector)[i]->GetZ();
0090         G4double density = nAtomsPerVolume[i];
0091 
0092         energies = new G4DataVector;
0093         data = new G4DataVector;
0094 
0095 
0096         for (size_t bin=0; bin<nOfBins; bin++)
0097       {
0098         G4double e = energyVector[bin];
0099         energies->push_back(e);
0100         G4double cross = density*FindValue(Z,e);
0101         data->push_back(cross);
0102       }
0103 
0104         G4RDVDataSetAlgorithm* algo1 = interpolationAlgo->Clone();
0105         G4RDVEMDataSet* elSet = new G4RDEMDataSet(i,energies,data,algo1,1.,1.);
0106         setForMat->AddComponent(elSet);
0107       }
0108 
0109       matCrossSections->push_back(setForMat);
0110     }
0111   return matCrossSections;
0112 }
0113