|
||||
File indexing completed on 2025-01-18 09:59:25
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 // G4VModularPhysicsList 0027 // 0028 // Class description: 0029 // 0030 // This class is a subclass of G4VUserPhysicsList. 0031 // The user should register his/her physics constructors by using: 0032 // G4VModularPhysicsList::RegsiterPhysics() 0033 // to construt particles and processes. 0034 // 0035 // Only one physics constructor can be registered for each "physics_type". 0036 // Physics constructors with same "physics_type" can be replaced using the 0037 // G4VModularPhysicsList::ReplacePhysics() method. 0038 0039 // Original author: H.Kurashige (Kobe University), 12 November 2000 0040 // -------------------------------------------------------------------- 0041 #ifndef G4VModularPhysicsList_hh 0042 #define G4VModularPhysicsList_hh 1 0043 0044 #include "G4VPhysicsConstructor.hh" 0045 #include "G4VUPLSplitter.hh" 0046 #include "G4VUserPhysicsList.hh" 0047 #include "G4ios.hh" 0048 #include "globals.hh" 0049 0050 #include "rundefs.hh" 0051 0052 #include <vector> 0053 0054 class G4VMPLData 0055 { 0056 // Encapsulate the fields of class G4VModularPhysicsList 0057 // that are per-thread. 0058 0059 public: 0060 void initialize(); 0061 using G4PhysConstVectorData = std::vector<G4VPhysicsConstructor*>; 0062 // See: https://jira-geant4.kek.jp/browse/DEV-284 0063 G4PhysConstVectorData* physicsVector = nullptr; 0064 }; 0065 0066 // The type G4VMPLManager is introduced to encapsulate the methods used by 0067 // both the master thread and worker threads to allocate memory space for 0068 // the fields encapsulated by the class G4VMPLData. When each thread 0069 // changes the value for these fields, it refers to them using a macro 0070 // definition defined below. For every G4VUserPhysicsList instance, 0071 // there is a corresponding G4VMPLData instance. All G4VMPLData instances 0072 // are organized by the class G4VMPLManager as an array. 0073 // The field "int G4VMPLInstanceID" is added to the class G4VUserPhysicsList. 0074 // The value of this field in each G4VUserPhysicsList instance is the 0075 // subscript of the corresponding G44VUPLData instance. 0076 // In order to use the class G44VUPLManager, we add a static member in the class 0077 // G4VUserPhysicsList as follows: "static G4VMPLManager subInstanceManager". 0078 // Both the master thread and worker threads change the length of the array 0079 // for G44VUPLData instances mutually along with G4VUserPhysicsList 0080 // instances are created. 0081 // 0082 using G4VMPLManager = G4VUPLSplitter<G4VMPLData>; 0083 using G4VModularPhysicsListSubInstanceManager = G4VMPLManager; 0084 0085 class G4VModularPhysicsList : public virtual G4VUserPhysicsList 0086 { 0087 public: 0088 G4VModularPhysicsList(); 0089 ~G4VModularPhysicsList() override; 0090 0091 // This method will be invoked in the Construct() method. 0092 // Each particle type will be instantiated. 0093 void ConstructParticle() override; 0094 0095 // This method will be invoked in the Construct() method. 0096 // Each physics process will be instantiated and 0097 // registered to the process manager of each particle type. 0098 void ConstructProcess() override; 0099 0100 // Register Physics Constructor. 0101 void RegisterPhysics(G4VPhysicsConstructor*); 0102 0103 const G4VPhysicsConstructor* GetPhysics(G4int index) const; 0104 const G4VPhysicsConstructor* GetPhysics(const G4String& name) const; 0105 const G4VPhysicsConstructor* GetPhysicsWithType(G4int physics_type) const; 0106 0107 // Replace the Physics Constructor. 0108 // The existing physics constructor with same physics_type as one of 0109 // the given physics constructor is replaced (existing physics will be 0110 // deleted). If a corresponding physics constructor is NOT found, 0111 // the given physics constructor is just added. 0112 void ReplacePhysics(G4VPhysicsConstructor*); 0113 0114 // Remove the Physics Constructor from the list. 0115 void RemovePhysics(G4VPhysicsConstructor*); 0116 void RemovePhysics(G4int type); 0117 void RemovePhysics(const G4String& name); 0118 0119 inline G4int GetInstanceID() const; 0120 static const G4VMPLManager& GetSubInstanceManager(); 0121 void TerminateWorker() override; 0122 0123 // Set/get control flag for output message 0124 // 0: Silent 0125 // 1: Warning message 0126 // 2: More 0127 // given verbose level is set to all physics constructors. 0128 void SetVerboseLevel(G4int value); 0129 G4int GetVerboseLevel() const; 0130 0131 protected: 0132 // Protected copy constructor and assignment operator. 0133 G4VModularPhysicsList(const G4VModularPhysicsList&); 0134 G4VModularPhysicsList& operator=(const G4VModularPhysicsList&); 0135 0136 using G4PhysConstVector = G4VMPLData::G4PhysConstVectorData; 0137 0138 G4int verboseLevel = 0; 0139 G4int g4vmplInstanceID = 0; 0140 G4RUN_DLL static G4VMPLManager G4VMPLsubInstanceManager; 0141 }; 0142 0143 // Inline methods implementations 0144 0145 inline G4int G4VModularPhysicsList::GetVerboseLevel() const 0146 { 0147 return verboseLevel; 0148 } 0149 0150 inline G4int G4VModularPhysicsList::GetInstanceID() const 0151 { 0152 return g4vmplInstanceID; 0153 } 0154 0155 inline const G4VMPLManager& G4VModularPhysicsList::GetSubInstanceManager() 0156 { 0157 return G4VMPLsubInstanceManager; 0158 } 0159 0160 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |