Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:59:11

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4ParticleHPThermalScattering
0027 //
0028 // Class Description:
0029 //
0030 // Final State Generators for a high precision (based on evaluated data
0031 // libraries) description of themal neutron scattering below 4 eV;
0032 // Based on Thermal neutron scattering files
0033 // from the evaluated nuclear data files ENDF/B-VI, Release2
0034 // To be used in your physics list in case you need this physics.
0035 // In this case you want to register an object of this class with
0036 // the corresponding process.
0037 //
0038 // Author: T. Koi (SLAC/SCCS), November-2006 - First implementation.
0039 //         P. Arce (CIEMAT), June-2014 - Conversion neutron_hp to particle_hp
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;  // should be close to 1
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     // For user prepared thermal files
0097     // Name of G4Element , Name of NDL file
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     // Coherent Elastic
0137     //         ElementID             temp                             BraggE     cumulativeP
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     // Incoherent Elastic
0142     //         ElementID          temp       aFS for this temp (and this element)
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     // Inelastic
0148     //         ElementID          temp        aFS for this temp (and this element)
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     // In order to judge whether the rebuilding of physics table is a necessity or not
0160     std::size_t nMaterial;
0161     std::size_t nElement;
0162 };
0163 
0164 #endif