Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MolecularConfiguration.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// $Id: G4MolecularConfiguration.cc 65022 2012-11-12 16:43:12Z gcosmo $
27//
28// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29//
30// History:
31// -----------
32// 10 Oct 2011 M.Karamitros created
33//
34// -------------------------------------------------------------------
35
37#include "G4UIcommand.hh"
38
39using namespace std;
40
41//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
42// G4MolecularConfigurationManager
44
47{
48 if(!fgManager)
49 {
51 }
52
53 return fgManager;
54}
55
57{
58 G4MolecularConfigurationManager::MolecularConfigurationTable::iterator it1;
59 std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::iterator it2;
60
61 for(it1 = fTable.begin() ; it1 != fTable.end() ; it1++)
62 {
63 for(it2=it1->second.begin(); it2!=it1->second.end(); it2++)
64 {
65 if(it2->second)
66 {
67 delete it2->second;
68 }
69 }
70 }
71}
72
73//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
74// Static method in G4MolecularConfiguration
76{
77 const G4ElectronOccupancy& elecOcc = *molDef->GetGroundStateElectronOccupancy();
78 if(GetManager()->fTable[molDef][elecOcc])
79 {
80 return GetManager()->fTable[molDef][elecOcc];
81 }
82 else
83 {
84 G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, elecOcc);
85 return newConf ;
86 }
87}
88
90 const G4ElectronOccupancy& elecOcc )
91{
92 if(GetManager()->fTable[molDef][elecOcc])
93 {
94 return GetManager()->fTable[molDef][elecOcc];
95 }
96 else
97 {
98 G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, elecOcc);
99 return newConf ;
100 }
101}
102
104{
105 if(fgManager) delete fgManager;
106 fgManager = 0;
107}
108
109//°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
110// G4MolecularConfiguration
112 const G4ElectronOccupancy& elecOcc)
113{
114 fMoleculeDefinition = moleculeDef ;
115 fgManager->fTable[fMoleculeDefinition][elecOcc] = this;
116 std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::iterator it ;
117 it = fgManager->fTable[moleculeDef].find(elecOcc);
118 fElectronOccupancy = &(it->first);
119
122
126}
127
129{
131 {
132 delete fElectronOccupancy;
134 }
135}
136
138{
139 G4MolecularConfiguration* output = fgManager->fTable[fMoleculeDefinition][newElectronOccupancy] ;
140 if(! output)
141 {
142 output = new G4MolecularConfiguration(fMoleculeDefinition, newElectronOccupancy);
143 }
144 return output ;
145}
146
148{
149 if (&right==this) return *this;
150 return *this;
151}
152
153
154/** Method used in Geant4-DNA to excite water molecules
155 */
157{
158 G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
159
160 newElectronOccupancy.RemoveElectron(ExcitedLevel,1);
161 newElectronOccupancy.AddElectron(5,1);
162
163 return ChangeConfiguration(newElectronOccupancy);
164}
165
166/** Method used in Geant4-DNA to ionize water molecules
167 */
169{
170 G4ElectronOccupancy newElectronOccupancy(*fElectronOccupancy);
171
172 if(newElectronOccupancy.GetOccupancy(IonizedLevel) != 0)
173 {
174 newElectronOccupancy.RemoveElectron(IonizedLevel,1);
175 }
176 else
177 {
178 G4String errMsg = "There is no electron on the orbit " + G4UIcommand::ConvertToString(IonizedLevel) +
179 " you want to free. The molecule's name you want to ionized is "+ GetName();
180 G4Exception("G4Molecule::IonizeMolecule","",FatalErrorInArgument, errMsg);
181 PrintState();
182 }
183
184 // PrintState();
185
186 return ChangeConfiguration(newElectronOccupancy);
187}
188
190{
191 G4ElectronOccupancy newElectronOccupancy(*fElectronOccupancy);
192 newElectronOccupancy.AddElectron(orbit, number);
193 return ChangeConfiguration(newElectronOccupancy);
194}
195
197{
198 G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
199
200 if(newElectronOccupancy.GetOccupancy(orbit) != 0)
201 {
202 newElectronOccupancy.RemoveElectron(orbit, number );
203 }
204 else
205 {
206 G4String errMsg = "There is already no electron into the orbit " + G4UIcommand::ConvertToString(orbit) +
207 " you want to free. The molecule's name is "+ GetName();
208 G4Exception("G4Molecule::RemoveElectron","",JustWarning, errMsg);
209 PrintState();
210 }
211
212 return ChangeConfiguration(newElectronOccupancy);
213}
214
216{
217 G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
218
219 if(newElectronOccupancy . GetOccupancy(orbitToFree)>=1)
220 {
221 newElectronOccupancy . RemoveElectron(orbitToFree,1);
222 newElectronOccupancy . AddElectron(orbitToFill,1);
223 }
224 else
225 {
226 G4String errMsg = "There is no electron on the orbit " + G4UIcommand::ConvertToString(orbitToFree) +
227 " you want to free. The molecule's name is "+ GetName();
228 G4Exception("G4Molecule::MoveOneElectron","",FatalErrorInArgument, errMsg);
229 PrintState();
230 }
231
232 return ChangeConfiguration(newElectronOccupancy);
233}
234
236{
237 if(fName.isNull())
238 {
240 fName+= "^";
241 fName+= "{";
243 fName+= "}";
244 }
245 return fName;
246}
247
249{
251}
252
254{
256}
257
259{
260 G4cout<<"--------------Print electronic state of "<<GetName()<<"---------------"<<G4endl;
263 {
264 G4cout<<"At ground state"<<G4endl;
265 }
266 else
267 {
269 G4cout<<"Transition :"<<(fMoleculeDefinition->GetDecayTable())->GetExcitedState(fElectronOccupancy)<<G4endl;
270 }
271}
272
273// added - to be transformed in a "Decay method"
274const vector <const G4MolecularDecayChannel*>* G4MolecularConfiguration::GetDecayChannel() const
275{
276 return fMoleculeDefinition-> GetDecayChannels(fElectronOccupancy);
277}
278
280{
283 else
284 G4Exception("G4Molecule::GetMoleculeID","",FatalErrorInArgument, "You should first enter a molecule defintion");
285
286 return INT_MAX;
287}
@ JustWarning
@ FatalErrorInArgument
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4int GetTotalOccupancy() const
G4int AddElectron(G4int orbit, G4int number=1)
G4int RemoveElectron(G4int orbit, G4int number=1)
G4int GetOccupancy(G4int orbit) const
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
static G4MolecularConfigurationManager * GetManager()
const G4String & GetName() const
const G4ElectronOccupancy * fElectronOccupancy
static G4MolecularConfigurationManager * fgManager
G4MolecularConfiguration * ChangeConfiguration(const G4ElectronOccupancy &newElectronOccupancy)
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &electronOccupancy)
G4MolecularConfiguration & operator=(G4MolecularConfiguration &right)
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &)
G4MolecularConfiguration * IonizeMolecule(G4int)
const G4MoleculeDefinition * fMoleculeDefinition
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
G4MolecularConfiguration * ExciteMolecule(G4int)
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
const G4String & GetName() const
G4double GetVanDerVaalsRadius() const
G4double GetDecayTime() const
const G4MolecularDecayTable * GetDecayTable() const
G4double GetDiffusionCoefficient() const
G4bool isNull() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define INT_MAX
Definition: templates.hh:111