|
||||
File indexing completed on 2025-01-18 09:59:26
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 // G4VPhysicsConstructor 0027 // 0028 // Class description: 0029 // 0030 // This class is a virtual class for constructing particles and processes. 0031 // This class objects is being registered to G4VPhysicsList. 0032 // 0033 // User must implement following four virtual methods in the concrete class 0034 // derived from this class: 0035 // 0036 // - virtual void ConstructParticle(); 0037 // All necessary particle type will be instantiated. 0038 // - virtual void ConstructProcess(); 0039 // All physics processes will be instantiated and 0040 // registered to the process manager of each particle type. 0041 // 0042 // Only one physics constructor can be registered to a Modular Physics List 0043 // for each "physics_type". Physics constructors with same "physics_type" 0044 // can be replaced by using the method: 0045 // G4VModularPhysicsList::ReplacePhysics(). 0046 0047 // Original author: H.Kurashige (Kobe University), 12 November 2000 0048 // -------------------------------------------------------------------- 0049 #ifndef G4VPhysicsConstructor_hh 0050 #define G4VPhysicsConstructor_hh 1 0051 0052 #include "G4ParticleTable.hh" 0053 #include "G4PhysicsListHelper.hh" 0054 #include "G4VUPLSplitter.hh" 0055 #include "G4ios.hh" 0056 #include "globals.hh" 0057 0058 #include "rundefs.hh" 0059 0060 #include <vector> 0061 0062 class G4PhysicsBuilderInterface; 0063 0064 class G4VPCData 0065 { 0066 // Encapsulate the fields of class G4VPhysicsConstructor 0067 // that are per-thread. 0068 0069 public: 0070 using PhysicsBuilders_V = std::vector<G4PhysicsBuilderInterface*>; 0071 void initialize(); 0072 G4ParticleTable::G4PTblDicIterator* _aParticleIterator; 0073 0074 PhysicsBuilders_V* _builders = nullptr; 0075 }; 0076 0077 // The type G4VPCManager is introduced to encapsulate the methods used by 0078 // both the master thread and worker threads to allocate memory space for 0079 // the fields encapsulated by the class G4VPCData. When each thread 0080 // changes the value for these fields, it refers to them using a macro 0081 // definition defined below. For every G4VPhysicsConstructor instance, 0082 // there is a corresponding G4VPCData instance. All G4VPCData instances 0083 // are organized by the class G4VUPLManager as an array. 0084 // The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList. 0085 // The value of this field in each G4VUserPhysicsList instance is the 0086 // subscript of the corresponding G44VUPLData instance. 0087 // In order to use the class G44VUPLManager, we add a static member in the class 0088 // G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager". 0089 // Both the master thread and worker threads change the length of the array 0090 // for G44VUPLData instances mutually along with G4VUserPhysicsList 0091 // instances are created. For each worker thread, it dynamically creates ions. 0092 // Consider any thread A, if there is any other thread which creates an ion. 0093 // This ion is shared by the thread A. So the thread A leaves an empty space 0094 // in the array of G4PDefData instances for the ion. 0095 // 0096 // Important Note: you may wonder why we are introducing this mechanism 0097 // since there is only one PL for each application. 0098 // This is true, in the sense that only one PL is allowed 0099 // to be associated to a G4RunManager, however a user can 0100 // instantiate as many PLs are needed and at run-time select 0101 // one of the PLs to be used we thus need this mechanism to 0102 // guarantee that the system works without problems in case of 0103 // this (unusual) case. This may be reviewed in the future 0104 // 0105 using G4VPCManager = G4VUPLSplitter<G4VPCData>; 0106 using G4VPhyscicsConstructorManager = G4VPCManager; 0107 0108 class G4VPhysicsConstructor 0109 { 0110 public: 0111 G4VPhysicsConstructor(const G4String& = ""); 0112 G4VPhysicsConstructor(const G4String& name, G4int physics_type); 0113 virtual ~G4VPhysicsConstructor(); 0114 0115 // This method will be invoked in the Construct() method. 0116 // Each particle type will be instantiated. 0117 virtual void ConstructParticle() = 0; 0118 0119 // This method will be invoked in the Construct() method. 0120 // Each physics process will be instantiated and 0121 // registered to the process manager of each particle type. 0122 virtual void ConstructProcess() = 0; 0123 0124 inline void SetPhysicsName(const G4String& = ""); 0125 inline const G4String& GetPhysicsName() const; 0126 0127 inline void SetPhysicsType(G4int); 0128 inline G4int GetPhysicsType() const; 0129 0130 inline G4int GetInstanceID() const; 0131 static const G4VPCManager& GetSubInstanceManager(); 0132 0133 // Method called by kernel to destroy thread-local data, equivalent to 0134 // destructor in sequential mode. Derived classes implementing this 0135 // method, must also call this base class method. 0136 virtual void TerminateWorker(); 0137 0138 // Set/get control flag for output message 0139 // 0: Silent 0140 // 1: Warning message 0141 // 2: More 0142 // verbose level is set equal to physics list when registered. 0143 inline void SetVerboseLevel(G4int value); 0144 inline G4int GetVerboseLevel() const; 0145 0146 protected: 0147 using PhysicsBuilder_V = G4VPCData::PhysicsBuilders_V; 0148 0149 // Register a process to the particle type according to the ordering 0150 // parameter table. 'true' is returned if the process is registered 0151 // successfully. 0152 inline G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle); 0153 0154 G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const; 0155 0156 // This returns a copy of the vector of pointers. 0157 PhysicsBuilder_V GetBuilders() const; 0158 0159 void AddBuilder(G4PhysicsBuilderInterface* bld); 0160 0161 protected: 0162 G4int verboseLevel = 0; 0163 G4String namePhysics = ""; 0164 G4int typePhysics = 0; 0165 0166 G4ParticleTable* theParticleTable = nullptr; 0167 G4int g4vpcInstanceID = 0; 0168 G4RUN_DLL static G4VPCManager subInstanceManager; 0169 }; 0170 0171 // Inline methods implementations 0172 0173 inline void G4VPhysicsConstructor::SetVerboseLevel(G4int value) 0174 { 0175 verboseLevel = value; 0176 } 0177 0178 inline G4int G4VPhysicsConstructor::GetVerboseLevel() const 0179 { 0180 return verboseLevel; 0181 } 0182 0183 inline void G4VPhysicsConstructor::SetPhysicsName(const G4String& name) 0184 { 0185 namePhysics = name; 0186 } 0187 0188 inline const G4String& G4VPhysicsConstructor::GetPhysicsName() const 0189 { 0190 return namePhysics; 0191 } 0192 0193 inline void G4VPhysicsConstructor::SetPhysicsType(G4int val) 0194 { 0195 if (val > 0) { 0196 typePhysics = val; 0197 } 0198 } 0199 0200 inline G4int G4VPhysicsConstructor::GetPhysicsType() const 0201 { 0202 return typePhysics; 0203 } 0204 0205 inline G4bool G4VPhysicsConstructor::RegisterProcess(G4VProcess* process, 0206 G4ParticleDefinition* particle) 0207 { 0208 return G4PhysicsListHelper::GetPhysicsListHelper()->RegisterProcess(process, particle); 0209 } 0210 0211 inline const G4VPCManager& G4VPhysicsConstructor::GetSubInstanceManager() 0212 { 0213 return subInstanceManager; 0214 } 0215 0216 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |