Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VPhysicsConstructor.hh
Go to the documentation of this file.
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// G4VPhysicsConstructor
27//
28// Class description:
29//
30// This class is a virtual class for constructing particles and processes.
31// This class objects is being registered to G4VPhysicsList.
32//
33// User must implement following four virtual methods in the concrete class
34// derived from this class:
35//
36// - virtual void ConstructParticle();
37// All necessary particle type will be instantiated.
38// - virtual void ConstructProcess();
39// All physics processes will be instantiated and
40// registered to the process manager of each particle type.
41//
42// Only one physics constructor can be registered to a Modular Physics List
43// for each "physics_type". Physics constructors with same "physics_type"
44// can be replaced by using the method:
45// G4VModularPhysicsList::ReplacePhysics().
46
47// Original author: H.Kurashige (Kobe University), 12 November 2000
48// --------------------------------------------------------------------
49#ifndef G4VPhysicsConstructor_hh
50#define G4VPhysicsConstructor_hh 1
51
52#include "G4ParticleTable.hh"
54#include "G4VUPLSplitter.hh"
55#include "G4ios.hh"
56#include "globals.hh"
57
58#include "rundefs.hh"
59
60#include <vector>
61
63
65{
66 // Encapsulate the fields of class G4VPhysicsConstructor
67 // that are per-thread.
68
69 public:
70 using PhysicsBuilders_V = std::vector<G4PhysicsBuilderInterface*>;
71 void initialize();
73
75};
76
77// The type G4VPCManager is introduced to encapsulate the methods used by
78// both the master thread and worker threads to allocate memory space for
79// the fields encapsulated by the class G4VPCData. When each thread
80// changes the value for these fields, it refers to them using a macro
81// definition defined below. For every G4VPhysicsConstructor instance,
82// there is a corresponding G4VPCData instance. All G4VPCData instances
83// are organized by the class G4VUPLManager as an array.
84// The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList.
85// The value of this field in each G4VUserPhysicsList instance is the
86// subscript of the corresponding G44VUPLData instance.
87// In order to use the class G44VUPLManager, we add a static member in the class
88// G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager".
89// Both the master thread and worker threads change the length of the array
90// for G44VUPLData instances mutually along with G4VUserPhysicsList
91// instances are created. For each worker thread, it dynamically creates ions.
92// Consider any thread A, if there is any other thread which creates an ion.
93// This ion is shared by the thread A. So the thread A leaves an empty space
94// in the array of G4PDefData instances for the ion.
95//
96// Important Note: you may wonder why we are introducing this mechanism
97// since there is only one PL for each application.
98// This is true, in the sense that only one PL is allowed
99// to be associated to a G4RunManager, however a user can
100// instantiate as many PLs are needed and at run-time select
101// one of the PLs to be used we thus need this mechanism to
102// guarantee that the system works without problems in case of
103// this (unusual) case. This may be reviewed in the future
104//
107
109{
110 public:
111 G4VPhysicsConstructor(const G4String& = "");
112 G4VPhysicsConstructor(const G4String& name, G4int physics_type);
113 virtual ~G4VPhysicsConstructor();
114
115 // This method will be invoked in the Construct() method.
116 // Each particle type will be instantiated.
117 virtual void ConstructParticle() = 0;
118
119 // This method will be invoked in the Construct() method.
120 // Each physics process will be instantiated and
121 // registered to the process manager of each particle type.
122 virtual void ConstructProcess() = 0;
123
124 inline void SetPhysicsName(const G4String& = "");
125 inline const G4String& GetPhysicsName() const;
126
127 inline void SetPhysicsType(G4int);
128 inline G4int GetPhysicsType() const;
129
130 inline G4int GetInstanceID() const;
131 static const G4VPCManager& GetSubInstanceManager();
132
133 // Method called by kernel to destroy thread-local data, equivalent to
134 // destructor in sequential mode. Derived classes implementing this
135 // method, must also call this base class method.
136 virtual void TerminateWorker();
137
138 // Set/get control flag for output message
139 // 0: Silent
140 // 1: Warning message
141 // 2: More
142 // verbose level is set equal to physics list when registered.
143 inline void SetVerboseLevel(G4int value);
144 inline G4int GetVerboseLevel() const;
145
146 protected:
148
149 // Register a process to the particle type according to the ordering
150 // parameter table. 'true' is returned if the process is registered
151 // successfully.
152 inline G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle);
153
155
156 // This returns a copy of the vector of pointers.
158
160
161 protected:
165
169};
170
171// Inline methods implementations
172
174{
175 verboseLevel = value;
176}
177
179{
180 return verboseLevel;
181}
182
184{
185 namePhysics = name;
186}
187
189{
190 return namePhysics;
191}
192
194{
195 if (val > 0) {
196 typePhysics = val;
197 }
198}
199
201{
202 return typePhysics;
203}
204
210
215
216#endif
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4VUPLSplitter< G4VPCData > G4VPCManager
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
static G4PhysicsListHelper * GetPhysicsListHelper()
std::vector< G4PhysicsBuilderInterface * > PhysicsBuilders_V
PhysicsBuilders_V * _builders
G4ParticleTable::G4PTblDicIterator * _aParticleIterator
virtual void ConstructParticle()=0
G4VPhysicsConstructor(const G4String &="")
static const G4VPCManager & GetSubInstanceManager()
void AddBuilder(G4PhysicsBuilderInterface *bld)
static G4RUN_DLL G4VPCManager subInstanceManager
virtual void ConstructProcess()=0
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
G4int GetInstanceID() const
const G4String & GetPhysicsName() const
PhysicsBuilder_V GetBuilders() const
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
void SetPhysicsName(const G4String &="")
G4ParticleTable * theParticleTable
G4VPCData::PhysicsBuilders_V PhysicsBuilder_V
void SetVerboseLevel(G4int value)
#define G4RUN_DLL
Definition rundefs.hh:45