Geant4 Cross Reference |
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 // Contact authors: S. Meylan, C. Villagrasa 28 // 29 // email: sylvain.meylan@symalgo-tech.com, carmen.villagrasa@irsn.fr 30 // updated : Hoang Tran : 6/1/2023 clean code 31 32 #ifndef G4DNAMODELINTERFACE_HH 33 #define G4DNAMODELINTERFACE_HH 34 35 #include "G4VEmModel.hh" 36 37 #include <map> 38 class G4ParticleChangeForGamma; 39 class G4VDNAModel; 40 class G4DNAModelInterface : public G4VEmModel 41 { 42 using MaterialParticleModelTable = 43 std::map<std::size_t /*MatID*/, std::map<const G4ParticleDefinition*, G4VEmModel*>>; 44 //should have only one model 45 public: 46 /*! 47 * \brief G4DNAModelManager 48 * Constructor 49 * \param nam 50 */ 51 explicit G4DNAModelInterface(const G4String& nam); 52 53 /*! 54 * \brief ~G4DNAModelManager 55 * Destructor 56 */ 57 ~G4DNAModelInterface() override = default; 58 59 G4DNAModelInterface(const G4DNAModelInterface&) = delete; // prevent copy-construction 60 G4DNAModelInterface& operator=(const G4DNAModelInterface& right) = delete; // prevent assignement 61 62 /*! 63 * \brief Initialise 64 * Initialise method to call all the initialise methods of the registered models 65 * \param particle 66 * \param cuts 67 */ 68 void Initialise(const G4ParticleDefinition* particle, const G4DataVector& cuts) override; 69 70 /*! 71 * \brief CrossSectionPerVolume 72 * Method called by the process and used to call the CrossSectionPerVolume method of the 73 * registered models. The method also calculates through G4DNAMolecularMaterial the number of 74 * molecule per volume unit for the current material or (component of a composite material). 75 * \param material 76 * \param p 77 * \param ekin 78 * \param emin 79 * \param emax 80 * \return the final cross section value times with the number of molecule per volume unit 81 */ 82 G4double CrossSectionPerVolume(const G4Material* material, const G4ParticleDefinition* p, 83 G4double ekin, G4double emin, G4double emax) override; 84 85 /*! 86 * \brief SampleSecondaries 87 * Used to call the SampleSecondaries method of the registered models. A sampling is done to 88 * select a component if the material is a composite one. \param fVect \param couple \param 89 * aDynamicElectron \param tmin \param tmax 90 */ 91 void SampleSecondaries(std::vector<G4DynamicParticle*>* fVect, const G4MaterialCutsCouple* couple, 92 const G4DynamicParticle* aDynamicElectron, G4double tmin, G4double tmax) override; 93 94 /*! 95 * \brief RegisterModel 96 * Method used to associate a model with the interaction 97 * \param model 98 */ 99 void RegisterModel(G4VEmModel* model); 100 /*! 101 * \brief GetSelectedMaterial 102 * To allow the user to retrieve the selected material in case of a composite material. 103 * \return the last selected material by SampleSecondaries. 104 */ 105 inline std::size_t GetSelectedMaterial() 106 { 107 return fSampledMat; 108 } 109 110 void StreamInfo(std::ostream& os) const; 111 112 private: 113 /*! 114 * \brief BuildMaterialParticleModelTable 115 * Method used to build a map allowing the code to quickly retrieve the good model for a 116 * particle/material couple \param p 117 */ 118 void BuildMaterialParticleModelTable(const G4ParticleDefinition* p); 119 120 void BuildMaterialMolPerVolTable(); 121 122 /*! 123 * \brief InsertModelInTable 124 * Used to put a model in the table after performing some checks. 125 * \param matName 126 * \param pName 127 */ 128 void InsertModelInTable(const std::size_t& matID, const G4ParticleDefinition* p); 129 130 /*! 131 * \brief GetDNAModel 132 * \param material 133 * \param particle 134 * \param ekin 135 * \return G4VDNAModel* 136 * Return the model corresponding to the material, particle and energy specified. 137 * This method will check the energy range of the models to find to good one for the current ekin. 138 */ 139 G4VEmModel* SelectModel( 140 const std::size_t& material, const G4ParticleDefinition* particle, const G4double& ekin); 141 142 G4double GetNumMoleculePerVolumeUnitForMaterial(const G4Material* mat); 143 G4double GetNumMolPerVolUnitForComponentInComposite( 144 const G4Material* component, const G4Material* composite); 145 146 const G4String fName; ///< name of the interaction 147 G4ParticleChangeForGamma* fpParticleChangeForGamma = nullptr; 148 std::vector<G4VEmModel*> fRegisteredModels; ///< vector containing all the registered models 149 150 std::map<std::size_t, G4double> fMaterialCS; ///< map used to share information between 151 ///< CrossSectionPerVolume and SampleSecondaries 152 G4double fCSsumTot = 0; ///< value which contains the sum of all the component cross sections in 153 ///< case of a composite material 154 std::size_t fSampledMat = 0; ///< for the user to retrieve selected material/component 155 MaterialParticleModelTable fMaterialParticleModelTable; 156 std::map<std::size_t, const std::vector<G4double>*> fMaterialMolPerVol; 157 G4Material* fpG4_WATER = nullptr; 158 }; 159 160 #endif // G4DNAMODELINTERFACE_HH 161