ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4CrossSectionDataSetRegistry.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4CrossSectionDataSetRegistry.cc
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
// Neeed 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
(
G4NucleonNuclearCrossSection
);
68
G4_REFERENCE_XS_FACTORY
(
G4ElectroNuclearCrossSection
);
69
G4_REFERENCE_XS_FACTORY
(
G4PhotoNuclearCrossSection
);
70
G4_REFERENCE_XS_FACTORY
(
G4PiNuclearCrossSection
);
71
G4_REFERENCE_XS_FACTORY
(
G4NeutronInelasticXS
);
72
G4_REFERENCE_XS_FACTORY
(
G4NeutronElasticXS
);
73
G4_REFERENCE_XS_FACTORY
(
G4NeutronCaptureXS
);
74
75
G4ThreadLocal
G4CrossSectionDataSetRegistry
*
G4CrossSectionDataSetRegistry::instance
=
nullptr
;
76
77
G4CrossSectionDataSetRegistry
*
G4CrossSectionDataSetRegistry::Instance
()
78
{
79
if
(!
instance
) {
80
static
G4ThreadLocalSingleton<G4CrossSectionDataSetRegistry>
inst;
81
instance
= inst.
Instance
();
82
}
83
return
instance
;
84
}
85
86
G4CrossSectionDataSetRegistry::G4CrossSectionDataSetRegistry
()
87
{}
88
89
G4CrossSectionDataSetRegistry::~G4CrossSectionDataSetRegistry
()
90
{
91
Clean
();
92
}
93
94
void
G4CrossSectionDataSetRegistry::Clean
()
95
{
96
size_t
n
=
xSections
.size();
97
for
(
size_t
i=0; i<
n
; ++i) {
98
G4VCrossSectionDataSet
*
p
=
xSections
[i];
99
if
(p) {
100
//std::cout << "Clean x-section #" << i << std::endl;
101
//std::cout << " " << p->GetName() << std::endl;
102
delete
p
;
103
xSections
[i] =
nullptr
;
104
}
105
}
106
n =
xComponents
.size();
107
for
(
size_t
i=0; i<
n
; ++i) {
108
G4VComponentCrossSection
*
p
=
xComponents
[i];
109
if
(p) {
110
//std::cout << "Clean component #" << i << std::endl;
111
//std::cout << " " << p->GetName() << std::endl;
112
delete
p
;
113
xComponents
[i] =
nullptr
;
114
}
115
}
116
}
117
118
void
G4CrossSectionDataSetRegistry::Register
(
G4VCrossSectionDataSet
*
p
)
119
{
120
if
(!p) {
return
; }
121
for
(
auto
xsec :
xSections
) {
122
if
(xsec == p) {
return
; }
123
}
124
//G4cout << "Register x-section #" << xSections.size()
125
//<< " " << p->GetName() << G4endl;
126
xSections.push_back(p);
127
}
128
129
void
G4CrossSectionDataSetRegistry::DeRegister
(
G4VCrossSectionDataSet
*
p
)
130
{
131
if
(!p) {
return
; }
132
size_t
n
=
xSections
.size();
133
for
(
size_t
i=0; i<
n
; ++i) {
134
if
(
xSections
[i] == p) {
135
//std::cout << "DeRegister x-section #" << i << std::endl;
136
//std:: cout << " " << p->GetName() << std::endl;
137
xSections
[i] =
nullptr
;
138
return
;
139
}
140
}
141
}
142
143
void
G4CrossSectionDataSetRegistry::Register
(
G4VComponentCrossSection
*
p
)
144
{
145
if
(!p) {
return
; }
146
for
(
auto
xsec :
xComponents
) {
147
if
(xsec == p) {
return
; }
148
}
149
//G4cout << "Register component #" << xComponents.size()
150
//<< " " << p->GetName() << G4endl;
151
xComponents.push_back(p);
152
}
153
154
void
G4CrossSectionDataSetRegistry::DeRegister
(
G4VComponentCrossSection
*
p
)
155
{
156
if
(!p) {
return
; }
157
size_t
n
=
xComponents
.size();
158
for
(
size_t
i=0; i<
n
; ++i) {
159
if
(
xComponents
[i] == p) {
160
//std::cout << "DeRegister component #" << i << std::endl;
161
//std::cout << " " << p->GetName() << std::endl;
162
xComponents
[i] =
nullptr
;
163
return
;
164
}
165
}
166
}
167
168
void
169
G4CrossSectionDataSetRegistry::DeleteComponent
(
G4VComponentCrossSection
*
p
)
170
{
171
if
(!p) {
return
; }
172
size_t
n
=
xComponents
.size();
173
for
(
size_t
i=0; i<
n
; ++i) {
174
if
(
xComponents
[i] == p) {
175
//std::cout << "Delete component #" << i << std::endl;
176
//std::cout << " " << p->GetName() << std::endl;
177
delete
p
;
178
return
;
179
}
180
}
181
}
182
183
G4VCrossSectionDataSet
*
184
G4CrossSectionDataSetRegistry::GetCrossSectionDataSet
(
const
G4String
&
name
,
185
G4bool
warning)
186
{
187
for
(
auto
xsec :
xSections
) {
188
if
(xsec && xsec->GetName() ==
name
) {
return
xsec; }
189
}
190
// check if factory exists...
191
//
192
G4CrossSectionFactoryRegistry
* factories =
193
G4CrossSectionFactoryRegistry::Instance
();
194
// This throws if factory is not found, add second parameter
195
// to false to avoid this
196
G4VBaseXSFactory
* factory = factories->
GetFactory
(name, warning );
197
if
( factory ) {
198
return
factory->
Instantiate
();
199
}
else
{
200
G4VCrossSectionDataSet
* ptr =
nullptr
;
201
return
ptr;
202
}
203
}
204
205
G4VComponentCrossSection
*
206
G4CrossSectionDataSetRegistry::GetComponentCrossSection
(
const
G4String
&
name
)
207
{
208
for
(
auto
xsec :
xComponents
) {
209
if
(xsec && xsec->GetName() ==
name
) {
return
xsec; }
210
}
211
G4VComponentCrossSection
* ptr =
nullptr
;
212
return
ptr;
213
}
geant4
tree
geant4-10.6-release
source
processes
hadronic
cross_sections
src
G4CrossSectionDataSetRegistry.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:37
using
1.8.2 with
ECCE GitHub integration