Geant4  10.02.p02
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"
35 #include "G4MoleculeDefinition.hh"
36 
38 
39 //------------------------------------------------------------------------------
40 
42 {
43 }
44 
45 //------------------------------------------------------------------------------
46 
48 {
49 }
50 
51 //------------------------------------------------------------------------------
52 
54 {
56  return fpgMoleculeTable;
57 }
58 
59 //------------------------------------------------------------------------------
60 
62 {
63  return Instance();
64 }
65 
66 //------------------------------------------------------------------------------
67 
70  double diffusion_coefficient)
71 {
72  // TODO
73 
74  MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
75  G4MoleculeDefinition* definition(0);
76  if (it == fMoleculeDefTable.end())
77  {
78  definition = new G4MoleculeDefinition(name, -1 /* mass*/,
79  diffusion_coefficient);
80  fMoleculeDefTable[name] = definition;
81  }
82  else
83  {
84  // exception
85  G4ExceptionDescription description;
86  description << "The molecule definition " << name
87  << " was already recorded in the table" << G4endl;
88  G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
89  "DEFINITION_ALREADY_CREATED", FatalException, description);
90  }
91  return definition;
92 }
93 
94 //------------------------------------------------------------------------------
95 
98  bool mustExist)
99 {
100  MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
101  G4MoleculeDefinition* definition(0);
102  if (it != fMoleculeDefTable.end())
103  {
104  definition = it->second;
105  }
106  else if(mustExist)
107  {
108  // exception
109  G4ExceptionDescription description;
110  description << "The molecule definition " << name
111  << " was NOT recorded in the table" << G4endl;
112  G4Exception("G4MoleculeTable::CreateMoleculeModel",
113  "MOLECULE_DEFINITION_NOT_CREATED",
115  description);
116  }
117  return definition;
118 }
119 
120 //------------------------------------------------------------------------------
121 
124 {
125  G4MolecularConfiguration* species =
127 
128  if(species == 0 && mustExist)
129  {
130  // exception
131  G4ExceptionDescription description;
132  description << "The configuration " << name
133  << " was not recorded in the table" << G4endl;
134  G4Exception("G4MoleculeTable::GetConfiguration",
135  "CONF_NOT_CREATED",
137  description);
138  }
139 
140  return species;
141 }
142 
143 //------------------------------------------------------------------------------
144 
147 {
148  G4MolecularConfiguration* species =
150 
151  return species;
152 }
153 
154 //------------------------------------------------------------------------------
155 
157 {
158 
159  const G4String& name = moleculeDefinition->GetName();
160  MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
161  if (it == fMoleculeDefTable.end())
162  {
163  fMoleculeDefTable[name] = moleculeDefinition;
164  }
165  else
166  {
167  // exception
168  G4ExceptionDescription description;
169  description << "The molecule definition " << name
170  << " was already recorded in the table" << G4endl;
171  G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
172  "DEFINITION_ALREADY_CREATED", FatalException, description);
173  }
174 }
175 
176 //------------------------------------------------------------------------------
177 
179 {
180  MoleculeDefTable::iterator it = fMoleculeDefTable.begin();
181 
182  for(; it != fMoleculeDefTable.end() ; ++it)
183  {
185  }
186 }
187 
188 //------------------------------------------------------------------------------
189 
192  G4MoleculeDefinition* molDef)
193 {
194  bool alreadyCreated(false);
195 
196  G4MolecularConfiguration* molConf =
198  molDef,
199  alreadyCreated);
200 
201  return molConf;
202 }
203 
204 //------------------------------------------------------------------------------
205 
208  G4MoleculeDefinition* molDef,
209  const G4String& configurationLabel,
210  int charge)
211 {
212  bool alreadyCreated(false);
213 
214  G4MolecularConfiguration* molConf =
216  molDef,
217  charge,
218  configurationLabel,
219  alreadyCreated);
220 
221  return molConf;
222 }
223 
224 //------------------------------------------------------------------------------
225 
228  G4MoleculeDefinition* molDef,
229  int charge,
230  double diffusion_coefficient)
231 {
232  bool alreadyCreated(false);
233 
234  G4MolecularConfiguration* molConf =
236  molDef,
237  charge,
238  userIdentifier,
239  alreadyCreated);
240 
241  if(diffusion_coefficient!=-1) // TODO
242  {
243  molConf->SetDiffusionCoefficient(diffusion_coefficient);
244  }
245  return molConf;
246 }
247 
248 //------------------------------------------------------------------------------
249 
252  const G4MoleculeDefinition* molDef,
253  const G4String& configurationLabel,
254  const G4ElectronOccupancy& eOcc)
255 {
256  bool alreadyCreated(false);
257 
258  G4MolecularConfiguration* molConf =
260  molDef,
261  configurationLabel,
262  eOcc,
263  alreadyCreated);
264 
265  return molConf;
266 }
267 
268 //------------------------------------------------------------------------------
269 
271 {
273 }
274 
276 {
278 }
279 
281 {
283 }
The pointer G4MolecularConfiguration will be shared by all the molecules having the same molecule def...
void Insert(G4MoleculeDefinition *)
G4MoleculeDefinition * GetMoleculeDefinition(const G4String &, bool mustExist=true)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String name
Definition: TRTMaterials.hh:40
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
int G4int
Definition: G4Types.hh:78
static std::map< G4String, G4MolecularConfiguration * > & GetUserIDTable()
static G4MoleculeTable * Instance()
void SetDiffusionCoefficient(G4double)
Sets the diffusion coefficient D of the molecule used in diffusion processes to calculate the mean sq...
static G4MoleculeTable * fpgMoleculeTable
G4ConfigurationIterator GetConfigurationIterator()
static G4MolecularConfiguration * GetOrCreateMolecularConfiguration(const G4MoleculeDefinition *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4MolecularConfiguration * CreateConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *molDef, const G4String &configurationLabel, const G4ElectronOccupancy &eOcc)
int GetNumberOfDefinedSpecies()
static G4MoleculeTable * GetMoleculeTable()
const G4String & GetName() const
MoleculeDefTable fMoleculeDefTable
#define G4endl
Definition: G4ios.hh:61
void PrepareMolecularConfiguration()
virtual ~G4MoleculeTable()
G4MoleculeIterator< G4MolecularConfiguration > G4ConfigurationIterator
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
G4MoleculeDefinition * CreateMoleculeDefinition(const G4String &userIdentifier, double diffusion_coefficient)
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)