File indexing completed on 2025-10-31 09:03:21
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 #ifndef G4ParticleHPThermalScattering_h
0042 #define G4ParticleHPThermalScattering_h 1
0043 
0044 #include "G4HadronicInteraction.hh"
0045 #include "G4ParticleHPThermalScatteringNames.hh"
0046 #include "globals.hh"
0047 
0048 class G4ParticleHPThermalScatteringData;
0049 class G4ParticleHPElastic;
0050 
0051 struct E_isoAng
0052 {
0053     G4double energy;
0054     G4int n;
0055     std::vector<G4double> isoAngle;
0056     E_isoAng()
0057     {
0058       energy = 0.0;
0059       n = 0;
0060     };
0061 };
0062 
0063 struct E_P_E_isoAng
0064 {
0065     G4double energy;
0066     G4int n;
0067     std::vector<G4double> prob;
0068     std::vector<E_isoAng*> vE_isoAngle;
0069     G4double sum_of_probXdEs;  
0070     std::vector<G4double> secondary_energy_cdf;
0071     std::vector<G4double> secondary_energy_pdf;
0072     std::vector<G4double> secondary_energy_value;
0073     G4int secondary_energy_cdf_size;
0074     E_P_E_isoAng()
0075     {
0076       energy = 0.0;
0077       n = 0;
0078       sum_of_probXdEs = 0.0;
0079       secondary_energy_cdf_size = 0;
0080     };
0081 };
0082 
0083 class G4ParticleHPThermalScattering : public G4HadronicInteraction
0084 {
0085   public:
0086 
0087     G4ParticleHPThermalScattering();
0088 
0089     ~G4ParticleHPThermalScattering() override;
0090 
0091     G4HadFinalState* ApplyYourself(const G4HadProjectile& aTrack,
0092                                    G4Nucleus& aTargetNucleus) override;
0093 
0094     const std::pair<G4double, G4double> GetFatalEnergyCheckLevels() const override;
0095 
0096     
0097     
0098     void AddUserThermalScatteringFile(const G4String&, const G4String&);
0099 
0100     void BuildPhysicsTable(const G4ParticleDefinition&) override;
0101 
0102     void ModelDescription(std::ostream& outFile) const override;
0103 
0104   private:
0105 
0106     void clearCurrentFSData();
0107 
0108     G4double getMu(E_isoAng*);
0109     G4double getMu(G4double rndm1, G4double rndm2, E_isoAng* anEPM);
0110 
0111     std::pair<G4double, G4double> find_LH(G4double, std::vector<G4double>*);
0112     G4double get_linear_interpolated(G4double, std::pair<G4double, G4double>,
0113                                      std::pair<G4double, G4double>);
0114 
0115     E_isoAng create_E_isoAng_from_energy(G4double, std::vector<E_isoAng*>*);
0116 
0117     G4double get_secondary_energy_from_E_P_E_isoAng(G4double random, E_P_E_isoAng* anE_P_E_isoAng);
0118 
0119     std::pair<G4double, G4double> sample_inelastic_E_mu(G4double pE,
0120                                                         std::vector<E_P_E_isoAng*>* vNEP_EPM);
0121     std::pair<G4double, G4int> sample_inelastic_E(G4double rndm1, G4double rndm2,
0122                                                   E_P_E_isoAng* anE_P_E_isoAng);
0123 
0124     std::pair<G4double, E_isoAng>
0125     create_sE_and_EPM_from_pE_and_vE_P_E_isoAng(G4double, G4double, std::vector<E_P_E_isoAng*>*);
0126 
0127     void buildPhysicsTable();
0128     G4int getTS_ID(const G4Material*, const G4Element*);
0129 
0130     G4bool check_E_isoAng(E_isoAng*);
0131 
0132   private:
0133 
0134     G4ParticleHPThermalScatteringNames names;
0135 
0136     
0137     
0138     std::map<G4int, std::map<G4double, std::vector<std::pair<G4double, G4double>*>*>*>* coherentFSs{nullptr};
0139     std::map<G4double, std::vector<std::pair<G4double, G4double>*>*>* readACoherentFSDATA(const G4String&);
0140 
0141     
0142     
0143     std::map<G4int, std::map<G4double, std::vector<E_isoAng*>*>*>* incoherentFSs{nullptr};
0144     std::map<G4double, std::vector<E_isoAng*>*>* readAnIncoherentFSDATA(const G4String&);
0145     E_isoAng* readAnE_isoAng(std::istream*);
0146 
0147     
0148     
0149     std::map<G4int, std::map<G4double, std::vector<E_P_E_isoAng*>*>*>* inelasticFSs{nullptr};
0150     std::map<G4double, std::vector<E_P_E_isoAng*>*>* readAnInelasticFSDATA(const G4String&);
0151     E_P_E_isoAng* readAnE_P_E_isoAng(std::istream*);
0152 
0153     G4ParticleHPThermalScatteringData* theXSection;
0154 
0155     G4ParticleHPElastic* theHPElastic;
0156 
0157     std::map<std::pair<const G4Material*, const G4Element*>, G4int> dic;
0158 
0159     
0160     std::size_t nMaterial;
0161     std::size_t nElement;
0162 };
0163 
0164 #endif