File indexing completed on 2025-01-18 09:58:12
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
0041
0042
0043
0044
0045
0046
0047
0048 #ifndef G4EmElementSelector_h
0049 #define G4EmElementSelector_h 1
0050
0051 #include "globals.hh"
0052 #include "G4ParticleDefinition.hh"
0053 #include "G4Material.hh"
0054 #include "G4Element.hh"
0055 #include "G4ElementVector.hh"
0056 #include "G4PhysicsLogVector.hh"
0057 #include "Randomize.hh"
0058 #include <vector>
0059
0060 class G4VEmModel;
0061
0062 class G4EmElementSelector
0063 {
0064
0065 public:
0066
0067 G4EmElementSelector(G4VEmModel*, const G4Material*, G4int bins,
0068 G4double emin, G4double emax,
0069 G4bool spline = true);
0070
0071 ~G4EmElementSelector();
0072
0073 void Initialise(const G4ParticleDefinition*, G4double cut = 0.0);
0074
0075 void Dump(const G4ParticleDefinition* p = nullptr);
0076
0077 const G4Element* SelectRandomAtom(const G4double kineticEnergy,
0078 const G4double logEKin) const;
0079
0080 inline const G4Element* SelectRandomAtom(G4double kineticEnergy) const;
0081
0082 inline const G4Material* GetMaterial() const;
0083
0084
0085 G4EmElementSelector & operator=(const G4EmElementSelector &right) = delete;
0086 G4EmElementSelector(const G4EmElementSelector&) = delete;
0087
0088 private:
0089
0090 G4VEmModel* model;
0091 const G4Material* material;
0092 const G4ElementVector* theElementVector;
0093
0094 G4int nElmMinusOne;
0095 G4int nbins;
0096
0097 G4double cutEnergy;
0098 G4double lowEnergy;
0099 G4double highEnergy;
0100
0101 std::vector<G4PhysicsLogVector*> xSections;
0102
0103 };
0104
0105
0106
0107
0108 inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e) const
0109 {
0110 const G4Element* element = (*theElementVector)[nElmMinusOne];
0111 if (nElmMinusOne > 0) {
0112 G4double x = G4UniformRand();
0113 size_t idx(0);
0114 for(G4int i=0; i<nElmMinusOne; ++i) {
0115 if (x <= (xSections[i])->Value(e, idx)) {
0116 element = (*theElementVector)[i];
0117 break;
0118 }
0119 }
0120 }
0121 return element;
0122 }
0123
0124
0125
0126 inline const G4Material* G4EmElementSelector::GetMaterial() const
0127 {
0128 return material;
0129 }
0130
0131
0132
0133 #endif
0134