Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ElementData.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// Description: Data structure for cross sections, shell cross sections
32// isotope cross sections
33//
34// Author: V.Ivanchenko 10.03.2011
35//
36// Modifications:
37//
38//----------------------------------------------------------------------------
39//
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42
43#include "G4ElementData.hh"
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46
48{
49 name = "";
50 for(G4int i=0; i<maxNumElements; ++i) {
51 elmData[i] = nullptr;
52 elm2Data[i] = nullptr;
53 compLength[i] = 0;
54 }
55}
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
60{
61 for(G4int i=0; i<maxNumElements; ++i) {
62 delete elmData[i];
63 delete elm2Data[i];
64 size_t n = compLength[i];
65 //G4cout << "Z= " << i << " L= " << n << G4endl;
66 for(size_t j=0; j<n; ++j) {
67 //G4cout << "j= " << j << " " << (compData[i])[j] << G4endl;
68 delete (compData[i])[j];
69 }
70 }
71}
72
74{
75 if(Z < 1 || Z >= maxNumElements) {
76 G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
77 << " Z = " << Z << " is out of range!" << G4endl;
78 G4Exception("G4ElementData::InitialiseForElement()", "mat601",
79 FatalException, "Wrong data handling");
80 return;
81 }
82 if(elmData[Z]) { delete elmData[Z]; }
83 elmData[Z] = v;
84}
85
87{
88 if(Z < 1 || Z >= maxNumElements) {
89 G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
90 << " Z = " << Z << " is out of range!" << G4endl;
91 G4Exception("G4ElementData::InitialiseForElement()", "mat601",
92 FatalException, "Wrong data handling");
93 return;
94 }
95 if(elm2Data[Z]) { delete elm2Data[Z]; }
96 elm2Data[Z] = v;
97}
98
100{
101 if(Z < 1 || Z >= maxNumElements) {
102 G4cout << "G4ElementData::InitialiseForComponent ERROR for " << name
103 << " Z = " << Z << " is out of range!" << G4endl;
104 G4Exception("G4ElementData::InitialiseForComponent()", "mat602",
105 FatalException, "Wrong data handling");
106 return;
107 }
108
109 // reserve a new structure
110 size_t n = compLength[Z];
111 if(0 < n) {
112 for(size_t i=0; i<n; ++i) { delete (compData[Z])[i]; }
113 (compData[Z]).clear();
114 (compID[Z]).clear();
115 }
116 (compData[Z]).reserve(nComponents);
117 (compID[Z]).reserve(nComponents);
118}
119
120void
122{
123 if(Z < 1 || Z >= maxNumElements) {
124 G4cout << "G4ElementData::AddComponent ERROR for " << name
125 << " Z = " << Z << " is out of range!" << G4endl;
126 G4Exception("G4ElementData::AddComponent()", "mat603",
127 FatalException, "Wrong data handling");
128 return;
129 }
130 (compData[Z]).push_back(v);
131 (compID[Z]).push_back(id);
132 ++compLength[Z];
133}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
const G4int maxNumElements
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void InitialiseForComponent(G4int Z, G4int nComponents=0)
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)