Geant4-11
source
processes
hadronic
cross_sections
src
G4CrossSectionDataSetRegistry.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
// -------------------------------------------------------------------
28
//
29
// GEANT4 Class file
30
//
31
//
32
// File name: G4CrossSectionDataSetRegistry
33
//
34
// Author V.Ivanchenko 24.01.2009
35
//
36
// Modifications:
37
//
38
39
#include "
G4ios.hh
"
40
41
#include "
G4CrossSectionDataSetRegistry.hh
"
42
#include "
G4VCrossSectionDataSet.hh
"
43
#include "
G4VComponentCrossSection.hh
"
44
#include "
G4CrossSectionFactory.hh
"
45
#include "
G4CrossSectionFactoryRegistry.hh
"
46
47
// Needed for running with 'static' libraries to pull the references of the
48
// declared factories
49
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonMinusInelasticXS
);
50
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonMinusElasticXS
);
51
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonPlusInelasticXS
);
52
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonPlusElasticXS
);
53
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonZeroInelasticXS
);
54
G4_REFERENCE_XS_FACTORY
(
G4ChipsKaonZeroElasticXS
);
55
G4_REFERENCE_XS_FACTORY
(
G4ChipsHyperonInelasticXS
);
56
G4_REFERENCE_XS_FACTORY
(
G4ChipsHyperonElasticXS
);
57
G4_REFERENCE_XS_FACTORY
(
G4ChipsProtonInelasticXS
);
58
G4_REFERENCE_XS_FACTORY
(
G4ChipsProtonElasticXS
);
59
G4_REFERENCE_XS_FACTORY
(
G4ChipsNeutronInelasticXS
);
60
G4_REFERENCE_XS_FACTORY
(
G4ChipsNeutronElasticXS
);
61
G4_REFERENCE_XS_FACTORY
(
G4ChipsPionPlusInelasticXS
);
62
G4_REFERENCE_XS_FACTORY
(
G4ChipsPionPlusElasticXS
);
63
G4_REFERENCE_XS_FACTORY
(
G4ChipsPionMinusInelasticXS
);
64
G4_REFERENCE_XS_FACTORY
(
G4ChipsPionMinusElasticXS
);
65
G4_REFERENCE_XS_FACTORY
(
G4ChipsAntiBaryonInelasticXS
);
66
G4_REFERENCE_XS_FACTORY
(
G4ChipsAntiBaryonElasticXS
);
67
G4_REFERENCE_XS_FACTORY
(
G4ElectroNuclearCrossSection
);
68
69
G4ThreadLocal
G4CrossSectionDataSetRegistry
*
G4CrossSectionDataSetRegistry::instance
=
nullptr
;
70
71
G4CrossSectionDataSetRegistry
*
G4CrossSectionDataSetRegistry::Instance
()
72
{
73
if
(
nullptr
==
instance
) {
74
static
G4ThreadLocalSingleton<G4CrossSectionDataSetRegistry>
inst;
75
instance
= inst.
Instance
();
76
}
77
return
instance
;
78
}
79
80
G4CrossSectionDataSetRegistry::G4CrossSectionDataSetRegistry
()
81
{}
82
83
G4CrossSectionDataSetRegistry::~G4CrossSectionDataSetRegistry
()
84
{
85
Clean
();
86
}
87
88
void
G4CrossSectionDataSetRegistry::Clean
()
89
{
90
size_t
n
=
xSections
.size();
91
for
(
size_t
i=0; i<
n
; ++i) {
92
G4VCrossSectionDataSet
* p =
xSections
[i];
93
if
(p) {
94
//std::cout << "Clean x-section #" << i << std::endl;
95
//std::cout << " " << p->GetName() << std::endl;
96
delete
p;
97
xSections
[i] =
nullptr
;
98
}
99
}
100
n
=
xComponents
.size();
101
for
(
size_t
i=0; i<
n
; ++i) {
102
G4VComponentCrossSection
* p =
xComponents
[i];
103
if
(p) {
104
//std::cout << "Clean component #" << i << std::endl;
105
//std::cout << " " << p->GetName() << std::endl;
106
delete
p;
107
xComponents
[i] =
nullptr
;
108
}
109
}
110
}
111
112
void
G4CrossSectionDataSetRegistry::Register
(
G4VCrossSectionDataSet
* p)
113
{
114
if
(
nullptr
== p) {
return
; }
115
for
(
auto
xsec :
xSections
) {
116
if
(xsec == p) {
return
; }
117
}
118
//G4cout << "Register x-section #" << xSections.size()
119
// << " " << p->GetName() << " " << p << G4endl;
120
xSections
.push_back(p);
121
}
122
123
void
G4CrossSectionDataSetRegistry::DeRegister
(
G4VCrossSectionDataSet
* p)
124
{
125
if
(
nullptr
== p) {
return
; }
126
size_t
n
=
xSections
.size();
127
for
(
size_t
i=0; i<
n
; ++i) {
128
if
(
xSections
[i] == p) {
129
//std::cout << "DeRegister x-section #" << i
130
// << " " << p->GetName() << " " << p << std::endl;
131
xSections
[i] =
nullptr
;
132
return
;
133
}
134
}
135
}
136
137
void
G4CrossSectionDataSetRegistry::Register
(
G4VComponentCrossSection
* p)
138
{
139
if
(!p) {
return
; }
140
for
(
auto
xsec :
xComponents
) {
141
if
(xsec == p) {
return
; }
142
}
143
//G4cout << "Register component #" << xComponents.size()
144
//<< " " << p->GetName() << G4endl;
145
xComponents
.push_back(p);
146
}
147
148
void
G4CrossSectionDataSetRegistry::DeRegister
(
G4VComponentCrossSection
* p)
149
{
150
if
(!p) {
return
; }
151
size_t
n
=
xComponents
.size();
152
for
(
size_t
i=0; i<
n
; ++i) {
153
if
(
xComponents
[i] == p) {
154
//std::cout << "DeRegister component #" << i << std::endl;
155
//std::cout << " " << p->GetName() << std::endl;
156
xComponents
[i] =
nullptr
;
157
return
;
158
}
159
}
160
}
161
162
void
163
G4CrossSectionDataSetRegistry::DeleteComponent
(
G4VComponentCrossSection
* p)
164
{
165
if
(!p) {
return
; }
166
size_t
n
=
xComponents
.size();
167
for
(
size_t
i=0; i<
n
; ++i) {
168
if
(
xComponents
[i] == p) {
169
//std::cout << "Delete component #" << i << std::endl;
170
//std::cout << " " << p->GetName() << std::endl;
171
delete
p;
172
return
;
173
}
174
}
175
}
176
177
G4VCrossSectionDataSet
*
178
G4CrossSectionDataSetRegistry::GetCrossSectionDataSet
(
const
G4String
&
name
,
179
G4bool
warning)
180
{
181
for
(
auto
xsec :
xSections
) {
182
if
(xsec && xsec->GetName() ==
name
) {
return
xsec; }
183
}
184
// check if factory exists...
185
//
186
G4CrossSectionFactoryRegistry
* factories =
187
G4CrossSectionFactoryRegistry::Instance
();
188
// This throws if factory is not found, add second parameter
189
// to false to avoid this
190
G4VBaseXSFactory
*
factory
= factories->
GetFactory
(
name
, warning );
191
if
(
factory
) {
192
return
factory
->Instantiate();
193
}
else
{
194
G4VCrossSectionDataSet
* ptr =
nullptr
;
195
return
ptr;
196
}
197
}
198
199
G4VComponentCrossSection
*
200
G4CrossSectionDataSetRegistry::GetComponentCrossSection
(
const
G4String
&
name
)
201
{
202
for
(
auto
xsec :
xComponents
) {
203
if
(xsec && xsec->GetName() ==
name
) {
return
xsec; }
204
}
205
G4VComponentCrossSection
* ptr =
nullptr
;
206
return
ptr;
207
}
G4_REFERENCE_XS_FACTORY
G4_REFERENCE_XS_FACTORY(G4ChipsKaonMinusInelasticXS)
G4CrossSectionDataSetRegistry.hh
G4CrossSectionFactoryRegistry.hh
G4CrossSectionFactory.hh
G4bool
bool G4bool
Definition:
G4Types.hh:86
G4VComponentCrossSection.hh
G4VCrossSectionDataSet.hh
G4ios.hh
G4ChipsAntiBaryonElasticXS
Definition:
G4ChipsAntiBaryonElasticXS.hh:47
G4ChipsAntiBaryonInelasticXS
Definition:
G4ChipsAntiBaryonInelasticXS.hh:45
G4ChipsHyperonElasticXS
Definition:
G4ChipsHyperonElasticXS.hh:47
G4ChipsHyperonInelasticXS
Definition:
G4ChipsHyperonInelasticXS.hh:46
G4ChipsKaonMinusElasticXS
Definition:
G4ChipsKaonMinusElasticXS.hh:47
G4ChipsKaonMinusInelasticXS
Definition:
G4ChipsKaonMinusInelasticXS.hh:46
G4ChipsKaonPlusElasticXS
Definition:
G4ChipsKaonPlusElasticXS.hh:47
G4ChipsKaonPlusInelasticXS
Definition:
G4ChipsKaonPlusInelasticXS.hh:48
G4ChipsKaonZeroElasticXS
Definition:
G4ChipsKaonZeroElasticXS.hh:50
G4ChipsKaonZeroInelasticXS
Definition:
G4ChipsKaonZeroInelasticXS.hh:50
G4ChipsNeutronElasticXS
Definition:
G4ChipsNeutronElasticXS.hh:47
G4ChipsNeutronInelasticXS
Definition:
G4ChipsNeutronInelasticXS.hh:46
G4ChipsPionMinusElasticXS
Definition:
G4ChipsPionMinusElasticXS.hh:48
G4ChipsPionMinusInelasticXS
Definition:
G4ChipsPionMinusInelasticXS.hh:48
G4ChipsPionPlusElasticXS
Definition:
G4ChipsPionPlusElasticXS.hh:47
G4ChipsPionPlusInelasticXS
Definition:
G4ChipsPionPlusInelasticXS.hh:49
G4ChipsProtonElasticXS
Definition:
G4ChipsProtonElasticXS.hh:46
G4ChipsProtonInelasticXS
Definition:
G4ChipsProtonInelasticXS.hh:45
G4CrossSectionDataSetRegistry
Definition:
G4CrossSectionDataSetRegistry.hh:56
G4CrossSectionDataSetRegistry::xComponents
std::vector< G4VComponentCrossSection * > xComponents
Definition:
G4CrossSectionDataSetRegistry.hh:96
G4CrossSectionDataSetRegistry::instance
static G4ThreadLocal G4CrossSectionDataSetRegistry * instance
Definition:
G4CrossSectionDataSetRegistry.hh:93
G4CrossSectionDataSetRegistry::DeRegister
void DeRegister(G4VCrossSectionDataSet *)
Definition:
G4CrossSectionDataSetRegistry.cc:123
G4CrossSectionDataSetRegistry::~G4CrossSectionDataSetRegistry
~G4CrossSectionDataSetRegistry()
Definition:
G4CrossSectionDataSetRegistry.cc:83
G4CrossSectionDataSetRegistry::GetCrossSectionDataSet
G4VCrossSectionDataSet * GetCrossSectionDataSet(const G4String &name, G4bool warning=false)
Definition:
G4CrossSectionDataSetRegistry.cc:178
G4CrossSectionDataSetRegistry::xSections
std::vector< G4VCrossSectionDataSet * > xSections
Definition:
G4CrossSectionDataSetRegistry.hh:95
G4CrossSectionDataSetRegistry::GetComponentCrossSection
G4VComponentCrossSection * GetComponentCrossSection(const G4String &name)
Definition:
G4CrossSectionDataSetRegistry.cc:200
G4CrossSectionDataSetRegistry::Register
void Register(G4VCrossSectionDataSet *)
Definition:
G4CrossSectionDataSetRegistry.cc:112
G4CrossSectionDataSetRegistry::Clean
void Clean()
Definition:
G4CrossSectionDataSetRegistry.cc:88
G4CrossSectionDataSetRegistry::Instance
static G4CrossSectionDataSetRegistry * Instance()
Definition:
G4CrossSectionDataSetRegistry.cc:71
G4CrossSectionDataSetRegistry::DeleteComponent
void DeleteComponent(G4VComponentCrossSection *)
Definition:
G4CrossSectionDataSetRegistry.cc:163
G4CrossSectionDataSetRegistry::G4CrossSectionDataSetRegistry
G4CrossSectionDataSetRegistry()
Definition:
G4CrossSectionDataSetRegistry.cc:80
G4CrossSectionFactoryRegistry
Definition:
G4CrossSectionFactoryRegistry.hh:49
G4CrossSectionFactoryRegistry::Instance
static G4CrossSectionFactoryRegistry * Instance()
Definition:
G4CrossSectionFactoryRegistry.cc:39
G4CrossSectionFactoryRegistry::GetFactory
G4VBaseXSFactory * GetFactory(const G4String &name, G4bool abortIfNotFound=true) const
Definition:
G4CrossSectionFactoryRegistry.cc:78
G4ElectroNuclearCrossSection
Definition:
G4ElectroNuclearCrossSection.hh:59
G4String
Definition:
G4String.hh:62
G4ThreadLocalSingleton
Definition:
G4ThreadLocalSingleton.hh:146
G4ThreadLocalSingleton::Instance
T * Instance() const
Definition:
G4ThreadLocalSingleton.hh:210
G4VBaseXSFactory
Definition:
G4CrossSectionFactory.hh:36
G4VComponentCrossSection
Definition:
G4VComponentCrossSection.hh:54
G4VCrossSectionDataSet
Definition:
G4VCrossSectionDataSet.hh:70
CLHEP::detail::n
n
Definition:
Ranlux64Engine.cc:90
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:76
test.factory
factory
Definition:
test.py:55
G4ThreadLocal
#define G4ThreadLocal
Definition:
tls.hh:77
Generated by
1.9.3