source: trunk/source/global/management/include/G4PhysicsVector.hh@ 1193

Last change on this file since 1193 was 1193, checked in by garnier, 16 years ago

CVS update

File size: 9.0 KB
Line 
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: G4PhysicsVector.hh,v 1.25 2009/11/04 11:32:43 vnivanch Exp $
28// GEANT4 tag $Name: global-V09-02-10 $
29//
30//
31//---------------------------------------------------------------
32// GEANT 4 class header file
33//
34// G4PhysicsVector.hh
35//
36// Class description:
37//
38// A physics vector which has values of energy-loss, cross-section,
39// and other physics values of a particle in matter in a given
40// range of the energy, momentum, etc.
41// This class serves as the base class for a vector having various
42// energy scale, for example like 'log', 'linear', 'free', etc.
43
44// History:
45// 02 Dec. 1995, G.Cosmo : Structure created based on object model
46// 03 Mar. 1996, K.Amako : Implemented the 1st version
47// 27 Apr. 1996, K.Amako : Cache mechanism added
48// 01 Jul. 1996, K.Amako : Now GetValue not virtual
49// 21 Sep. 1996, K.Amako : Added [] and () operators
50// 11 Nov. 2000, H.Kurashige : Use STL vector for dataVector and binVector
51// 09 Mar. 2001, H.Kurashige : Added G4PhysicsVectorType & Store/Retrieve()
52// 02 Apr. 2008, A.Bagulya : Added SplineInterpolation() and SetSpline()
53// 11 May 2009, V.Ivanchenko : Added ComputeSecondDerivatives
54// 19 Jun. 2009, V.Ivanchenko : Removed hidden bin
55//
56//---------------------------------------------------------------
57
58#ifndef G4PhysicsVector_h
59#define G4PhysicsVector_h 1
60
61#include <vector>
62#include "globals.hh"
63#include "G4ios.hh"
64#include <iostream>
65#include <fstream>
66
67#include "G4PhysicsVectorType.hh"
68
69class G4PhysicsVector
70{
71 public:
72
73 G4PhysicsVector(G4bool spline = false);
74 // constructor
75 // This class is an abstract class with pure virtual method of
76 // virtual size_t FindBinLocation(G4double theEnergy) const
77 // So, default constructor is not supposed to be invoked explicitly
78
79 G4PhysicsVector(const G4PhysicsVector&);
80 G4PhysicsVector& operator=(const G4PhysicsVector&);
81 // Copy constructor and assignment operator.
82
83 public: // with description
84
85 virtual ~G4PhysicsVector();
86 // destructor
87
88 inline G4double Value(G4double theEnergy);
89 // Get the cross-section/energy-loss value corresponding to the
90 // given energy. An appropriate interpolation is used to calculate
91 // the value.
92
93 inline G4double GetValue(G4double theEnergy, G4bool& isOutRange);
94 // Obolete method to get value, isOutRange is not used anymore.
95 // This method is kept for the compatibility reason.
96
97 G4int operator==(const G4PhysicsVector &right) const ;
98 G4int operator!=(const G4PhysicsVector &right) const ;
99
100 inline G4double operator[](const size_t binNumber) const ;
101 // Returns simply the value in the bin specified by 'binNumber'
102 // of the dataVector. The boundary check will not be done.
103
104 inline G4double operator()(const size_t binNumber) const ;
105 // Returns simply the value in the bin specified by 'binNumber'
106 // of the dataVector. The boundary check will not be Done.
107
108 inline void PutValue(size_t index, G4double theValue);
109 // Put 'theValue' into the bin specified by 'binNumber'.
110 // Take note that the 'index' starts from '0'.
111 // To fill the vector, you have beforehand to construct a vector
112 // by the constructor with Emin, Emax, Nbin. 'theValue' should
113 // be the crosssection/energyloss value corresponding to the
114 // energy of the index. You can get this energy by the next method
115 // or by the old method GetLowEdgeEnergy().
116
117 void ScaleVector(G4double factorE, G4double factorV);
118 // Scale all values of the vector and second derivatives
119 // by factorV, energies by vectorE. This method may be applied
120 // for example after Retrieve a vector from an external file to
121 // convert values into Geant4 units
122
123 inline G4double Energy(size_t index) const;
124 // Returns simply the value in the energy specified by 'index'
125 // of the energy vector. The boundary check will not be done.
126 // Use this function when you fill physis vector by PutValue().
127
128 virtual G4double GetLowEdgeEnergy(size_t binNumber) const;
129 // Obsolete method
130 // Get the energy value at the low edge of the specified bin.
131 // Take note that the 'binNumber' starts from '0'.
132 // This value should be defined before the call.
133 // The boundary check will not be done.
134
135 inline size_t GetVectorLength() const;
136 // Get the toal length (bin number) of the vector.
137
138 void FillSecondDerivatives();
139 // Initialise second derivatives for spline keeping
140 // 3d derivative continues - default algorithm
141
142 void ComputeSecDerivatives();
143 // Initialise second derivatives for spline using algorithm
144 // which garantee only 1st derivative continues
145 // Warning: this method should be called when the vector
146 // is already filled
147
148 void ComputeSecondDerivatives(G4double firstPointDerivative,
149 G4double endPointDerivative);
150 // Initialise second derivatives for spline using
151 // user defined 1st derivatives at edge points
152 // Warning: this method should be called when the vector
153 // is already filled
154
155 inline G4bool IsFilledVectorExist() const;
156 // Is non-empty physics vector already exist?
157
158 inline void PutComment(const G4String& theComment);
159 // Put a comment to the G4PhysicsVector. This may help to check
160 // whether your are accessing to the one you want.
161
162 inline const G4String& GetComment() const;
163 // Retrieve the comment of the G4PhysicsVector.
164
165 inline G4PhysicsVectorType GetType() const;
166 // Get physics vector type
167
168 inline void SetSpline(G4bool);
169 // Activate/deactivate Spline interpolation.
170
171 virtual G4bool Store(std::ofstream& fOut, G4bool ascii=false);
172 virtual G4bool Retrieve(std::ifstream& fIn, G4bool ascii=false);
173 // To store/retrieve persistent data to/from file streams.
174
175 friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&);
176
177 protected:
178
179 virtual size_t FindBinLocation(G4double theEnergy) const=0;
180 // Find the bin# in which theEnergy belongs - pure virtual function
181
182 void DeleteData();
183 void CopyData(const G4PhysicsVector& vec);
184 // Internal methods for allowing copy of objects
185
186 protected:
187
188 typedef std::vector<G4double> G4PVDataVector;
189
190 G4PhysicsVectorType type; // The type of PhysicsVector (enumerator)
191
192 G4double edgeMin; // Energy of first point
193 G4double edgeMax; // Energy of the last point
194
195 size_t numberOfNodes;
196
197 G4double lastEnergy; // Cache the last input value
198 G4double lastValue; // Cache the last output value
199 size_t lastBin; // Cache the last bin location
200
201 G4PVDataVector dataVector; // Vector to keep the crossection/energyloss
202 G4PVDataVector binVector; // Vector to keep energy
203 G4PVDataVector secDerivative; // Vector to keep second derivatives
204
205 private:
206
207 G4bool SplinePossible();
208
209 inline G4double LinearInterpolation();
210 // Linear interpolation function
211 inline G4double SplineInterpolation();
212 // Spline interpolation function
213
214 inline void Interpolation();
215
216 G4String comment;
217 G4bool useSpline;
218};
219
220#include "G4PhysicsVector.icc"
221
222#endif
Note: See TracBrowser for help on using the repository browser.