|
|
|||
File indexing completed on 2026-07-22 09:16:33
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 // G4CachedMagneticField 0027 // 0028 // Class description: 0029 // 0030 // Caches Magnetic Field value, for field whose evaluation is expensive. 0031 0032 // Author: John Apostolakis (CERN), 20.07.2009. 0033 // -------------------------------------------------------------------- 0034 #ifndef G4CACHED_MAGNETIC_FIELD_HH 0035 #define G4CACHED_MAGNETIC_FIELD_HH 0036 0037 #include "G4Types.hh" 0038 #include "G4ThreeVector.hh" 0039 #include "G4MagneticField.hh" 0040 0041 /** 0042 * @brief G4CachedMagneticField is a specialisation of G4MagneticField and 0043 * is used to cache the Magnetic Field value, for fields whose evaluation is 0044 * expensive. 0045 */ 0046 0047 class G4CachedMagneticField : public G4MagneticField 0048 { 0049 public: 0050 0051 /** 0052 * Constructor for G4CachedMagneticField. 0053 * @param[in] pMagField Pointer to the original magnetic field. 0054 * @param[in] distance Distance for field evaluation, within 0055 * which the field does not change. 0056 */ 0057 G4CachedMagneticField(G4MagneticField* pMagField, G4double distance); 0058 0059 /** 0060 * Default Destructor. 0061 */ 0062 ~G4CachedMagneticField() override = default; 0063 0064 /** 0065 * Copy constructor and assignment operator. 0066 */ 0067 G4CachedMagneticField(const G4CachedMagneticField& r); 0068 G4CachedMagneticField& operator = (const G4CachedMagneticField& p); 0069 0070 /** 0071 * Returns the value of the field at the give 'Point'. 0072 * @param[in] Point The given position time vector (x,y,z,t). 0073 * @param[out] Bfield The returned field array. 0074 */ 0075 void GetFieldValue( const G4double Point[4], 0076 G4double* Bfield ) const override; 0077 0078 /** 0079 * Getter and setter for the distance within which field is constant. 0080 */ 0081 inline G4double GetConstDistance() const { return fDistanceConst; } 0082 inline void SetConstDistance( G4double dist ) { fDistanceConst = dist;} 0083 0084 /** 0085 * Accessors. 0086 */ 0087 inline G4int GetCountCalls() const { return fCountCalls; } 0088 inline G4int GetCountEvaluations() const { return fCountEvaluations; } 0089 0090 /** 0091 * Resets counters. 0092 */ 0093 inline void ClearCounts() { fCountCalls = 0; fCountEvaluations=0; } 0094 0095 /** 0096 * Streams on standard output the values of counters. 0097 */ 0098 void ReportStatistics(); 0099 0100 /** 0101 * Returns a pointer of an allocated clone of the field. 0102 */ 0103 G4Field* Clone() const override; 0104 0105 protected: 0106 0107 mutable G4int fCountCalls = 0, fCountEvaluations = 0; 0108 0109 private: 0110 0111 G4MagneticField* fpMagneticField = nullptr; 0112 0113 /** When the field is evaluated within this distance it will not change. */ 0114 G4double fDistanceConst; 0115 0116 /** Caching state. */ 0117 mutable G4ThreeVector fLastLocation; 0118 mutable G4ThreeVector fLastValue; 0119 }; 0120 0121 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|