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 /* 26 /* 27 * G4MoleculeTable.cc 27 * G4MoleculeTable.cc 28 * 28 * 29 * Created on: 23 oct. 2013 29 * Created on: 23 oct. 2013 30 * Author: kara 30 * Author: kara 31 */ 31 */ 32 32 33 #include "G4MoleculeTable.hh" 33 #include "G4MoleculeTable.hh" 34 #include "G4MolecularConfiguration.hh" 34 #include "G4MolecularConfiguration.hh" 35 #include "G4MoleculeDefinition.hh" 35 #include "G4MoleculeDefinition.hh" 36 #include "G4MoleculeTableMessenger.hh" 36 #include "G4MoleculeTableMessenger.hh" 37 37 38 G4MoleculeTable* G4MoleculeTable::fpgMoleculeT << 38 G4MoleculeTable* G4MoleculeTable::fpgMoleculeTable(0); 39 39 40 //-------------------------------------------- 40 //------------------------------------------------------------------------------ 41 41 42 G4MoleculeTable::G4MoleculeTable() 42 G4MoleculeTable::G4MoleculeTable() 43 : fMoleculeDefTableMessenger(new G4MoleculeT 43 : fMoleculeDefTableMessenger(new G4MoleculeTableMessenger()) 44 { 44 { 45 } 45 } 46 46 47 //-------------------------------------------- 47 //------------------------------------------------------------------------------ 48 48 49 G4MoleculeTable::~G4MoleculeTable() 49 G4MoleculeTable::~G4MoleculeTable() 50 = default; << 50 { >> 51 } 51 52 52 //-------------------------------------------- 53 //------------------------------------------------------------------------------ 53 54 54 G4MoleculeTable* G4MoleculeTable::Instance() 55 G4MoleculeTable* G4MoleculeTable::Instance() 55 { 56 { 56 if (fpgMoleculeTable == nullptr) fpgMolecule << 57 if (!fpgMoleculeTable) fpgMoleculeTable = new G4MoleculeTable; 57 return fpgMoleculeTable; 58 return fpgMoleculeTable; 58 } 59 } 59 60 60 //-------------------------------------------- 61 //------------------------------------------------------------------------------ 61 62 62 G4MoleculeTable* G4MoleculeTable::GetMoleculeT 63 G4MoleculeTable* G4MoleculeTable::GetMoleculeTable() 63 { 64 { 64 return Instance(); 65 return Instance(); 65 } 66 } 66 67 67 //-------------------------------------------- 68 //------------------------------------------------------------------------------ 68 69 69 G4MoleculeDefinition* 70 G4MoleculeDefinition* 70 G4MoleculeTable::CreateMoleculeDefinition(cons 71 G4MoleculeTable::CreateMoleculeDefinition(const G4String& name, 71 doub 72 double diffusion_coefficient) 72 { 73 { 73 return new G4MoleculeDefinition(name, -1 /* 74 return new G4MoleculeDefinition(name, -1 /* mass*/, 74 diffusion_co 75 diffusion_coefficient); 75 } 76 } 76 77 77 //-------------------------------------------- 78 //------------------------------------------------------------------------------ 78 79 79 G4MoleculeDefinition* 80 G4MoleculeDefinition* 80 G4MoleculeTable::GetMoleculeDefinition(const G 81 G4MoleculeTable::GetMoleculeDefinition(const G4String& name, 81 bool mu 82 bool mustExist) 82 { 83 { 83 auto it = fMoleculeDefTable.find(name); << 84 MoleculeDefTable::iterator it = fMoleculeDefTable.find(name); 84 G4MoleculeDefinition* definition(nullptr); << 85 G4MoleculeDefinition* definition(0); 85 if (it != fMoleculeDefTable.end()) 86 if (it != fMoleculeDefTable.end()) 86 { 87 { 87 definition = it->second; 88 definition = it->second; 88 } 89 } 89 else if(mustExist) 90 else if(mustExist) 90 { 91 { 91 // exception 92 // exception 92 G4ExceptionDescription description; 93 G4ExceptionDescription description; 93 description << "The molecule definition " 94 description << "The molecule definition " << name 94 << " was NOT recorded in the t 95 << " was NOT recorded in the table" << G4endl; 95 G4Exception("G4MoleculeTable::CreateMolecu 96 G4Exception("G4MoleculeTable::CreateMoleculeModel", 96 "MOLECULE_DEFINITION_NOT_CREAT 97 "MOLECULE_DEFINITION_NOT_CREATED", 97 FatalException, 98 FatalException, 98 description); 99 description); 99 } 100 } 100 return definition; 101 return definition; 101 } 102 } 102 103 103 //-------------------------------------------- 104 //------------------------------------------------------------------------------ 104 105 105 G4MolecularConfiguration* 106 G4MolecularConfiguration* 106 G4MoleculeTable::GetConfiguration(const G4Stri 107 G4MoleculeTable::GetConfiguration(const G4String& name, bool mustExist) 107 { 108 { 108 G4MolecularConfiguration* species = 109 G4MolecularConfiguration* species = 109 G4MolecularConfiguration::GetMolecularCo 110 G4MolecularConfiguration::GetMolecularConfiguration(name); 110 111 111 if(species == nullptr && mustExist) << 112 if(species == 0 && mustExist) 112 { 113 { 113 // exception 114 // exception 114 G4ExceptionDescription description; 115 G4ExceptionDescription description; 115 description << "The configuration " << nam 116 description << "The configuration " << name 116 << " was not recorded in the t 117 << " was not recorded in the table" << G4endl; 117 G4Exception("G4MoleculeTable::GetConfigura 118 G4Exception("G4MoleculeTable::GetConfiguration", 118 "CONF_NOT_CREATED", 119 "CONF_NOT_CREATED", 119 FatalException, 120 FatalException, 120 description); 121 description); 121 } 122 } 122 123 123 return species; 124 return species; 124 } 125 } 125 126 126 //-------------------------------------------- 127 //------------------------------------------------------------------------------ 127 128 128 G4MolecularConfiguration* 129 G4MolecularConfiguration* 129 G4MoleculeTable::GetConfiguration(G4int id) 130 G4MoleculeTable::GetConfiguration(G4int id) 130 { 131 { 131 G4MolecularConfiguration* species = 132 G4MolecularConfiguration* species = 132 G4MolecularConfiguration::GetMolecular 133 G4MolecularConfiguration::GetMolecularConfiguration(id); 133 134 134 return species; 135 return species; 135 } 136 } 136 137 137 //-------------------------------------------- 138 //------------------------------------------------------------------------------ 138 139 139 void G4MoleculeTable::Insert(G4MoleculeDefinit 140 void G4MoleculeTable::Insert(G4MoleculeDefinition* moleculeDefinition) 140 { 141 { 141 142 142 const G4String& name = moleculeDefinition->G 143 const G4String& name = moleculeDefinition->GetName(); 143 auto it = fMoleculeDefTable.find(name); << 144 MoleculeDefTable::iterator it = fMoleculeDefTable.find(name); 144 if (it == fMoleculeDefTable.end()) 145 if (it == fMoleculeDefTable.end()) 145 { 146 { 146 fMoleculeDefTable[name] = moleculeDefiniti 147 fMoleculeDefTable[name] = moleculeDefinition; 147 } 148 } 148 else 149 else 149 { 150 { 150 // exception 151 // exception 151 G4ExceptionDescription description; 152 G4ExceptionDescription description; 152 description << "The molecule definition " 153 description << "The molecule definition " << name 153 << " was already recorded in t 154 << " was already recorded in the table" << G4endl; 154 G4Exception("G4MoleculeTable::CreateMolecu 155 G4Exception("G4MoleculeTable::CreateMoleculeDefinition", 155 "DEFINITION_ALREADY_CREATED", 156 "DEFINITION_ALREADY_CREATED", FatalException, description); 156 } 157 } 157 } 158 } 158 159 159 //-------------------------------------------- 160 //------------------------------------------------------------------------------ 160 161 161 void G4MoleculeTable::PrepareMolecularConfigur 162 void G4MoleculeTable::PrepareMolecularConfiguration() 162 { 163 { 163 auto it = fMoleculeDefTable.begin(); << 164 MoleculeDefTable::iterator it = fMoleculeDefTable.begin(); 164 165 165 for(; it != fMoleculeDefTable.end() ; ++it) 166 for(; it != fMoleculeDefTable.end() ; ++it) 166 { 167 { 167 G4MolecularConfiguration::GetOrCreateMolec 168 G4MolecularConfiguration::GetOrCreateMolecularConfiguration(it->second); 168 } 169 } 169 } 170 } 170 171 171 //-------------------------------------------- 172 //------------------------------------------------------------------------------ 172 173 173 G4MolecularConfiguration* 174 G4MolecularConfiguration* 174 G4MoleculeTable::CreateConfiguration(const G4S 175 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier, 175 G4Molecul 176 G4MoleculeDefinition* molDef) 176 { 177 { 177 bool alreadyCreated(false); 178 bool alreadyCreated(false); 178 179 179 G4MolecularConfiguration* molConf = 180 G4MolecularConfiguration* molConf = 180 G4MolecularConfiguration::CreateMolecula 181 G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier, 181 182 molDef, 182 183 alreadyCreated); 183 184 184 return molConf; 185 return molConf; 185 } 186 } 186 187 187 //-------------------------------------------- 188 //------------------------------------------------------------------------------ 188 189 189 G4MolecularConfiguration* 190 G4MolecularConfiguration* 190 G4MoleculeTable::CreateConfiguration(const G4S 191 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier, 191 G4Molecul 192 G4MoleculeDefinition* molDef, 192 const G4S 193 const G4String& configurationLabel, 193 int charg 194 int charge) 194 { 195 { 195 bool alreadyCreated(false); 196 bool alreadyCreated(false); 196 197 197 G4MolecularConfiguration* molConf = 198 G4MolecularConfiguration* molConf = 198 G4MolecularConfiguration::CreateMolecula 199 G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier, 199 200 molDef, 200 201 charge, 201 202 configurationLabel, 202 203 alreadyCreated); 203 204 204 return molConf; 205 return molConf; 205 } 206 } 206 207 207 //-------------------------------------------- 208 //------------------------------------------------------------------------------ 208 209 209 G4MolecularConfiguration* 210 G4MolecularConfiguration* 210 G4MoleculeTable::CreateConfiguration(const G4S 211 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier, 211 G4Molecul 212 G4MoleculeDefinition* molDef, 212 int charg 213 int charge, 213 double di 214 double diffusion_coefficient) 214 { 215 { 215 bool alreadyCreated(false); 216 bool alreadyCreated(false); 216 217 217 G4MolecularConfiguration* molConf = 218 G4MolecularConfiguration* molConf = 218 G4MolecularConfiguration::CreateMolecu 219 G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier, 219 220 molDef, 220 221 charge, 221 222 userIdentifier, 222 223 alreadyCreated); 223 224 224 if(diffusion_coefficient!=-1) // TODO 225 if(diffusion_coefficient!=-1) // TODO 225 { 226 { 226 molConf->SetDiffusionCoefficient(diffusion 227 molConf->SetDiffusionCoefficient(diffusion_coefficient); 227 } 228 } 228 return molConf; 229 return molConf; 229 } 230 } 230 231 231 //-------------------------------------------- 232 //------------------------------------------------------------------------------ 232 233 233 G4MolecularConfiguration* 234 G4MolecularConfiguration* 234 G4MoleculeTable::CreateConfiguration(const G4S 235 G4MoleculeTable::CreateConfiguration(const G4String& userIdentifier, 235 const G4M 236 const G4MoleculeDefinition* molDef, 236 const G4S 237 const G4String& configurationLabel, 237 const G4E 238 const G4ElectronOccupancy& eOcc) 238 { 239 { 239 bool alreadyCreated(false); 240 bool alreadyCreated(false); 240 241 241 G4MolecularConfiguration* molConf = 242 G4MolecularConfiguration* molConf = 242 G4MolecularConfiguration::CreateMolecula 243 G4MolecularConfiguration::CreateMolecularConfiguration(userIdentifier, 243 244 molDef, 244 245 configurationLabel, 245 246 eOcc, 246 247 alreadyCreated); 247 248 248 return molConf; 249 return molConf; 249 } 250 } 250 251 251 //-------------------------------------------- 252 //------------------------------------------------------------------------------ 252 253 253 void G4MoleculeTable::Finalize() 254 void G4MoleculeTable::Finalize() 254 { 255 { 255 G4MolecularConfiguration::FinalizeAll(); 256 G4MolecularConfiguration::FinalizeAll(); 256 } 257 } 257 258 258 //-------------------------------------------- 259 //------------------------------------------------------------------------------ 259 260 260 G4ConfigurationIterator G4MoleculeTable::GetCo 261 G4ConfigurationIterator G4MoleculeTable::GetConfigurationIterator() 261 { 262 { 262 return G4ConfigurationIterator(G4MolecularCo 263 return G4ConfigurationIterator(G4MolecularConfiguration::GetUserIDTable()); 263 } 264 } 264 265 265 //-------------------------------------------- 266 //------------------------------------------------------------------------------ 266 267 267 int G4MoleculeTable::GetNumberOfDefinedSpecies 268 int G4MoleculeTable::GetNumberOfDefinedSpecies() 268 { 269 { 269 return G4MolecularConfiguration::GetNumberOf 270 return G4MolecularConfiguration::GetNumberOfSpecies(); 270 } 271 } 271 272