Geant4-11
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 <vector>
53
54#include "G4ParticleTable.hh"
56#include "G4VUPLSplitter.hh"
57#include "G4ios.hh"
58#include "globals.hh"
59#include "rundefs.hh"
60
62
64{
65 // Encapsulate the fields of class G4VPhysicsConstructor
66 // that are per-thread.
67
68 public:
69
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
112 G4VPhysicsConstructor(const G4String& = "");
113 G4VPhysicsConstructor(const G4String& name, G4int physics_type);
114 virtual ~G4VPhysicsConstructor();
115
116 virtual void ConstructParticle() = 0;
117 // This method will be invoked in the Construct() method.
118 // Each particle type will be instantiated.
119
120 virtual void ConstructProcess() = 0;
121 // This method will be invoked in the Construct() method.
122 // Each physics process will be instantiated and
123 // registered to the process manager of each particle type.
124
125 inline void SetPhysicsName(const G4String& = "");
126 inline const G4String& GetPhysicsName() const;
127
128 inline void SetPhysicsType(G4int);
129 inline G4int GetPhysicsType() const;
130
131 inline G4int GetInstanceID() const;
132 static const G4VPCManager& GetSubInstanceManager();
133
134 virtual void TerminateWorker();
135 // Method called by kernel to destroy thread-local data, equivalent to
136 // destructor in sequential mode. Derived classes implementing this
137 // method, must also call this base class method.
138
139 inline void SetVerboseLevel(G4int value);
140 inline G4int GetVerboseLevel() const;
141 // Set/get control flag for output message
142 // 0: Silent
143 // 1: Warning message
144 // 2: More
145 // verbose level is set equal to physics list when registered.
146
147 protected:
148
150
151 inline G4bool RegisterProcess(G4VProcess* process,
152 G4ParticleDefinition* particle);
153 // Register a process to the particle type according to the ordering
154 // parameter table. 'true' is returned if the process is registered
155 // successfully.
156
158
160 // This returns a copy of the vector of pointers.
162
163 protected:
164
168
172};
173
174// Inline methods implementations
175
177{
178 verboseLevel = value;
179}
180
182{
183 return verboseLevel;
184}
185
187{
189}
190
192{
193 return namePhysics;
194}
195
197{
198 if(val > 0) { typePhysics = val; }
199}
200
202{
203 return typePhysics;
204}
205
207 G4VProcess* process, G4ParticleDefinition* particle)
208{
210 ->RegisterProcess(process, particle);
211}
212
214{
215 return subInstanceManager;
216}
217
218#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)
const char * name(G4int ptype)
#define G4RUN_DLL
Definition: rundefs.hh:45