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 // 28 // GEANT4 Class file 29 // GEANT4 Class file 29 // 30 // 30 // Description: Data structure for cross secti 31 // Description: Data structure for cross sections, shell cross sections, 31 // isotope cross sections. Data a << 32 // isotope cross sections. Control of vector size should be 32 // Z (atomic number in majority o << 33 // performed in user code, no protection in this class 33 // be in the interval 0 <= Z < le << 34 // data a second parameter idx or << 35 // In most cases ID = A - atomic << 36 // There are run time const metho << 37 // assuming responsibility of con << 38 // check input and may throwgh a << 39 // 34 // 40 // Author: V.Ivanchenko 10.03.2011 35 // Author: V.Ivanchenko 10.03.2011 41 // 36 // 42 // Modifications: 30.09.2023 Extended function << 37 // Modifications: 43 // 38 // 44 //-------------------------------------------- 39 //---------------------------------------------------------------------------- 45 // 40 // 46 41 47 #ifndef G4ElementData_h << 42 #ifndef ElementData_h 48 #define G4ElementData_h 1 << 43 #define ElementData_h 1 49 44 50 #include "G4Physics2DVector.hh" << 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 #include "G4PhysicsVector.hh" << 52 #include "globals.hh" << 53 46 >> 47 #include "globals.hh" >> 48 #include "G4PhysicsVector.hh" >> 49 #include "G4Physics2DVector.hh" 54 #include <vector> 50 #include <vector> 55 51 56 class G4ElementData << 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 53 >> 54 class G4ElementData 57 { 55 { 58 public: << 56 public: 59 explicit G4ElementData(G4int length = 99); << 60 57 61 ~G4ElementData(); << 58 explicit G4ElementData(); 62 59 63 // Assignment operator and copy constructor << 60 ~G4ElementData(); 64 G4ElementData& operator=(const G4ElementData << 65 G4ElementData(const G4ElementData&) = delete << 66 61 67 // add cross section for the element 62 // add cross section for the element 68 void InitialiseForElement(G4int Z, G4Physics 63 void InitialiseForElement(G4int Z, G4PhysicsVector* v); 69 64 70 // add 2D cross section for the element 65 // add 2D cross section for the element 71 void InitialiseForElement(G4int Z, G4Physics 66 void InitialiseForElement(G4int Z, G4Physics2DVector* v); 72 67 73 // reserve vector of components 68 // reserve vector of components 74 void InitialiseForComponent(G4int Z, G4int n << 69 void InitialiseForComponent(G4int Z, G4int nComponents=0); 75 << 76 // reserve vector of 2D components << 77 void InitialiseFor2DComponent(G4int Z, G4int << 78 70 79 // prepare vector of components 71 // prepare vector of components 80 void AddComponent(G4int Z, G4int id, G4Physi 72 void AddComponent(G4int Z, G4int id, G4PhysicsVector* v); 81 73 82 // prepare vector of 2D components << 74 // set name of the dataset 83 void Add2DComponent(G4int Z, G4int id, G4Phy << 75 void SetName(const G4String& nam); 84 << 85 // set name of the dataset (optional) << 86 inline void SetName(const G4String& nam); << 87 76 88 //------------------------------------------ 77 //-------------------------------------------------------------- 89 // run time const methods - no check on vali << 78 // >> 79 // run time methods - no check on validity of input index 90 // it is a responsibility of the consume cod 80 // it is a responsibility of the consume code to check the input >> 81 // 91 //------------------------------------------ 82 //-------------------------------------------------------------- 92 83 93 // get name of the dataset << 84 // get vector for the element 94 inline const G4String& GetName() const; << 85 inline G4PhysicsVector* GetElementData(G4int Z); 95 << 96 // get vector for the element << 97 inline G4PhysicsVector* GetElementData(G4int << 98 << 99 // get 2-D vector for the element << 100 inline G4Physics2DVector* GetElement2DData(G << 101 << 102 // get vector per shell or per isotope << 103 inline G4PhysicsVector* GetComponentDataByID << 104 86 105 // get vector per shell or per isotope << 87 // get 2-D vector for the element 106 inline G4Physics2DVector* Get2DComponentData << 88 inline G4Physics2DVector* GetElement2DData(G4int Z); 107 89 108 // return cross section per element << 90 // get number of components for the element 109 inline G4double GetValueForElement(G4int Z, << 91 inline size_t GetNumberOfComponents(G4int Z); 110 92 111 //------------------------------------------ << 93 // get component ID which may be number of nucleons, 112 // run time const methods with input paramet << 113 //------------------------------------------ << 114 << 115 // get number of components for the element << 116 inline std::size_t GetNumberOfComponents(G4i << 117 << 118 // get number of 2D components for the eleme << 119 inline std::size_t GetNumberOf2DComponents(G << 120 << 121 // get component ID which may be number of n << 122 // or shell number, or any other integer 94 // or shell number, or any other integer 123 inline G4int GetComponentID(G4int Z, std::si << 95 inline G4int GetComponentID(G4int Z, G4int idx); 124 96 125 // get vector per shell or per isotope 97 // get vector per shell or per isotope 126 inline G4PhysicsVector* << 98 inline G4PhysicsVector* GetComponentDataByIndex(G4int Z, G4int idx); 127 GetComponentDataByIndex(G4int Z, std::size_t << 128 99 129 // get vector per shell or per isotope 100 // get vector per shell or per isotope 130 inline G4Physics2DVector* << 101 inline G4PhysicsVector* GetComponentDataByID(G4int Z, G4int id); 131 Get2DComponentDataByIndex(G4int Z, std::size << 132 102 133 // return cross section per element << 103 // return cross section per element 134 // if not available return zero 104 // if not available return zero 135 inline G4double << 105 inline G4double GetValueForElement(G4int Z, G4double kinEnergy); 136 GetValueForComponent(G4int Z, std::size_t id << 137 << 138 private: << 139 106 140 void DataError(G4int Z, const G4String&); << 107 // return cross section per element >> 108 // if not available return zero >> 109 inline G4double GetValueForComponent(G4int Z, G4int idx, >> 110 G4double kinEnergy); 141 111 142 const G4int maxNumElm; << 112 // Assignment operator and copy constructor >> 113 G4ElementData & operator=(const G4ElementData &right) = delete; >> 114 G4ElementData(const G4ElementData&) = delete; 143 115 144 std::vector<G4PhysicsVector*> elmData; << 116 private: 145 std::vector<G4Physics2DVector*> elm2Data; << 146 std::vector<std::vector<std::pair<G4int, G4P << 147 std::vector<std::vector<std::pair<G4int, G4P << 148 117 149 G4String name{""}; << 118 static const G4int maxNumElm = 99; >> 119 G4PhysicsVector* elmData[maxNumElm]; >> 120 G4Physics2DVector* elm2Data[maxNumElm]; >> 121 std::vector<G4PhysicsVector*>* compData[maxNumElm]; >> 122 std::vector<G4int>* compID[maxNumElm]; >> 123 G4int compLength[maxNumElm]; >> 124 >> 125 G4String name = ""; 150 }; 126 }; 151 127 152 //-------------------------------------------- << 153 // run time const methods without check on val << 154 //-------------------------------------------- << 155 << 156 inline void G4ElementData::SetName(const G4Str 128 inline void G4ElementData::SetName(const G4String& nam) 157 { 129 { 158 name = nam; 130 name = nam; 159 } 131 } 160 132 161 inline const G4String& G4ElementData::GetName( << 133 inline 162 { << 134 G4PhysicsVector* G4ElementData::GetElementData(G4int Z) 163 return name; << 164 } << 165 << 166 inline G4PhysicsVector* G4ElementData::GetElem << 167 { 135 { 168 return elmData[Z]; 136 return elmData[Z]; 169 } 137 } 170 138 171 inline G4Physics2DVector* G4ElementData::GetEl << 139 inline >> 140 G4Physics2DVector* G4ElementData::GetElement2DData(G4int Z) 172 { 141 { 173 return elm2Data[Z]; 142 return elm2Data[Z]; 174 } 143 } 175 144 176 inline G4PhysicsVector* << 145 inline 177 G4ElementData::GetComponentDataByID(G4int Z, G << 146 size_t G4ElementData::GetNumberOfComponents(G4int Z) 178 { 147 { 179 G4PhysicsVector* v = nullptr; << 148 return compID[Z]->size(); 180 for (auto const & p : *(compData[Z])) { << 181 if (id == p.first) { << 182 v = p.second; << 183 break; << 184 } << 185 } << 186 return v; << 187 } 149 } 188 150 189 inline G4Physics2DVector* << 151 inline G4int G4ElementData::GetComponentID(G4int Z, G4int idx) 190 G4ElementData::Get2DComponentDataByID(G4int Z, << 191 { 152 { 192 G4Physics2DVector* v = nullptr; << 153 return (*(compID[Z]))[idx]; 193 for (auto const & p : *(comp2D[Z])) { << 194 if (id == p.first) { << 195 v = p.second; << 196 break; << 197 } << 198 } << 199 return v; << 200 } 154 } 201 155 202 inline G4double << 156 inline G4PhysicsVector* 203 G4ElementData::GetValueForElement(G4int Z, G4d << 157 G4ElementData::GetComponentDataByIndex(G4int Z, G4int idx) 204 { 158 { 205 return elmData[Z]->Value(kinEnergy); << 159 return (*(compData[Z]))[idx]; 206 } 160 } 207 161 208 //-------------------------------------------- << 162 inline 209 // run time const methods with check on validi << 163 G4PhysicsVector* G4ElementData::GetComponentDataByID(G4int Z, G4int id) 210 //-------------------------------------------- << 211 << 212 inline std::size_t G4ElementData::GetNumberOfC << 213 { 164 { 214 return (nullptr != compData[Z]) ? compData[Z << 165 G4PhysicsVector* v = nullptr; 215 } << 166 for(G4int i=0; i<compLength[Z]; ++i) { 216 << 167 if(id == (*(compID[Z]))[i]) { 217 inline std::size_t G4ElementData::GetNumberOf2 << 168 v = (*(compData[Z]))[i]; 218 { << 169 break; 219 return (nullptr != comp2D[Z]) ? comp2D[Z]->s << 170 } 220 } << 171 } 221 << 172 return v; 222 inline G4int G4ElementData::GetComponentID(G4i << 223 { << 224 return (idx < GetNumberOfComponents(Z)) ? (* << 225 } 173 } 226 174 227 inline G4PhysicsVector* << 175 inline 228 G4ElementData::GetComponentDataByIndex(G4int Z << 176 G4double G4ElementData::GetValueForElement(G4int Z, G4double kinEnergy) 229 { 177 { 230 return << 178 return elmData[Z]->Value(kinEnergy); 231 (idx < GetNumberOfComponents(Z)) ? (*(comp << 232 } 179 } 233 180 234 inline G4Physics2DVector* << 181 inline G4double 235 G4ElementData::Get2DComponentDataByIndex(G4int << 182 G4ElementData::GetValueForComponent(G4int Z, G4int idx, G4double kinEnergy) 236 { 183 { 237 return << 184 return (*(compData[Z]))[idx]->Value(kinEnergy); 238 (idx < GetNumberOf2DComponents(Z)) ? (*(co << 239 } 185 } 240 186 241 inline G4double << 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 242 G4ElementData::GetValueForComponent(G4int Z, s << 243 { << 244 return (idx < GetNumberOfComponents(Z)) ? << 245 (*(compData[Z]))[idx].second->Value(e) : 0 << 246 } << 247 188 248 #endif 189 #endif >> 190 249 191