Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 96794 2016-05-09 10:09:30Z 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] = nullptr;
53  elm2Data[i] = nullptr;
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  for(size_t j=0; j<n; ++j) {
68  //G4cout << "j= " << j << " " << (compData[i])[j] << G4endl;
69  delete (compData[i])[j];
70  }
71  }
72 }
73 
75 {
76  if(Z < 1 || Z >= maxNumElements) {
77  G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
78  << " Z = " << Z << " is out of range!" << G4endl;
79  G4Exception("G4ElementData::InitialiseForElement()", "mat601",
80  FatalException, "Wrong data handling");
81  return;
82  }
83  if(elmData[Z]) { delete elmData[Z]; }
84  elmData[Z] = v;
85 }
86 
88 {
89  if(Z < 1 || Z >= maxNumElements) {
90  G4cout << "G4ElementData::InitialiseForElement ERROR for " << name
91  << " Z = " << Z << " is out of range!" << G4endl;
92  G4Exception("G4ElementData::InitialiseForElement()", "mat601",
93  FatalException, "Wrong data handling");
94  return;
95  }
96  if(elm2Data[Z]) { delete elm2Data[Z]; }
97  elm2Data[Z] = v;
98 }
99 
101 {
102  if(Z < 1 || Z >= maxNumElements) {
103  G4cout << "G4ElementData::InitialiseForComponent ERROR for " << name
104  << " Z = " << Z << " is out of range!" << G4endl;
105  G4Exception("G4ElementData::InitialiseForComponent()", "mat602",
106  FatalException, "Wrong data handling");
107  return;
108  }
109 
110  // reserve a new structure
111  size_t n = compLength[Z];
112  if(0 < n) {
113  for(size_t i=0; i<n; ++i) { delete (compData[Z])[i]; }
114  (compData[Z]).clear();
115  (compID[Z]).clear();
116  }
117  (compData[Z]).reserve(nComponents);
118  (compID[Z]).reserve(nComponents);
119 }
120 
121 void
123 {
124  if(Z < 1 || Z >= maxNumElements) {
125  G4cout << "G4ElementData::AddComponent ERROR for " << name
126  << " Z = " << Z << " is out of range!" << G4endl;
127  G4Exception("G4ElementData::AddComponent()", "mat603",
128  FatalException, "Wrong data handling");
129  return;
130  }
131  (compData[Z]).push_back(v);
132  (compID[Z]).push_back(id);
133  ++compLength[Z];
134 }
const XML_Char * name
Definition: expat.h:151
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
int G4int
Definition: G4Types.hh:78
const G4int maxNumElements
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
G4GLOB_DLL std::ostream G4cout
const G4int n
tuple v
Definition: test.py:18
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void InitialiseForComponent(G4int Z, G4int nComponents=0)