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.18 2008/09/22 08:26:33 gcosmo Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-cand-01 $ |
---|
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 | // |
---|
54 | //--------------------------------------------------------------- |
---|
55 | |
---|
56 | #ifndef G4PhysicsVector_h |
---|
57 | #define G4PhysicsVector_h 1 |
---|
58 | |
---|
59 | #include <vector> |
---|
60 | #include "globals.hh" |
---|
61 | #include "G4ios.hh" |
---|
62 | #include <iostream> |
---|
63 | #include <fstream> |
---|
64 | |
---|
65 | #include "G4PhysicsVectorType.hh" |
---|
66 | |
---|
67 | class G4PhysicsVector |
---|
68 | { |
---|
69 | public: |
---|
70 | |
---|
71 | G4PhysicsVector(G4bool spline = false); |
---|
72 | // constructor |
---|
73 | // This class is an abstract class with pure virtual method of |
---|
74 | // virtual size_t FindBinLocation(G4double theEnergy) const |
---|
75 | // So, default constructor is not supposed to be invoked explicitly |
---|
76 | |
---|
77 | G4PhysicsVector(const G4PhysicsVector&); |
---|
78 | G4PhysicsVector& operator=(const G4PhysicsVector&); |
---|
79 | // Copy constructor and assignment operator. |
---|
80 | |
---|
81 | public: // with description |
---|
82 | |
---|
83 | virtual ~G4PhysicsVector(); |
---|
84 | // destructor |
---|
85 | |
---|
86 | inline G4double GetValue(G4double theEnergy, G4bool& isOutRange); |
---|
87 | // Get the cross-section/energy-loss value corresponding to the |
---|
88 | // given energy. An appropriate interpolation is used to calculate |
---|
89 | // the value. |
---|
90 | // [Note] isOutRange is not used anymore. This argument is kept |
---|
91 | // for the compatibility reason. |
---|
92 | |
---|
93 | G4int operator==(const G4PhysicsVector &right) const ; |
---|
94 | G4int operator!=(const G4PhysicsVector &right) const ; |
---|
95 | inline G4double operator[](const size_t binNumber) const ; |
---|
96 | // Returns simply the value in the bin specified by 'binNumber' |
---|
97 | // of the dataVector. The boundary check will be Done. If you |
---|
98 | // don't want this check, use the operator (). |
---|
99 | inline G4double operator()(const size_t binNumber) const ; |
---|
100 | // Returns simply the value in the bin specified by 'binNumber' |
---|
101 | // of the dataVector. The boundary check will not be Done. If |
---|
102 | // you want this check, use the operator []. |
---|
103 | |
---|
104 | inline void PutValue(size_t binNumber, G4double theValue); |
---|
105 | // Put 'theValue' into the bin specified by 'binNumber'. |
---|
106 | // Take note that the 'binNumber' starts from '0'. |
---|
107 | // To fill the vector, you have beforehand to Construct a vector |
---|
108 | // by the constructor with Emin, Emax, Nbin. 'theValue' should |
---|
109 | // be the crosssection/energyloss value corresponding to the low |
---|
110 | // edge energy of the bin specified by 'binNumber'. You can get |
---|
111 | // the low edge energy value of a bin by GetLowEdgeEnergy(). |
---|
112 | virtual G4double GetLowEdgeEnergy(size_t binNumber) const; |
---|
113 | // Get the energy value at the low edge of the specified bin. |
---|
114 | // Take note that the 'binNumber' starts from '0'. |
---|
115 | // This value is defined when a physics vector is constructed |
---|
116 | // by a constructor of a derived class. Use this function |
---|
117 | // when you fill physis vector by PutValue(). |
---|
118 | inline size_t GetVectorLength() const; |
---|
119 | // Get the toal length (bin number) of the vector. |
---|
120 | inline G4bool IsFilledVectorExist() const; |
---|
121 | // Is non-empty physics vector already exist? |
---|
122 | |
---|
123 | inline void PutComment(const G4String& theComment); |
---|
124 | // Put a comment to the G4PhysicsVector. This may help to check |
---|
125 | // whether your are accessing to the one you want. |
---|
126 | inline const G4String& GetComment() const; |
---|
127 | // Retrieve the comment of the G4PhysicsVector. |
---|
128 | |
---|
129 | inline G4PhysicsVectorType GetType() const; |
---|
130 | // Get physics vector type |
---|
131 | |
---|
132 | inline void SetSpline(G4bool); |
---|
133 | // Activate/deactivate Spline interpolation. |
---|
134 | |
---|
135 | virtual G4bool Store(std::ofstream& fOut, G4bool ascii=false); |
---|
136 | virtual G4bool Retrieve(std::ifstream& fIn, G4bool ascii=false); |
---|
137 | // To store/retrieve persistent data to/from file streams. |
---|
138 | |
---|
139 | friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&); |
---|
140 | |
---|
141 | protected: |
---|
142 | |
---|
143 | virtual size_t FindBinLocation(G4double theEnergy) const=0; |
---|
144 | // Find the bin# in which theEnergy belongs - pure virtual function |
---|
145 | |
---|
146 | void DeleteData(); |
---|
147 | void CopyData(const G4PhysicsVector& vec); |
---|
148 | // Internal methods for allowing copy of objects |
---|
149 | |
---|
150 | protected: |
---|
151 | |
---|
152 | typedef std::vector<G4double> G4PVDataVector; |
---|
153 | |
---|
154 | G4PhysicsVectorType type; // The type of PhysicsVector (enumerator) |
---|
155 | |
---|
156 | G4double edgeMin; // Lower edge value of the lowest bin |
---|
157 | G4double edgeMax; // Lower edge value of the highest bin |
---|
158 | size_t numberOfBin; |
---|
159 | |
---|
160 | G4double lastEnergy; // Cache the last input value |
---|
161 | G4double lastValue; // Cache the last output value |
---|
162 | size_t lastBin; // Cache the last bin location |
---|
163 | |
---|
164 | G4PVDataVector dataVector; // Vector to keep the crossection/energyloss |
---|
165 | G4PVDataVector binVector; // Vector to keep the low edge value of bin |
---|
166 | |
---|
167 | private: |
---|
168 | |
---|
169 | inline G4double LinearInterpolation(); |
---|
170 | // Linear interpolation function |
---|
171 | inline G4double SplineInterpolation(); |
---|
172 | // Spline interpolation function |
---|
173 | |
---|
174 | inline void Interpolation(); |
---|
175 | |
---|
176 | void FillSecondDerivatives(); |
---|
177 | // Initialise second derivatives for spline |
---|
178 | |
---|
179 | G4double* secDerivative; |
---|
180 | |
---|
181 | G4String comment; |
---|
182 | G4bool useSpline; |
---|
183 | }; |
---|
184 | |
---|
185 | #include "G4PhysicsVector.icc" |
---|
186 | |
---|
187 | #endif |
---|