Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 << 25 // >> 26 // >> 27 // 26 ////////////////////////////////////////////// 28 //////////////////////////////////////////////////////////////////////// 27 // 29 // 28 // class G4MaterialPropertiesTable 30 // class G4MaterialPropertiesTable 29 // 31 // 30 // Class description: 32 // Class description: 31 // 33 // 32 // A Material properties table is a hash table << 34 // A Material properties table is a hash table, with 33 // key = property name, and value either G4dou 35 // key = property name, and value either G4double or 34 // G4MaterialPropertyVector 36 // G4MaterialPropertyVector 35 // << 37 36 // File: G4MaterialPropertiesTable.hh 38 // File: G4MaterialPropertiesTable.hh 37 // Version: 1.0 39 // Version: 1.0 38 // Created: 1996-02-08 40 // Created: 1996-02-08 39 // Author: Juliet Armstrong 41 // Author: Juliet Armstrong 40 // Updated: 2005-05-12 add SetGROUPVEL() b 42 // Updated: 2005-05-12 add SetGROUPVEL() by P. Gumplinger 41 // 2002-11-05 add named material 43 // 2002-11-05 add named material constants by P. Gumplinger 42 // 1999-11-05 Migration from G4RW 44 // 1999-11-05 Migration from G4RWTPtrHashDictionary to STL 43 // by John Allison 45 // by John Allison 44 // 1999-10-29 add method and clas 46 // 1999-10-29 add method and class descriptors 45 // 1997-03-25 by Peter Gumplinger 47 // 1997-03-25 by Peter Gumplinger 46 // > cosmetics (only) 48 // > cosmetics (only) 47 // 49 // 48 ////////////////////////////////////////////// 50 //////////////////////////////////////////////////////////////////////// 49 51 50 #ifndef G4MaterialPropertiesTable_h 52 #ifndef G4MaterialPropertiesTable_h 51 #define G4MaterialPropertiesTable_h 1 53 #define G4MaterialPropertiesTable_h 1 52 54 >> 55 ///////////// >> 56 // Includes >> 57 ///////////// >> 58 >> 59 #include <cmath> >> 60 #include <map> >> 61 #include "globals.hh" 53 #include "G4MaterialPropertiesIndex.hh" 62 #include "G4MaterialPropertiesIndex.hh" 54 #include "G4MaterialPropertyVector.hh" 63 #include "G4MaterialPropertyVector.hh" 55 #include "globals.hh" << 56 64 57 #include <vector> << 65 ///////////////////// >> 66 // Class Definition >> 67 ///////////////////// 58 68 59 class G4MaterialPropertiesTable 69 class G4MaterialPropertiesTable 60 { 70 { 61 public: << 71 public: // Without description 62 G4MaterialPropertiesTable(); << 72 63 virtual ~G4MaterialPropertiesTable(); << 73 G4MaterialPropertiesTable(); 64 << 74 virtual ~G4MaterialPropertiesTable(); 65 // Add a new property to the table by giving << 75 66 void AddConstProperty(const G4String& key, G << 76 public: // With description 67 void AddConstProperty(const char* key, G4dou << 77 68 << 78 inline void AddConstProperty(const G4String& key, 69 // Add a new property to the table by giving << 79 G4double PropertyValue); 70 // vectors of values << 80 inline void AddConstProperty(const char *key, 71 G4MaterialPropertyVector* AddProperty(const << 81 G4double PropertyValue); 72 const std::vector<G4double>& photonEnergie << 82 // Add a new property to the table by giving a key-name and value 73 G4bool createNewKey = false, G4bool spline << 83 74 << 84 G4MaterialPropertyVector* AddProperty(const G4String& key, 75 // Add a new property to the table by giving << 85 const std::vector<G4double>& photonEnergies, 76 // arrays x and y of size NumEntries. << 86 const std::vector<G4double>& propertyValues); 77 G4MaterialPropertyVector* AddProperty(const << 87 78 G4double* propertyValues, G4int numEntries << 88 G4MaterialPropertyVector* AddProperty(const char *key, 79 << 89 G4double *PhotonEnergies, 80 // Add a new property to the table by giving << 90 G4double *PropertyValues, 81 // already constructed G4MaterialPropertyVec << 91 G4int NumEntries); 82 void AddProperty(const G4String& key, G4Mate << 92 // Add a new property to the table by giving a key-name and the 83 void AddProperty(const char* key, G4Material << 93 // arrays x and y of size NumEntries. 84 << 94 85 // Add a new property to the table by giving << 95 void AddProperty(const G4String& key, G4MaterialPropertyVector* opv); 86 // name. Properties are in namespace G4Optic << 96 void AddProperty(const char *key, G4MaterialPropertyVector *opv); 87 // Not possible to create a new key with thi << 97 // Add a new property to the table by giving a key-name and an 88 void AddProperty(const G4String& key, const << 98 // already constructed G4MaterialPropertyVector. 89 << 99 90 // Remove a constant property from the table << 100 inline void RemoveConstProperty(const G4String& key); 91 void RemoveConstProperty(const G4String& key << 101 inline void RemoveConstProperty(const char *key); 92 void RemoveConstProperty(const char* key); << 102 // Remove a constant property from the table. 93 << 103 94 // Remove a property from the table. << 104 inline void RemoveProperty(const G4String& key); 95 void RemoveProperty(const G4String& key); << 105 inline void RemoveProperty(const char *key); 96 void RemoveProperty(const char* key); << 106 // Remove a property from the table. 97 << 107 98 // Get a constant property from the table << 108 G4double GetConstProperty(const G4String& key) const; 99 // It is an error to ask for a const propert << 109 G4double GetConstProperty(const char *key) const; 100 // Check if it has been defined with ConstP << 110 // Get the constant property from the table corresponding to the key-name 101 G4double GetConstProperty(const G4String& ke << 111 102 G4double GetConstProperty(const char* key) c << 112 G4double GetConstProperty(const G4int index) const; 103 G4double GetConstProperty(const G4int index) << 113 // Get the constant property from the table corresponding to the key-index 104 << 114 105 // Return true if a const property has been << 115 G4bool ConstPropertyExists(const G4String& key) const; 106 // Despite the name, this returns false for << 116 G4bool ConstPropertyExists(const char *key) const; 107 // GetMaterialConstPropertyNames() but not << 117 // Return true if a const property 'key' exists. 108 // Use this method before calling GetConstPr << 118 109 G4bool ConstPropertyExists(const G4String& k << 119 G4bool ConstPropertyExists(const G4int index) const; 110 G4bool ConstPropertyExists(const char* key) << 120 // Return true if a const property with key-index 'index' exists. 111 G4bool ConstPropertyExists(const G4int index << 121 112 << 122 G4MaterialPropertyVector* GetProperty(const char *key, 113 // Get the property from the table correspon << 123 G4bool warning=false); 114 // nullptr is returned if the property has n << 124 G4MaterialPropertyVector* GetProperty(const G4String& key, 115 G4MaterialPropertyVector* GetProperty(const << 125 G4bool warning=false); 116 G4MaterialPropertyVector* GetProperty(const << 126 // Get the property from the table corresponding to the key-name. 117 G4MaterialPropertyVector* GetProperty(const << 127 118 << 128 G4MaterialPropertyVector* GetProperty(const G4int index, 119 // Add a new entry (pair of numbers) to the << 129 G4bool warning=false); 120 void AddEntry(const G4String& key, G4double << 130 // Get the property from the table corresponding to the key-index. 121 void AddEntry(const char* key, G4double aPho << 131 122 << 132 void AddEntry(const G4String& key, G4double aPhotonEnergy, 123 // Get the constant property index from the << 133 G4double aPropertyValue); 124 // It is an error to request the index of a << 134 void AddEntry(const char *key, G4double aPhotonEnergy, 125 // present in fMaterialConstPropertyNames() << 135 G4double aPropertyValue); 126 G4int GetConstPropertyIndex(const G4String& << 136 // Add a new entry (pair of numbers) to the table for a given key. 127 << 137 128 // Get the property index by the key-name. << 138 G4int GetConstPropertyIndex(const G4String& key, 129 // It is an error to request the index of a << 139 G4bool warning=false) const; 130 // present in GetMaterialPropertyNames()). << 140 // Get the constant property index from the key-name 131 G4int GetPropertyIndex(const G4String& key) << 141 132 << 142 G4int GetPropertyIndex(const G4String& key, G4bool warning=false) const; 133 // print the material properties and materia << 143 // Get the property index by the key-name. 134 void DumpTable() const; << 144 135 << 145 std::vector<G4String> GetMaterialPropertyNames() const; 136 // the next four methods are used in persist << 146 std::vector<G4String> GetMaterialConstPropertyNames() const; 137 const std::vector<G4String>& GetMaterialProp << 147 138 const std::vector<G4String>& GetMaterialCons << 148 void DumpTable(); 139 // return references to the vectors of mater << 149 140 const std::vector<G4MaterialPropertyVector*> << 150 public: // without description 141 const std::vector<std::pair<G4double, G4bool << 151 142 << 152 std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >* 143 private: << 153 GetPropertiesMap(); 144 // Calculate the group velocity based on RIN << 154 std::map< G4String, G4double, std::less<G4String> >* 145 G4MaterialPropertyVector* CalculateGROUPVEL( << 155 GetPropertiesCMap(); 146 << 156 147 // Vector of pointer to material property ve << 157 const std::map<G4int, G4MaterialPropertyVector*, std::less<G4int> >* 148 // All entries are initialized to nullptr. << 158 GetPropertyMap() const { return &MP; } 149 // Order of entries in MP defined by enum in << 159 const std::map<G4int, G4double, std::less<G4int> >* 150 std::vector<G4MaterialPropertyVector*> fMP; << 160 GetConstPropertyMap() const { return &MCP; } 151 << 161 // Accessors required for persistency purposes 152 // Vector of energy-independent (i.e., "cons << 162 153 // need to keep track if a property is defin << 163 private: 154 // is 'true' if the property is defined. << 164 155 // Order of entries in MCP defined by enum i << 165 G4MaterialPropertyVector* CalculateGROUPVEL(); 156 std::vector<std::pair<G4double, G4bool>> fMC << 166 // Calculate the group velocity based on RINDEX >> 167 >> 168 G4MaterialPropertyVector* SetGROUPVEL(); >> 169 // Dummy method: will be obsolete from the next (version 11) release >> 170 >> 171 private: >> 172 >> 173 std::map<G4String, G4MaterialPropertyVector*, std::less<G4String> > MPT; >> 174 typedef std::map< G4String, G4MaterialPropertyVector*, >> 175 std::less<G4String> >::const_iterator MPTiterator; >> 176 >> 177 std::map< G4String, G4double, std::less<G4String> > MPTC; >> 178 typedef std::map< G4String, G4double, >> 179 std::less<G4String> >::const_iterator MPTCiterator; >> 180 // MPT and MPTC will be obsolete when associate public interfaces, >> 181 // GetPropertiesMap and GetPropertiesCMap are removed from the version 11. >> 182 >> 183 std::map<G4int, G4MaterialPropertyVector*, std::less<G4int> > MP; >> 184 typedef std::map< G4int, G4MaterialPropertyVector*, >> 185 std::less<G4int> >::const_iterator MPiterator; >> 186 >> 187 std::map< G4int, G4double, std::less<G4int> > MCP; >> 188 typedef std::map< G4int, G4double, >> 189 std::less<G4int> >::const_iterator MCPiterator; >> 190 //material property map and constant property map by index types >> 191 >> 192 std::vector<G4String> G4MaterialPropertyName; >> 193 std::vector<G4String> G4MaterialConstPropertyName; >> 194 // vectors of strings of property names 157 195 158 std::vector<G4String> fMatPropNames; // vec << 159 std::vector<G4String> fMatConstPropNames; / << 160 }; 196 }; >> 197 >> 198 ///////////////////// >> 199 // Inline definitions >> 200 ///////////////////// >> 201 >> 202 #include "G4MaterialPropertiesTable.icc" 161 203 162 #endif /* G4MaterialPropertiesTable_h */ 204 #endif /* G4MaterialPropertiesTable_h */ 163 205