Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 //std::cout << "G4EmDataHandler::~G4EmDataHandler "
62 // << tLength << " " << this << std::endl;
63 for(size_t i=0; i<tLength; ++i) { CleanTable(i); }
64}
65
66//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67
69{
70 data.push_back(ptr);
71 ++tLength;
72 return tLength-1;
73}
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
78{
79 G4PhysicsTable* table = nullptr;
80 // create new table only if index corresponds to the
81 // position in the vector
82 if(i <= tLength) {
83 if(i < tLength) { table = data[i]; }
85 if(i == tLength) {
86 data.push_back(table);
87 ++tLength;
88 } else { data[i] = table; }
89 }
90 return table;
91}
92
93//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94
96{
97 //std::cout << i << " " << data[i] << std::endl;
98 if(i < tLength && data[i]) {
99 data[i]->clearAndDestroy();
100 delete data[i];
101 data[i] = nullptr;
102 }
103}
104
105//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106
108 const G4ParticleDefinition* part,
109 const G4String& fname,
110 G4bool ascii)
111{
112 G4bool yes = true;
113 if(data[idx]) {
114 yes = data[idx]->StorePhysicsTable(fname, ascii);
115
116 if ( yes ) {
117 G4cout << "Physics table is stored for "
118 << part->GetParticleName()
119 << " <" << fname << "> " << G4endl;
120 } else {
121 G4cout << "Fail to store Physics Table for "
122 << part->GetParticleName()
123 << " <" << fname << "> " << G4endl;
124 }
125 }
126 return yes;
127}
128
129//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130
132 const G4ParticleDefinition* part,
133 const G4String& fname,
134 G4bool ascii)
135{
136 G4bool yes =
137 G4PhysicsTableHelper::RetrievePhysicsTable(data[idx], fname, ascii);
139 if ( yes ) {
140 if (0 < param->Verbose()) {
141 G4cout << "Physics table " << idx << " for "
142 << part->GetParticleName()
143 << " is retrieved from <" << fname << ">"
144 << G4endl;
145 }
146 if(param->Spline()) {
147 G4PhysicsTable* table = data[idx];
148 size_t n = table->length();
149 for(size_t i=0; i<n; ++i) {
150 if((*table)[i]) { (*table)[i]->SetSpline(true); }
151 }
152 }
153 } else if (1 < param->Verbose()) {
154 G4cout << "Fail to retrieve physics table " << idx << " for "
155 << part->GetParticleName() << " from <"
156 << fname << ">" << G4endl;
157 }
158 return yes;
159}
160
161//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162
164{
165 masterProcess.push_back(ptr);
166}
167
168//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169
171{
172 return (idx < masterProcess.size()) ? masterProcess[idx] : nullptr;
173}
174
175//....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)
const G4VEmProcess * GetMasterProcess(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
G4bool Spline() const
const G4String & GetParticleName() const
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
static G4bool RetrievePhysicsTable(G4PhysicsTable *physTable, const G4String &fileName, G4bool ascii)
std::size_t length() const