Geant4  10.02.p01
G4RDCrossSectionHandler.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id$
28 // GEANT4 tag $Name: geant4-09-01-ref-00 $
29 //
30 // Author: Maria Grazia Pia (Maria.Grazia.Pia@cern.ch)
31 //
32 // History:
33 // -----------
34 // 1 Aug 2001 MGP Created
35 // 19 Jul 2002 VI Create composite data set for material
36 // 24 Apr 2003 VI Cut per region mfpt
37 //
38 // -------------------------------------------------------------------
39 
41 #include "G4RDVDataSetAlgorithm.hh"
42 #include "G4RDVEMDataSet.hh"
43 #include "G4RDEMDataSet.hh"
45 #include "G4RDShellEMDataSet.hh"
46 #include "G4ProductionCutsTable.hh"
47 #include "G4Material.hh"
48 #include "G4Element.hh"
49 #include "Randomize.hh"
50 #include <map>
51 #include <vector>
52 
54 
56 { }
57 
59 { }
60 
61 std::vector<G4RDVEMDataSet*>*
63  const G4DataVector*)
64 {
65  G4DataVector* energies;
66  G4DataVector* data;
67 
68  std::vector<G4RDVEMDataSet*>* matCrossSections = new std::vector<G4RDVEMDataSet*>;
69 
70  const G4ProductionCutsTable* theCoupleTable=
72  size_t numOfCouples = theCoupleTable->GetTableSize();
73 
74  size_t nOfBins = energyVector.size();
75  const G4RDVDataSetAlgorithm* interpolationAlgo = CreateInterpolation();
76 
77  for (size_t m=0; m<numOfCouples; m++)
78  {
79  const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(m);
80  const G4Material* material= couple->GetMaterial();
81  G4int nElements = material->GetNumberOfElements();
82  const G4ElementVector* elementVector = material->GetElementVector();
83  const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
84 
85  G4RDVDataSetAlgorithm* algo = interpolationAlgo->Clone();
86 
87  G4RDVEMDataSet* setForMat = new G4RDCompositeEMDataSet(algo,1.,1.);
88 
89  for (G4int i=0; i<nElements; i++) {
90 
91  G4int Z = (G4int) (*elementVector)[i]->GetZ();
92  G4double density = nAtomsPerVolume[i];
93 
94  energies = new G4DataVector;
95  data = new G4DataVector;
96 
97 
98  for (size_t bin=0; bin<nOfBins; bin++)
99  {
100  G4double e = energyVector[bin];
101  energies->push_back(e);
102  G4double cross = density*FindValue(Z,e);
103  data->push_back(cross);
104  }
105 
106  G4RDVDataSetAlgorithm* algo1 = interpolationAlgo->Clone();
107  G4RDVEMDataSet* elSet = new G4RDEMDataSet(i,energies,data,algo1,1.,1.);
108  setForMat->AddComponent(elSet);
109  }
110 
111  matCrossSections->push_back(setForMat);
112  }
113  return matCrossSections;
114 }
115 
virtual G4RDVDataSetAlgorithm * Clone() const =0
std::vector< G4Element * > G4ElementVector
G4double FindValue(G4int Z, G4double e) const
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
G4double density
Definition: TRTMaterials.hh:39
virtual G4RDVDataSetAlgorithm * CreateInterpolation()
virtual std::vector< G4RDVEMDataSet * > * BuildCrossSectionsForMaterials(const G4DataVector &energyVector, const G4DataVector *energyCuts=0)
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:216
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static const double m
Definition: G4SIunits.hh:128
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76
virtual void AddComponent(G4RDVEMDataSet *dataSet)=0
const G4Material * GetMaterial() const