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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /global/management/include/G4PhysicsVector.hh (Version 11.3.0) and /global/management/include/G4PhysicsVector.hh (Version 9.4.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4PhysicsVector                             << 
 27 //                                                 26 //
 28 // Class description:                          <<  27 // $Id: G4PhysicsVector.hh,v 1.31 2010-05-28 05:13:43 kurasige Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-09-04-patch-02 $
 29 //                                                 29 //
 30 // A physics vector which has values of energy <<  30 // 
 31 // and other physics values of a particle in m <<  31 //---------------------------------------------------------------
 32 // range of energy, momentum, etc.             <<  32 //      GEANT 4 class header file
 33 // This class serves as the base class for a v <<  33 //
 34 // energy scale, for example like 'log', 'line <<  34 //  G4PhysicsVector.hh
 35                                                <<  35 //
 36 // Authors:                                    <<  36 //  Class description:
 37 // - 02 Dec. 1995, G.Cosmo: Structure created  <<  37 //
 38 // - 03 Mar. 1996, K.Amako: Implemented the 1s <<  38 //    A physics vector which has values of energy-loss, cross-section, 
 39 // Revisions:                                  <<  39 //    and other physics values of a particle in matter in a given 
 40 // - 11 Nov. 2000, H.Kurashige: Use STL vector <<  40 //    range of the energy, momentum, etc.
 41 // ------------------------------------------- <<  41 //    This class serves as the base class for a vector having various 
 42 #ifndef G4PhysicsVector_hh                     <<  42 //    energy scale, for example like 'log', 'linear', 'free', etc.
 43 #define G4PhysicsVector_hh 1                   <<  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 //    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
                                                   >>  58 //---------------------------------------------------------------
                                                   >>  59 
                                                   >>  60 #ifndef G4PhysicsVector_h
                                                   >>  61 #define G4PhysicsVector_h 1
 44                                                    62 
 45 #include <fstream>                             << 
 46 #include <iostream>                            << 
 47 #include <vector>                                  63 #include <vector>
                                                   >>  64 #include "globals.hh"
                                                   >>  65 #include "G4ios.hh"
                                                   >>  66 #include <iostream>
                                                   >>  67 #include <fstream>
 48                                                    68 
 49 #include "G4Log.hh"                            <<  69 #include "G4PhysicsVectorCache.hh"
 50 #include "G4PhysicsVectorType.hh"                  70 #include "G4PhysicsVectorType.hh"
 51 #include "G4ios.hh"                            << 
 52 #include "globals.hh"                          << 
 53                                                    71 
 54 class G4PhysicsVector                          <<  72 typedef std::vector<G4double> G4PVDataVector;
                                                   >>  73 
                                                   >>  74 class G4PhysicsVector 
 55 {                                                  75 {
 56 public:                                        <<  76   public:  
 57   // Default constructor - vector will be fill <<  77 
 58   // Free vector may be filled via InsertValue <<  78     G4PhysicsVector(G4bool spline = false);
 59   explicit G4PhysicsVector(G4bool spline = fal <<  79          // constructor  
 60                                                <<  80          // This class is an abstract class with pure virtual method of
 61   // Copy constructor and assignment operator  <<  81          // virtual size_t FindBinLocation(G4double theEnergy) const
 62   G4PhysicsVector(const G4PhysicsVector&) = de <<  82          // So, default constructor is not supposed to be invoked explicitly
 63   G4PhysicsVector& operator=(const G4PhysicsVe <<  83 
 64                                                <<  84     G4PhysicsVector(const G4PhysicsVector&);
 65   // not used operators                        <<  85     G4PhysicsVector& operator=(const G4PhysicsVector&);
 66   G4PhysicsVector(const G4PhysicsVector&&) = d <<  86          // Copy constructor and assignment operator.
 67   G4PhysicsVector& operator=(const G4PhysicsVe <<  87 
 68   G4bool operator==(const G4PhysicsVector& rig <<  88   public:  // with description
 69   G4bool operator!=(const G4PhysicsVector& rig <<  89 
 70                                                <<  90     virtual ~G4PhysicsVector();
 71   virtual ~G4PhysicsVector() = default;        <<  91          // destructor
 72                                                <<  92 
 73   // Get the cross-section/energy-loss value c <<  93     G4double Value(G4double theEnergy);
 74   // given energy. An appropriate interpolatio <<  94          // Get the cross-section/energy-loss value corresponding to the
 75   // the value. Consumer code gets changed ind <<  95          // given energy. An appropriate interpolation is used to calculate
 76   // for the next call to save CPU for bin loc <<  96          // the value. 
 77   inline G4double Value(const G4double energy, <<  97 
 78                                                <<  98     inline G4double GetValue(G4double theEnergy, G4bool& isOutRange);
 79   // Get the cross-section/energy-loss value c <<  99          // Obolete method to get value, isOutRange is not used anymore. 
 80   // given energy. An appropriate interpolatio << 100          // This method is kept for the compatibility reason.
 81   // the value. This method should be used if  << 101 
 82   // kept in the user code.                    << 102     G4int operator==(const G4PhysicsVector &right) const ;
 83   inline G4double Value(const G4double energy) << 103     G4int operator!=(const G4PhysicsVector &right) const ;
 84                                                << 104 
 85   // Obsolete method to get value, 'isOutRange << 105     inline G4double operator[](const size_t binNumber) const ;
 86   // This method is kept for the compatibility << 106          // Returns simply the value in the bin specified by 'binNumber'
 87   inline G4double GetValue(const G4double ener << 107          // of the dataVector. The boundary check will not be done. 
 88                                                << 108 
 89   // Same as the Value() method above but spec << 109     inline G4double operator()(const size_t binNumber) const ;
 90   // Note, unlike the general Value() method a << 110          // Returns simply the value in the bin specified by 'binNumber'
 91   // properly only for G4PhysicsLogVector.     << 111          // of the dataVector. The boundary check will not be Done. 
 92   inline G4double LogVectorValue(const G4doubl << 112 
 93                                  const G4doubl << 113     inline void PutValue(size_t index, G4double theValue);
 94                                                << 114          // Put 'theValue' into the bin specified by 'binNumber'.
 95   // Same as the Value() method above but spec << 115          // Take note that the 'index' starts from '0'.
 96   // with logarithmic seach of bin number      << 116          // To fill the vector, you have beforehand to construct a vector
 97   inline G4double LogFreeVectorValue(const G4d << 117          // by the constructor with Emin, Emax, Nbin. 'theValue' should
 98                                      const G4d << 118          // be the crosssection/energyloss value corresponding to the  
 99                                                << 119          // energy of the index. You can get this energy by the next method
100   // Returns the value for the specified index << 120          // or by the old method GetLowEdgeEnergy().
101   // The boundary check will not be done       << 121 
102   inline G4double operator[](const std::size_t << 122     void ScaleVector(G4double factorE, G4double factorV);
103   inline G4double operator()(const std::size_t << 123          // Scale all values of the vector and second derivatives
104                                                << 124          // by factorV, energies by vectorE. This method may be applied 
105   // Put data into the vector at 'index' posit << 125          // for example after Retrieve a vector from an external file to 
106   // Take note that the 'index' starts from '0 << 126          // convert values into Geant4 units
107   // It is assumed that energies are already f << 127 
108   inline void PutValue(const std::size_t index << 128     inline G4double Energy(size_t index) const;
109                                                << 129          // Returns simply the value in the energy specified by 'index'
110   // Returns the value in the energy specified << 130          // of the energy vector. The boundary check will not be done. 
111   // of the energy vector. The boundary check  << 131          // Use this function when you fill physis vector by PutValue().
112   // Use this when compute cross-section, dEdx << 132 
113   // before filling the vector by PutValue().  << 133     virtual G4double GetLowEdgeEnergy(size_t binNumber) const;
114   inline G4double Energy(const std::size_t ind << 134          // Obsolete method
115   inline G4double GetLowEdgeEnergy(const std:: << 135          // Get the energy value at the low edge of the specified bin.
116                                                << 136          // Take note that the 'binNumber' starts from '0'.
117   // Returns the energy of the first and the l << 137          // This value should be defined before the call.
118   inline G4double GetMinEnergy() const;        << 138          // The boundary check will not be done.
119   inline G4double GetMaxEnergy() const;        << 139 
120                                                << 140     inline size_t GetVectorLength() const;
121   // Returns the data of the first and the las << 141          // Get the toal length (bin number) of the vector. 
122   // If the vector is empty returns zeros.     << 142 
123   inline G4double GetMinValue() const;         << 143     void FillSecondDerivatives();
124   inline G4double GetMaxValue() const;         << 144         // Initialise second derivatives for spline keeping 
125                                                << 145         // 3d derivative continues - default algorithm
126   // Get the total length of the vector        << 146 
127   inline std::size_t GetVectorLength() const;  << 147     void ComputeSecDerivatives();
128                                                << 148          // Initialise second derivatives for spline using algorithm 
129   // Computes the lower index the energy bin i << 149          // which garantee only 1st derivative continues 
130   // in case of vectors with equal bin widths  << 150          // Warning: this method should be called when the vector 
131   // Note, that no check on the boundary is pe << 151          // is already filled
132   inline std::size_t ComputeLogVectorBin(const << 152 
133                                                << 153     void ComputeSecondDerivatives(G4double firstPointDerivative, 
134   // Get physics vector type.                  << 154                                   G4double endPointDerivative);
135   inline G4PhysicsVectorType GetType() const;  << 155          // Initialise second derivatives for spline using 
136                                                << 156          // user defined 1st derivatives at edge points
137   // True if using spline interpolation.       << 157          // Warning: this method should be called when the vector 
138   inline G4bool GetSpline() const;             << 158          // is already filled
139                                                << 159 
140   // Define verbosity level.                   << 160     inline G4bool IsFilledVectorExist() const;
141   inline void SetVerboseLevel(G4int value);    << 161          // Is non-empty physics vector already exist?
142                                                << 162 
143   // Find energy using linear interpolation fo << 163     inline void PutComment(const G4String& theComment);
144   // filled by cumulative probability function << 164          // Put a comment to the G4PhysicsVector. This may help to check
145   // Assuming that vector is already filled.   << 165          // whether your are accessing to the one you want. 
146   inline G4double FindLinearEnergy(const G4dou << 166 
147                                                << 167     inline const G4String& GetComment() const;
148   // Find low edge index of a bin for given en << 168          // Retrieve the comment of the G4PhysicsVector.
149   // Min value 0, max value idxmax.            << 169 
150   std::size_t FindBin(const G4double energy, s << 170     inline G4PhysicsVectorType GetType() const;
151                                                << 171          // Get physics vector type
152   // Scale all values of the vector by factorV << 172   
153   // AFter this method FillSecondDerivatives(. << 173     inline void SetSpline(G4bool);
154   // This method may be applied for example af << 174          // Activate/deactivate Spline interpolation.
155   // from an external file to convert values i << 175 
156   void ScaleVector(const G4double factorE, con << 176     virtual G4bool Store(std::ofstream& fOut, G4bool ascii=false);
157                                                << 177     virtual G4bool Retrieve(std::ifstream& fIn, G4bool ascii=false);
158   // This method should be called when the vec << 178          // To store/retrieve persistent data to/from file streams.
159   // There are 3 types of second derivative co << 179 
160   //    fSplineSimple -     2d derivative cont << 180     friend std::ostream& operator<<(std::ostream&, const G4PhysicsVector&);
161   //    fSplineBase -       3d derivative cont << 181 
162   //    fSplineFixedEdges - 3d derivatives con << 182     
163   //                        derivatives are fi << 183     G4double GetLastEnergy() const;
164   void FillSecondDerivatives(const G4SplineTyp << 184     G4double GetLastValue() const;
165                              const G4double di << 185     size_t GetLastBin() const;
166                              const G4double di << 186          // Get cache values 
167                                                << 187 
168   // This method can be applied if both energy << 188   protected:
169   // grow monotonically, for example, if in th << 189 
170   // cumulative probability density function i << 190     virtual size_t FindBinLocation(G4double theEnergy) const=0;
171   G4double GetEnergy(const G4double value) con << 191          // Find the bin# in which theEnergy belongs - pure virtual function
172                                                << 192 
173   // To store/retrieve persistent data to/from << 193     void DeleteData();
174   G4bool Store(std::ofstream& fOut, G4bool asc << 194     void CopyData(const G4PhysicsVector& vec);
175   G4bool Retrieve(std::ifstream& fIn, G4bool a << 195          // Internal methods for allowing copy of objects
176                                                << 196 
177   // Print vector                              << 197   protected:
178   friend std::ostream& operator<<(std::ostream << 198 
179   void DumpValues(G4double unitE = 1.0, G4doub << 199     G4PhysicsVectorType type;   // The type of PhysicsVector (enumerator)
180                                                << 200 
181 protected:                                     << 201     G4double edgeMin;           // Energy of first point
182                                                << 202     G4double edgeMax;           // Energy of the last point
183   // The default implements a free vector init << 203 
184   virtual void Initialise();                   << 204     size_t numberOfNodes;
185                                                << 205 
186   void PrintPutValueError(std::size_t index, G << 206     G4PhysicsVectorCache*  cache;
187                           const G4String& text << 207 
188                                                << 208     G4PVDataVector  dataVector;    // Vector to keep the crossection/energyloss
189 private:                                       << 209     G4PVDataVector  binVector;     // Vector to keep energy
190                                                << 210     G4PVDataVector  secDerivative; // Vector to keep second derivatives 
191   void ComputeSecDerivative0();                << 211 
192   void ComputeSecDerivative1();                << 212   private:
193   void ComputeSecDerivative2(const G4double fi << 213 
194                              const G4double en << 214     G4bool SplinePossible();
195   // Internal methods for computing of spline  << 215 
196                                                << 216     inline G4double LinearInterpolation(G4int lastBin);
197   // Linear or spline interpolation.           << 217          // Linear interpolation function
198   inline G4double Interpolation(const std::siz << 218     inline G4double SplineInterpolation(G4int lastBin);
199                                 const G4double << 219          // Spline interpolation function
200                                                << 
201   // Assuming (edgeMin <= energy <= edgeMax).  << 
202   inline std::size_t LogBin(const G4double ene << 
203   inline std::size_t BinaryBin(const G4double  << 
204   inline std::size_t GetBin(const G4double ene << 
205                                                << 
206 protected:                                     << 
207                                                << 
208   G4double edgeMin = 0.0;  // Energy of first  << 
209   G4double edgeMax = 0.0;  // Energy of the la << 
210                                                << 
211   G4double invdBin = 0.0;  // 1/Bin width for  << 
212   G4double logemin = 0.0;  // used only for lo << 
213                                                << 
214   G4double iBin1 = 0.0;  // 1/Bin width for sc << 
215   G4double lmin1 = 0.0;  // used for log searc << 
216                                                << 
217   G4int verboseLevel = 0;                      << 
218   std::size_t idxmax = 0;                      << 
219   std::size_t imax1 = 0;                       << 
220   std::size_t numberOfNodes = 0;               << 
221   std::size_t nLogNodes = 0;                   << 
222                                                << 
223   G4PhysicsVectorType type = T_G4PhysicsFreeVe << 
224   // The type of PhysicsVector (enumerator)    << 
225                                                << 
226   std::vector<G4double> binVector;      // ene << 
227   std::vector<G4double> dataVector;     // cro << 
228   std::vector<G4double> secDerivative;  // sec << 
229   std::vector<std::size_t> scale;       // log << 
230                                                   220 
231 private:                                       << 221     inline void Interpolation(G4int lastBin);
232                                                   222 
233   G4bool useSpline = false;                    << 223     G4String   comment;
                                                   >> 224     G4bool     useSpline;
234 };                                                225 };
235                                                   226 
236 #include "G4PhysicsVector.icc"                    227 #include "G4PhysicsVector.icc"
237                                                   228 
238 #endif                                            229 #endif
239                                                   230