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 | // $Id: G4IonTable.cc,v 1.53 2008/10/15 02:41:37 kurasige Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | // |
---|
31 | // -------------------------------------------------------------- |
---|
32 | // GEANT 4 class implementation file |
---|
33 | // |
---|
34 | // History: first implementation, based on object model of |
---|
35 | // 27 June 1998 H.Kurashige |
---|
36 | // --------------------------------------------------------------- |
---|
37 | // modified GetIon 02 Aug., 98 H.Kurashige |
---|
38 | // added Remove() 06 Nov.,98 H.Kurashige |
---|
39 | // use G4NucleiPropoerties to get nuceli Mass 17 Nov.,98 H.Kurashige |
---|
40 | // use G4GenericIon for process List |
---|
41 | // modify fomula of Ion mass 09 Dec., 98 H.Kurashige |
---|
42 | // ----- |
---|
43 | // Modified GetIon methods 17 Aug. 99 H.Kurashige |
---|
44 | // New design using G4VIsotopeTable 5 Oct. 99 H.Kurashige |
---|
45 | // Modified Element Name for Z>103 06 Apr. 01 H.Kurashige |
---|
46 | // Remove test of cuts in SetCuts 16 Jan 03 V.Ivanchenko |
---|
47 | |
---|
48 | #include "G4IonTable.hh" |
---|
49 | #include "G4ParticleTable.hh" |
---|
50 | #include "G4StateManager.hh" |
---|
51 | #include "G4Ions.hh" |
---|
52 | #include "G4UImanager.hh" |
---|
53 | #include "G4NucleiProperties.hh" |
---|
54 | #include "G4HyperNucleiProperties.hh" |
---|
55 | |
---|
56 | #include "G4IsotopeProperty.hh" |
---|
57 | #include "G4VIsotopeTable.hh" |
---|
58 | |
---|
59 | #include "G4ios.hh" |
---|
60 | #include <iostream> |
---|
61 | #include <iomanip> |
---|
62 | |
---|
63 | #include <sstream> |
---|
64 | |
---|
65 | |
---|
66 | //////////////////// |
---|
67 | G4IonTable::G4IonTable() |
---|
68 | { |
---|
69 | fIonList = new G4IonList(); |
---|
70 | fIsotopeTableList = new std::vector<G4VIsotopeTable*>; |
---|
71 | } |
---|
72 | |
---|
73 | //////////////////// |
---|
74 | G4IonTable::~G4IonTable() |
---|
75 | { |
---|
76 | // delete IsotopeTable if exists |
---|
77 | if (fIsotopeTableList != 0) { |
---|
78 | for (size_t i = 0; i< fIsotopeTableList->size(); ++i) { |
---|
79 | G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i]; |
---|
80 | delete fIsotopeTable; |
---|
81 | } |
---|
82 | fIsotopeTableList->clear(); |
---|
83 | delete fIsotopeTableList; |
---|
84 | } |
---|
85 | fIsotopeTableList =0; |
---|
86 | |
---|
87 | |
---|
88 | if (fIonList ==0) return; |
---|
89 | // remove all contents in the Ion List |
---|
90 | // No need to delete here because all particles are dynamic objects |
---|
91 | fIonList->clear(); |
---|
92 | |
---|
93 | delete fIonList; |
---|
94 | fIonList =0; |
---|
95 | } |
---|
96 | |
---|
97 | |
---|
98 | //////////////////// |
---|
99 | // -- CreateIon method ------ |
---|
100 | //////////////////// |
---|
101 | G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, |
---|
102 | G4double E, G4int J) |
---|
103 | { |
---|
104 | G4ParticleDefinition* ion=0; |
---|
105 | |
---|
106 | // check whether the cuurent state is not "PreInit" |
---|
107 | // to make sure that GenericIon has processes |
---|
108 | G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState(); |
---|
109 | if (currentState == G4State_PreInit){ |
---|
110 | #ifdef G4VERBOSE |
---|
111 | if (GetVerboseLevel()>1) { |
---|
112 | G4cout << "G4IonTable::CreateIon() : can not create ion of "; |
---|
113 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
114 | G4cout << " because the current state is PreInit !!" << G4endl; |
---|
115 | } |
---|
116 | #endif |
---|
117 | G4Exception( "G4IonTable::CreateIon()","Illegal operation", |
---|
118 | JustWarning, "Can not create ions in PreInit state"); |
---|
119 | return 0; |
---|
120 | } |
---|
121 | |
---|
122 | // get ion name |
---|
123 | G4String name = GetIonName(Z, A, E); |
---|
124 | if ( name(0) == '?') { |
---|
125 | #ifdef G4VERBOSE |
---|
126 | if (GetVerboseLevel()>0) { |
---|
127 | G4cout << "G4IonTable::CreateIon() : can not create ions " << G4endl; |
---|
128 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
129 | } |
---|
130 | #endif |
---|
131 | return 0; |
---|
132 | } |
---|
133 | |
---|
134 | G4double life = -1.0; |
---|
135 | G4DecayTable* decayTable =0; |
---|
136 | G4bool stable = true; |
---|
137 | G4double mu = 0.0; |
---|
138 | |
---|
139 | G4IsotopeProperty* fProperty = FindIsotope(Z, A, E, J); |
---|
140 | if (fProperty !=0 ){ |
---|
141 | E = fProperty->GetEnergy(); |
---|
142 | J = fProperty->GetiSpin(); |
---|
143 | life = fProperty->GetLifeTime(); |
---|
144 | mu = fProperty->GetMagneticMoment(); |
---|
145 | decayTable = fProperty->GetDecayTable(); |
---|
146 | } |
---|
147 | stable = life <= 0.; |
---|
148 | G4double mass = GetNucleusMass(Z, A)+ E; |
---|
149 | G4double charge = G4double(Z)*eplus; |
---|
150 | |
---|
151 | G4int encoding = GetNucleusEncoding(Z,A,E,J); |
---|
152 | |
---|
153 | // create an ion |
---|
154 | // spin, parity, isospin values are fixed |
---|
155 | // |
---|
156 | ion = new G4Ions( name, mass, 0.0*MeV, charge, |
---|
157 | J, +1, 0, |
---|
158 | 0, 0, 0, |
---|
159 | "nucleus", 0, A, encoding, |
---|
160 | stable, life, decayTable, false, |
---|
161 | "generic", 0, |
---|
162 | E ); |
---|
163 | ion->SetPDGMagneticMoment(mu); |
---|
164 | |
---|
165 | //No Anti particle registered |
---|
166 | ion->SetAntiPDGEncoding(0); |
---|
167 | |
---|
168 | #ifdef G4VERBOSE |
---|
169 | if (GetVerboseLevel()>1) { |
---|
170 | G4cout << "G4IonTable::CreateIon() : create ion of " << name << G4endl; |
---|
171 | } |
---|
172 | #endif |
---|
173 | |
---|
174 | // Add process manager to the ion |
---|
175 | AddProcessManager(name); |
---|
176 | |
---|
177 | if (fProperty !=0) delete fProperty; |
---|
178 | return ion; |
---|
179 | } |
---|
180 | |
---|
181 | |
---|
182 | //////////////////// |
---|
183 | G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, G4int L, |
---|
184 | G4double E, G4int J) |
---|
185 | { |
---|
186 | if (L==0) return CreateIon(A,Z,E,J); |
---|
187 | |
---|
188 | // create hyper nucleus |
---|
189 | G4ParticleDefinition* ion=0; |
---|
190 | |
---|
191 | // check whether the cuurent state is not "PreInit" |
---|
192 | // to make sure that GenericIon has processes |
---|
193 | G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState(); |
---|
194 | if (currentState == G4State_PreInit){ |
---|
195 | #ifdef G4VERBOSE |
---|
196 | if (GetVerboseLevel()>1) { |
---|
197 | G4cout << "G4IonTable::CreateIon() : can not create ion of "; |
---|
198 | G4cout << " Z =" << Z << " A = " << A << " L = " <<L << G4endl; |
---|
199 | G4cout << " because the current state is PreInit !!" << G4endl; |
---|
200 | } |
---|
201 | #endif |
---|
202 | G4Exception( "G4IonTable::CreateIon()","Illegal operation", |
---|
203 | JustWarning, "Can not create ions in PreInit state"); |
---|
204 | return 0; |
---|
205 | } |
---|
206 | |
---|
207 | // get ion name |
---|
208 | G4String name = GetIonName(Z, A, L, E); |
---|
209 | if ( name(L) == '?') { |
---|
210 | #ifdef G4VERBOSE |
---|
211 | if (GetVerboseLevel()>0) { |
---|
212 | G4cout << "G4IonTable::CreateIon() : can not create ions " << G4endl; |
---|
213 | G4cout << " Z =" << Z << " A = " << A << " L = " << L << G4endl; |
---|
214 | } |
---|
215 | #endif |
---|
216 | return 0; |
---|
217 | } |
---|
218 | |
---|
219 | G4double life = -1.0; |
---|
220 | G4DecayTable* decayTable =0; |
---|
221 | G4bool stable = true; |
---|
222 | G4double mu = 0.0; |
---|
223 | G4double mass = GetNucleusMass(Z, A, L)+ E; |
---|
224 | G4double charge = G4double(Z)*eplus; |
---|
225 | |
---|
226 | G4int encoding = GetNucleusEncoding(Z,A,L,E,J); |
---|
227 | |
---|
228 | // create an ion |
---|
229 | // spin, parity, isospin values are fixed |
---|
230 | // |
---|
231 | ion = new G4Ions( name, mass, 0.0*MeV, charge, |
---|
232 | J, +1, 0, |
---|
233 | 0, 0, 0, |
---|
234 | "nucleus", 0, A, encoding, |
---|
235 | stable, life, decayTable, false, |
---|
236 | "generic", 0, |
---|
237 | E ); |
---|
238 | ion->SetPDGMagneticMoment(mu); |
---|
239 | |
---|
240 | //No Anti particle registered |
---|
241 | ion->SetAntiPDGEncoding(0); |
---|
242 | |
---|
243 | #ifdef G4VERBOSE |
---|
244 | if (GetVerboseLevel()>1) { |
---|
245 | G4cout << "G4IonTable::CreateIon() : create ion of " << name << G4endl; |
---|
246 | } |
---|
247 | #endif |
---|
248 | |
---|
249 | // Add process manager to the ion |
---|
250 | AddProcessManager(name); |
---|
251 | |
---|
252 | return ion; |
---|
253 | } |
---|
254 | |
---|
255 | //////////////////// |
---|
256 | // -- GetIon methods ------ |
---|
257 | //////////////////// |
---|
258 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int , G4int ) |
---|
259 | { |
---|
260 | return GetIon(Z, A); |
---|
261 | } |
---|
262 | |
---|
263 | //////////////////// |
---|
264 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int J) |
---|
265 | { |
---|
266 | return GetIon( Z, A, 0.0, J); |
---|
267 | } |
---|
268 | |
---|
269 | //////////////////// |
---|
270 | G4ParticleDefinition* G4IonTable::GetIon(G4int encoding) |
---|
271 | { |
---|
272 | G4int Z, A, L, J; |
---|
273 | G4double E; |
---|
274 | if (!GetNucleusByEncoding(encoding,Z,A,L,E,J) ){ |
---|
275 | #ifdef G4VERBOSE |
---|
276 | if (GetVerboseLevel()>0) { |
---|
277 | G4cout << "G4IonTable::GetIon() : illegal encoding" << G4endl; |
---|
278 | G4cout << " CODE:" << encoding << G4endl; |
---|
279 | } |
---|
280 | #endif |
---|
281 | G4Exception( "G4IonTable::GetIon()","Illegal operation", |
---|
282 | JustWarning, "illegal encoding"); |
---|
283 | return 0; |
---|
284 | } |
---|
285 | // Only ground state is supported |
---|
286 | return GetIon( Z, A, L, 0.0, J); |
---|
287 | } |
---|
288 | |
---|
289 | //////////////////// |
---|
290 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4double E, G4int J) |
---|
291 | { |
---|
292 | if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) { |
---|
293 | #ifdef G4VERBOSE |
---|
294 | if (GetVerboseLevel()>0) { |
---|
295 | G4cout << "G4IonTable::GetIon() : illegal atomic number/mass" << G4endl; |
---|
296 | G4cout << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl; |
---|
297 | } |
---|
298 | #endif |
---|
299 | return 0; |
---|
300 | } |
---|
301 | |
---|
302 | // Search ions with A, Z |
---|
303 | G4ParticleDefinition* ion = FindIon(Z,A,E,J); |
---|
304 | |
---|
305 | // create ion |
---|
306 | if (ion == 0) { |
---|
307 | ion = CreateIon(Z, A, E, J); |
---|
308 | } |
---|
309 | |
---|
310 | return ion; |
---|
311 | } |
---|
312 | |
---|
313 | //////////////////// |
---|
314 | G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int L, G4double E, G4int J) |
---|
315 | { |
---|
316 | if (L==0) return GetIon(Z,A,E,J); |
---|
317 | |
---|
318 | if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) { |
---|
319 | #ifdef G4VERBOSE |
---|
320 | if (GetVerboseLevel()>0) { |
---|
321 | G4cout << "G4IonTable::GetIon() : illegal atomic number/mass" << G4endl; |
---|
322 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
323 | <<" E = " << E/keV << G4endl; |
---|
324 | } |
---|
325 | #endif |
---|
326 | return 0; |
---|
327 | } else if( A==2 ) { |
---|
328 | #ifdef G4VERBOSE |
---|
329 | if (GetVerboseLevel()>0) { |
---|
330 | G4cout << "G4IonTable::GetIon() : No boud state for " << G4endl; |
---|
331 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
332 | << " E = " << E/keV << G4endl; |
---|
333 | } |
---|
334 | #endif |
---|
335 | return 0; |
---|
336 | } |
---|
337 | |
---|
338 | // Search ions with A, Z |
---|
339 | G4ParticleDefinition* ion = FindIon(Z,A,L,E,J); |
---|
340 | |
---|
341 | // create ion |
---|
342 | if (ion == 0) { |
---|
343 | ion = CreateIon(Z, A, L, E, J); |
---|
344 | } |
---|
345 | |
---|
346 | return ion; |
---|
347 | } |
---|
348 | |
---|
349 | //////////////////// |
---|
350 | G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4double E, G4int J) |
---|
351 | { |
---|
352 | const G4double EnergyTorelance = 0.1 * keV; |
---|
353 | |
---|
354 | if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) { |
---|
355 | #ifdef G4VERBOSE |
---|
356 | if (GetVerboseLevel()>0) { |
---|
357 | G4cout << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level " << G4endl; |
---|
358 | G4cout << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl; |
---|
359 | } |
---|
360 | #endif |
---|
361 | G4Exception( "G4IonTable::FindIon()","Illegal operation", |
---|
362 | JustWarning, "illegal atomic number/mass"); |
---|
363 | return 0; |
---|
364 | } |
---|
365 | // Search ions with A, Z ,E |
---|
366 | // !! J is omitted now !! |
---|
367 | G4ParticleDefinition* ion=0; |
---|
368 | G4bool isFound = false; |
---|
369 | |
---|
370 | // -- loop over all particles in Ion table |
---|
371 | G4IonList::iterator idx; |
---|
372 | for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { |
---|
373 | ion = *idx; |
---|
374 | |
---|
375 | // Z = Atomic Number |
---|
376 | G4int anAtomicNumber = ion->GetAtomicNumber(); |
---|
377 | // A = baryon number |
---|
378 | G4int anAtomicMass = ion->GetAtomicMass(); |
---|
379 | // excitation level |
---|
380 | G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy(); |
---|
381 | |
---|
382 | if ( (A == anAtomicMass) && |
---|
383 | (Z == anAtomicNumber ) && |
---|
384 | ( std::abs(E - anExcitaionEnergy ) < EnergyTorelance ) ) { |
---|
385 | isFound = true; |
---|
386 | break; |
---|
387 | } |
---|
388 | } |
---|
389 | |
---|
390 | if ( isFound ){ |
---|
391 | return ion; |
---|
392 | } else { |
---|
393 | return 0; |
---|
394 | } |
---|
395 | } |
---|
396 | |
---|
397 | |
---|
398 | //////////////////// |
---|
399 | G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4int L, G4double E, G4int J) |
---|
400 | { |
---|
401 | if (L==0) return FindIon(Z,A,E,J); |
---|
402 | |
---|
403 | const G4double EnergyTorelance = 0.1 * keV; |
---|
404 | |
---|
405 | if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) { |
---|
406 | #ifdef G4VERBOSE |
---|
407 | if (GetVerboseLevel()>0) { |
---|
408 | G4cout << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level " << G4endl; |
---|
409 | G4cout << " Z =" << Z << " A = " << A << " L = " << L |
---|
410 | <<" E = " << E/keV << G4endl; |
---|
411 | } |
---|
412 | #endif |
---|
413 | G4Exception( "G4IonTable::FindIon()","Illegal operation", |
---|
414 | JustWarning, "illegal atomic number/mass"); |
---|
415 | return 0; |
---|
416 | } |
---|
417 | // Search ions with A, Z ,E |
---|
418 | // !! J is omitted now !! |
---|
419 | G4ParticleDefinition* ion=0; |
---|
420 | G4bool isFound = false; |
---|
421 | |
---|
422 | // -- loop over all particles in Ion table |
---|
423 | G4IonList::iterator idx; |
---|
424 | for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { |
---|
425 | ion = *idx; |
---|
426 | |
---|
427 | // Z = Atomic Number |
---|
428 | G4int anAtomicNumber = ion->GetAtomicNumber(); |
---|
429 | // A = baryon number |
---|
430 | G4int anAtomicMass = ion->GetAtomicMass(); |
---|
431 | // L = lambda number |
---|
432 | G4int lambdaNumber = ion->GetQuarkContent(3); |
---|
433 | // excitation level |
---|
434 | G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy(); |
---|
435 | |
---|
436 | if ( (A == anAtomicMass) && |
---|
437 | (Z == anAtomicNumber ) && |
---|
438 | (L == lambdaNumber ) && |
---|
439 | ( std::abs(E - anExcitaionEnergy ) < EnergyTorelance ) ) { |
---|
440 | isFound = true; |
---|
441 | break; |
---|
442 | } |
---|
443 | } |
---|
444 | |
---|
445 | if ( isFound ){ |
---|
446 | return ion; |
---|
447 | } else { |
---|
448 | return 0; |
---|
449 | } |
---|
450 | } |
---|
451 | |
---|
452 | |
---|
453 | ///////////////// |
---|
454 | G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4double E, G4int ) |
---|
455 | { |
---|
456 | // PDG code for Ions |
---|
457 | // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI. |
---|
458 | //For a nucleus consisting of np protons and nn neutrons |
---|
459 | // A = np + nn and Z = np. |
---|
460 | // I gives the isomer level, with I = 0 corresponding |
---|
461 | // to the ground state and I >0 to excitations |
---|
462 | |
---|
463 | //!!! I = 1 is assigned fo all excitation states !!! |
---|
464 | |
---|
465 | G4int encoding = 1000000000; |
---|
466 | encoding += Z * 10000; |
---|
467 | encoding += A *10; |
---|
468 | if (E>0.0) encoding += 1; |
---|
469 | |
---|
470 | return encoding; |
---|
471 | } |
---|
472 | |
---|
473 | ///////////////// |
---|
474 | G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4int L, |
---|
475 | G4double E, G4int ) |
---|
476 | { |
---|
477 | // get PDG code for Hyper-Nucleus Ions |
---|
478 | // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI. |
---|
479 | //For a nucleus consisting of np protons and nn neutrons |
---|
480 | // A = np + nn +nlambda and Z = np. |
---|
481 | // L = nlambda |
---|
482 | // I gives the isomer level, with I = 0 corresponding |
---|
483 | // to the ground state and I >0 to excitations |
---|
484 | // |
---|
485 | //!!! I = 1 is assigned fo all excitation states in Geant4 |
---|
486 | |
---|
487 | G4int encoding = 1000000000; |
---|
488 | encoding += L* 10000000; |
---|
489 | encoding += Z * 10000; |
---|
490 | encoding += A *10; |
---|
491 | if (E>0.0) encoding += 1; |
---|
492 | |
---|
493 | return encoding; |
---|
494 | } |
---|
495 | |
---|
496 | /////////////// |
---|
497 | G4bool G4IonTable::GetNucleusByEncoding(G4int encoding, |
---|
498 | G4int &Z, G4int &A, |
---|
499 | G4double &E, G4int &J) |
---|
500 | { |
---|
501 | if (encoding <= 0) { |
---|
502 | // anti particle |
---|
503 | return false; |
---|
504 | } |
---|
505 | if (encoding % 10 != 0) { |
---|
506 | //!!!not supported for excitation states !!! |
---|
507 | return false; |
---|
508 | } |
---|
509 | |
---|
510 | encoding -= 1000000000; |
---|
511 | Z = encoding/10000; |
---|
512 | encoding -= 10000*Z; |
---|
513 | A = encoding/10; |
---|
514 | |
---|
515 | E=0.0; |
---|
516 | J=0; |
---|
517 | |
---|
518 | return true; |
---|
519 | } |
---|
520 | /////////////// |
---|
521 | G4bool G4IonTable::GetNucleusByEncoding(G4int encoding, |
---|
522 | G4int &Z, G4int &A, |
---|
523 | G4int &L, |
---|
524 | G4double &E, G4int &J) |
---|
525 | { |
---|
526 | if (encoding <= 0) { |
---|
527 | // anti particle |
---|
528 | return false; |
---|
529 | } |
---|
530 | if (encoding % 10 != 0) { |
---|
531 | //!!!not supported for excitation states !!! |
---|
532 | return false; |
---|
533 | } |
---|
534 | if (encoding < 1000000000) { |
---|
535 | // anti particle |
---|
536 | return false; |
---|
537 | } |
---|
538 | |
---|
539 | encoding -= 1000000000; |
---|
540 | L = encoding/10000000; |
---|
541 | encoding -= 10000000*L; |
---|
542 | Z = encoding/10000; |
---|
543 | encoding -= 10000*Z; |
---|
544 | A = encoding/10; |
---|
545 | |
---|
546 | E=0.0; |
---|
547 | J=0; |
---|
548 | |
---|
549 | return true; |
---|
550 | } |
---|
551 | ///////////////// |
---|
552 | const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4double E) const |
---|
553 | { |
---|
554 | static G4String name; |
---|
555 | name =""; |
---|
556 | if ( (0< Z) && (Z <=numberOfElements) ) { |
---|
557 | name = elementName[Z-1]; |
---|
558 | } else if (Z > numberOfElements) { |
---|
559 | std::ostringstream os1; |
---|
560 | os1.setf(std::ios::fixed); |
---|
561 | os1 << Z ; |
---|
562 | name = "E" + os1.str() + "-"; |
---|
563 | } else { |
---|
564 | name = "?"; |
---|
565 | return name; |
---|
566 | } |
---|
567 | std::ostringstream os; |
---|
568 | os.setf(std::ios::fixed); |
---|
569 | os << A << '[' << std::setprecision(1) << E/keV << ']'; |
---|
570 | name += os.str(); |
---|
571 | return name; |
---|
572 | } |
---|
573 | |
---|
574 | ///////////////// |
---|
575 | const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4int L, G4double E) const |
---|
576 | { |
---|
577 | if (L==0) return GetIonName(Z, A, E); |
---|
578 | static G4String name; |
---|
579 | name =""; |
---|
580 | for (int i =0; i<L; i++){ |
---|
581 | name +="L"; |
---|
582 | } |
---|
583 | name += GetIonName(Z, A, E); |
---|
584 | return name; |
---|
585 | } |
---|
586 | |
---|
587 | ///////////////// |
---|
588 | G4bool G4IonTable::IsIon(G4ParticleDefinition* particle) |
---|
589 | { |
---|
590 | // return true if the particle is ion |
---|
591 | |
---|
592 | // particles derived from G4VIon and G4Ions |
---|
593 | G4bool value = (particle->GetParticleType() == "nucleus"); |
---|
594 | |
---|
595 | // proton (Hydrogen nucleus) |
---|
596 | value = value || (particle->GetParticleName() == "proton"); |
---|
597 | |
---|
598 | return value; |
---|
599 | } |
---|
600 | |
---|
601 | ///////////////// |
---|
602 | #include <algorithm> |
---|
603 | |
---|
604 | G4bool G4IonTable::IsLightIon(G4ParticleDefinition* particle) const |
---|
605 | { |
---|
606 | static const std::string names[] = { "proton", "neutron", "alpha", "deuteron", |
---|
607 | "triton", "He3", "GenericIon"}; |
---|
608 | |
---|
609 | // return true if the particle is pre-defined ion |
---|
610 | return std::find(names, names+7, particle->GetParticleName())!=names+7; |
---|
611 | } |
---|
612 | |
---|
613 | ///////////////// |
---|
614 | G4ParticleDefinition* G4IonTable::GetLightIon(G4int Z, G4int A) const |
---|
615 | { |
---|
616 | // returns pointer to pre-defined ions |
---|
617 | static G4bool isInitialized = false; |
---|
618 | static G4ParticleDefinition* p_proton=0; |
---|
619 | static G4ParticleDefinition* p_neutron=0; |
---|
620 | static G4ParticleDefinition* p_deuteron=0; |
---|
621 | static G4ParticleDefinition* p_triton=0; |
---|
622 | static G4ParticleDefinition* p_alpha=0; |
---|
623 | static G4ParticleDefinition* p_He3=0; |
---|
624 | |
---|
625 | if (!isInitialized) { |
---|
626 | p_proton = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton |
---|
627 | p_neutron = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); // neutron |
---|
628 | p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron |
---|
629 | p_triton = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon |
---|
630 | p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("alpha"); // alpha |
---|
631 | p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("He3"); // He3 |
---|
632 | isInitialized = true; |
---|
633 | } |
---|
634 | |
---|
635 | G4ParticleDefinition* ion=0; |
---|
636 | if ( (Z<=2) ) { |
---|
637 | if ( (Z==1)&&(A==1) ) { |
---|
638 | ion = p_proton; |
---|
639 | } else if ( (Z==0)&&(A==1) ) { |
---|
640 | ion = p_neutron; |
---|
641 | } else if ( (Z==1)&&(A==2) ) { |
---|
642 | ion = p_deuteron; |
---|
643 | } else if ( (Z==1)&&(A==3) ) { |
---|
644 | ion = p_triton; |
---|
645 | } else if ( (Z==2)&&(A==4) ) { |
---|
646 | ion = p_alpha; |
---|
647 | } else if ( (Z==2)&&(A==3) ) { |
---|
648 | ion = p_He3; |
---|
649 | } |
---|
650 | } |
---|
651 | return ion; |
---|
652 | } |
---|
653 | |
---|
654 | ///////////////// |
---|
655 | // -- GetNucleusMass/GetIonMass --- |
---|
656 | ///////////////// |
---|
657 | G4double G4IonTable::GetNucleusMass(G4int Z, G4int A, G4int L) const |
---|
658 | { |
---|
659 | if ( (A<1) || (Z<0) || (L<0) ){ |
---|
660 | #ifdef G4VERBOSE |
---|
661 | if (GetVerboseLevel()>0) { |
---|
662 | G4cout << "G4IonTable::GetNucleusMass() : illegal atomic number/mass " << G4endl; |
---|
663 | G4cout << " Z =" << Z << " A = " << A << G4endl; |
---|
664 | } |
---|
665 | #endif |
---|
666 | G4Exception( "G4IonTable::GetNucleusMass()","Illegal operation", |
---|
667 | EventMustBeAborted, "illegal atomic number/mass"); |
---|
668 | return -1.0; |
---|
669 | } |
---|
670 | |
---|
671 | G4double mass; |
---|
672 | if (L == 0) { |
---|
673 | // calculate nucleus mass |
---|
674 | G4ParticleDefinition* ion=GetLightIon(Z, A); |
---|
675 | |
---|
676 | if (ion!=0) { |
---|
677 | mass = ion->GetPDGMass(); |
---|
678 | } else { |
---|
679 | // use G4NucleiProperties::GetNuclearMass |
---|
680 | mass = G4NucleiProperties::GetNuclearMass(A, Z); |
---|
681 | } |
---|
682 | |
---|
683 | } else { |
---|
684 | mass = G4HyperNucleiProperties::GetNuclearMass(A, Z, L); |
---|
685 | } |
---|
686 | return mass; |
---|
687 | } |
---|
688 | |
---|
689 | ////////////////// |
---|
690 | G4double G4IonTable::GetIonMass(G4int Z, G4int A, G4int L) const |
---|
691 | { |
---|
692 | return GetNucleusMass(Z,A,L); |
---|
693 | } |
---|
694 | |
---|
695 | |
---|
696 | ///////////////// |
---|
697 | // -- Methods for handling conatiner --- |
---|
698 | ///////////////// |
---|
699 | void G4IonTable::Insert(G4ParticleDefinition* particle) |
---|
700 | { |
---|
701 | if (IsIon(particle)) { |
---|
702 | fIonList->push_back(particle); |
---|
703 | } |
---|
704 | } |
---|
705 | |
---|
706 | ///////////////// |
---|
707 | void G4IonTable::Remove(G4ParticleDefinition* particle) |
---|
708 | { |
---|
709 | if (IsIon(particle)) { |
---|
710 | G4IonList::iterator idx; |
---|
711 | for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { |
---|
712 | if ( particle == *idx) { |
---|
713 | fIonList->erase(idx); |
---|
714 | break; |
---|
715 | } |
---|
716 | } |
---|
717 | } else { |
---|
718 | #ifdef G4VERBOSE |
---|
719 | if (GetVerboseLevel()>1) { |
---|
720 | G4cout << "G4IonTable::Remove :" << particle->GetParticleName() ; |
---|
721 | G4cout << " is not ions" << G4endl; |
---|
722 | } |
---|
723 | #endif |
---|
724 | } |
---|
725 | |
---|
726 | } |
---|
727 | |
---|
728 | |
---|
729 | |
---|
730 | ///////////////// |
---|
731 | // -- Dump Information |
---|
732 | ///////////////// |
---|
733 | void G4IonTable::DumpTable(const G4String &particle_name) const |
---|
734 | { |
---|
735 | G4ParticleDefinition* ion; |
---|
736 | G4IonList::iterator idx; |
---|
737 | for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) { |
---|
738 | ion = *idx; |
---|
739 | if (( particle_name == "ALL" ) || (particle_name == "all")){ |
---|
740 | ion->DumpTable(); |
---|
741 | } else if ( particle_name == ion->GetParticleName() ) { |
---|
742 | ion->DumpTable(); |
---|
743 | } |
---|
744 | } |
---|
745 | } |
---|
746 | |
---|
747 | ///////////////// |
---|
748 | const G4String G4IonTable::elementName[] = { |
---|
749 | "H", "He", |
---|
750 | "Li", "Be", "B", "C", "N", "O", "F", "Ne", |
---|
751 | "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", |
---|
752 | "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", |
---|
753 | "Rb", "Sr", "Y", "Zr", "Nb", "Mo","Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", |
---|
754 | "Cs", "Ba", |
---|
755 | "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", |
---|
756 | "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", |
---|
757 | "Fr", "Ra", |
---|
758 | "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", |
---|
759 | "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", |
---|
760 | "Uub", "Uut", "Uuq","Uup","Uuh","Uus","Uuo" |
---|
761 | }; |
---|
762 | |
---|
763 | |
---|
764 | ///////////////// |
---|
765 | G4int G4IonTable::GetVerboseLevel() const |
---|
766 | { |
---|
767 | return G4ParticleTable::GetParticleTable()->GetVerboseLevel(); |
---|
768 | } |
---|
769 | |
---|
770 | ///////////////// |
---|
771 | void G4IonTable::AddProcessManager(const G4String& name) |
---|
772 | { |
---|
773 | // create command string for addProcManager |
---|
774 | std::ostringstream osAdd; |
---|
775 | osAdd << "/run/particle/addProcManager "<< name; |
---|
776 | G4String cmdAdd = osAdd.str(); |
---|
777 | |
---|
778 | // set /control/verbose 0 |
---|
779 | G4int tempVerboseLevel = G4UImanager::GetUIpointer()->GetVerboseLevel(); |
---|
780 | G4UImanager::GetUIpointer()->SetVerboseLevel(0); |
---|
781 | |
---|
782 | // issue /run/particle/addProcManage |
---|
783 | G4UImanager::GetUIpointer()->ApplyCommand(cmdAdd); |
---|
784 | |
---|
785 | // retreive /control/verbose |
---|
786 | G4UImanager::GetUIpointer()->SetVerboseLevel(tempVerboseLevel); |
---|
787 | } |
---|
788 | |
---|
789 | #include <vector> |
---|
790 | |
---|
791 | //////////////////// |
---|
792 | void G4IonTable::RegisterIsotopeTable(G4VIsotopeTable* table) |
---|
793 | { |
---|
794 | fIsotopeTableList->push_back(table); |
---|
795 | } |
---|
796 | |
---|
797 | //////////////////// |
---|
798 | G4VIsotopeTable* G4IonTable::GetIsotopeTable(size_t index) const |
---|
799 | { |
---|
800 | G4VIsotopeTable* fIsotopeTable=0; |
---|
801 | if ( index < fIsotopeTableList->size() ) { |
---|
802 | fIsotopeTable = (*fIsotopeTableList)[index]; |
---|
803 | } |
---|
804 | return fIsotopeTable; |
---|
805 | } |
---|
806 | |
---|
807 | |
---|
808 | //////////////////// |
---|
809 | G4IsotopeProperty* G4IonTable::FindIsotope(G4int Z, G4int A, G4double E, G4int ) |
---|
810 | { |
---|
811 | if (fIsotopeTableList ==0) return 0; |
---|
812 | if (fIsotopeTableList->size()==0) return 0; |
---|
813 | |
---|
814 | // ask IsotopeTable |
---|
815 | G4IsotopeProperty* property =0; |
---|
816 | |
---|
817 | // iterate |
---|
818 | for (size_t i = 0; i< fIsotopeTableList->size(); ++i) { |
---|
819 | G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i]; |
---|
820 | G4IsotopeProperty* tmp = fIsotopeTable->GetIsotope(Z,A,E); |
---|
821 | if ( tmp !=0) { |
---|
822 | |
---|
823 | #ifdef G4VERBOSE |
---|
824 | if (GetVerboseLevel()>1) { |
---|
825 | G4cout << "G4IonTable::FindIsotope:"; |
---|
826 | G4cout << " Z: " << Z; |
---|
827 | G4cout << " A: " << A; |
---|
828 | G4cout << " E: " << E; |
---|
829 | G4cout << G4endl; |
---|
830 | tmp->DumpInfo(); |
---|
831 | } |
---|
832 | #endif |
---|
833 | if (property !=0) { |
---|
834 | // overwrite spin/magnetic moment/decay table if not defined |
---|
835 | if( property->GetiSpin() ==0) { |
---|
836 | property->SetiSpin( tmp->GetiSpin() ); |
---|
837 | } |
---|
838 | if( property->GetMagneticMoment() <= 0.0) { |
---|
839 | property->SetMagneticMoment( tmp->GetMagneticMoment() ); |
---|
840 | } |
---|
841 | if( property->GetLifeTime() <= 0.0) { |
---|
842 | property->SetLifeTime( tmp->GetLifeTime() ); |
---|
843 | if ( (property->GetLifeTime() > 0.0) |
---|
844 | && (property->GetDecayTable() ==0 ) ) { |
---|
845 | property->SetDecayTable( tmp->GetDecayTable() ); |
---|
846 | tmp->SetDecayTable( 0 ); |
---|
847 | } |
---|
848 | } |
---|
849 | } else { |
---|
850 | property = tmp; |
---|
851 | } |
---|
852 | } |
---|
853 | } |
---|
854 | |
---|
855 | return property; |
---|
856 | } |
---|
857 | |
---|
858 | |
---|
859 | |
---|
860 | |
---|
861 | |
---|
862 | |
---|
863 | |
---|
864 | |
---|
865 | |
---|
866 | |
---|
867 | |
---|
868 | |
---|
869 | |
---|
870 | |
---|