Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 25 26 //-------------------------------------------- 26 //--------------------------------------------------------------------------- 27 // 27 // 28 // GEANT4 Class file 28 // GEANT4 Class file 29 // 29 // 30 // Description: Data structure for cross secti 30 // Description: Data structure for cross sections, shell cross sections, 31 // isotope cross sections. Data a 31 // isotope cross sections. Data access via integer variable 32 // Z (atomic number in majority o 32 // Z (atomic number in majority of applications), which may 33 // be in the interval 0 <= Z < le 33 // be in the interval 0 <= Z < length. For isotope like 34 // data a second parameter idx or 34 // data a second parameter idx or data ID code are used. 35 // In most cases ID = A - atomic 35 // In most cases ID = A - atomic weight number. 36 // There are run time const metho 36 // There are run time const methods, in which input is not checked 37 // assuming responsibility of con 37 // assuming responsibility of consumer code. Another run time 38 // check input and may throwgh a 38 // check input and may throwgh a fatal exception 39 // 39 // 40 // Author: V.Ivanchenko 10.03.2011 40 // Author: V.Ivanchenko 10.03.2011 41 // 41 // 42 // Modifications: 30.09.2023 Extended function 42 // Modifications: 30.09.2023 Extended functionality, data size defined in constructor 43 // 43 // 44 //-------------------------------------------- 44 //---------------------------------------------------------------------------- 45 // 45 // 46 46 47 #ifndef G4ElementData_h 47 #ifndef G4ElementData_h 48 #define G4ElementData_h 1 48 #define G4ElementData_h 1 49 49 50 #include "G4Physics2DVector.hh" 50 #include "G4Physics2DVector.hh" 51 #include "G4PhysicsVector.hh" 51 #include "G4PhysicsVector.hh" 52 #include "globals.hh" 52 #include "globals.hh" 53 53 54 #include <vector> 54 #include <vector> 55 55 56 class G4ElementData 56 class G4ElementData 57 { 57 { 58 public: 58 public: 59 explicit G4ElementData(G4int length = 99); 59 explicit G4ElementData(G4int length = 99); 60 60 61 ~G4ElementData(); 61 ~G4ElementData(); 62 62 63 // Assignment operator and copy constructor 63 // Assignment operator and copy constructor 64 G4ElementData& operator=(const G4ElementData 64 G4ElementData& operator=(const G4ElementData& right) = delete; 65 G4ElementData(const G4ElementData&) = delete 65 G4ElementData(const G4ElementData&) = delete; 66 66 67 // add cross section for the element 67 // add cross section for the element 68 void InitialiseForElement(G4int Z, G4Physics 68 void InitialiseForElement(G4int Z, G4PhysicsVector* v); 69 69 70 // add 2D cross section for the element 70 // add 2D cross section for the element 71 void InitialiseForElement(G4int Z, G4Physics 71 void InitialiseForElement(G4int Z, G4Physics2DVector* v); 72 72 73 // reserve vector of components 73 // reserve vector of components 74 void InitialiseForComponent(G4int Z, G4int n 74 void InitialiseForComponent(G4int Z, G4int nComponents = 0); 75 75 76 // reserve vector of 2D components 76 // reserve vector of 2D components 77 void InitialiseFor2DComponent(G4int Z, G4int 77 void InitialiseFor2DComponent(G4int Z, G4int nComponents = 0); 78 78 79 // prepare vector of components 79 // prepare vector of components 80 void AddComponent(G4int Z, G4int id, G4Physi 80 void AddComponent(G4int Z, G4int id, G4PhysicsVector* v); 81 81 82 // prepare vector of 2D components 82 // prepare vector of 2D components 83 void Add2DComponent(G4int Z, G4int id, G4Phy 83 void Add2DComponent(G4int Z, G4int id, G4Physics2DVector* v); 84 84 85 // set name of the dataset (optional) 85 // set name of the dataset (optional) 86 inline void SetName(const G4String& nam); 86 inline void SetName(const G4String& nam); 87 87 88 //------------------------------------------ 88 //-------------------------------------------------------------- 89 // run time const methods - no check on vali 89 // run time const methods - no check on validity of input 90 // it is a responsibility of the consume cod 90 // it is a responsibility of the consume code to check the input 91 //------------------------------------------ 91 //-------------------------------------------------------------- 92 92 93 // get name of the dataset 93 // get name of the dataset 94 inline const G4String& GetName() const; 94 inline const G4String& GetName() const; 95 95 96 // get vector for the element 96 // get vector for the element 97 inline G4PhysicsVector* GetElementData(G4int 97 inline G4PhysicsVector* GetElementData(G4int Z) const; 98 98 99 // get 2-D vector for the element 99 // get 2-D vector for the element 100 inline G4Physics2DVector* GetElement2DData(G 100 inline G4Physics2DVector* GetElement2DData(G4int Z) const; 101 101 102 // get vector per shell or per isotope 102 // get vector per shell or per isotope 103 inline G4PhysicsVector* GetComponentDataByID 103 inline G4PhysicsVector* GetComponentDataByID(G4int Z, G4int id) const; 104 104 105 // get vector per shell or per isotope 105 // get vector per shell or per isotope 106 inline G4Physics2DVector* Get2DComponentData 106 inline G4Physics2DVector* Get2DComponentDataByID(G4int Z, G4int id) const; 107 107 108 // return cross section per element 108 // return cross section per element 109 inline G4double GetValueForElement(G4int Z, 109 inline G4double GetValueForElement(G4int Z, G4double kinEnergy) const; 110 110 111 //------------------------------------------ 111 //-------------------------------------------------------------- 112 // run time const methods with input paramet 112 // run time const methods with input parameters control 113 //------------------------------------------ 113 //-------------------------------------------------------------- 114 114 115 // get number of components for the element 115 // get number of components for the element 116 inline std::size_t GetNumberOfComponents(G4i 116 inline std::size_t GetNumberOfComponents(G4int Z) const; 117 117 118 // get number of 2D components for the eleme 118 // get number of 2D components for the element 119 inline std::size_t GetNumberOf2DComponents(G 119 inline std::size_t GetNumberOf2DComponents(G4int Z) const; 120 120 121 // get component ID which may be number of n 121 // get component ID which may be number of nucleons, 122 // or shell number, or any other integer 122 // or shell number, or any other integer 123 inline G4int GetComponentID(G4int Z, std::si 123 inline G4int GetComponentID(G4int Z, std::size_t idx) const; 124 124 125 // get vector per shell or per isotope 125 // get vector per shell or per isotope 126 inline G4PhysicsVector* 126 inline G4PhysicsVector* 127 GetComponentDataByIndex(G4int Z, std::size_t 127 GetComponentDataByIndex(G4int Z, std::size_t idx) const; 128 128 129 // get vector per shell or per isotope 129 // get vector per shell or per isotope 130 inline G4Physics2DVector* 130 inline G4Physics2DVector* 131 Get2DComponentDataByIndex(G4int Z, std::size 131 Get2DComponentDataByIndex(G4int Z, std::size_t idx) const; 132 132 133 // return cross section per element 133 // return cross section per element 134 // if not available return zero 134 // if not available return zero 135 inline G4double 135 inline G4double 136 GetValueForComponent(G4int Z, std::size_t id 136 GetValueForComponent(G4int Z, std::size_t idx, G4double kinEnergy) const; 137 137 138 private: 138 private: 139 139 140 void DataError(G4int Z, const G4String&); 140 void DataError(G4int Z, const G4String&); 141 141 142 const G4int maxNumElm; 142 const G4int maxNumElm; 143 143 144 std::vector<G4PhysicsVector*> elmData; 144 std::vector<G4PhysicsVector*> elmData; 145 std::vector<G4Physics2DVector*> elm2Data; 145 std::vector<G4Physics2DVector*> elm2Data; 146 std::vector<std::vector<std::pair<G4int, G4P 146 std::vector<std::vector<std::pair<G4int, G4PhysicsVector*> >* > compData; 147 std::vector<std::vector<std::pair<G4int, G4P 147 std::vector<std::vector<std::pair<G4int, G4Physics2DVector*> >* > comp2D; 148 148 149 G4String name{""}; 149 G4String name{""}; 150 }; 150 }; 151 151 152 //-------------------------------------------- 152 //-------------------------------------------------------------- 153 // run time const methods without check on val 153 // run time const methods without check on validity of input 154 //-------------------------------------------- 154 //-------------------------------------------------------------- 155 155 156 inline void G4ElementData::SetName(const G4Str 156 inline void G4ElementData::SetName(const G4String& nam) 157 { 157 { 158 name = nam; 158 name = nam; 159 } 159 } 160 160 161 inline const G4String& G4ElementData::GetName( 161 inline const G4String& G4ElementData::GetName() const 162 { 162 { 163 return name; 163 return name; 164 } 164 } 165 165 166 inline G4PhysicsVector* G4ElementData::GetElem 166 inline G4PhysicsVector* G4ElementData::GetElementData(G4int Z) const 167 { 167 { 168 return elmData[Z]; 168 return elmData[Z]; 169 } 169 } 170 170 171 inline G4Physics2DVector* G4ElementData::GetEl 171 inline G4Physics2DVector* G4ElementData::GetElement2DData(G4int Z) const 172 { 172 { 173 return elm2Data[Z]; 173 return elm2Data[Z]; 174 } 174 } 175 175 176 inline G4PhysicsVector* 176 inline G4PhysicsVector* 177 G4ElementData::GetComponentDataByID(G4int Z, G 177 G4ElementData::GetComponentDataByID(G4int Z, G4int id) const 178 { 178 { 179 G4PhysicsVector* v = nullptr; 179 G4PhysicsVector* v = nullptr; 180 for (auto const & p : *(compData[Z])) { 180 for (auto const & p : *(compData[Z])) { 181 if (id == p.first) { 181 if (id == p.first) { 182 v = p.second; 182 v = p.second; 183 break; 183 break; 184 } 184 } 185 } 185 } 186 return v; 186 return v; 187 } 187 } 188 188 189 inline G4Physics2DVector* 189 inline G4Physics2DVector* 190 G4ElementData::Get2DComponentDataByID(G4int Z, 190 G4ElementData::Get2DComponentDataByID(G4int Z, G4int id) const 191 { 191 { 192 G4Physics2DVector* v = nullptr; 192 G4Physics2DVector* v = nullptr; 193 for (auto const & p : *(comp2D[Z])) { 193 for (auto const & p : *(comp2D[Z])) { 194 if (id == p.first) { 194 if (id == p.first) { 195 v = p.second; 195 v = p.second; 196 break; 196 break; 197 } 197 } 198 } 198 } 199 return v; 199 return v; 200 } 200 } 201 201 202 inline G4double 202 inline G4double 203 G4ElementData::GetValueForElement(G4int Z, G4d 203 G4ElementData::GetValueForElement(G4int Z, G4double kinEnergy) const 204 { 204 { 205 return elmData[Z]->Value(kinEnergy); 205 return elmData[Z]->Value(kinEnergy); 206 } 206 } 207 207 208 //-------------------------------------------- 208 //-------------------------------------------------------------- 209 // run time const methods with check on validi 209 // run time const methods with check on validity of input 210 //-------------------------------------------- 210 //-------------------------------------------------------------- 211 211 212 inline std::size_t G4ElementData::GetNumberOfC 212 inline std::size_t G4ElementData::GetNumberOfComponents(G4int Z) const 213 { 213 { 214 return (nullptr != compData[Z]) ? compData[Z 214 return (nullptr != compData[Z]) ? compData[Z]->size() : 0; 215 } 215 } 216 216 217 inline std::size_t G4ElementData::GetNumberOf2 217 inline std::size_t G4ElementData::GetNumberOf2DComponents(G4int Z) const 218 { 218 { 219 return (nullptr != comp2D[Z]) ? comp2D[Z]->s 219 return (nullptr != comp2D[Z]) ? comp2D[Z]->size() : 0; 220 } 220 } 221 221 222 inline G4int G4ElementData::GetComponentID(G4i 222 inline G4int G4ElementData::GetComponentID(G4int Z, std::size_t idx) const 223 { 223 { 224 return (idx < GetNumberOfComponents(Z)) ? (* 224 return (idx < GetNumberOfComponents(Z)) ? (*(compData[Z]))[idx].first : 0; 225 } 225 } 226 226 227 inline G4PhysicsVector* 227 inline G4PhysicsVector* 228 G4ElementData::GetComponentDataByIndex(G4int Z 228 G4ElementData::GetComponentDataByIndex(G4int Z, std::size_t idx) const 229 { 229 { 230 return 230 return 231 (idx < GetNumberOfComponents(Z)) ? (*(comp 231 (idx < GetNumberOfComponents(Z)) ? (*(compData[Z]))[idx].second : nullptr; 232 } 232 } 233 233 234 inline G4Physics2DVector* 234 inline G4Physics2DVector* 235 G4ElementData::Get2DComponentDataByIndex(G4int 235 G4ElementData::Get2DComponentDataByIndex(G4int Z, std::size_t idx) const 236 { 236 { 237 return 237 return 238 (idx < GetNumberOf2DComponents(Z)) ? (*(co 238 (idx < GetNumberOf2DComponents(Z)) ? (*(comp2D[Z]))[idx].second : nullptr; 239 } 239 } 240 240 241 inline G4double 241 inline G4double 242 G4ElementData::GetValueForComponent(G4int Z, s 242 G4ElementData::GetValueForComponent(G4int Z, std::size_t idx, G4double e) const 243 { 243 { 244 return (idx < GetNumberOfComponents(Z)) ? 244 return (idx < GetNumberOfComponents(Z)) ? 245 (*(compData[Z]))[idx].second->Value(e) : 0 245 (*(compData[Z]))[idx].second->Value(e) : 0.0; 246 } 246 } 247 247 248 #endif 248 #endif 249 249