Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4EmDataHandler.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// 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"
45#include "G4EmParameters.hh"
47#include "G4VEmProcess.hh"
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
53{
54 data.resize(n, nullptr);
55}
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
60{
61 for(size_t i=0; i<tLength; ++i) {
62 for(size_t j = i+1; j<tLength; ++j) {
63 if(data[j] == data[i]) { data[j] = nullptr; }
64 }
65 CleanTable(i);
66 }
67}
68
69//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70
72{
73 data.push_back(ptr);
74 ++tLength;
75 return tLength-1;
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
81{
82 // update table pointer but not delete previous
83 if(idx < tLength) {
84 if(ptr != data[idx]) { data[idx] = ptr; }
85 } else {
86 G4cout << "### G4EmDataHandler::UpdateTable fail for idx=" << idx
87 << " length=" << tLength << G4endl;
88 }
89}
90
91//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92
94{
95 size_t idx = i;
96 if(idx >= tLength) {
97 data.push_back(nullptr);
98 idx = tLength;
99 ++tLength;
100 }
101 data[idx] = G4PhysicsTableHelper::PreparePhysicsTable(data[idx]);
102 return data[idx];
103}
104
105//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106
108{
109 size_t idx = i;
110 // create new table only if index corresponds to the
111 // position in the vector
112 if(idx < tLength) {
113 if(ptr != data[idx]) {
114 CleanTable(idx);
115 data[idx] = ptr;
116 }
117 } else {
118 data.push_back(ptr);
119 idx = tLength;
120 ++tLength;
121 }
123 return data[idx];
124}
125
126//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127
129{
130 if(i < tLength && nullptr != data[i]) {
131 data[i]->clearAndDestroy();
132 delete data[i];
133 data[i] = nullptr;
134 }
135}
136
137//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138
140 const G4ParticleDefinition* part,
141 const G4String& fname,
142 G4bool ascii)
143{
144 G4bool yes = true;
145 if(nullptr != data[idx]) {
146 yes = data[idx]->StorePhysicsTable(fname, ascii);
147
148 if ( yes ) {
149 G4cout << "### Physics table is stored for "
150 << part->GetParticleName()
151 << " <" << fname << "> " << G4endl;
152 } else {
153 G4cout << "### Fail to store Physics Table for "
154 << part->GetParticleName()
155 << " <" << fname << "> " << G4endl;
156 }
157 }
158 return yes;
159}
160
161//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162
164 const G4ParticleDefinition* part,
165 const G4String& fname,
166 G4bool ascii, G4bool spline)
167{
168 G4PhysicsTable* table = Table(idx);
169 G4bool yes = G4PhysicsTableHelper::RetrievePhysicsTable(table, fname, ascii, spline);
171 if ( yes ) {
172 if (0 < param->Verbose()) {
173 G4cout << "### Physics table " << idx << " for "
174 << part->GetParticleName()
175 << " is retrieved from <" << fname << ">"
176 << G4endl;
177 }
178 } else if (1 < param->Verbose()) {
179 G4cout << "### Fail to retrieve physics table " << idx << " for "
180 << part->GetParticleName() << " from <"
181 << fname << ">" << G4endl;
182 }
183 return yes;
184}
185
186//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187
189{
190 masterProcess.push_back(ptr);
191}
192
193//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
194
196{
197 return (idx < masterProcess.size()) ? masterProcess[idx] : nullptr;
198}
199
200//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void SetMasterProcess(const G4VEmProcess *)
void CleanTable(size_t idx)
G4PhysicsTable * MakeTable(size_t idx)
G4bool RetrievePhysicsTable(size_t idx, const G4ParticleDefinition *part, const G4String &fname, G4bool ascii, G4bool spline)
void UpdateTable(G4PhysicsTable *, size_t idx)
const G4VEmProcess * GetMasterProcess(size_t idx) const
G4PhysicsTable * Table(size_t idx) const
size_t SetTable(G4PhysicsTable *)
G4EmDataHandler(size_t nTable)
G4bool StorePhysicsTable(size_t idx, const G4ParticleDefinition *part, const G4String &fname, G4bool ascii)
static G4EmParameters * Instance()
G4int Verbose() const
const G4String & GetParticleName() const
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
static G4bool RetrievePhysicsTable(G4PhysicsTable *physTable, const G4String &fileName, G4bool ascii, G4bool spline)