Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MoleculeTable.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/*
27 * G4MoleculeTable.cc
28 *
29 * Created on: 23 oct. 2013
30 * Author: kara
31 */
32
33#include "G4MoleculeTable.hh"
37
39
40//------------------------------------------------------------------------------
41
43 : fMoleculeDefTableMessenger(new G4MoleculeTableMessenger())
44{
45}
46
47//------------------------------------------------------------------------------
48
50= default;
51
52//------------------------------------------------------------------------------
53
59
60//------------------------------------------------------------------------------
61
66
67//------------------------------------------------------------------------------
68
71 double diffusion_coefficient)
72{
73 return new G4MoleculeDefinition(name, -1 /* mass*/,
74 diffusion_coefficient);
75}
76
77//------------------------------------------------------------------------------
78
81 bool mustExist)
82{
83 auto it = fMoleculeDefTable.find(name);
84 G4MoleculeDefinition* definition(nullptr);
85 if (it != fMoleculeDefTable.end())
86 {
87 definition = it->second;
88 }
89 else if(mustExist)
90 {
91 // exception
92 G4ExceptionDescription description;
93 description << "The molecule definition " << name
94 << " was NOT recorded in the table" << G4endl;
95 G4Exception("G4MoleculeTable::CreateMoleculeModel",
96 "MOLECULE_DEFINITION_NOT_CREATED",
98 description);
99 }
100 return definition;
101}
102
103//------------------------------------------------------------------------------
104
106G4MoleculeTable::GetConfiguration(const G4String& name, bool mustExist)
107{
108 G4MolecularConfiguration* species =
110
111 if(species == nullptr && mustExist)
112 {
113 // exception
114 G4ExceptionDescription description;
115 description << "The configuration " << name
116 << " was not recorded in the table" << G4endl;
117 G4Exception("G4MoleculeTable::GetConfiguration",
118 "CONF_NOT_CREATED",
120 description);
121 }
122
123 return species;
124}
125
126//------------------------------------------------------------------------------
127
136
137//------------------------------------------------------------------------------
138
140{
141
142 const G4String& name = moleculeDefinition->GetName();
143 auto it = fMoleculeDefTable.find(name);
144 if (it == fMoleculeDefTable.end())
145 {
146 fMoleculeDefTable[name] = moleculeDefinition;
147 }
148 else
149 {
150 // exception
151 G4ExceptionDescription description;
152 description << "The molecule definition " << name
153 << " was already recorded in the table" << G4endl;
154 G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
155 "DEFINITION_ALREADY_CREATED", FatalException, description);
156 }
157}
158
159//------------------------------------------------------------------------------
160
162{
163 auto it = fMoleculeDefTable.begin();
164
165 for(; it != fMoleculeDefTable.end() ; ++it)
166 {
168 }
169}
170
171//------------------------------------------------------------------------------
172
175 G4MoleculeDefinition* molDef)
176{
177 bool alreadyCreated(false);
178
179 G4MolecularConfiguration* molConf =
181 molDef,
182 alreadyCreated);
183
184 return molConf;
185}
186
187//------------------------------------------------------------------------------
188
191 G4MoleculeDefinition* molDef,
192 const G4String& configurationLabel,
193 int charge)
194{
195 bool alreadyCreated(false);
196
197 G4MolecularConfiguration* molConf =
199 molDef,
200 charge,
201 configurationLabel,
202 alreadyCreated);
203
204 return molConf;
205}
206
207//------------------------------------------------------------------------------
208
211 G4MoleculeDefinition* molDef,
212 int charge,
213 double diffusion_coefficient)
214{
215 bool alreadyCreated(false);
216
217 G4MolecularConfiguration* molConf =
219 molDef,
220 charge,
221 userIdentifier,
222 alreadyCreated);
223
224 if(diffusion_coefficient!=-1) // TODO
225 {
226 molConf->SetDiffusionCoefficient(diffusion_coefficient);
227 }
228 return molConf;
229}
230
231//------------------------------------------------------------------------------
232
235 const G4MoleculeDefinition* molDef,
236 const G4String& configurationLabel,
237 const G4ElectronOccupancy& eOcc)
238{
239 bool alreadyCreated(false);
240
241 G4MolecularConfiguration* molConf =
243 molDef,
244 configurationLabel,
245 eOcc,
246 alreadyCreated);
247
248 return molConf;
249}
250
251//------------------------------------------------------------------------------
252
257
258//------------------------------------------------------------------------------
259
264
265//------------------------------------------------------------------------------
266
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4MoleculeIterator< G4MolecularConfiguration > G4ConfigurationIterator
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
static std::map< G4String, G4MolecularConfiguration * > & GetUserIDTable()
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
const G4String & GetName() const
static G4MoleculeTable * GetMoleculeTable()
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)
G4MolecularConfiguration * CreateConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *molDef, const G4String &configurationLabel, const G4ElectronOccupancy &eOcc)
virtual ~G4MoleculeTable()
G4MoleculeDefinition * CreateMoleculeDefinition(const G4String &userIdentifier, double diffusion_coefficient)
G4MoleculeDefinition * GetMoleculeDefinition(const G4String &, bool mustExist=true)
void PrepareMolecularConfiguration()
void Insert(G4MoleculeDefinition *)
MoleculeDefTable fMoleculeDefTable
static G4MoleculeTable * Instance()
G4ConfigurationIterator GetConfigurationIterator()
static G4MoleculeTable * fpgMoleculeTable