ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MoleculeDefinition.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MoleculeDefinition.cc
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 
34 #include "G4MoleculeDefinition.hh"
36 #include "G4MoleculeTable.hh"
37 #include "G4Serialize.hh"
38 
39 using namespace std;
40 
41 // -----------------------------------------------------------------------------
42 // ### MoleculeDefinition ###
43 // -----------------------------------------------------------------------------
44 
46  G4double mass,
47  G4double diffCoeff,
48  G4int charge,
49  G4int electronicLevels,
51  G4int atomsNumber,
52  G4double lifetime,
53  G4String aType,
54  G4FakeParticleID ID) :
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  {
70  }
71  fDecayTable = NULL;
73 }
74 
76 {
77  G4String name;
78  G4double mass;
79  G4double diffCoeff;
80  G4int charge;
81  G4int electronicLevels;
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 
108 void G4MoleculeDefinition::Serialize(std::ostream& out)
109 {
115  WRITE(out,fCharge);
117  {
119  }
120  else
121  {
122  WRITE(out,(int) 0);
123  }
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 {
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 
208 void G4MoleculeDefinition::AddDecayChannel(const G4String& molecularConfLabel,
209  const G4MolecularDissociationChannel* channel)
210 {
211  if(!fDecayTable)
212  {
214  }
215 
217  molecularConfLabel),
218  channel);
219 }
220 
221 //______________________________________________________________________________
222 
224  const G4MolecularDissociationChannel* channel)
225 {
226  if (!fDecayTable)
227  {
229  }
230  fDecayTable->AddChannel(molConf, channel);
231 }
232 
233 //___________________________________________________________________________
234 
235 const 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  {
246  G4ExceptionDescription errMsg;
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 
258 const vector<const G4MolecularDissociationChannel*>*
260  const
261 {
262  if(fDecayTable)
263  {
264  const vector<const G4MolecularDissociationChannel*>* output =
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 // Protected
284 //___________________________________________________________________________
285 
288  fDiffusionCoefficient(right.fDiffusionCoefficient),
289  fAtomsNb(right.fAtomsNb),
290  fVanDerVaalsRadius(right.fVanDerVaalsRadius)
291 {
292  if (right.fElectronOccupancy != 0)
293  {
295  }
296  else fElectronOccupancy = 0;
297 
298  if (right.fDecayTable != 0)
299  {
301  }
302  else fDecayTable = 0;
303 
304  fCharge = right.fCharge;
305 }
306 
307 //___________________________________________________________________________
308 
311 {
312  if (this != &right)
313  {
314  }
315  return *this;
316 }
317 
318 //___________________________________________________________________________
319 
321 {
323 }
324 
325 //___________________________________________________________________________
326 
327