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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 4.1.p1)


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