Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
39 using 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 
120  fDynCharge = fMoleculeDefinition->GetNbElectrons()-fElectronOccupancy->GetTotalOccupancy();
121  fDynMass = fMoleculeDefinition->GetMass() ;
122 
123  fDynDiffusionCoefficient = fMoleculeDefinition->GetDiffusionCoefficient() ;
124  fDynVanDerVaalsRadius = fMoleculeDefinition->GetVanDerVaalsRadius() ;
125  fDynDecayTime = fMoleculeDefinition->GetDecayTime() ;
126 }
127 
129 {
130  if(fElectronOccupancy)
131  {
132  delete fElectronOccupancy;
133  fElectronOccupancy = 0;
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 
157 {
158  G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
159 
160  newElectronOccupancy.RemoveElectron(ExcitedLevel,1);
161  newElectronOccupancy.AddElectron(5,1);
162 
163  return ChangeConfiguration(newElectronOccupancy);
164 }
165 
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  {
239  fName = fMoleculeDefinition->GetName();
240  fName+= "^";
241  fName+= "{";
242  fName+= G4UIcommand::ConvertToString(fDynCharge);
243  fName+= "}";
244  }
245  return fName;
246 }
247 
249 {
250  return fMoleculeDefinition->GetAtomsNumber();
251 }
252 
254 {
255  return fElectronOccupancy->GetTotalOccupancy();
256 }
257 
259 {
260  G4cout<<"--------------Print electronic state of "<<GetName()<<"---------------"<<G4endl;
261  fElectronOccupancy->DumpInfo();
262  if(fElectronOccupancy==fMoleculeDefinition->GetGroundStateElectronOccupancy())
263  {
264  G4cout<<"At ground state"<<G4endl;
265  }
266  else
267  {
268  if(fMoleculeDefinition->GetDecayTable())
269  G4cout<<"Transition :"<<(fMoleculeDefinition->GetDecayTable())->GetExcitedState(fElectronOccupancy)<<G4endl;
270  }
271 }
272 
273 // added - to be transformed in a "Decay method"
274 const vector <const G4MolecularDecayChannel*>* G4MolecularConfiguration::GetDecayChannel() const
275 {
276  return fMoleculeDefinition-> GetDecayChannels(fElectronOccupancy);
277 }
278 
280 {
281  if(fMoleculeDefinition)
282  return fMoleculeDefinition->GetPDGEncoding();
283  else
284  G4Exception("G4Molecule::GetMoleculeID","",FatalErrorInArgument, "You should first enter a molecule defintion");
285 
286  return INT_MAX;
287 }