File indexing completed on 2026-10-02 09:04:28
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
0042
0043
0044
0045
0046
0047 #ifndef G4ElementData_h
0048 #define G4ElementData_h 1
0049
0050 #include "G4Physics2DVector.hh"
0051 #include "G4PhysicsVector.hh"
0052 #include "globals.hh"
0053
0054 #include <vector>
0055
0056 class G4ElementDataRegistry;
0057
0058 class G4ElementData
0059 {
0060 public:
0061 explicit G4ElementData(G4int length = 99);
0062
0063 ~G4ElementData();
0064
0065
0066 G4ElementData& operator=(const G4ElementData& right) = delete;
0067 G4ElementData(const G4ElementData&) = delete;
0068
0069
0070 void Reserve1D(std::size_t);
0071 void Reserve2D(std::size_t);
0072
0073
0074 void InitialiseForElement(G4int Z, G4PhysicsVector* v);
0075
0076
0077 void InitialiseForElement(G4int Z, G4Physics2DVector* v);
0078
0079
0080 void InitialiseForComponent(G4int Z, G4int nComponents = 0);
0081
0082
0083 void InitialiseFor2DComponent(G4int Z, G4int nComponents = 0);
0084
0085
0086 void AddComponent(G4int Z, G4int id, G4PhysicsVector* v);
0087
0088
0089 void Add2DComponent(G4int Z, G4int id, G4Physics2DVector* v);
0090
0091
0092 G4PhysicsVector* New1DVector(G4int Z, G4int ne);
0093
0094
0095 G4Physics2DVector* New2DVector(G4int Z, G4int ny, G4int ne);
0096
0097
0098 inline void SetName(const G4String& nam);
0099
0100
0101
0102
0103
0104
0105
0106 inline const G4String& GetName() const;
0107
0108
0109 inline G4PhysicsVector* GetElementData(G4int Z) const;
0110
0111
0112 inline G4Physics2DVector* GetElement2DData(G4int Z) const;
0113
0114
0115 inline G4PhysicsVector* GetComponentDataByID(G4int Z, G4int id) const;
0116
0117
0118 inline G4Physics2DVector* Get2DComponentDataByID(G4int Z, G4int id) const;
0119
0120
0121 inline G4double GetValueForElement(G4int Z, G4double kinEnergy) const;
0122
0123
0124
0125
0126
0127
0128 inline std::size_t GetNumberOfComponents(G4int Z) const;
0129
0130
0131 inline std::size_t GetNumberOf2DComponents(G4int Z) const;
0132
0133
0134
0135 inline G4int GetComponentID(G4int Z, std::size_t idx) const;
0136
0137
0138 inline G4PhysicsVector*
0139 GetComponentDataByIndex(G4int Z, std::size_t idx) const;
0140
0141
0142 inline G4Physics2DVector*
0143 Get2DComponentDataByIndex(G4int Z, std::size_t idx) const;
0144
0145
0146
0147 inline G4double
0148 GetValueForComponent(G4int Z, std::size_t idx, G4double kinEnergy) const;
0149
0150 private:
0151
0152 void DataError(G4int Z, const G4String&);
0153
0154 const G4int maxNumElm;
0155
0156 G4ElementDataRegistry* fRegistry{nullptr};
0157
0158 std::vector<G4PhysicsVector*> elmData;
0159 std::vector<std::vector<std::pair<G4int, G4PhysicsVector*> >* > compData;
0160
0161 std::vector<G4Physics2DVector*> elm2Data;
0162 std::vector<std::vector<std::pair<G4int, G4Physics2DVector*> >* > comp2D;
0163
0164 G4String name{""};
0165 };
0166
0167
0168
0169
0170
0171 inline void G4ElementData::SetName(const G4String& nam)
0172 {
0173 name = nam;
0174 }
0175
0176 inline const G4String& G4ElementData::GetName() const
0177 {
0178 return name;
0179 }
0180
0181 inline G4PhysicsVector* G4ElementData::GetElementData(G4int Z) const
0182 {
0183 return elmData[Z];
0184 }
0185
0186 inline G4Physics2DVector* G4ElementData::GetElement2DData(G4int Z) const
0187 {
0188 return elm2Data[Z];
0189 }
0190
0191 inline G4PhysicsVector*
0192 G4ElementData::GetComponentDataByID(G4int Z, G4int id) const
0193 {
0194 G4PhysicsVector* v = nullptr;
0195 for (auto const & p : *(compData[Z])) {
0196 if (id == p.first) {
0197 v = p.second;
0198 break;
0199 }
0200 }
0201 return v;
0202 }
0203
0204 inline G4Physics2DVector*
0205 G4ElementData::Get2DComponentDataByID(G4int Z, G4int id) const
0206 {
0207 G4Physics2DVector* v = nullptr;
0208 for (auto const & p : *(comp2D[Z])) {
0209 if (id == p.first) {
0210 v = p.second;
0211 break;
0212 }
0213 }
0214 return v;
0215 }
0216
0217 inline G4double
0218 G4ElementData::GetValueForElement(G4int Z, G4double kinEnergy) const
0219 {
0220 return elmData[Z]->Value(kinEnergy);
0221 }
0222
0223
0224
0225
0226
0227 inline std::size_t G4ElementData::GetNumberOfComponents(G4int Z) const
0228 {
0229 return (nullptr != compData[Z]) ? compData[Z]->size() : 0;
0230 }
0231
0232 inline std::size_t G4ElementData::GetNumberOf2DComponents(G4int Z) const
0233 {
0234 return (nullptr != comp2D[Z]) ? comp2D[Z]->size() : 0;
0235 }
0236
0237 inline G4int G4ElementData::GetComponentID(G4int Z, std::size_t idx) const
0238 {
0239 return (idx < GetNumberOfComponents(Z)) ? (*(compData[Z]))[idx].first : 0;
0240 }
0241
0242 inline G4PhysicsVector*
0243 G4ElementData::GetComponentDataByIndex(G4int Z, std::size_t idx) const
0244 {
0245 return
0246 (idx < GetNumberOfComponents(Z)) ? (*(compData[Z]))[idx].second : nullptr;
0247 }
0248
0249 inline G4Physics2DVector*
0250 G4ElementData::Get2DComponentDataByIndex(G4int Z, std::size_t idx) const
0251 {
0252 return
0253 (idx < GetNumberOf2DComponents(Z)) ? (*(comp2D[Z]))[idx].second : nullptr;
0254 }
0255
0256 inline G4double
0257 G4ElementData::GetValueForComponent(G4int Z, std::size_t idx, G4double e) const
0258 {
0259 return (idx < GetNumberOfComponents(Z)) ?
0260 (*(compData[Z]))[idx].second->Value(e) : 0.0;
0261 }
0262
0263 #endif