Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MoleculeDefinition.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// ----------------------------------------------------------------------
28// GEANT 4 class implementation file
29//
30// 21 Oct 2009 first implementation by A. Mantero and M.Karamitros
31// Based on prototype of A.Mantero
32// **********************************************************************
33
36#include "G4MoleculeTable.hh"
37#include "G4Serialize.hh"
38
39using namespace std;
40
41// -----------------------------------------------------------------------------
42// ### MoleculeDefinition ###
43// -----------------------------------------------------------------------------
44
46 G4double mass,
47 G4double diffCoeff,
48 G4int charge,
49 G4int electronicLevels,
50 G4double radius,
51 G4int atomsNumber,
52 G4double lifetime,
53 G4String aType,
55 G4ParticleDefinition(name, mass, 0., charge, 0, 0, 0, 0, 0, 0, "Molecule",
56 0, 0, ID, false, lifetime, NULL, false, aType, 0, 0.0),
57 fDiffusionCoefficient(diffCoeff),
58 fAtomsNb(atomsNumber),
59 fVanDerVaalsRadius(radius)
60
61{
62 fCharge = charge;
63 if(electronicLevels)
64 {
65 fElectronOccupancy = new G4ElectronOccupancy(electronicLevels);
66 }
67 else
68 {
69 fElectronOccupancy = 0;
70 }
71 fDecayTable = NULL;
73}
74
76{
77 G4String name;
78 G4double mass;
79 G4double diffCoeff;
80 G4int charge;
81 G4int electronicLevels;
82 G4double radius;
83 G4int atomsNumber;
84 G4double lifetime;
85 G4String aType;
86
87 READ(in,name);
88 READ(in,mass);
89 READ(in,diffCoeff);
90 READ(in,charge);
91 READ(in,electronicLevels);
92 READ(in,radius);
93 READ(in,atomsNumber);
94 READ(in,lifetime);
95 READ(in,aType);
96
97 return new G4MoleculeDefinition(name,
98 mass,
99 diffCoeff,
100 charge,
101 electronicLevels,
102 radius,
103 atomsNumber,
104 lifetime,
105 aType);
106}
107
108void G4MoleculeDefinition::Serialize(std::ostream& out)
109{
114 WRITE(out,fDiffusionCoefficient);
115 WRITE(out,fCharge);
116 if(fElectronOccupancy)
117 {
118 WRITE(out,fElectronOccupancy->GetSizeOfOrbit());
119 }
120 else
121 {
122 WRITE(out,(int) 0);
123 }
124 WRITE(out,fVanDerVaalsRadius);
125 WRITE(out,fAtomsNb);
126}
127
128//______________________________________________________________________________
129
131{
132 if (fElectronOccupancy)
133 {
134 delete fElectronOccupancy;
135 fElectronOccupancy = 0;
136 }
137 if (fDecayTable)
138 {
139 delete fDecayTable;
140 fDecayTable = 0;
141 }
142}
143
144//___________________________________________________________________________
145
148{
149 bool alreadyExist(false);
151 molConfLabel,
152 this,
153 molConfLabel,
154 alreadyExist);
155}
156
157//___________________________________________________________________________
158
161{
163 molecularConfLabel);
164}
165
166//______________________________________________________________________________
167
171 const G4ElectronOccupancy& elecConf,
172 double decayTime)
173{
174 bool alreadyExist(false);
177 exStId,
178 this,
179 exStId,
180 elecConf,
181 alreadyExist);
182
183 conf->SetDecayTime(decayTime);
184
185 return conf;
186}
187
188//______________________________________________________________________________
189
191{
192 if(fElectronOccupancy)
193 {
194 G4int levelOccupancy = fElectronOccupancy->GetOccupancy(shell);
195
196 if(levelOccupancy)
197 {
198
199 fElectronOccupancy->RemoveElectron(shell, levelOccupancy);
200 }
201
202 fElectronOccupancy->AddElectron(shell, eNb);
203 }
204}
205
206//______________________________________________________________________________
207
208void G4MoleculeDefinition::AddDecayChannel(const G4String& molecularConfLabel,
209 const G4MolecularDissociationChannel* channel)
210{
211 if(!fDecayTable)
212 {
213 fDecayTable = new G4MolecularDissociationTable();
214 }
215
217 molecularConfLabel),
218 channel);
219}
220
221//______________________________________________________________________________
222
224 const G4MolecularDissociationChannel* channel)
225{
226 if (!fDecayTable)
227 {
228 fDecayTable = new G4MolecularDissociationTable();
229 }
230 fDecayTable->AddChannel(molConf, channel);
231}
232
233//___________________________________________________________________________
234
235const vector<const G4MolecularDissociationChannel*>*
237{
238 if (fDecayTable)
239 {
240 const vector<const G4MolecularDissociationChannel*>* output =
241 fDecayTable->GetDecayChannels(ExState);
242 return output;
243 }
244 else
245 {
247 errMsg << ": no Excited States and Decays for"
248 << GetName()
249 << " are defined.";
250 G4Exception("G4MoleculeDefinition::GetDecayChannels", "",
251 FatalErrorInArgument, errMsg);
252 }
253 return 0;
254}
255
256//___________________________________________________________________________
257
258const vector<const G4MolecularDissociationChannel*>*
260 const
261{
262 if(fDecayTable)
263 {
264 const vector<const G4MolecularDissociationChannel*>* output =
265 fDecayTable->GetDecayChannels(conf);
266 return output;
267 }
268// else
269// {
270// G4ExceptionDescription errMsg;
271// errMsg << ": no Excited States and Decays for"
272// << GetName()
273// << " are defined.";
274// G4Exception("G4MoleculeDefinition::GetDecayChannels",
275// "",
276// FatalErrorInArgument,
277// errMsg);
278// }
279 return 0;
280}
281
282//___________________________________________________________________________
283
285{
287}
288
289//___________________________________________________________________________
290
291
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
void WRITE(std::ostream &out, const T &toBeSaved)
Definition: G4Serialize.hh:41
void READ(std::istream &in, T &toBeSaved)
Definition: G4Serialize.hh:49
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4int AddElectron(G4int orbit, G4int number=1)
G4int RemoveElectron(G4int orbit, G4int number=1)
G4int GetOccupancy(G4int orbit) const
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4MolecularConfiguration *) const
void AddChannel(const G4MolecularConfiguration *molConf, const G4MolecularDissociationChannel *channel)
const G4String & GetName() const
void Serialize(std::ostream &)
G4MolecularConfiguration * GetConfigurationWithLabel(const G4String &molecularConfLabel)
static G4MoleculeDefinition * Load(std::istream &)
void SetLevelOccupation(G4int, G4int eNb=2)
void AddDecayChannel(const G4MolecularConfiguration *molConf, const G4MolecularDissociationChannel *channel)
G4MolecularConfiguration * NewConfiguration(const G4String &excitedStateLabel)
G4MolecularConfiguration * NewConfigurationWithElectronOccupancy(const G4String &excitedStateLabel, const G4ElectronOccupancy &, double decayTime=0.)
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4MolecularConfiguration *) const
void Finalize(G4MoleculeDefinition *)
void Insert(G4MoleculeDefinition *)
static G4MoleculeTable * Instance()
const G4String & GetParticleType() const
G4double GetPDGLifeTime() const
const G4String & GetParticleName() const