ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VCrossSectionDataSet.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VCrossSectionDataSet.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 // GEANT4 Class file
29 //
30 // File name: G4VCrossSectionDataSet
31 //
32 // Author F.W. Jones, TRIUMF, 20-JAN-97
33 //
34 // Modifications:
35 // 23.01.2009 V.Ivanchenko move constructor and destructor to source
36 // 12.08.2011 G.Folger, V.Ivanchenko, T.Koi, D.Wright redesign the class
37 //
38 
40 #include "G4SystemOfUnits.hh"
42 #include "G4Material.hh"
43 #include "G4Element.hh"
44 #include "G4Isotope.hh"
45 #include "G4NistManager.hh"
46 #include "Randomize.hh"
47 #include "G4HadronicParameters.hh"
48 
50  verboseLevel(0),minKinEnergy(0.0),
51  maxKinEnergy(G4HadronicParameters::Instance()->GetMaxEnergy()),
52  isForAllAtomsAndEnergies(false),name(nam)
53 {
55  registry->Register(this);
56 }
57 
59 {
60  registry->DeRegister(this);
61 }
62 
63 G4bool
65  G4int,
66  const G4Material*)
67 {
68  return false;
69 }
70 
71 G4bool
73  G4int, G4int,
74  const G4Element*,
75  const G4Material*)
76 {
77  return false;
78 }
79 
80 G4double
82  const G4Element* elm,
83  const G4Material* mat)
84 {
85  G4int Z = elm->GetZasInt();
86 
87  if (IsElementApplicable(part, Z, mat)) {
88  return GetElementCrossSection(part, Z, mat);
89  }
90 
91  // isotope-wise cross section making sum over available
92  // isotope cross sections, which may be incomplete, so
93  // the result is corrected
94  size_t nIso = elm->GetNumberOfIsotopes();
95  G4double fact = 0.0;
96  G4double xsec = 0.0;
97 
98  // user-defined isotope abundances
99  const G4IsotopeVector* isoVector = elm->GetIsotopeVector();
100  const G4double* abundVector = elm->GetRelativeAbundanceVector();
101 
102  for (size_t j=0; j<nIso; ++j) {
103  const G4Isotope* iso = (*isoVector)[j];
104  G4int A = iso->GetN();
105  if(abundVector[j] > 0.0 && IsIsoApplicable(part, Z, A, elm, mat)) {
106  fact += abundVector[j];
107  xsec += abundVector[j]*GetIsoCrossSection(part, Z, A, iso, elm, mat);
108  }
109  }
110  return (fact > 0.0) ? xsec/fact : 0.0;
111 }
112 
113 G4double
115  G4int Z,
116  const G4Material* mat)
117 {
119  ed << "GetElementCrossSection is not implemented in <" << name << ">\n"
120  << "Particle: " << dynPart->GetDefinition()->GetParticleName()
121  << " Ekin(MeV)= " << dynPart->GetKineticEnergy()/MeV;
122  if(mat) { ed << " material: " << mat->GetName(); }
123  ed << " target Z= " << Z << G4endl;
124  G4Exception("G4VCrossSectionDataSet::GetElementCrossSection", "had001",
125  FatalException, ed);
126  return 0.0;
127 }
128 
129 G4double
131  G4int Z, G4int A,
132  const G4Isotope*,
133  const G4Element* elm,
134  const G4Material* mat)
135 {
137  ed << "GetIsoCrossSection is not implemented in <" << name << ">\n"
138  << "Particle: " << dynPart->GetDefinition()->GetParticleName()
139  << " Ekin(MeV)= " << dynPart->GetKineticEnergy()/MeV;
140  if(mat) { ed << " material: " << mat->GetName(); }
141  if(elm) { ed << " element: " << elm->GetName(); }
142  ed << " target Z= " << Z << " A= " << A << G4endl;
143  G4Exception("G4VCrossSectionDataSet::GetIsoCrossSection", "had001",
144  FatalException, ed);
145  return 0.0;
146 }
147 
148 const G4Isotope*
151 {
152  size_t nIso = anElement->GetNumberOfIsotopes();
153  const G4Isotope* iso = anElement->GetIsotope(0);
154 
155  // more than 1 isotope
156  if(1 < nIso) {
157  const G4double* abundVector = anElement->GetRelativeAbundanceVector();
158  G4double sum = 0.0;
159  G4double q = G4UniformRand();
160  for (size_t j=0; j<nIso; ++j) {
161  sum += abundVector[j];
162  if(q <= sum) {
163  iso = anElement->GetIsotope(j);
164  break;
165  }
166  }
167  }
168  return iso;
169 }
170 
172 {}
173 
175 {}
176 
177 void G4VCrossSectionDataSet::CrossSectionDescription(std::ostream& outFile) const
178 {
179  outFile << "The description for this cross section data set has not been written yet.\n";
180 }