|
||||
Warning, file /include/Geant4/G4PhysicsVector.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4PhysicsVector 0027 // 0028 // Class description: 0029 // 0030 // A physics vector which has values of energy-loss, cross-section, 0031 // and other physics values of a particle in matter in a given 0032 // range of energy, momentum, etc. 0033 // This class serves as the base class for a vector having various 0034 // energy scale, for example like 'log', 'linear', 'free', etc. 0035 0036 // Authors: 0037 // - 02 Dec. 1995, G.Cosmo: Structure created based on object model 0038 // - 03 Mar. 1996, K.Amako: Implemented the 1st version 0039 // Revisions: 0040 // - 11 Nov. 2000, H.Kurashige: Use STL vector for dataVector and binVector 0041 // -------------------------------------------------------------------- 0042 #ifndef G4PhysicsVector_hh 0043 #define G4PhysicsVector_hh 1 0044 0045 #include <fstream> 0046 #include <iostream> 0047 #include <vector> 0048 0049 #include "G4Log.hh" 0050 #include "G4PhysicsVectorType.hh" 0051 #include "G4ios.hh" 0052 #include "globals.hh" 0053 0054 class G4PhysicsVector 0055 { 0056 public: 0057 // Default constructor - vector will be filled via Retrieve() method 0058 // Free vector may be filled via InsertValue(..) method 0059 explicit G4PhysicsVector(G4bool spline = false); 0060 0061 // Copy constructor and assignment operator 0062 G4PhysicsVector(const G4PhysicsVector&) = default; 0063 G4PhysicsVector& operator=(const G4PhysicsVector&) = default; 0064 0065 // not used operators 0066 G4PhysicsVector(const G4PhysicsVector&&) = delete; 0067 G4PhysicsVector& operator=(const G4PhysicsVector&&) = delete; 0068 G4bool operator==(const G4PhysicsVector& right) const = delete; 0069 G4bool operator!=(const G4PhysicsVector& right) const = delete; 0070 0071 virtual ~G4PhysicsVector() = default; 0072 0073 // Get the cross-section/energy-loss value corresponding to the 0074 // given energy. An appropriate interpolation is used to calculate 0075 // the value. Consumer code gets changed index and may reuse it 0076 // for the next call to save CPU for bin location. 0077 inline G4double Value(const G4double energy, std::size_t& lastidx) const; 0078 0079 // Get the cross-section/energy-loss value corresponding to the 0080 // given energy. An appropriate interpolation is used to calculate 0081 // the value. This method should be used if bin location cannot be 0082 // kept in the user code. 0083 inline G4double Value(const G4double energy) const; 0084 0085 // Obsolete method to get value, 'isOutRange' is not used anymore. 0086 // This method is kept for the compatibility reason 0087 inline G4double GetValue(const G4double energy, G4bool& isOutRange) const; 0088 0089 // Same as the Value() method above but specialised for log-vector type. 0090 // Note, unlike the general Value() method above, this method will work 0091 // properly only for G4PhysicsLogVector. 0092 inline G4double LogVectorValue(const G4double energy, 0093 const G4double theLogEnergy) const; 0094 0095 // Same as the Value() method above but specialised for free vector 0096 // with logarithmic seach of bin number 0097 inline G4double LogFreeVectorValue(const G4double energy, 0098 const G4double theLogEnergy) const; 0099 0100 // Returns the value for the specified index of the dataVector 0101 // The boundary check will not be done 0102 inline G4double operator[](const std::size_t index) const; 0103 inline G4double operator()(const std::size_t index) const; 0104 0105 // Put data into the vector at 'index' position. 0106 // Take note that the 'index' starts from '0'. 0107 // It is assumed that energies are already filled. 0108 inline void PutValue(const std::size_t index, const G4double value); 0109 0110 // Returns the value in the energy specified by 'index' 0111 // of the energy vector. The boundary check will not be done. 0112 // Use this when compute cross-section, dEdx, or other value 0113 // before filling the vector by PutValue(). 0114 inline G4double Energy(const std::size_t index) const; 0115 inline G4double GetLowEdgeEnergy(const std::size_t index) const; 0116 0117 // Returns the energy of the first and the last point of the vector. 0118 inline G4double GetMinEnergy() const; 0119 inline G4double GetMaxEnergy() const; 0120 0121 // Returns the data of the first and the last point of the vector. 0122 // If the vector is empty returns zeros. 0123 inline G4double GetMinValue() const; 0124 inline G4double GetMaxValue() const; 0125 0126 // Get the total length of the vector 0127 inline std::size_t GetVectorLength() const; 0128 0129 // Computes the lower index the energy bin in case of log-vector i.e. 0130 // in case of vectors with equal bin widths on log-scale 0131 // Note, that no check on the boundary is performed 0132 inline std::size_t ComputeLogVectorBin(const G4double logenergy) const; 0133 0134 // Get physics vector type. 0135 inline G4PhysicsVectorType GetType() const; 0136 0137 // True if using spline interpolation. 0138 inline G4bool GetSpline() const; 0139 0140 // Define verbosity level. 0141 inline void SetVerboseLevel(G4int value); 0142 0143 // Find energy using linear interpolation for vector 0144 // filled by cumulative probability function. 0145 // Assuming that vector is already filled. 0146 inline G4double FindLinearEnergy(const G4double rand) const; 0147 0148 // Find low edge index of a bin for given energy. 0149 // Min value 0, max value idxmax. 0150 std::size_t FindBin(const G4double energy, std::size_t idx) const; 0151 0152 // Scale all values of the vector by factorV, energies by vectorE. 0153 // AFter this method FillSecondDerivatives(...) should be called. 0154 // This method may be applied for example after retrieving a vector 0155 // from an external file to convert values into Geant4 units. 0156 void ScaleVector(const G4double factorE, const G4double factorV); 0157 0158 // This method should be called when the vector is fully filled 0159 // There are 3 types of second derivative computations: 0160 // fSplineSimple - 2d derivative continues 0161 // fSplineBase - 3d derivative continues (the default) 0162 // fSplineFixedEdges - 3d derivatives continues, 1st and last 0163 // derivatives are fixed 0164 void FillSecondDerivatives(const G4SplineType = G4SplineType::Base, 0165 const G4double dir1 = 0.0, 0166 const G4double dir2 = 0.0); 0167 0168 // This method can be applied if both energy and data values 0169 // grow monotonically, for example, if in this vector a 0170 // cumulative probability density function is stored. 0171 G4double GetEnergy(const G4double value) const; 0172 0173 // To store/retrieve persistent data to/from file streams. 0174 G4bool Store(std::ofstream& fOut, G4bool ascii = false) const; 0175 G4bool Retrieve(std::ifstream& fIn, G4bool ascii = false); 0176 0177 // Print vector 0178 friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&); 0179 void DumpValues(G4double unitE = 1.0, G4double unitV = 1.0) const; 0180 0181 protected: 0182 0183 // The default implements a free vector initialisation. 0184 virtual void Initialise(); 0185 0186 void PrintPutValueError(std::size_t index, G4double value, 0187 const G4String& text); 0188 0189 private: 0190 0191 void ComputeSecDerivative0(); 0192 void ComputeSecDerivative1(); 0193 void ComputeSecDerivative2(const G4double firstPointDerivative, 0194 const G4double endPointDerivative); 0195 // Internal methods for computing of spline coeffitients 0196 0197 // Linear or spline interpolation. 0198 inline G4double Interpolation(const std::size_t idx, 0199 const G4double energy) const; 0200 0201 // Assuming (edgeMin <= energy <= edgeMax). 0202 inline std::size_t LogBin(const G4double energy, const G4double loge) const; 0203 inline std::size_t BinaryBin(const G4double energy) const; 0204 inline std::size_t GetBin(const G4double energy) const; 0205 0206 protected: 0207 0208 G4double edgeMin = 0.0; // Energy of first point 0209 G4double edgeMax = 0.0; // Energy of the last point 0210 0211 G4double invdBin = 0.0; // 1/Bin width for linear and log vectors 0212 G4double logemin = 0.0; // used only for log vector 0213 0214 G4double iBin1 = 0.0; // 1/Bin width for scale log vector 0215 G4double lmin1 = 0.0; // used for log search of free vector 0216 0217 G4int verboseLevel = 0; 0218 std::size_t idxmax = 0; 0219 std::size_t imax1 = 0; 0220 std::size_t numberOfNodes = 0; 0221 std::size_t nLogNodes = 0; 0222 0223 G4PhysicsVectorType type = T_G4PhysicsFreeVector; 0224 // The type of PhysicsVector (enumerator) 0225 0226 std::vector<G4double> binVector; // energy 0227 std::vector<G4double> dataVector; // crossection/energyloss 0228 std::vector<G4double> secDerivative; // second derivatives 0229 std::vector<std::size_t> scale; // log seach 0230 0231 private: 0232 0233 G4bool useSpline = false; 0234 }; 0235 0236 #include "G4PhysicsVector.icc" 0237 0238 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |