ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4eIonisationCrossSectionHandler.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4eIonisationCrossSectionHandler.cc
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 // -------------------------------------------------------------------
28 //
29 // GEANT4 Class file
30 //
31 //
32 // File name: G4eIonisationCrossSectionHandler
33 //
34 // Author: V.Ivanchenko (Vladimir.Ivanchenko@cern.ch)
35 //
36 // Creation date: 25 Sept 2001
37 //
38 // Modifications:
39 // 10 Oct 2001 M.G. Pia Revision to improve code quality and consistency with design
40 // 19 Jul 2002 VI Create composite data set for material
41 // 21 Jan 2003 V.Ivanchenko Cut per region
42 // 28 Jan 2009 L.Pandola Added public method to make a easier migration of
43 // G4LowEnergyIonisation to G4LivermoreIonisationModel
44 // 15 Jul 2009 Nicolas A. Karakatsanis
45 //
46 // - BuildCrossSectionForMaterials method was revised in order to calculate the
47 // logarithmic values of the loaded data.
48 // It retrieves the data values from the G4EMLOW data files but, then, calculates the
49 // respective log values and loads them to seperate data structures.
50 // The EM data sets, initialized this way, contain both non-log and log values.
51 // These initialized data sets can enhance the computing performance of data interpolation
52 // operations
53 //
54 //
55 //
56 // -------------------------------------------------------------------
57 
59 #include "G4SystemOfUnits.hh"
60 #include "G4VEnergySpectrum.hh"
61 #include "G4DataVector.hh"
62 #include "G4CompositeEMDataSet.hh"
63 #include "G4VDataSetAlgorithm.hh"
66 #include "G4VEMDataSet.hh"
67 #include "G4EMDataSet.hh"
68 #include "G4Material.hh"
69 #include "G4ProductionCutsTable.hh"
70 
71 
76  theParam(spec),verbose(0)
77 {
78  G4VCrossSectionHandler::Initialise(alg, emin, emax, nbin);
80 }
81 
82 
84 {
85  delete interp;
86 }
87 
88 
90  const G4DataVector& energyVector,
91  const G4DataVector* energyCuts)
92 {
93  std::vector<G4VEMDataSet*>* set = new std::vector<G4VEMDataSet*>;
94 
95  G4DataVector* energies;
96  G4DataVector* cs;
97 
98  G4DataVector* log_energies;
99  G4DataVector* log_cs;
100 
101  G4int nOfBins = energyVector.size();
102 
103  const G4ProductionCutsTable* theCoupleTable=
105  size_t numOfCouples = theCoupleTable->GetTableSize();
106 
107  for (size_t mLocal=0; mLocal<numOfCouples; mLocal++) {
108 
109  const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(mLocal);
110  const G4Material* material= couple->GetMaterial();
111  const G4ElementVector* elementVector = material->GetElementVector();
112  const G4double* nAtomsPerVolume = material->GetAtomicNumDensityVector();
113  G4int nElements = material->GetNumberOfElements();
114 
115  if(verbose > 0)
116  {
117  G4cout << "eIonisation CS for " << mLocal << "th material "
118  << material->GetName()
119  << " eEl= " << nElements << G4endl;
120  }
121 
122  G4double tcut = (*energyCuts)[mLocal];
123 
124  G4VDataSetAlgorithm* algo = interp->Clone();
125  G4VEMDataSet* setForMat = new G4CompositeEMDataSet(algo,1.,1.);
126 
127  for (G4int i=0; i<nElements; i++) {
128 
129  G4int Z = (G4int) (*elementVector)[i]->GetZ();
130  G4int nShells = NumberOfComponents(Z);
131 
132  energies = new G4DataVector;
133  cs = new G4DataVector;
134 
135  log_energies = new G4DataVector;
136  log_cs = new G4DataVector;
137 
138  G4double density = nAtomsPerVolume[i];
139 
140  for (G4int bin=0; bin<nOfBins; bin++) {
141 
142  G4double e = energyVector[bin];
143  energies->push_back(e);
144  log_energies->push_back(std::log10(e));
145  G4double value = 0.0;
146  G4double log_value = -300;
147 
148  if(e > tcut) {
149  for (G4int n=0; n<nShells; n++) {
150  G4double cross = FindValue(Z, e, n);
151  G4double p = theParam->Probability(Z, tcut, e, e, n);
152  value += cross * p * density;
153 
154  if(verbose>0 && mLocal == 0 && e>=1. && e<=0.)
155  {
156  G4cout << "G4eIonCrossSH: e(MeV)= " << e/MeV
157  << " n= " << n
158  << " cross= " << cross
159  << " p= " << p
160  << " value= " << value
161  << " tcut(MeV)= " << tcut/MeV
162  << " rho= " << density
163  << " Z= " << Z
164  << G4endl;
165  }
166 
167  }
168  if (value == 0.) value = 1e-300;
169  log_value = std::log10(value);
170  }
171  cs->push_back(value);
172  log_cs->push_back(log_value);
173  }
174  G4VDataSetAlgorithm* algoLocal = interp->Clone();
175 
176  //G4VEMDataSet* elSet = new G4EMDataSet(i,energies,cs,algoLocal,1.,1.);
177 
178  G4VEMDataSet* elSet = new G4EMDataSet(i,energies,cs,log_energies,log_cs,algoLocal,1.,1.);
179 
180  setForMat->AddComponent(elSet);
181  }
182  set->push_back(setForMat);
183  }
184 
185  return set;
186 }
187 
189  G4double cutEnergy,
190  G4int Z)
191 {
192  G4int nShells = NumberOfComponents(Z);
193  G4double value = 0.;
194  if(energy > cutEnergy)
195  {
196  for (G4int n=0; n<nShells; n++) {
197  G4double cross = FindValue(Z, energy, n);
198  G4double p = theParam->Probability(Z, cutEnergy, energy, energy, n);
199  value += cross * p;
200  }
201  }
202  return value;
203 }