Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4PhysicsVector.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id$
28//
29//
30//---------------------------------------------------------------
31// GEANT 4 class header file
32//
33// G4PhysicsVector.hh
34//
35// Class description:
36//
37// A physics vector which has values of energy-loss, cross-section,
38// and other physics values of a particle in matter in a given
39// range of the energy, momentum, etc.
40// This class serves as the base class for a vector having various
41// energy scale, for example like 'log', 'linear', 'free', etc.
42
43// History:
44// 02 Dec. 1995, G.Cosmo : Structure created based on object model
45// 03 Mar. 1996, K.Amako : Implemented the 1st version
46// 27 Apr. 1996, K.Amako : Cache mechanism added
47// 01 Jul. 1996, K.Amako : Now GetValue not virtual
48// 21 Sep. 1996, K.Amako : Added [] and () operators
49// 11 Nov. 2000, H.Kurashige : Use STL vector for dataVector and binVector
50// 09 Mar. 2001, H.Kurashige : Added G4PhysicsVectorType & Store/Retrieve()
51// 02 Apr. 2008, A.Bagulya : Added SplineInterpolation() and SetSpline()
52// 11 May 2009, V.Ivanchenko : Added ComputeSecondDerivatives
53// 19 Jun. 2009, V.Ivanchenko : Removed hidden bin
54// 22 Dec. 2009 H.Kurashige : Use pointers to G4PVDataVector
55// 04 May. 2010 H.Kurashige : Use G4PhysicsVectorCache
56// 28 May 2010 H.Kurashige : Stop using pointers to G4PVDataVector
57// 16 Aug. 2011 H.Kurashige : Add dBin, baseBin and verboseLevel
58//---------------------------------------------------------------
59
60#ifndef G4PhysicsVector_h
61#define G4PhysicsVector_h 1
62
63#include "globals.hh"
64#include "G4ios.hh"
65
66#include <iostream>
67#include <fstream>
68#include <vector>
69
70#include "G4Allocator.hh"
73
74typedef std::vector<G4double> G4PVDataVector;
75
77{
78 public: // with description
79
80 G4PhysicsVector(G4bool spline = false);
81 // constructor
82 // This class is an abstract class with pure virtual method of
83 // virtual size_t FindBinLocation(G4double theEnergy) const
84 // So, default constructor is not supposed to be invoked explicitly
85
88 // Copy constructor and assignment operator.
89
90 virtual ~G4PhysicsVector();
91 // destructor
92
93 inline void* operator new(size_t);
94 inline void operator delete(void*);
95
96 inline G4double Value(G4double theEnergy);
97 // Get the cross-section/energy-loss value corresponding to the
98 // given energy. An appropriate interpolation is used to calculate
99 // the value.
100
101 inline G4double GetValue(G4double theEnergy, G4bool& isOutRange);
102 // Obolete method to get value, isOutRange is not used anymore.
103 // This method is kept for the compatibility reason.
104
105 G4int operator==(const G4PhysicsVector &right) const ;
106 G4int operator!=(const G4PhysicsVector &right) const ;
107
108 inline G4double operator[](const size_t binNumber) const ;
109 // Returns simply the value in the bin specified by 'binNumber'
110 // of the dataVector. The boundary check will not be done.
111
112 inline G4double operator()(const size_t binNumber) const ;
113 // Returns simply the value in the bin specified by 'binNumber'
114 // of the dataVector. The boundary check will not be Done.
115
116 inline void PutValue(size_t index, G4double theValue);
117 // Put 'theValue' into the bin specified by 'binNumber'.
118 // Take note that the 'index' starts from '0'.
119 // To fill the vector, you have beforehand to construct a vector
120 // by the constructor with Emin, Emax, Nbin. 'theValue' should
121 // be the crosssection/energyloss value corresponding to the
122 // energy of the index. You can get this energy by the next method
123 // or by the old method GetLowEdgeEnergy().
124
125 virtual void ScaleVector(G4double factorE, G4double factorV);
126 // Scale all values of the vector and second derivatives
127 // by factorV, energies by vectorE. This method may be applied
128 // for example after Retrieve a vector from an external file to
129 // convert values into Geant4 units
130
131 inline G4double Energy(size_t index) const;
132 // Returns simply the value in the energy specified by 'index'
133 // of the energy vector. The boundary check will not be done.
134 // Use this function when you fill physis vector by PutValue().
135
136 inline G4double GetMaxEnergy() const;
137 // Returns the energy of last point
138
139 virtual G4double GetLowEdgeEnergy(size_t binNumber) const;
140 // Obsolete method
141 // Get the energy value at the low edge of the specified bin.
142 // Take note that the 'binNumber' starts from '0'.
143 // This value should be defined before the call.
144 // The boundary check will not be done.
145
146 inline size_t GetVectorLength() const;
147 // Get the toal length (bin number) of the vector.
148
150 // Initialise second derivatives for spline keeping
151 // 3d derivative continues - default algorithm
152
154 // Initialise second derivatives for spline using algorithm
155 // which garantee only 1st derivative continues
156 // Warning: this method should be called when the vector
157 // is already filled
158
159 void ComputeSecondDerivatives(G4double firstPointDerivative,
160 G4double endPointDerivative);
161 // Initialise second derivatives for spline using
162 // user defined 1st derivatives at edge points
163 // Warning: this method should be called when the vector
164 // is already filled
165
167 // Is non-empty physics vector already exist?
168
170 // Get physics vector type
171
172 inline void SetSpline(G4bool);
173 // Activate/deactivate Spline interpolation.
174
175 virtual G4bool Store(std::ofstream& fOut, G4bool ascii=false);
176 virtual G4bool Retrieve(std::ifstream& fIn, G4bool ascii=false);
177 // To store/retrieve persistent data to/from file streams.
178
179 friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&);
180
181
182 inline G4double GetLastEnergy() const;
183 inline G4double GetLastValue() const;
184 inline size_t GetLastBin() const;
185 // Get cache values
186
187 inline void SetVerboseLevel(G4int value);
189 // Set/Get Verbose level
190
191 protected:
192
193 virtual size_t FindBinLocation(G4double theEnergy) const=0;
194 // Find the bin# in which theEnergy belongs - pure virtual function
195
196 void DeleteData();
197 void CopyData(const G4PhysicsVector& vec);
198 // Internal methods for allowing copy of objects
199
200 protected:
201
202 G4PhysicsVectorType type; // The type of PhysicsVector (enumerator)
203
204 G4double edgeMin; // Energy of first point
205 G4double edgeMax; // Energy of the last point
206
208
210
211 G4PVDataVector dataVector; // Vector to keep the crossection/energyloss
212 G4PVDataVector binVector; // Vector to keep energy
213 G4PVDataVector secDerivative; // Vector to keep second derivatives
214
215 private:
216
217 void ComputeValue(G4double theEnergy);
218
219 G4bool SplinePossible();
220
221 inline G4double LinearInterpolation(G4int lastBin);
222 // Linear interpolation function
223 inline G4double SplineInterpolation(G4int lastBin);
224 // Spline interpolation function
225
226 inline void Interpolation(G4int lastBin);
227
228 G4bool useSpline;
229
230 protected:
231 G4double dBin; // Bin width - useful only for fixed binning
232 G4double baseBin; // Set this in constructor for performance
233
235};
236
237#include "G4PhysicsVector.icc"
238
239#endif
G4PhysicsVectorType
std::vector< G4double > G4PVDataVector
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
void SetVerboseLevel(G4int value)
G4PVDataVector binVector
void ComputeSecondDerivatives(G4double firstPointDerivative, G4double endPointDerivative)
G4double Value(G4double theEnergy)
G4PhysicsVectorType type
size_t GetLastBin() const
size_t GetVectorLength() const
G4int GetVerboseLevel(G4int)
virtual size_t FindBinLocation(G4double theEnergy) const =0
G4double GetMaxEnergy() const
G4double GetValue(G4double theEnergy, G4bool &isOutRange)
G4double operator[](const size_t binNumber) const
virtual void ScaleVector(G4double factorE, G4double factorV)
G4double Energy(size_t index) const
G4PhysicsVectorCache * cache
G4bool IsFilledVectorExist() const
G4PVDataVector secDerivative
virtual ~G4PhysicsVector()
G4PhysicsVectorType GetType() const
void ComputeSecDerivatives()
void FillSecondDerivatives()
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
void SetSpline(G4bool)
G4double operator()(const size_t binNumber) const
G4PVDataVector dataVector
void CopyData(const G4PhysicsVector &vec)
virtual G4double GetLowEdgeEnergy(size_t binNumber) const
void PutValue(size_t index, G4double theValue)
G4int operator==(const G4PhysicsVector &right) const
G4double GetLastValue() const
G4int operator!=(const G4PhysicsVector &right) const
friend std::ostream & operator<<(std::ostream &, const G4PhysicsVector &)
G4PhysicsVector & operator=(const G4PhysicsVector &)
G4double GetLastEnergy() const
virtual G4bool Store(std::ofstream &fOut, G4bool ascii=false)