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
G4EmDataHandler.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4EmDataHandler.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
// File name: G4EmDataHandler
32
//
33
// Author: V. Ivanchenko
34
//
35
// Creation date: 16 August 2017
36
//
37
// Modifications:
38
//
39
// -------------------------------------------------------------------
40
//
41
//
42
43
#include "
G4EmDataHandler.hh
"
44
#include "
G4ParticleDefinition.hh
"
45
#include "
G4EmParameters.hh
"
46
#include "
G4PhysicsTableHelper.hh
"
47
#include "
G4VEmProcess.hh
"
48
49
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50
51
G4EmDataHandler::G4EmDataHandler
(
size_t
n
) : tLength(n)
52
{
53
data
.resize(n,
nullptr
);
54
}
55
56
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58
G4EmDataHandler::~G4EmDataHandler
()
59
{
60
//std::cout << "G4EmDataHandler::~G4EmDataHandler "
61
// << tLength << " " << this << std::endl;
62
for
(
size_t
i=0; i<
tLength
; ++i) {
CleanTable
(i); }
63
}
64
65
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66
67
size_t
G4EmDataHandler::SetTable
(
G4PhysicsTable
* ptr)
68
{
69
data
.push_back(ptr);
70
++
tLength
;
71
return
tLength
-1;
72
}
73
74
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75
76
G4PhysicsTable
*
G4EmDataHandler::MakeTable
(
size_t
i)
77
{
78
G4PhysicsTable
* table =
nullptr
;
79
// create new table only if index corresponds to the
80
// position in the vector
81
if
(i <=
tLength
) {
82
if
(i <
tLength
) { table =
data
[i]; }
83
table =
G4PhysicsTableHelper::PreparePhysicsTable
(table);
84
if
(i ==
tLength
) {
85
data
.push_back(table);
86
++
tLength
;
87
}
else
{
data
[i] = table; }
88
}
89
return
table;
90
}
91
92
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93
94
void
G4EmDataHandler::CleanTable
(
size_t
i)
95
{
96
//std::cout << i << " " << data[i] << std::endl;
97
if
(i <
tLength
&&
data
[i]) {
98
data
[i]->clearAndDestroy();
99
delete
data
[i];
100
data
[i] =
nullptr
;
101
}
102
}
103
104
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105
106
G4bool
G4EmDataHandler::StorePhysicsTable
(
size_t
idx
,
107
const
G4ParticleDefinition
*
part
,
108
const
G4String
&
fname
,
109
G4bool
ascii)
110
{
111
G4bool
yes =
true
;
112
if
(
data
[idx]) {
113
yes =
data
[
idx
]->StorePhysicsTable(fname, ascii);
114
115
if
( yes ) {
116
G4cout
<<
"Physics table is stored for "
117
<< part->
GetParticleName
()
118
<<
" <"
<< fname <<
"> "
<<
G4endl
;
119
}
else
{
120
G4cout
<<
"Fail to store Physics Table for "
121
<< part->
GetParticleName
()
122
<<
" <"
<< fname <<
"> "
<<
G4endl
;
123
}
124
}
125
return
yes;
126
}
127
128
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129
130
G4bool
G4EmDataHandler::RetrievePhysicsTable
(
size_t
idx
,
131
const
G4ParticleDefinition
*
part
,
132
const
G4String
&
fname
,
133
G4bool
ascii)
134
{
135
G4bool
yes =
136
G4PhysicsTableHelper::RetrievePhysicsTable
(
data
[idx], fname, ascii);
137
G4EmParameters
* param =
G4EmParameters::Instance
();
138
if
( yes ) {
139
if
(0 < param->
Verbose
()) {
140
G4cout
<<
"Physics table "
<< idx <<
" for "
141
<< part->
GetParticleName
()
142
<<
" is retrieved from <"
<< fname <<
">"
143
<<
G4endl
;
144
}
145
if
(param->
Spline
()) {
146
G4PhysicsTable
* table =
data
[
idx
];
147
size_t
n
= table->
length
();
148
for
(
size_t
i=0; i<
n
; ++i) {
149
if
((*table)[i]) { (*table)[i]->SetSpline(
true
); }
150
}
151
}
152
}
else
if
(1 < param->
Verbose
()) {
153
G4cout
<<
"Fail to retrieve physics table "
<< idx <<
" for "
154
<< part->
GetParticleName
() <<
" from <"
155
<< fname <<
">"
<<
G4endl
;
156
}
157
return
yes;
158
}
159
160
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
161
162
void
G4EmDataHandler::SetMasterProcess
(
const
G4VEmProcess
* ptr)
163
{
164
masterProcess
.push_back(ptr);
165
}
166
167
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168
169
const
G4VEmProcess
*
G4EmDataHandler::GetMasterProcess
(
size_t
idx
)
const
170
{
171
const
G4VEmProcess
* ptr =
172
(idx <
masterProcess
.size()) ?
masterProcess
[idx] :
nullptr
;
173
return
ptr;
174
}
175
176
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
geant4
tree
geant4-10.6-release
source
processes
electromagnetic
utils
src
G4EmDataHandler.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:35
using
1.8.2 with
ECCE GitHub integration