Geant4-11
G4MaterialPropertiesTable.hh
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//
29//
30// class G4MaterialPropertiesTable
31//
32// Class description:
33//
34// A Material properties table is a hash table, with
35// key = property name, and value either G4double or
36// G4MaterialPropertyVector
37
38// File: G4MaterialPropertiesTable.hh
39// Version: 1.0
40// Created: 1996-02-08
41// Author: Juliet Armstrong
42// Updated: 2005-05-12 add SetGROUPVEL() by P. Gumplinger
43// 2002-11-05 add named material constants by P. Gumplinger
44// 1999-11-05 Migration from G4RWTPtrHashDictionary to STL
45// by John Allison
46// 1999-10-29 add method and class descriptors
47// 1997-03-25 by Peter Gumplinger
48// > cosmetics (only)
49//
51
52#ifndef G4MaterialPropertiesTable_h
53#define G4MaterialPropertiesTable_h 1
54
55#include "globals.hh"
58
59#include <vector>
60
62{
63 public:
66
67 void AddConstProperty(const G4String& key, G4double propertyValue,
68 G4bool createNewKey = false);
69 void AddConstProperty(const char* key, G4double propertyValue,
70 G4bool createNewKey = false);
71 // Add a new property to the table by giving a key-name and value
72
74 const G4String& key, const std::vector<G4double>& photonEnergies,
75 const std::vector<G4double>& propertyValues, G4bool createNewKey = false,
76 G4bool spline = false);
77 // Add a new property to the table by giving a key-name and
78 // vectors of values
79
81 const char* key, G4double* photonEnergies, G4double* propertyValues,
82 G4int numEntries, G4bool createNewKey = false, G4bool spline = false);
83 // Add a new property to the table by giving a key-name and the
84 // arrays x and y of size NumEntries.
85
86 void AddProperty(const G4String& key, G4MaterialPropertyVector* opv,
87 G4bool createNewKey = false);
88 void AddProperty(const char* key, G4MaterialPropertyVector* opv,
89 G4bool createNewKey = false);
90 // Add a new property to the table by giving a key-name and an
91 // already constructed G4MaterialPropertyVector.
92
93 void AddProperty(const G4String& key, const G4String& mat);
94 // Add a new property to the table by giving a key name and a material
95 // name. Properties are in namespace G4OpticalMaterialProperties
96 // Not possible to create a new key with this method.
97
98 void RemoveConstProperty(const G4String& key);
99 void RemoveConstProperty(const char* key);
100 // Remove a constant property from the table.
101
102 void RemoveProperty(const G4String& key);
103 void RemoveProperty(const char* key);
104 // Remove a property from the table.
105
106 G4double GetConstProperty(const G4String& key) const;
107 G4double GetConstProperty(const char* key) const;
108 G4double GetConstProperty(const G4int index) const;
109 // Get a constant property from the table
110 // It is an error to ask for a const property that the user has not defined.
111 // Check if it has been defined with ConstPropertyExists() first.
112
113 G4bool ConstPropertyExists(const G4String& key) const;
114 G4bool ConstPropertyExists(const char* key) const;
115 G4bool ConstPropertyExists(const G4int index) const;
116 // Return true if a const property has been defined by the user.
117 // Despite the name, this returns false for a const property in
118 // GetMaterialConstPropertyNames() but not defined by user.
119 // Use this method before calling GetConstProperty().
120
121 G4MaterialPropertyVector* GetProperty(const char* key) const;
123 G4MaterialPropertyVector* GetProperty(const G4int index) const;
124 // Get the property from the table corresponding to the key-index or index.
125 // nullptr is returned if the property has not been defined by the user.
126
127 void AddEntry(const G4String& key, G4double aPhotonEnergy,
128 G4double aPropertyValue);
129 void AddEntry(const char* key, G4double aPhotonEnergy,
130 G4double aPropertyValue);
131 // Add a new entry (pair of numbers) to the table for a given key.
132
133 G4int GetConstPropertyIndex(const G4String& key) const;
134 // Get the constant property index from the key-name
135 // It is an error to request the index of a non-existent key (key not
136 // present in fMaterialConstPropertyNames()).
137
138 G4int GetPropertyIndex(const G4String& key) const;
139 // Get the property index by the key-name.
140 // It is an error to request the index of a non-existent key (key not
141 // present in GetMaterialPropertyNames()).
142
143 void DumpTable() const;
144 // print the material properties and material constant properties
145
146 // the next four methods are used in persistency/GDML:
147 const std::vector<G4String>& GetMaterialPropertyNames() const
148 {
149 return fMatPropNames;
150 }
151 const std::vector<G4String>& GetMaterialConstPropertyNames() const
152 {
153 return fMatConstPropNames;
154 }
155 const std::vector<G4MaterialPropertyVector*>& GetProperties() const
156 {
157 return fMP;
158 }
159 const std::vector<std::pair<G4double, G4bool>>& GetConstProperties()
160 const
161 {
162 return fMCP;
163 }
164 // return references to the vectors of material (constant) properties.
165
166 private:
168 // Calculate the group velocity based on RINDEX
169
170 std::vector<G4MaterialPropertyVector*> fMP;
171 // Vector of pointer to material property vectors. All entries are
172 // initialized to nullptr. Pointer is not null when mat.prop. vector defined.
173 // Order of entries in MP defined by enum in G4MaterialPropertiesIndex.
174
175 std::vector<std::pair<G4double, G4bool>> fMCP;
176 // Vector of energy-independent (i.e., "constant") material properties. We
177 // need to keep track if a property is defined or not: the bool in the pair
178 // is 'true' if the property is defined.
179 // Order of entries in MCP defined by enum in G4MaterialPropertiesIndex.
180
181 std::vector<G4String> fMatPropNames;
182 std::vector<G4String> fMatConstPropNames;
183 // vectors of strings of property names
184};
185
186#endif /* G4MaterialPropertiesTable_h */
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4MaterialPropertyVector * CalculateGROUPVEL()
G4int GetConstPropertyIndex(const G4String &key) const
void AddConstProperty(const G4String &key, G4double propertyValue, G4bool createNewKey=false)
const std::vector< G4String > & GetMaterialConstPropertyNames() const
G4bool ConstPropertyExists(const G4String &key) const
void RemoveProperty(const G4String &key)
G4int GetPropertyIndex(const G4String &key) const
const std::vector< std::pair< G4double, G4bool > > & GetConstProperties() const
std::vector< std::pair< G4double, G4bool > > fMCP
const std::vector< G4MaterialPropertyVector * > & GetProperties() const
const std::vector< G4String > & GetMaterialPropertyNames() const
G4double GetConstProperty(const G4String &key) const
void AddEntry(const G4String &key, G4double aPhotonEnergy, G4double aPropertyValue)
G4MaterialPropertyVector * AddProperty(const G4String &key, const std::vector< G4double > &photonEnergies, const std::vector< G4double > &propertyValues, G4bool createNewKey=false, G4bool spline=false)
std::vector< G4MaterialPropertyVector * > fMP
std::vector< G4String > fMatConstPropNames
G4MaterialPropertyVector * GetProperty(const char *key) const
std::vector< G4String > fMatPropNames
void RemoveConstProperty(const G4String &key)