Geant4_10
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 66872 2013-01-15 01:25:57Z japost $
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 
46 
49 {
50  if(!fgManager)
51  {
53  }
54 
55  return fgManager;
56 }
57 
59 {
60  G4MolecularConfigurationManager::MolecularConfigurationTable::iterator it1;
61  std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::iterator it2;
62 
63  for(it1 = fTable.begin() ; it1 != fTable.end() ; it1++)
64  {
65  for(it2=it1->second.begin(); it2!=it1->second.end(); it2++)
66  {
67  if(it2->second)
68  {
69  delete it2->second;
70  }
71  }
72  }
73 }
74 
75 //°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
76 // Static method in G4MolecularConfiguration
78 {
79  const G4ElectronOccupancy& elecOcc = *molDef->GetGroundStateElectronOccupancy();
80  if(GetManager()->fTable[molDef][elecOcc])
81  {
82  return GetManager()->fTable[molDef][elecOcc];
83  }
84  else
85  {
86  G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, elecOcc);
87  return newConf ;
88  }
89 }
90 
92  const G4ElectronOccupancy& elecOcc )
93 {
94  if(GetManager()->fTable[molDef][elecOcc])
95  {
96  return GetManager()->fTable[molDef][elecOcc];
97  }
98  else
99  {
100  G4MolecularConfiguration* newConf = new G4MolecularConfiguration(molDef, elecOcc);
101  return newConf ;
102  }
103 }
104 
106 {
107  if(fgManager) delete fgManager;
108  fgManager = 0;
109 }
110 
111 //°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
112 // G4MolecularConfiguration
114  const G4ElectronOccupancy& elecOcc)
115 {
116  fMoleculeDefinition = moleculeDef ;
117  fgManager->fTable[fMoleculeDefinition][elecOcc] = this;
118  std::map<G4ElectronOccupancy, G4MolecularConfiguration*, comparator>::iterator it ;
119  it = fgManager->fTable[moleculeDef].find(elecOcc);
120  fElectronOccupancy = &(it->first);
121 
122  fDynCharge = fMoleculeDefinition->GetNbElectrons()-fElectronOccupancy->GetTotalOccupancy();
123  fDynMass = fMoleculeDefinition->GetMass() ;
124 
125  fDynDiffusionCoefficient = fMoleculeDefinition->GetDiffusionCoefficient() ;
126  fDynVanDerVaalsRadius = fMoleculeDefinition->GetVanDerVaalsRadius() ;
127  fDynDecayTime = fMoleculeDefinition->GetDecayTime() ;
128 }
129 
131 {
132  if(fElectronOccupancy)
133  {
134  delete fElectronOccupancy;
135  fElectronOccupancy = 0;
136  }
137 }
138 
140 {
141  G4MolecularConfiguration* output = fgManager->fTable[fMoleculeDefinition][newElectronOccupancy] ;
142  if(! output)
143  {
144  output = new G4MolecularConfiguration(fMoleculeDefinition, newElectronOccupancy);
145  }
146  return output ;
147 }
148 
150 {
151  if (&right==this) return *this;
152  return *this;
153 }
154 
155 
159 {
160  G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
161 
162  newElectronOccupancy.RemoveElectron(ExcitedLevel,1);
163  newElectronOccupancy.AddElectron(5,1);
164 
165  return ChangeConfiguration(newElectronOccupancy);
166 }
167 
171 {
172  G4ElectronOccupancy newElectronOccupancy(*fElectronOccupancy);
173 
174  if(newElectronOccupancy.GetOccupancy(IonizedLevel) != 0)
175  {
176  newElectronOccupancy.RemoveElectron(IonizedLevel,1);
177  }
178  else
179  {
180  G4String errMsg = "There is no electron on the orbit " + G4UIcommand::ConvertToString(IonizedLevel) +
181  " you want to free. The molecule's name you want to ionized is "+ GetName();
182  G4Exception("G4Molecule::IonizeMolecule","",FatalErrorInArgument, errMsg);
183  PrintState();
184  }
185 
186  // PrintState();
187 
188  return ChangeConfiguration(newElectronOccupancy);
189 }
190 
192 {
193  G4ElectronOccupancy newElectronOccupancy(*fElectronOccupancy);
194  newElectronOccupancy.AddElectron(orbit, number);
195  return ChangeConfiguration(newElectronOccupancy);
196 }
197 
199 {
200  G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
201 
202  if(newElectronOccupancy.GetOccupancy(orbit) != 0)
203  {
204  newElectronOccupancy.RemoveElectron(orbit, number );
205  }
206  else
207  {
208  G4String errMsg = "There is already no electron into the orbit " + G4UIcommand::ConvertToString(orbit) +
209  " you want to free. The molecule's name is "+ GetName();
210  G4Exception("G4Molecule::RemoveElectron","",JustWarning, errMsg);
211  PrintState();
212  }
213 
214  return ChangeConfiguration(newElectronOccupancy);
215 }
216 
218 {
219  G4ElectronOccupancy newElectronOccupancy (*fElectronOccupancy);
220 
221  if(newElectronOccupancy . GetOccupancy(orbitToFree)>=1)
222  {
223  newElectronOccupancy . RemoveElectron(orbitToFree,1);
224  newElectronOccupancy . AddElectron(orbitToFill,1);
225  }
226  else
227  {
228  G4String errMsg = "There is no electron on the orbit " + G4UIcommand::ConvertToString(orbitToFree) +
229  " you want to free. The molecule's name is "+ GetName();
230  G4Exception("G4Molecule::MoveOneElectron","",FatalErrorInArgument, errMsg);
231  PrintState();
232  }
233 
234  return ChangeConfiguration(newElectronOccupancy);
235 }
236 
238 {
239  if(fName.isNull())
240  {
241  fName = fMoleculeDefinition->GetName();
242  fName+= "^";
243  fName+= "{";
244  fName+= G4UIcommand::ConvertToString(fDynCharge);
245  fName+= "}";
246  }
247  return fName;
248 }
249 
251 {
252  return fMoleculeDefinition->GetAtomsNumber();
253 }
254 
256 {
257  return fElectronOccupancy->GetTotalOccupancy();
258 }
259 
261 {
262  G4cout<<"--------------Print electronic state of "<<GetName()<<"---------------"<<G4endl;
263  fElectronOccupancy->DumpInfo();
264  if(fElectronOccupancy==fMoleculeDefinition->GetGroundStateElectronOccupancy())
265  {
266  G4cout<<"At ground state"<<G4endl;
267  }
268  else
269  {
270  if(fMoleculeDefinition->GetDecayTable())
271  G4cout<<"Transition :"<<(fMoleculeDefinition->GetDecayTable())->GetExcitedState(fElectronOccupancy)<<G4endl;
272  }
273 }
274 
275 // added - to be transformed in a "Decay method"
276 const vector <const G4MolecularDecayChannel*>* G4MolecularConfiguration::GetDecayChannel() const
277 {
278  return fMoleculeDefinition-> GetDecayChannels(fElectronOccupancy);
279 }
280 
282 {
283  if(fMoleculeDefinition)
284  return fMoleculeDefinition->GetPDGEncoding();
285  else
286  G4Exception("G4Molecule::GetMoleculeID","",FatalErrorInArgument, "You should first enter a molecule defintion");
287 
288  return INT_MAX;
289 }
const G4String & GetName() const
G4String fName
Definition: G4AttUtils.hh:55
G4MolecularConfiguration * ChangeConfiguration(const G4ElectronOccupancy &newElectronOccupancy)
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &electronOccupancy)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
const std::vector< const G4MolecularDecayChannel * > * GetDecayChannel() const
G4GLOB_DLL std::ostream G4cout
G4int GetOccupancy(G4int orbit) const
G4MolecularConfiguration * IonizeMolecule(G4int)
G4MolecularConfiguration * AddElectron(G4int orbit, G4int n=1)
G4MolecularConfiguration::G4MolecularConfigurationManager MolecularConfigurationManager
G4int AddElectron(G4int orbit, G4int number=1)
G4MolecularConfiguration * MoveOneElectron(G4int, G4int)
G4MolecularConfiguration & operator=(G4MolecularConfiguration &right)
static G4MolecularConfigurationManager * GetManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define INT_MAX
Definition: templates.hh:111
static G4ThreadLocal G4MolecularConfigurationManager * fgManager
G4MolecularConfiguration(const G4MoleculeDefinition *, const G4ElectronOccupancy &)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
const G4ElectronOccupancy * GetGroundStateElectronOccupancy() const
G4MolecularConfiguration * RemoveElectron(G4int, G4int number=1)
G4MolecularConfiguration * ExciteMolecule(G4int)
G4bool isNull() const
G4int RemoveElectron(G4int orbit, G4int number=1)