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