|
||||
File indexing completed on 2025-01-18 09:59:20
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4VelocityTable 0027 // 0028 // Class description: 0029 // 0030 // This class keeps a table of velocity as a function of the ratio 0031 // kinetic erngy and mass. G4VelocityTable is used by 0032 // G4Track::CalculateVelocity(). 0033 0034 // Author: Hisaya Kurashige, 17 August 2011 0035 // -------------------------------------------------------------------- 0036 #ifndef G4VelocityTable_hh 0037 #define G4VelocityTable_hh 1 0038 0039 #include <vector> 0040 #include <iostream> 0041 0042 #include "globals.hh" 0043 #include "G4ios.hh" 0044 #include "G4ThreadLocalSingleton.hh" 0045 0046 class G4VelocityTable 0047 { 0048 friend class G4ThreadLocalSingleton<G4VelocityTable>; 0049 0050 using G4VTDataVector = std::vector<G4double>; 0051 0052 public: 0053 0054 G4double Value(G4double theEnergy); 0055 // Get the cross-section/energy-loss value corresponding to the 0056 // given energy. An appropriate interpolation is used to calculate 0057 // the value 0058 0059 static G4VelocityTable* GetVelocityTable(); 0060 0061 static void SetVelocityTableProperties(G4double t_max, G4double t_min, 0062 G4int nbin); 0063 static G4double GetMaxTOfVelocityTable(); 0064 static G4double GetMinTOfVelocityTable(); 0065 static G4int GetNbinOfVelocityTable(); 0066 0067 private: 0068 0069 G4VelocityTable(); 0070 ~G4VelocityTable(); 0071 0072 void PrepareVelocityTable(); 0073 0074 std::size_t FindBinLocation(G4double theEnergy) const; 0075 // Find the bin# in which theEnergy belongs - pure virtual function 0076 0077 inline G4double Interpolation() const; 0078 0079 // -------------------------------------------------------------------- 0080 0081 G4double edgeMin = 0.0; // Energy of first point 0082 G4double edgeMax = 0.0; // Energy of the last point 0083 0084 std::size_t numberOfNodes = 0; 0085 0086 G4VTDataVector dataVector; // Vector to keep the crossection/energyloss 0087 G4VTDataVector binVector; // Vector to keep energy 0088 G4VTDataVector secDerivative; // Vector to keep second derivatives 0089 0090 G4double dBin = 0.0; // Bin width - useful only for fixed binning 0091 G4double baseBin = 0.0; // Set this in constructor for performance 0092 0093 G4double lastEnergy = -DBL_MAX; // Cache the last input value 0094 G4double lastValue = 0.0; // Cache the last output value 0095 std::size_t lastBin = 0; // Cache the last bin location 0096 0097 static G4ThreadLocal G4VelocityTable* theInstance; 0098 0099 G4double maxT = 1000.0; 0100 G4double minT = 0.0001; 0101 G4int NbinT = 500; 0102 }; 0103 0104 // ---------------------- 0105 // Inline methods 0106 // ---------------------- 0107 0108 inline G4double G4VelocityTable::Interpolation() const 0109 { 0110 // Linear interpolation is used to get the value. If the give energy 0111 // is in the highest bin, no interpolation will be Done. Because 0112 // there is an extra bin hidden from a user at locBin=numberOfBin, 0113 // the following interpolation is valid even the current locBin= 0114 // numberOfBin-1. 0115 0116 G4double intplFactor = 0117 (lastEnergy - binVector[lastBin]) / 0118 (binVector[lastBin + 1] - binVector[lastBin]); // Interpol. factor 0119 0120 return dataVector[lastBin] + 0121 (dataVector[lastBin + 1] - dataVector[lastBin]) * intplFactor; 0122 } 0123 0124 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |