Geant4  10.02.p02
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 // $Id: G4MoleculeDefinition.cc 93883 2015-11-03 08:25:04Z gcosmo $
27 //
28 // ----------------------------------------------------------------------
29 // GEANT 4 class implementation file
30 //
31 // 21 Oct 2009 first implementation by A. Mantero and M.Karamitros
32 // Based on prototype of A.Mantero
33 // **********************************************************************
34 
35 #include "G4MoleculeDefinition.hh"
37 #include "G4MoleculeTable.hh"
38 #include "G4Serialize.hh"
39 
40 using namespace std;
41 
42 // -----------------------------------------------------------------------------
43 // ### MoleculeDefinition ###
44 // -----------------------------------------------------------------------------
45 
47  G4double mass,
48  G4double diffCoeff,
49  G4int charge,
50  G4int electronicLevels,
51  G4double radius,
52  G4int atomsNumber,
53  G4double lifetime,
54  G4String aType,
55  G4FakeParticleID ID) :
56  G4ParticleDefinition(name, mass, 0., charge, 0, 0, 0, 0, 0, 0, "Molecule",
57  0, 0, ID, false, lifetime, NULL, false, aType, 0, 0.0),
58  fDiffusionCoefficient(diffCoeff),
59  fAtomsNb(atomsNumber),
60  fVanDerVaalsRadius(radius)
61 
62 {
63  fCharge = charge;
64  if(electronicLevels)
65  {
66  fElectronOccupancy = new G4ElectronOccupancy(electronicLevels);
67  }
68  else
69  {
71  }
72  fDecayTable = NULL;
74 }
75 
77 {
78  G4String name;
79  G4double mass;
80  G4double diffCoeff;
81  G4int charge;
82  G4int electronicLevels;
83  G4double radius;
84  G4int atomsNumber;
85  G4double lifetime;
86  G4String aType;
87 
88  READ(in,name);
89  READ(in,mass);
90  READ(in,diffCoeff);
91  READ(in,charge);
92  READ(in,electronicLevels);
93  READ(in,radius);
94  READ(in,atomsNumber);
95  READ(in,lifetime);
96  READ(in,aType);
97 
98  return new G4MoleculeDefinition(name,
99  mass,
100  diffCoeff,
101  charge,
102  electronicLevels,
103  radius,
104  atomsNumber,
105  lifetime,
106  aType);
107 }
108 
109 void G4MoleculeDefinition::Serialize(std::ostream& out)
110 {
116  WRITE(out,fCharge);
118  {
120  }
121  else
122  {
123  WRITE(out,(int) 0);
124  }
126  WRITE(out,fAtomsNb);
127 }
128 
129 //______________________________________________________________________________
130 
132 {
133  if (fElectronOccupancy)
134  {
135  delete fElectronOccupancy;
136  fElectronOccupancy = 0;
137  }
138  if (fDecayTable)
139  {
140  delete fDecayTable;
141  fDecayTable = 0;
142  }
143 }
144 
145 //___________________________________________________________________________
146 
149 {
150  bool alreadyExist(false);
152  molConfLabel,
153  this,
154  molConfLabel,
155  alreadyExist);
156 }
157 
158 //___________________________________________________________________________
159 
162 {
164  molecularConfLabel);
165 }
166 
167 //______________________________________________________________________________
168 
172  const G4ElectronOccupancy& elecConf,
173  double decayTime)
174 {
175  bool alreadyExist(false);
178  exStId,
179  this,
180  exStId,
181  elecConf,
182  alreadyExist);
183 
184  conf->SetDecayTime(decayTime);
185 
186  return conf;
187 }
188 
189 //______________________________________________________________________________
190 
192 {
194  {
195  G4int levelOccupancy = fElectronOccupancy->GetOccupancy(shell);
196 
197  if(levelOccupancy)
198  {
199 
200  fElectronOccupancy->RemoveElectron(shell, levelOccupancy);
201  }
202 
203  fElectronOccupancy->AddElectron(shell, eNb);
204  }
205 }
206 
207 //______________________________________________________________________________
208 
209 void G4MoleculeDefinition::AddDecayChannel(const G4String& molecularConfLabel,
210  const G4MolecularDissociationChannel* channel)
211 {
212  if(!fDecayTable)
213  {
215  }
216 
218  molecularConfLabel),
219  channel);
220 }
221 
222 //______________________________________________________________________________
223 
225  const G4MolecularDissociationChannel* channel)
226 {
227  if (!fDecayTable)
228  {
230  }
231  fDecayTable->AddChannel(molConf, channel);
232 }
233 
234 //___________________________________________________________________________
235 
236 const vector<const G4MolecularDissociationChannel*>*
238 {
239  if (fDecayTable)
240  {
241  const vector<const G4MolecularDissociationChannel*>* output =
242  fDecayTable->GetDecayChannels(ExState);
243  return output;
244  }
245  else
246  {
247  G4ExceptionDescription errMsg;
248  errMsg << ": no Excited States and Decays for"
249  << GetName()
250  << " are defined.";
251  G4Exception("G4MoleculeDefinition::GetDecayChannels", "",
252  FatalErrorInArgument, errMsg);
253  }
254  return 0;
255 }
256 
257 //___________________________________________________________________________
258 
259 const vector<const G4MolecularDissociationChannel*>*
261  const
262 {
263  if(fDecayTable)
264  {
265  const vector<const G4MolecularDissociationChannel*>* output =
267  return output;
268  }
269 // else
270 // {
271 // G4ExceptionDescription errMsg;
272 // errMsg << ": no Excited States and Decays for"
273 // << GetName()
274 // << " are defined.";
275 // G4Exception("G4MoleculeDefinition::GetDecayChannels",
276 // "",
277 // FatalErrorInArgument,
278 // errMsg);
279 // }
280  return 0;
281 }
282 
283 //___________________________________________________________________________
284 // Protected
285 //___________________________________________________________________________
286 
289  fDiffusionCoefficient(right.fDiffusionCoefficient),
290  fAtomsNb(right.fAtomsNb),
291  fVanDerVaalsRadius(right.fVanDerVaalsRadius)
292 {
293  if (right.fElectronOccupancy != 0)
294  {
296  }
297  else fElectronOccupancy = 0;
298 
299  if (right.fDecayTable != 0)
300  {
302  }
303  else fDecayTable = 0;
304 
305  fCharge = right.fCharge;
306 }
307 
308 //___________________________________________________________________________
309 
312 {
313  if (this != &right)
314  {
315  }
316  return *this;
317 }
318 
319 //___________________________________________________________________________
320 
322 {
324 }
325 
326 //___________________________________________________________________________
327 
328 
The pointer G4MolecularConfiguration will be shared by all the molecules having the same molecule def...
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4MolecularConfiguration *) const
static G4MoleculeDefinition * Load(std::istream &)
void Insert(G4MoleculeDefinition *)
void Serialize(std::ostream &)
G4ElectronOccupancy * fElectronOccupancy
G4MolecularDissociationTable * fDecayTable
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const std::vector< const G4MolecularDissociationChannel * > * GetDecayChannels(const G4MolecularConfiguration *) const
void AddDecayChannel(const G4MolecularConfiguration *molConf, const G4MolecularDissociationChannel *channel)
G4String name
Definition: TRTMaterials.hh:40
static G4MolecularConfiguration * GetMolecularConfiguration(const G4MoleculeDefinition *, const G4String &label)
void WRITE(std::ostream &out, const T &toBeSaved)
Definition: G4Serialize.hh:41
Class Description G4MolecularDecayTable operates as a container of deexcitation modes for excited or ...
G4int GetSizeOfOrbit() const
void Finalize(G4MoleculeDefinition *)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4MolecularConfiguration * NewConfiguration(const G4String &excitedStateLabel)
G4int GetOccupancy(G4int orbit) const
G4int AddElectron(G4int orbit, G4int number=1)
static G4MoleculeTable * Instance()
const G4String & GetParticleType() const
void AddChannel(const G4MolecularConfiguration *molConf, const G4MolecularDissociationChannel *channel)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double GetPDGMass() const
void SetDecayTime(G4double)
Set the decay time of the molecule.
const G4String & GetName() const
const G4MoleculeDefinition & operator=(const G4MoleculeDefinition &right)
G4double GetPDGLifeTime() const
void SetLevelOccupation(G4int, G4int eNb=2)
void READ(std::istream &in, T &toBeSaved)
Definition: G4Serialize.hh:49
double G4double
Definition: G4Types.hh:76
G4MolecularConfiguration * NewConfigurationWithElectronOccupancy(const G4String &excitedStateLabel, const G4ElectronOccupancy &, double decayTime=0.)
G4MolecularConfiguration * GetConfigurationWithLabel(const G4String &molecularConfLabel)
G4int RemoveElectron(G4int orbit, G4int number=1)
static G4MolecularConfiguration * CreateMolecularConfiguration(const G4String &userIdentifier, const G4MoleculeDefinition *, bool &wasAlreadyCreated)