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 // G4Physics2DVector << 27 // 26 // 28 // Class description: << 27 // $Id:$ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ 29 // 29 // 30 // A 2-dimentional vector with linear interpol << 30 // >> 31 //--------------------------------------------------------------- >> 32 // GEANT 4 class header file >> 33 // >> 34 // G4Physics2DVector.hh >> 35 // >> 36 // Class description: >> 37 // >> 38 // A 2-dimentional vector with linear interpolation. 31 39 32 // Author: Vladimir Ivanchenko, 25.09.2011 << 40 // Author: Vladimir Ivanchenko 33 // ------------------------------------------- << 41 // 34 #ifndef G4Physics2DVector_hh << 42 // Creation date: 25.09.2011 35 #define G4Physics2DVector_hh 1 << 43 //--------------------------------------------------------------- >> 44 >> 45 #ifndef G4Physics2DVector_h >> 46 #define G4Physics2DVector_h 1 >> 47 >> 48 #include "globals.hh" >> 49 #include "G4ios.hh" 36 50 37 #include <fstream> << 38 #include <iostream> 51 #include <iostream> >> 52 #include <fstream> 39 #include <vector> 53 #include <vector> 40 54 >> 55 #include "G4Physics2DVectorCache.hh" 41 #include "G4PhysicsVectorType.hh" 56 #include "G4PhysicsVectorType.hh" 42 #include "G4ios.hh" << 43 #include "globals.hh" << 44 57 45 using G4PV2DDataVector = std::vector<G4double> << 58 typedef std::vector<G4double> G4PV2DDataVector; 46 59 47 class G4Physics2DVector << 60 class G4Physics2DVector 48 { 61 { 49 public: << 62 public: // with description 50 G4Physics2DVector(); << 51 // Vector will be filled via Retrieve method << 52 63 53 explicit G4Physics2DVector(std::size_t nx, s << 64 G4Physics2DVector(); 54 // Vector will be filled via Put methods << 65 G4Physics2DVector(size_t nx, size_t ny); >> 66 // constructors 55 67 56 G4Physics2DVector(const G4Physics2DVector&); 68 G4Physics2DVector(const G4Physics2DVector&); 57 G4Physics2DVector& operator=(const G4Physics 69 G4Physics2DVector& operator=(const G4Physics2DVector&); 58 // Copy constructor and assignment operator << 70 // Copy constructor and assignment operator. 59 << 60 G4bool operator==(const G4Physics2DVector& r << 61 G4bool operator!=(const G4Physics2DVector& r << 62 71 63 ~G4Physics2DVector(); 72 ~G4Physics2DVector(); 64 // Destructor << 73 // destructor 65 74 66 G4double Value(G4double x, G4double y, std:: << 75 inline G4double Value(G4double x, G4double y); 67 std::size_t& lastidy) const; << 68 G4double Value(G4double x, G4double y) const << 69 // Main method to interpolate 2D vector 76 // Main method to interpolate 2D vector 70 // Consumer class should provide initial val << 71 77 72 inline void PutX(std::size_t idx, G4double v << 78 inline void PutX(size_t idx, G4double value); 73 inline void PutY(std::size_t idy, G4double v << 79 inline void PutY(size_t idy, G4double value); 74 inline void PutValue(std::size_t idx, std::s << 80 inline void PutValue(size_t idx, size_t idy, G4double value); 75 void PutVectors(const std::vector<G4double>& 81 void PutVectors(const std::vector<G4double>& vecX, 76 const std::vector<G4double>& << 82 const std::vector<G4double>& vecY); 77 // Methods to fill vector << 83 // Methods to fill vector 78 // Take note that the 'index' starts from '0 << 84 // Take note that the 'index' starts from '0'. 79 85 80 void ScaleVector(G4double factor); 86 void ScaleVector(G4double factor); 81 // Scale all values of the vector by factor. << 87 // Scale all values of the vector by factor, 82 // This method may be applied for example af << 88 // This method may be applied 83 // from an external file to convert values i << 89 // for example after Retrieve a vector from an external file to 84 << 90 // convert values into Geant4 units 85 G4double FindLinearX(G4double rand, G4double << 91 86 inline G4double FindLinearX(G4double rand, G << 92 inline G4double GetX(size_t index) const; 87 // Find Y using linear interpolation for Y-v << 93 inline G4double GetY(size_t index) const; 88 // probability function value of rand should << 94 inline G4double GetValue(size_t idx, size_t idy) const; 89 << 90 inline G4double GetX(std::size_t index) cons << 91 inline G4double GetY(std::size_t index) cons << 92 inline G4double GetValue(std::size_t idx, st << 93 // Returns simply the values of the vector b 95 // Returns simply the values of the vector by index 94 // of the energy vector. The boundary check << 96 // of the energy vector. The boundary check will not be done. 95 97 96 inline std::size_t FindBinLocationX(const G4 << 98 inline size_t GetLengthX() const; 97 const st << 99 inline size_t GetLengthY() const; 98 inline std::size_t FindBinLocationY(const G4 << 100 // Get the lengths of the vector. 99 const st << 100 // Find the bin# in which theEnergy belongs. << 101 << 102 inline std::size_t GetLengthX() const; << 103 inline std::size_t GetLengthY() const; << 104 // Get the lengths of the vector << 105 101 106 inline G4PhysicsVectorType GetType() const; 102 inline G4PhysicsVectorType GetType() const; 107 // Get physics vector type 103 // Get physics vector type 108 104 109 inline void SetBicubicInterpolation(G4bool); 105 inline void SetBicubicInterpolation(G4bool); 110 // Activate/deactivate bicubic interpolation << 106 // Activate/deactivate bicubic interpolation. 111 107 112 void Store(std::ofstream& fOut) const; << 108 void Store(std::ofstream& fOut); 113 G4bool Retrieve(std::ifstream& fIn); 109 G4bool Retrieve(std::ifstream& fIn); 114 // To store/retrieve persistent data to/from << 110 // To store/retrieve persistent data to/from file streams. >> 111 >> 112 inline G4double GetLastX() const; >> 113 inline G4double GetLastY() const; >> 114 inline G4double GetLastValue() const; >> 115 inline size_t GetLastBinX() const; >> 116 inline size_t GetLastBinY() const; >> 117 // Get cache values 115 118 116 inline void SetVerboseLevel(G4int value); 119 inline void SetVerboseLevel(G4int value); >> 120 inline G4int GetVerboseLevel() const; >> 121 // Set/Get Verbose level >> 122 >> 123 protected: 117 124 118 protected: << 119 void PrepareVectors(); 125 void PrepareVectors(); 120 126 121 void ClearVectors(); 127 void ClearVectors(); 122 128 123 void CopyData(const G4Physics2DVector& vec); 129 void CopyData(const G4Physics2DVector& vec); 124 130 125 G4double BicubicInterpolation(const G4double << 131 void ComputeValue(G4double x, G4double y); 126 const std::siz << 132 // Main method to interpolate 2D vector 127 const std::siz << 133 // by default by linear interpolation 128 // Bicubic interpolation of 2D vector << 134 129 << 135 void BicubicInterpolation(size_t idx, size_t idy); 130 inline std::size_t FindBin(const G4double z, << 136 // Bicubic interpolation of 2D vector 131 const std::size_t << 137 132 const std::size_t << 138 size_t FindBinLocation(G4double z, const G4PV2DDataVector&); 133 << 139 // Main method to local bin 134 private: << 140 135 G4double InterpolateLinearX(G4PV2DDataVector << 141 inline void FindBin(G4double z, const G4PV2DDataVector&, 136 << 142 size_t& lastidx); 137 inline G4double DerivativeX(std::size_t idx, << 143 inline void FindBinLocationX(G4double x); 138 G4double fac) co << 144 inline void FindBinLocationY(G4double y); 139 inline G4double DerivativeY(std::size_t idx, << 145 // Find the bin# in which theEnergy belongs 140 G4double fac) co << 146 // Starting from 0 141 inline G4double DerivativeXY(std::size_t idx << 147 142 G4double fac) c << 148 private: >> 149 >> 150 inline G4double DerivativeX(size_t idx, size_t idy, G4double fac); >> 151 inline G4double DerivativeY(size_t idx, size_t idy, G4double fac); >> 152 inline G4double DerivativeXY(size_t idx, size_t idy, G4double fac); 143 // computation of derivatives 153 // computation of derivatives 144 154 145 G4PhysicsVectorType type = T_G4PhysicsFreeVe << 155 G4int operator==(const G4Physics2DVector &right) const ; 146 // The type of PhysicsVector (enumerator) << 156 G4int operator!=(const G4Physics2DVector &right) const ; >> 157 >> 158 G4PhysicsVectorType type; // The type of PhysicsVector (enumerator) >> 159 >> 160 size_t numberOfXNodes; >> 161 size_t numberOfYNodes; 147 162 148 std::size_t numberOfXNodes = 0; << 163 G4Physics2DVectorCache* cache; 149 std::size_t numberOfYNodes = 0; << 150 164 151 G4PV2DDataVector xVector; << 165 G4PV2DDataVector xVector; 152 G4PV2DDataVector yVector; << 166 G4PV2DDataVector yVector; 153 std::vector<G4PV2DDataVector*> value; 167 std::vector<G4PV2DDataVector*> value; 154 168 155 G4int verboseLevel = 0; << 169 G4int verboseLevel; 156 G4bool useBicubic = false; << 170 G4bool useBicubic; 157 }; 171 }; 158 172 159 #include "G4Physics2DVector.icc" 173 #include "G4Physics2DVector.icc" 160 174 161 #endif 175 #endif 162 176