Geant4
10.03
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
G4PhysicsConstructorRegistry.cc
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
// $Id:
28
//
29
// -------------------------------------------------------------------
30
//
31
// GEANT4 Class file
32
//
33
//
34
// File name: G4PhysicsConstructorRegistry
35
//
36
// Author W. Pokorski 21.09.2012
37
//
38
// Modifications:
39
//
40
41
#include "
G4ios.hh
"
42
#include <iomanip>
43
44
#include "
G4PhysicsConstructorRegistry.hh
"
45
#include "
G4VPhysicsConstructor.hh
"
46
#include "
G4PhysicsConstructorFactory.hh
"
47
48
G4ThreadLocal
G4PhysicsConstructorRegistry
*
G4PhysicsConstructorRegistry::theInstance
= 0;
49
50
G4PhysicsConstructorRegistry
*
G4PhysicsConstructorRegistry::Instance
()
51
{
52
if
(0 ==
theInstance
) {
53
static
G4ThreadLocal
G4PhysicsConstructorRegistry
*manager_G4MT_TLS_ = 0 ;
if
(!manager_G4MT_TLS_) manager_G4MT_TLS_ =
new
G4PhysicsConstructorRegistry
;
G4PhysicsConstructorRegistry
&manager = *manager_G4MT_TLS_;
54
theInstance
= &manager;
55
}
56
return
theInstance
;
57
}
58
59
G4PhysicsConstructorRegistry::G4PhysicsConstructorRegistry
()
60
{}
61
62
G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry
()
63
{
64
Clean
();
65
}
66
67
void
G4PhysicsConstructorRegistry::Clean
()
68
{
69
size_t
n
=
physConstr
.size();
70
if
(n > 0) {
71
for
(
size_t
i=0; i<
n
; ++i) {
72
if
(
physConstr
[i]) {
73
G4VPhysicsConstructor
* p =
physConstr
[i];
74
physConstr
[i] = 0;
75
delete
p;
76
}
77
}
78
physConstr
.clear();
79
}
80
}
81
82
void
G4PhysicsConstructorRegistry::Register
(
G4VPhysicsConstructor
* p)
83
{
84
if
(!p)
return
;
85
size_t
n
=
physConstr
.size();
86
if
(n > 0) {
87
for
(
size_t
i=0; i<
n
; ++i) {
88
if
(
physConstr
[i] == p) {
return
; }
89
}
90
}
91
physConstr
.push_back(p);
92
}
93
94
void
G4PhysicsConstructorRegistry::DeRegister
(
G4VPhysicsConstructor
* p)
95
{
96
if
( !p )
return
;
97
size_t
n
=
physConstr
.size();
98
if
( n > 0 ) {
99
for
(
size_t
i=0; i<
n
; ++i) {
100
if
(
physConstr
[i] == p ) {
101
physConstr
[i] = 0;
102
return
;
103
}
104
}
105
}
106
}
107
108
void
G4PhysicsConstructorRegistry::AddFactory
(
G4String
name
,
G4VBasePhysConstrFactory
* factory)
109
{
110
factories
[
name
] = factory;
111
}
112
113
G4VPhysicsConstructor
*
G4PhysicsConstructorRegistry::GetPhysicsConstructor
(
const
G4String
&
name
)
114
{
115
// check if factory exists...
116
//
117
if
(
factories
.find(name)!=
factories
.end())
118
{
119
// we could store the list of called factories in some vector and
120
// before returning we can could first check if this physics constructor was already instantiated
121
// if yes, we can throw an exception saying that this physics can been already registered
122
123
return
factories
[
name
]->Instantiate();
124
}
125
else
126
{
127
G4ExceptionDescription
ED;
128
ED <<
"The factory for the physics constructor ["
<< name <<
"] does not exist!"
<<
G4endl
;
129
G4Exception
(
"G4PhysicsConstructorRegistry::GetPhysicsConstructor"
,
"PhysicsList001"
,
FatalException
, ED);
130
return
0;
131
}
132
}
133
134
G4bool
G4PhysicsConstructorRegistry::IsKnownPhysicsConstructor
(
const
G4String
&
name
)
135
{
136
return
(
factories
.find(name) !=
factories
.end() );
137
}
138
139
140
std::vector<G4String>
G4PhysicsConstructorRegistry::AvailablePhysicsConstructors
()
const
141
{
142
std::vector<G4String> avail;
143
std::map<G4String,G4VBasePhysConstrFactory*>::const_iterator itr;
144
for
( itr =
factories
.begin(); itr !=
factories
.end(); ++itr ) {
145
avail.push_back(itr->first);
146
}
147
148
return
avail;
149
}
150
151
void
G4PhysicsConstructorRegistry::PrintAvailablePhysicsConstructors
()
const
152
{
153
std::vector<G4String> avail =
AvailablePhysicsConstructors
();
154
G4cout
<<
"G4VPhysicsConstructors in G4PhysicsConstructorRegistry are:"
155
<<
G4endl
;
156
if
( avail.empty() )
G4cout
<<
"... no registered processes"
<< G4endl;
157
else
{
158
size_t
n
= avail.size();
159
for
(
size_t
i=0; i<
n
; ++i ) {
160
G4cout
<<
" ["
<< std::setw(3) << i <<
"] "
161
<<
" \""
<< avail[i] <<
"\""
<<
G4endl
;
162
}
163
}
164
}
165
166
//
167
// External reference to phy ctor factories for running with 'static'
168
// libraries to pull the references of the declared factories into the
169
// same compilation unit as the registry itself.
170
// No harm having them in the non-static case.
171
//
172
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4ChargeExchangePhysics
);
173
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4DecayPhysics
);
174
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAChemistry
);
175
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics
);
176
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option1
);
177
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option2
);
178
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option3
);
179
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option4
);
180
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option5
);
181
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmDNAPhysics_option7
);
182
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmExtraPhysics
);
183
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmLivermorePhysics
);
184
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmLivermorePolarizedPhysics
);
185
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmLowEPPhysics
);
186
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmPenelopePhysics
);
187
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysics
);
188
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysicsGS
);
189
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysicsSS
);
190
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysicsWVI
);
191
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysics_option1
);
192
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysics_option2
);
193
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysics_option3
);
194
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4EmStandardPhysics_option4
);
195
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4GenericBiasingPhysics
);
196
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronDElasticPhysics
);
197
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronElasticPhysics
);
198
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronElasticPhysicsHP
);
199
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronElasticPhysicsLEND
);
200
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronElasticPhysicsXS
);
201
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronHElasticPhysics
);
202
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronInelasticQBBC
);
203
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsFTFP_BERT
);
204
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsFTFP_BERT_ATL
);
205
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsFTFP_BERT_HP
);
206
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsFTFP_BERT_TRV
);
207
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsFTF_BIC
);
208
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsINCLXX
);
209
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsNuBeam
);
210
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_BERT
);
211
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_BERT_HP
);
212
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_BIC
);
213
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_BIC_AllHP
);
214
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_BIC_HP
);
215
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGSP_FTFP_BERT
);
216
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsQGS_BIC
);
217
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4HadronPhysicsShielding
);
218
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4ImportanceBiasing
);
219
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4IonBinaryCascadePhysics
);
220
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4IonElasticPhysics
);
221
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4IonINCLXXPhysics
);
222
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4IonPhysics
);
223
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4IonQMDPhysics
);
224
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4NeutronCrossSectionXS
);
225
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4NeutronTrackingCut
);
226
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4OpticalPhysics
);
227
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4ParallelWorldPhysics
);
228
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4RadioactiveDecayPhysics
);
229
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4SpinDecayPhysics
);
230
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4StepLimiterPhysics
);
231
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4StoppingPhysics
);
232
G4_REFERENCE_PHYSCONSTR_FACTORY
(
G4WeightWindowBiasing
);
233
G4IonBinaryCascadePhysics
Definition:
G4IonBinaryCascadePhysics.hh:54
G4PhysicsConstructorRegistry::~G4PhysicsConstructorRegistry
~G4PhysicsConstructorRegistry()
Definition:
G4PhysicsConstructorRegistry.cc:62
G4HadronElasticPhysicsHP
Definition:
G4HadronElasticPhysicsHP.hh:47
G4ParallelWorldPhysics
Definition:
G4ParallelWorldPhysics.hh:40
G4HadronPhysicsQGSP_BIC_HP
Definition:
G4HadronPhysicsQGSP_BIC_HP.hh:75
G4HadronPhysicsQGSP_FTFP_BERT
Definition:
G4HadronPhysicsQGSP_FTFP_BERT.hh:69
G4PhysicsConstructorRegistry::G4PhysicsConstructorRegistry
G4PhysicsConstructorRegistry()
Definition:
G4PhysicsConstructorRegistry.cc:59
G4ExceptionDescription
std::ostringstream G4ExceptionDescription
Definition:
globals.hh:76
G4PhysicsConstructorRegistry::theInstance
static G4ThreadLocal G4PhysicsConstructorRegistry * theInstance
Definition:
G4PhysicsConstructorRegistry.hh:89
G4EmStandardPhysics_option2
Definition:
G4EmStandardPhysics_option2.hh:55
G4RadioactiveDecayPhysics
Definition:
G4RadioactiveDecayPhysics.hh:38
G4PhysicsConstructorRegistry::PrintAvailablePhysicsConstructors
void PrintAvailablePhysicsConstructors() const
Definition:
G4PhysicsConstructorRegistry.cc:151
G4EmExtraPhysics
Definition:
G4EmExtraPhysics.hh:56
G4PhysicsConstructorRegistry::IsKnownPhysicsConstructor
G4bool IsKnownPhysicsConstructor(const G4String &name)
Definition:
G4PhysicsConstructorRegistry.cc:134
G4EmDNAPhysics
Definition:
G4EmDNAPhysics.hh:37
G4SpinDecayPhysics
Definition:
G4SpinDecayPhysics.hh:46
G4HadronPhysicsFTF_BIC
Definition:
G4HadronPhysicsFTF_BIC.hh:68
G4PhysicsConstructorRegistry
Definition:
G4PhysicsConstructorRegistry.hh:57
G4PhysicsConstructorRegistry::physConstr
std::vector< G4VPhysicsConstructor * > physConstr
Definition:
G4PhysicsConstructorRegistry.hh:91
G4HadronPhysicsINCLXX
Definition:
G4HadronPhysicsINCLXX.hh:89
G4EmLivermorePolarizedPhysics
Definition:
G4EmLivermorePolarizedPhysics.hh:36
G4HadronElasticPhysics
Definition:
G4HadronElasticPhysics.hh:52
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:77
G4NeutronTrackingCut
Definition:
G4NeutronTrackingCut.hh:46
G4EmDNAChemistry
Definition:
G4EmDNAChemistry.hh:35
G4ThreadLocal
#define G4ThreadLocal
Definition:
tls.hh:89
G4NeutronCrossSectionXS
Definition:
G4NeutronCrossSectionXS.hh:45
G4IonPhysics
Definition:
G4IonPhysics.hh:53
G4EmDNAPhysics_option5
Definition:
G4EmDNAPhysics_option5.hh:37
G4HadronElasticPhysicsXS
Definition:
G4HadronElasticPhysicsXS.hh:49
G4EmStandardPhysics_option1
Definition:
G4EmStandardPhysics_option1.hh:54
G4HadronDElasticPhysics
Definition:
G4HadronDElasticPhysics.hh:45
G4_REFERENCE_PHYSCONSTR_FACTORY
G4_REFERENCE_PHYSCONSTR_FACTORY(G4ChargeExchangePhysics)
G4EmStandardPhysics_option4
Definition:
G4EmStandardPhysics_option4.hh:53
G4ChargeExchangePhysics
Definition:
G4ChargeExchangePhysics.hh:47
G4EmLowEPPhysics
Definition:
G4EmLowEPPhysics.hh:35
G4cout
G4GLOB_DLL std::ostream G4cout
G4HadronPhysicsFTFP_BERT
Definition:
G4HadronPhysicsFTFP_BERT.hh:73
G4PhysicsConstructorRegistry::GetPhysicsConstructor
G4VPhysicsConstructor * GetPhysicsConstructor(const G4String &name)
Definition:
G4PhysicsConstructorRegistry.cc:113
G4VPhysicsConstructor.hh
G4PhysicsConstructorRegistry.hh
G4bool
bool G4bool
Definition:
G4Types.hh:79
G4EmLivermorePhysics
Definition:
G4EmLivermorePhysics.hh:36
G4HadronHElasticPhysics
Definition:
G4HadronHElasticPhysics.hh:47
G4PhysicsConstructorRegistry::Clean
void Clean()
Definition:
G4PhysicsConstructorRegistry.cc:67
G4EmDNAPhysics_option2
Definition:
G4EmDNAPhysics_option2.hh:37
G4EmDNAPhysics_option4
Definition:
G4EmDNAPhysics_option4.hh:37
G4HadronPhysicsFTFP_BERT_TRV
Definition:
G4HadronPhysicsFTFP_BERT_TRV.hh:70
G4EmStandardPhysicsGS
Definition:
G4EmStandardPhysicsGS.hh:52
n
const G4int n
Definition:
G4UrQMD1_3Interface.hh:144
G4HadronPhysicsQGSP_BERT
Definition:
G4HadronPhysicsQGSP_BERT.hh:74
G4EmStandardPhysicsSS
Definition:
G4EmStandardPhysicsSS.hh:50
G4PhysicsConstructorRegistry::AddFactory
void AddFactory(G4String, G4VBasePhysConstrFactory *)
Definition:
G4PhysicsConstructorRegistry.cc:108
G4PhysicsConstructorRegistry::factories
std::map< G4String, G4VBasePhysConstrFactory * > factories
Definition:
G4PhysicsConstructorRegistry.hh:93
G4Exception
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition:
G4Exception.cc:41
G4EmStandardPhysics_option3
Definition:
G4EmStandardPhysics_option3.hh:52
G4HadronInelasticQBBC
Definition:
G4HadronInelasticQBBC.hh:48
G4PhysicsConstructorRegistry::Instance
static G4PhysicsConstructorRegistry * Instance()
Definition:
G4PhysicsConstructorRegistry.cc:50
G4IonQMDPhysics
Definition:
G4IonQMDPhysics.hh:56
G4HadronElasticPhysicsLEND
Definition:
G4HadronElasticPhysicsLEND.hh:47
G4PhysicsConstructorFactory.hh
G4StepLimiterPhysics
Definition:
G4StepLimiterPhysics.hh:43
G4DecayPhysics
Definition:
G4DecayPhysics.hh:49
G4EmDNAPhysics_option1
Definition:
G4EmDNAPhysics_option1.hh:37
G4ios.hh
FatalException
Definition:
G4ExceptionSeverity.hh:60
G4EmDNAPhysics_option3
Definition:
G4EmDNAPhysics_option3.hh:34
G4GenericBiasingPhysics
Definition:
G4GenericBiasingPhysics.hh:42
G4ImportanceBiasing
Definition:
G4ImportanceBiasing.hh:41
G4WeightWindowBiasing
Definition:
G4WeightWindowBiasing.hh:42
G4endl
#define G4endl
Definition:
G4ios.hh:61
G4HadronPhysicsFTFP_BERT_HP
Definition:
G4HadronPhysicsFTFP_BERT_HP.hh:72
G4PhysicsConstructorRegistry::AvailablePhysicsConstructors
std::vector< G4String > AvailablePhysicsConstructors() const
Definition:
G4PhysicsConstructorRegistry.cc:140
G4EmStandardPhysicsWVI
Definition:
G4EmStandardPhysicsWVI.hh:53
G4VBasePhysConstrFactory
Definition:
G4PhysicsConstructorFactory.hh:34
G4HadronPhysicsNuBeam
Definition:
G4HadronPhysicsNuBeam.hh:67
G4IonINCLXXPhysics
Definition:
G4IonINCLXXPhysics.hh:54
G4EmDNAPhysics_option7
Definition:
G4EmDNAPhysics_option7.hh:37
G4EmPenelopePhysics
Definition:
G4EmPenelopePhysics.hh:36
G4PhysicsConstructorRegistry::DeRegister
void DeRegister(G4VPhysicsConstructor *)
Definition:
G4PhysicsConstructorRegistry.cc:94
G4HadronPhysicsQGS_BIC
Definition:
G4HadronPhysicsQGS_BIC.hh:75
G4PhysicsConstructorRegistry::Register
void Register(G4VPhysicsConstructor *)
Definition:
G4PhysicsConstructorRegistry.cc:82
G4OpticalPhysics
Definition:
G4OpticalPhysics.hh:61
G4HadronPhysicsFTFP_BERT_ATL
Definition:
G4HadronPhysicsFTFP_BERT_ATL.hh:67
G4IonElasticPhysics
Definition:
G4IonElasticPhysics.hh:46
G4VPhysicsConstructor
Definition:
G4VPhysicsConstructor.hh:121
G4HadronPhysicsQGSP_BIC
Definition:
G4HadronPhysicsQGSP_BIC.hh:73
G4HadronPhysicsQGSP_BERT_HP
Definition:
G4HadronPhysicsQGSP_BERT_HP.hh:73
G4HadronPhysicsShielding
Definition:
G4HadronPhysicsShielding.hh:70
G4HadronPhysicsQGSP_BIC_AllHP
Definition:
G4HadronPhysicsQGSP_BIC_AllHP.hh:64
G4StoppingPhysics
Definition:
G4StoppingPhysics.hh:63
G4String
Definition:
G4String.hh:45
G4EmStandardPhysics
Definition:
G4EmStandardPhysics.hh:52
geant4.10.03
source
physics_lists
constructors
factory
src
G4PhysicsConstructorRegistry.cc
Generated on Thu Feb 14 2002 02:28:32 for Geant4 by
1.8.8