File indexing completed on 2025-01-18 09:58:55
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 #ifndef G4Physics2DVector_hh
0035 #define G4Physics2DVector_hh 1
0036
0037 #include <fstream>
0038 #include <iostream>
0039 #include <vector>
0040
0041 #include "G4PhysicsVectorType.hh"
0042 #include "G4ios.hh"
0043 #include "globals.hh"
0044
0045 using G4PV2DDataVector = std::vector<G4double>;
0046
0047 class G4Physics2DVector
0048 {
0049 public:
0050 G4Physics2DVector();
0051
0052
0053 explicit G4Physics2DVector(std::size_t nx, std::size_t ny);
0054
0055
0056 G4Physics2DVector(const G4Physics2DVector&);
0057 G4Physics2DVector& operator=(const G4Physics2DVector&);
0058
0059
0060 G4bool operator==(const G4Physics2DVector& right) const = delete;
0061 G4bool operator!=(const G4Physics2DVector& right) const = delete;
0062
0063 ~G4Physics2DVector();
0064
0065
0066 G4double Value(G4double x, G4double y, std::size_t& lastidx,
0067 std::size_t& lastidy) const;
0068 G4double Value(G4double x, G4double y) const;
0069
0070
0071
0072 inline void PutX(std::size_t idx, G4double value);
0073 inline void PutY(std::size_t idy, G4double value);
0074 inline void PutValue(std::size_t idx, std::size_t idy, G4double value);
0075 void PutVectors(const std::vector<G4double>& vecX,
0076 const std::vector<G4double>& vecY);
0077
0078
0079
0080 void ScaleVector(G4double factor);
0081
0082
0083
0084
0085 G4double FindLinearX(G4double rand, G4double y, std::size_t& lastidy) const;
0086 inline G4double FindLinearX(G4double rand, G4double y) const;
0087
0088
0089
0090 inline G4double GetX(std::size_t index) const;
0091 inline G4double GetY(std::size_t index) const;
0092 inline G4double GetValue(std::size_t idx, std::size_t idy) const;
0093
0094
0095
0096 inline std::size_t FindBinLocationX(const G4double x,
0097 const std::size_t lastidx) const;
0098 inline std::size_t FindBinLocationY(const G4double y,
0099 const std::size_t lastidy) const;
0100
0101
0102 inline std::size_t GetLengthX() const;
0103 inline std::size_t GetLengthY() const;
0104
0105
0106 inline G4PhysicsVectorType GetType() const;
0107
0108
0109 inline void SetBicubicInterpolation(G4bool);
0110
0111
0112 void Store(std::ofstream& fOut) const;
0113 G4bool Retrieve(std::ifstream& fIn);
0114
0115
0116 inline void SetVerboseLevel(G4int value);
0117
0118 protected:
0119 void PrepareVectors();
0120
0121 void ClearVectors();
0122
0123 void CopyData(const G4Physics2DVector& vec);
0124
0125 G4double BicubicInterpolation(const G4double x, const G4double y,
0126 const std::size_t idx,
0127 const std::size_t idy) const;
0128
0129
0130 inline std::size_t FindBin(const G4double z, const G4PV2DDataVector&,
0131 const std::size_t idz,
0132 const std::size_t idzmax) const;
0133
0134 private:
0135 G4double InterpolateLinearX(G4PV2DDataVector& v, G4double rand) const;
0136
0137 inline G4double DerivativeX(std::size_t idx, std::size_t idy,
0138 G4double fac) const;
0139 inline G4double DerivativeY(std::size_t idx, std::size_t idy,
0140 G4double fac) const;
0141 inline G4double DerivativeXY(std::size_t idx, std::size_t idy,
0142 G4double fac) const;
0143
0144
0145 G4PhysicsVectorType type = T_G4PhysicsFreeVector;
0146
0147
0148 std::size_t numberOfXNodes = 0;
0149 std::size_t numberOfYNodes = 0;
0150
0151 G4PV2DDataVector xVector;
0152 G4PV2DDataVector yVector;
0153 std::vector<G4PV2DDataVector*> value;
0154
0155 G4int verboseLevel = 0;
0156 G4bool useBicubic = false;
0157 };
0158
0159 #include "G4Physics2DVector.icc"
0160
0161 #endif