Geant4 Cross Reference |
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 // Class Description: 27 // 28 // A utility static class, responsable for keeping common parameters 29 // for all transportation processes. These parameters can be relevant only 30 // to some types of particles, e.g. only stable charged particles. 31 // 32 // Constraints (creation/update): 33 // - It must initialized only by the master thread. 34 // - It should be updated before the transportation processes have been instantiated. 35 // Note: It can be updated only if the state of the simulation is PreInit, Init or Idle. 36 // 37 // Only those instances of G4Transportation (and derived classes) that are created 38 // *after* G4TransportationParameters will be aware of it and will copy 39 // the values of its parameters. 40 // (So in a multithreaded application, runs that start after this is created will obtain them.) 41 // 42 // Use: Parameters may be used in run time or at initialisation 43 // 44 // Meaning of parameters: 45 // - Warning energy: below this, looping tracks can be killed without any message 46 // - Important energy: between warning E and this, looping tracks will complain and die 47 // - Number of Trials: above 'important energy' looping tracks get this number of chances. 48 49 // Author: J. Apostolakis Nov 2022 50 // Inspired by G4EmParameters by V. Ivanchenko 51 // ------------------------------------------------------------------- 52 // 53 54 #ifndef G4TransportationParameters_hh 55 #define G4TransportationParameters_hh 56 57 #include "globals.hh" 58 59 class G4TransportationParameters 60 { 61 public: 62 static G4TransportationParameters* Instance(); 63 64 ~G4TransportationParameters() = default; 65 66 G4bool SetNumberOfTrials( G4int val ); 67 68 // All three methods below enforce the relation WarningE <= ImportantE 69 G4bool SetWarningEnergy( G4double val ); 70 G4bool SetImportantEnergy( G4double val ); 71 // If the relation fails, the methods above warn and use the new value for both. 72 G4bool SetWarningAndImportantEnergies( G4double warnE, G4double imprtE ); 73 // If the relation does *not* hold, it warns and 74 // uses the smaller as the 'warning Energy' 75 // and the larger as the 'important energy' 76 77 G4int GetNumberOfTrials() const { return fNumberOfTrials; } 78 G4double GetWarningEnergy() const { return fWarningEnergy; } 79 G4double GetImportantEnergy() const { return fImportantEnergy; } 80 G4bool IsMagneticMomentEnabled() const { return fUseMagneticMoment; } 81 82 G4bool EnableUseOfMagneticMoment(G4bool useMoment=true); 83 // Whether to deflect particles with force due to magnetic moment 84 85 G4bool SetHighLooperThresholds(); // Shortcut method - old values (meant for HEP) 86 G4bool SetIntermediateLooperThresholds(); // Intermediate values - also used as default 87 G4bool SetLowLooperThresholds(); // Set low thresholds - for low-E applications 88 G4bool SetSilenceAllLooperWarnings(G4bool val=true); 89 // return value = success or failure of setting the parameter 90 91 G4bool GetSilenceAllLooperWarnings(){ return fSilenceLooperWarnings; } 92 93 void ReportLockError(G4String methodName, G4bool verbose= false) const; 94 // Report error - in case the state of G4 is incorrect, and update methods fail 95 96 // Probe whether the 'default' instance exists, without creating it 97 static G4bool Exists() { return theInstance != nullptr; } 98 99 // printing 100 void StreamInfo(std::ostream& os) const; 101 void Dump() const; 102 friend std::ostream& operator<< (std::ostream& os, const G4TransportationParameters&); 103 104 private: 105 G4TransportationParameters(); 106 // Currently private - but potentially will open it up, to allow per-particle specialisation 107 108 // void Initialise(); 109 110 G4bool IsLocked() const; 111 112 void PrintWarning(G4ExceptionDescription& ed) const; 113 114 private: 115 static G4TransportationParameters* theInstance; 116 117 // STATE 118 // Values for initialising 'loopers' parameters of Transport process 119 G4double fWarningEnergy = -1.0; // Warn above this energy 120 G4double fImportantEnergy = -1.0; // Give a few trials above this E 121 G4int fNumberOfTrials = 10; // Number of trials an important looper survives 122 123 // Flags for use of gravity field(s) or fields which interact with the magnetic moment 124 G4bool fUseMagneticMoment = false; 125 G4bool fUseGravity = false; 126 127 // Flag to *Supress* all 'looper' warnings 128 G4bool fSilenceLooperWarnings= false; 129 }; 130 131 #endif 132