Geant4  10.01.p01
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 // $Id: G4ElementData.cc 83419 2014-08-21 15:31:56Z gcosmo $
27 //
28 //---------------------------------------------------------------------------
29 //
30 // GEANT4 Class file
31 //
32 // Description: Data structure for cross sections, shell cross sections
33 // isotope cross sections
34 //
35 // Author: V.Ivanchenko 10.03.2011
36 //
37 // Modifications:
38 //
39 //----------------------------------------------------------------------------
40 //
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
44 #include "G4ElementData.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
49 {
50  name = "";
51  for(G4int i=0; i<maxNumElements; ++i) {
52  elmData[i] = 0;
53  elm2Data[i] = 0;
54  compLength[i] = 0;
55  }
56 }
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 {
62  for(G4int i=0; i<maxNumElements; ++i) {
63  delete elmData[i];
64  delete elm2Data[i];
65  size_t n = compLength[i];
66  //G4cout << "Z= " << i << " L= " << n << G4endl;
67  if(n > 0) {
68  for(size_t j=0; j<n; ++j) {
69  //G4cout << "j= " << j << " " << (compData[i])[j] << G4endl;
70  delete (compData[i])[j];
71  }
72  }
73  }
74 }
75 
77 {
78  if(Z < 1 || Z >= maxNumElements) {
79  G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
80  << " Z = " << Z << " is out of range!" << G4endl;
81  G4Exception("G4ElementData::InitialiseForElement()", "mat601",
82  FatalException, "Wrong data handling");
83  return;
84  }
85  if(elmData[Z]) { delete elmData[Z]; }
86  elmData[Z] = v;
87 }
88 
90 {
91  if(Z < 1 || Z >= maxNumElements) {
92  G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
93  << " Z = " << Z << " is out of range!" << G4endl;
94  G4Exception("G4ElementData::InitialiseForElement()", "mat601",
95  FatalException, "Wrong data handling");
96  return;
97  }
98  if(elm2Data[Z]) { delete elm2Data[Z]; }
99  elm2Data[Z] = v;
100 }
101 
103 {
104  if(Z < 1 || Z >= maxNumElements) {
105  G4cout << "G4ElementData::InitialiseForComponent ERROR for " << name
106  << " Z = " << Z << " is out of range!" << G4endl;
107  G4Exception("G4ElementData::InitialiseForComponent()", "mat602",
108  FatalException, "Wrong data handling");
109  return;
110  }
111 
112  // reserve a new structure
113  size_t n = compLength[Z];
114  if(0 < n) {
115  for(size_t i=0; i<n; ++i) { delete (compData[Z])[i]; }
116  (compData[Z]).clear();
117  (compID[Z]).clear();
118  }
119  (compData[Z]).reserve(nComponents);
120  (compID[Z]).reserve(nComponents);
121 }
122 
123 void
125 {
126  if(Z < 1 || Z >= maxNumElements) {
127  G4cout << "G4ElementData::AddComponent ERROR for " << name
128  << " Z = " << Z << " is out of range!" << G4endl;
129  G4Exception("G4ElementData::AddComponent()", "mat603",
130  FatalException, "Wrong data handling");
131  return;
132  }
133  (compData[Z]).push_back(v);
134  (compID[Z]).push_back(id);
135  ++compLength[Z];
136 }
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
std::vector< G4PhysicsVector * > compData[maxNumElements]
G4int nComponents
Definition: TRTMaterials.hh:41
int G4int
Definition: G4Types.hh:78
const G4int maxNumElements
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
G4GLOB_DLL std::ostream G4cout
size_t compLength[maxNumElements]
G4PhysicsVector * elmData[maxNumElements]
std::vector< G4int > compID[maxNumElements]
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4Physics2DVector * elm2Data[maxNumElements]
#define G4endl
Definition: G4ios.hh:61
void InitialiseForComponent(G4int Z, G4int nComponents=0)