File indexing completed on 2025-01-18 09:58:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #ifndef HadronXSDataTable_h
0041 #define HadronXSDataTable_h 1
0042
0043
0044
0045 #include "globals.hh"
0046 #include "G4Element.hh"
0047 #include "G4ElementVector.hh"
0048 #include "G4PhysicsVector.hh"
0049 #include "Randomize.hh"
0050 #include <vector>
0051
0052
0053
0054 class G4Material;
0055 class G4DynamicParticle;
0056 class G4CrossSectionDataStore;
0057
0058 class G4HadElementSelector
0059 {
0060 public:
0061
0062 G4HadElementSelector(G4DynamicParticle*, G4CrossSectionDataStore*,
0063 const G4Material*, G4int bins,
0064 G4double emin, G4double emax, G4bool spline);
0065
0066 ~G4HadElementSelector();
0067
0068 void Dump();
0069
0070 inline const G4Element* SelectRandomAtom(G4double e) const
0071 {
0072 const G4Element* element = (*theElementVector)[nElmMinusOne];
0073 if (nElmMinusOne > 0) {
0074 G4double x = G4UniformRand();
0075 for(G4int i=0; i<nElmMinusOne; ++i) {
0076 if (x <= xSections[i]->Value(e)) {
0077 element = (*theElementVector)[i];
0078 break;
0079 }
0080 }
0081 }
0082 return element;
0083 }
0084
0085 private:
0086
0087 G4HadElementSelector(G4HadElementSelector &) = delete;
0088 G4HadElementSelector& operator=(const G4HadElementSelector &right) = delete;
0089
0090 G4int nElmMinusOne;
0091 const G4ElementVector* theElementVector;
0092 std::vector<G4PhysicsVector*> xSections;
0093 };
0094
0095 class G4HadronXSDataTable
0096 {
0097
0098 public:
0099
0100 explicit G4HadronXSDataTable();
0101
0102 ~G4HadronXSDataTable();
0103
0104 void Initialise(G4DynamicParticle*, G4CrossSectionDataStore*,
0105 G4int bins, G4double emin, G4double emax,
0106 G4bool spline);
0107
0108 inline const G4PhysicsVector* HasData(size_t idx) const
0109 {
0110 return xsData[idx];
0111 };
0112
0113 inline G4double GetCrossSection(G4double e, size_t idx) const
0114 {
0115 return xsData[idx]->Value(e);
0116 };
0117
0118 inline const G4Element* SelectRandomAtom(G4double e, size_t idx) const
0119 {
0120 return elmSelectors[idx]->SelectRandomAtom(e);
0121 };
0122
0123 void Dump();
0124
0125 private:
0126
0127
0128 G4HadronXSDataTable & operator=
0129 (const G4HadronXSDataTable &right) = delete;
0130 G4HadronXSDataTable(const G4HadronXSDataTable&) = delete;
0131
0132 std::vector<G4PhysicsVector*> xsData;
0133 std::vector<G4HadElementSelector*> elmSelectors;
0134
0135 size_t nMaterials;
0136 };
0137
0138
0139
0140 #endif
0141