Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
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
// $Id$
28
//
29
// -------------------------------------------------------------------
30
//
31
// GEANT4 Class file
32
//
33
//
34
// File name: G4CrossSectionDataSetRegistry
35
//
36
// Author V.Ivanchenko 24.01.2009
37
//
38
// Modifications:
39
//
40
41
#include "
G4ios.hh
"
42
43
#include "
G4CrossSectionDataSetRegistry.hh
"
44
#include "
G4VCrossSectionDataSet.hh
"
45
#include "
G4CrossSectionFactory.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
(
G4GlauberGribovCrossSection
);
69
G4_REFERENCE_XS_FACTORY
(
G4GGNuclNuclCrossSection
);
70
71
72
G4CrossSectionDataSetRegistry
* G4CrossSectionDataSetRegistry::theInstance = 0;
73
74
G4CrossSectionDataSetRegistry
*
G4CrossSectionDataSetRegistry::Instance
()
75
{
76
if
(0 == theInstance) {
77
static
G4CrossSectionDataSetRegistry
manager;
78
theInstance = &manager;
79
}
80
return
theInstance;
81
}
82
83
G4CrossSectionDataSetRegistry::G4CrossSectionDataSetRegistry()
84
{}
85
86
G4CrossSectionDataSetRegistry::~G4CrossSectionDataSetRegistry
()
87
{
88
Clean
();
89
}
90
91
void
G4CrossSectionDataSetRegistry::Clean
()
92
{
93
size_t
n
= xSections.size();
94
if
(n > 0) {
95
for
(
size_t
i=0; i<
n
; ++i) {
96
if
(xSections[i]) {
97
G4VCrossSectionDataSet
*
p
= xSections[i];
98
xSections[i] = 0;
99
delete
p
;
100
}
101
}
102
xSections.clear();
103
}
104
}
105
106
void
G4CrossSectionDataSetRegistry::Register
(
G4VCrossSectionDataSet
*
p
)
107
{
108
if
(!p)
return
;
109
size_t
n
= xSections.size();
110
if
(n > 0) {
111
for
(
size_t
i=0; i<
n
; ++i) {
112
if
(xSections[i] == p) {
return
; }
113
}
114
}
115
xSections.push_back(p);
116
}
117
118
void
G4CrossSectionDataSetRegistry::DeRegister
(
G4VCrossSectionDataSet
*
p
)
119
{
120
if
(!p)
return
;
121
size_t
n
= xSections.size();
122
if
(n > 0) {
123
for
(
size_t
i=0; i<
n
; ++i) {
124
if
(xSections[i] == p) {
125
xSections[i] = 0;
126
return
;
127
}
128
}
129
}
130
}
131
132
void
G4CrossSectionDataSetRegistry::AddFactory
(
G4String
name
,
G4VBaseXSFactory
* factory)
133
{
134
factories[
name
] = factory;
135
}
136
137
G4VCrossSectionDataSet
*
G4CrossSectionDataSetRegistry::GetCrossSectionDataSet
(
const
G4String
&
name
,
G4bool
warning)
138
{
139
size_t
n
= xSections.size();
140
141
for
(
size_t
i=0; i<
n
; ++i)
142
{
143
if
(xSections[i])
144
{
145
G4VCrossSectionDataSet
*
p
= xSections[i];
146
if
(p->
GetName
() ==
name
)
return
p;
147
}
148
}
149
// check if factory exists...
150
//
151
if
(factories.find(name)!=factories.end())
152
{
153
return
factories[
name
]->Instantiate();
154
}
155
else
156
{
157
if
(warning)
158
{
159
G4ExceptionDescription
ED;
160
ED <<
"Factory for ["
<< name <<
"] cross section data set not found."
<<
G4endl
;
161
G4Exception
(
"G4CrossSectionDataSetRegistry::GetCrossSectionDataSet"
,
"CrossSection001"
,
FatalException
, ED);
162
}
163
return
0;
164
}
165
}
Generated on Sat May 25 2013 14:33:41 for Geant4 by
1.8.4