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
G4Physics2DVector.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// GEANT4 tag $Name: not supported by cvs2svn $
29//
30//
31//---------------------------------------------------------------
32// GEANT 4 class header file
33//
34// G4Physics2DVector.hh
35//
36// Class description:
37//
38// A 2-dimentional vector with linear interpolation.
39
40// Author: Vladimir Ivanchenko
41//
42// Creation date: 25.09.2011
43//---------------------------------------------------------------
44
45#ifndef G4Physics2DVector_h
46#define G4Physics2DVector_h 1
47
48#include "globals.hh"
49#include "G4ios.hh"
50
51#include <iostream>
52#include <fstream>
53#include <vector>
54
57
58typedef std::vector<G4double> G4PV2DDataVector;
59
61{
62public: // with description
63
65 G4Physics2DVector(size_t nx, size_t ny);
66 // constructors
67
70 // Copy constructor and assignment operator.
71
73 // destructor
74
76 // Main method to interpolate 2D vector
77
78 inline void PutX(size_t idx, G4double value);
79 inline void PutY(size_t idy, G4double value);
80 inline void PutValue(size_t idx, size_t idy, G4double value);
81 void PutVectors(const std::vector<G4double>& vecX,
82 const std::vector<G4double>& vecY);
83 // Methods to fill vector
84 // Take note that the 'index' starts from '0'.
85
86 void ScaleVector(G4double factor);
87 // Scale all values of the vector by factor,
88 // This method may be applied
89 // for example after Retrieve a vector from an external file to
90 // convert values into Geant4 units
91
92 inline G4double GetX(size_t index) const;
93 inline G4double GetY(size_t index) const;
94 inline G4double GetValue(size_t idx, size_t idy) const;
95 // Returns simply the values of the vector by index
96 // of the energy vector. The boundary check will not be done.
97
98 inline size_t GetLengthX() const;
99 inline size_t GetLengthY() const;
100 // Get the lengths of the vector.
101
103 // Get physics vector type
104
106 // Activate/deactivate bicubic interpolation.
107
108 void Store(std::ofstream& fOut);
109 G4bool Retrieve(std::ifstream& fIn);
110 // To store/retrieve persistent data to/from file streams.
111
112 inline G4double GetLastX() const;
113 inline G4double GetLastY() const;
114 inline G4double GetLastValue() const;
115 inline size_t GetLastBinX() const;
116 inline size_t GetLastBinY() const;
117 // Get cache values
118
119 inline void SetVerboseLevel(G4int value);
120 inline G4int GetVerboseLevel() const;
121 // Set/Get Verbose level
122
123protected:
124
125 void PrepareVectors();
126
127 void ClearVectors();
128
129 void CopyData(const G4Physics2DVector& vec);
130
131 void ComputeValue(G4double x, G4double y);
132 // Main method to interpolate 2D vector
133 // by default by linear interpolation
134
135 void BicubicInterpolation(size_t idx, size_t idy);
136 // Bicubic interpolation of 2D vector
137
138 size_t FindBinLocation(G4double z, const G4PV2DDataVector&);
139 // Main method to local bin
140
141 inline void FindBin(G4double z, const G4PV2DDataVector&,
142 size_t& lastidx);
145 // Find the bin# in which theEnergy belongs
146 // Starting from 0
147
148private:
149
150 inline G4double DerivativeX(size_t idx, size_t idy, G4double fac);
151 inline G4double DerivativeY(size_t idx, size_t idy, G4double fac);
152 inline G4double DerivativeXY(size_t idx, size_t idy, G4double fac);
153 // computation of derivatives
154
155 G4int operator==(const G4Physics2DVector &right) const ;
156 G4int operator!=(const G4Physics2DVector &right) const ;
157
158 G4PhysicsVectorType type; // The type of PhysicsVector (enumerator)
159
160 size_t numberOfXNodes;
161 size_t numberOfYNodes;
162
164
165 G4PV2DDataVector xVector;
166 G4PV2DDataVector yVector;
167 std::vector<G4PV2DDataVector*> value;
168
169 G4int verboseLevel;
170 G4bool useBicubic;
171};
172
173#include "G4Physics2DVector.icc"
174
175#endif
std::vector< G4double > G4PV2DDataVector
G4PhysicsVectorType
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4double GetX(size_t index) const
G4bool Retrieve(std::ifstream &fIn)
void FindBinLocationY(G4double y)
G4Physics2DVector & operator=(const G4Physics2DVector &)
void FindBin(G4double z, const G4PV2DDataVector &, size_t &lastidx)
void BicubicInterpolation(size_t idx, size_t idy)
void CopyData(const G4Physics2DVector &vec)
G4double GetY(size_t index) const
G4double GetLastX() const
void PutX(size_t idx, G4double value)
void PutVectors(const std::vector< G4double > &vecX, const std::vector< G4double > &vecY)
G4double Value(G4double x, G4double y)
size_t GetLengthX() const
void SetVerboseLevel(G4int value)
void PutY(size_t idy, G4double value)
size_t GetLastBinX() const
G4PhysicsVectorType GetType() const
G4double GetValue(size_t idx, size_t idy) const
G4double GetLastY() const
size_t FindBinLocation(G4double z, const G4PV2DDataVector &)
size_t GetLastBinY() const
void FindBinLocationX(G4double x)
G4int GetVerboseLevel() const
G4double GetLastValue() const
void Store(std::ofstream &fOut)
size_t GetLengthY() const
void ScaleVector(G4double factor)
void SetBicubicInterpolation(G4bool)
void PutValue(size_t idx, size_t idy, G4double value)
void ComputeValue(G4double x, G4double y)