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

Last change on this file was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

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