Geant4 10.7.0
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//
27//
28//
29// ------------------------------------------------------------
30// GEANT 4 class header file
31// Class Description:
32// This class is an virtual class for constructing
33// particles and processes. This class objects will be
34// registered to G4VPhysicsList.
35//
36// User must implement following four virtual methods
37// in his own concrete class derived from this class.
38//
39// all necessary particle type will be instantiated
40// virtual void ConstructParticle();
41//
42// all physics processes will be instantiated and
43// registered to the process manager of each particle type
44// virtual void ConstructProcess();
45//
46// Only one physics constructor can be registered to
47// Modular Physics List for each "physics_type".
48// Physics constructors with same "physics_type" can be
49// replaced by using the method of
50// G4VModularPhysicsList::ReplacePhysics()
51//
52//
53// -------------------------------------------
54// History
55// first version 12 Nov. 2000 by H.Kurashige
56// Add physicsType 14 Mar. 2011 by H.Kurashige
57// Add RegisterProcess 1 May 2011 by H.Kurashige
58// Add G4PhysicsBuilderInterface 21 Apr 2017 by A.Dotti
59// ------------------------------------------------------------
60#ifndef G4VPhysicsConstructor_h
61#define G4VPhysicsConstructor_h 1
62
63#include "G4ParticleTable.hh"
65#include "G4VUPLSplitter.hh"
66#include "G4ios.hh"
67#include "globals.hh"
68#include "rundefs.hh"
69#include <vector>
70
72
74{
75 // Encapsulate the fields of class G4VPhysicsConstructor
76 // that are per-thread.
77 public:
78 using PhysicsBuilders_V = std::vector<G4PhysicsBuilderInterface*>;
79 void initialize();
82};
83
84// The type G4VPCManager is introduced to encapsulate the methods used by
85// both the master thread and worker threads to allocate memory space for
86// the fields encapsulated by the class G4VPCData. When each thread
87// changes the value for these fields, it refers to them using a macro
88// definition defined below. For every G4VPhysicsConstructor instance,
89// there is a corresponding G4VPCData instance. All G4VPCData instances
90// are organized by the class G4VUPLManager as an array.
91// The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList.
92// The value of this field in each G4VUserPhysicsList instance is the
93// subscript of the corresponding G44VUPLData instance.
94// In order to use the class G44VUPLManager, we add a static member in the class
95// G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager".
96// Both the master thread and worker threads change the length of the array
97// for G44VUPLData instances mutually along with G4VUserPhysicsList
98// instances are created. For each worker thread, it dynamically creates ions.
99// Consider any thread A, if there is any other thread which creates an ion.
100// This ion is shared by the thread A. So the thread A leaves an empty space
101// in the array of G4PDefData instances for the ion.
102//
103// Important Note: you may wonder why we are introducing this mechanism
104// since there is only one PL for each application.
105// This is true, in the sense that only one PL is allowed
106// to be associated to a G4RunManager, however user can
107// instantiate as many PLs are needed and at run-time select one
108// of the PLs to be used we thus need this mechanism to
109// guarantee that the system works without problems in case of
110// this (unusual) case. This may be reviewed in the future
113
114// This macros change the references to fields that are now encapsulated
115// in the class G4VPCData.
116//
117// Note1: the use of this-> this is needed to avoid compilation errors
118// when using templated class with T=G4VUserPhysicsList. Don't know why.
119// Note2: the name of the first #define is different, because otherwise
120// we need to change its use in all classes that inherits from
121// this base class (all examples). However one should note comment
122// on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
123
124//#define aParticleIterator
125//((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
126
128{
129 public: // with description
130 G4VPhysicsConstructor(const G4String& = "");
131 G4VPhysicsConstructor(const G4String& name, G4int physics_type);
132 virtual ~G4VPhysicsConstructor();
133
134 virtual void ConstructParticle() = 0;
135 // This method will be invoked in the Construct() method.
136 // each particle type will be instantiated
137
138 virtual void ConstructProcess() = 0;
139 // This method will be invoked in the Construct() method.
140 // each physics process will be instantiated and
141 // registered to the process manager of each particle type
142
143 inline void SetPhysicsName(const G4String& = "");
144 inline const G4String& GetPhysicsName() const;
145
146 inline void SetPhysicsType(G4int);
147 inline G4int GetPhysicsType() const;
148
149 inline void SetVerboseLevel(G4int value);
150 inline G4int GetVerboseLevel() const;
151 // set/get controle flag for output message
152 // 0: Silent
153 // 1: Warning message
154 // 2: More
155 // verbose level is set equal to physics list when registered
156
157 protected:
158 inline G4bool RegisterProcess(G4VProcess* process,
159 G4ParticleDefinition* particle);
160 // Register a process to the particle type
161 // according to the ordering parameter table
162 // 'true' is returned if the process is registerd successfully
163
164 protected:
168
174 // This returns a copy of the vector of pointers
177
178 public:
179 inline G4int GetInstanceID() const;
180 static const G4VPCManager& GetSubInstanceManager();
181
182 // Method called by kernel to destroy thread-local
183 // data, equivalent to destructor in sequential mode
184 // Derived classes implementing this method, must also call
185 // this base class method.
186 virtual void TerminateWorker();
187};
188
189// Inlined methods
190
192{
193 verboseLevel = value;
194}
195
197{
198 return verboseLevel;
199}
200
202{
203 namePhysics = name;
204}
205
207{
208 return namePhysics;
209}
210
212{
213 if(val > 0)
214 typePhysics = val;
215}
216
218{
219 return typePhysics;
220}
221
223 G4VProcess* process, G4ParticleDefinition* particle)
224{
226 particle);
227 // return aPLHelper->RegisterProcess(process, particle);
228}
229
231{
232 return subInstanceManager;
233}
234#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4VUPLSplitter< G4VPCData > G4VPCManager
G4VPCManager G4VPhyscicsConstructorManager
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
static G4PhysicsListHelper * GetPhysicsListHelper()
std::vector< G4PhysicsBuilderInterface * > PhysicsBuilders_V
PhysicsBuilders_V * _builders
G4ParticleTable::G4PTblDicIterator * _aParticleIterator
virtual void ConstructParticle()=0
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:47