Geant4 11.2.2
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, nullptr, false, aType, 0, 0.0),
57 fDiffusionCoefficient(diffCoeff),
58 fAtomsNb(atomsNumber),
59 fVanDerVaalsRadius(radius)
60
61{
62 fCharge = charge;
63 if(electronicLevels != 0)
64 {
65 fElectronOccupancy = new G4ElectronOccupancy(electronicLevels);
66 }
67 else
68 {
69 fElectronOccupancy = nullptr;
70 }
71 fDecayTable = nullptr;
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 != nullptr)
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 != nullptr)
133 {
134 delete fElectronOccupancy;
135 fElectronOccupancy = nullptr;
136 }
137 if (fDecayTable != nullptr)
138 {
139 delete fDecayTable;
140 fDecayTable = nullptr;
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 != nullptr)
193 {
194 G4int levelOccupancy = fElectronOccupancy->GetOccupancy(shell);
195
196 if(levelOccupancy != 0)
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 == nullptr)
212 {
213 fDecayTable = new G4MolecularDissociationTable();
214 }
215
217 molecularConfLabel),
218 channel);
219}
220
221//______________________________________________________________________________
222
224 const G4MolecularDissociationChannel* channel)
225{
226 if (fDecayTable == nullptr)
227 {
228 fDecayTable = new G4MolecularDissociationTable();
229 }
230 fDecayTable->AddChannel(molConf, channel);
231}
232
233//___________________________________________________________________________
234
235const vector<const G4MolecularDissociationChannel*>*
237{
238 if (fDecayTable != nullptr)
239 {
240 const vector<const G4MolecularDissociationChannel*>* output =
241 fDecayTable->GetDecayChannels(ExState);
242 return output;
243 }
244
246 errMsg << ": no Excited States and Decays for"
247 << GetName()
248 << " are defined.";
249 G4Exception("G4MoleculeDefinition::GetDecayChannels", "",
250 FatalErrorInArgument, errMsg);
251 return nullptr;
252}
253
254//___________________________________________________________________________
255
256const vector<const G4MolecularDissociationChannel*>*
258 const
259{
260 if(fDecayTable != nullptr)
261 {
262 const vector<const G4MolecularDissociationChannel*>* output =
263 fDecayTable->GetDecayChannels(conf);
264 return output;
265 }
266// else
267// {
268// G4ExceptionDescription errMsg;
269// errMsg << ": no Excited States and Decays for"
270// << GetName()
271// << " are defined.";
272// G4Exception("G4MoleculeDefinition::GetDecayChannels",
273// "",
274// FatalErrorInArgument,
275// errMsg);
276// }
277 return nullptr;
278}
279
280//___________________________________________________________________________
281
286
287//___________________________________________________________________________
288
289
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
void WRITE(std::ostream &out, const T &toBeSaved)
void READ(std::istream &in, T &toBeSaved)
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