source: trunk/source/particles/management/src/G4IonTable.cc@ 1344

Last change on this file since 1344 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 27.7 KB
Line 
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.65 2010/10/16 06:04:51 kurasige Exp $
28// GEANT4 tag $Name: particles-V09-03-15 $
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////////////////////
67G4IonTable::G4IonTable()
68{
69 fIonList = new G4IonList();
70 fIsotopeTableList = new std::vector<G4VIsotopeTable*>;
71}
72
73////////////////////
74G4IonTable::~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////////////////////
101G4ParticleDefinition* 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 G4cerr << "G4IonTable::CreateIon() : can not create ion of "
113 << " Z =" << Z << " A = " << A
114 << " 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 G4cerr << "G4IonTable::CreateIon() : can not create ions "
128 << " 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 const 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
171 << " " << Z << ", " << A
172 << " encoding=" << encoding << G4endl;
173 }
174#endif
175
176 // Add process manager to the ion
177 AddProcessManager(name);
178
179 return ion;
180}
181
182
183////////////////////
184G4ParticleDefinition* G4IonTable::CreateIon(G4int Z, G4int A, G4int L,
185 G4double E, G4int J)
186{
187 if (L==0) return CreateIon(A,Z,E,J);
188
189 // create hyper nucleus
190 G4ParticleDefinition* ion=0;
191
192 // check whether the cuurent state is not "PreInit"
193 // to make sure that GenericIon has processes
194 G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
195 if (currentState == G4State_PreInit){
196#ifdef G4VERBOSE
197 if (GetVerboseLevel()>1) {
198 G4cerr << "G4IonTable::CreateIon() : can not create ion of "
199 << " Z =" << Z << " A = " << A << " L = " <<L
200 << " because the current state is PreInit !!" << G4endl;
201 }
202#endif
203 G4Exception( "G4IonTable::CreateIon()","Illegal operation",
204 JustWarning, "Can not create ions in PreInit state");
205 return 0;
206 }
207
208 // get ion name
209 G4String name = GetIonName(Z, A, L, E);
210 if ( name(L) == '?') {
211#ifdef G4VERBOSE
212 if (GetVerboseLevel()>0) {
213 G4cerr << "G4IonTable::CreateIon() : can not create ions "
214 << " Z =" << Z << " A = " << A << " L = " << L << G4endl;
215 }
216#endif
217 return 0;
218 }
219
220 G4double life = -1.0;
221 G4DecayTable* decayTable =0;
222 G4bool stable = true;
223 G4double mu = 0.0;
224 G4double mass = GetNucleusMass(Z, A, L)+ E;
225 G4double charge = G4double(Z)*eplus;
226
227 G4int encoding = GetNucleusEncoding(Z,A,L,E,J);
228
229 // create an ion
230 // spin, parity, isospin values are fixed
231 //
232 ion = new G4Ions( name, mass, 0.0*MeV, charge,
233 J, +1, 0,
234 0, 0, 0,
235 "nucleus", 0, A, encoding,
236 stable, life, decayTable, false,
237 "generic", 0,
238 E );
239 ion->SetPDGMagneticMoment(mu);
240
241 //No Anti particle registered
242 ion->SetAntiPDGEncoding(0);
243
244#ifdef G4VERBOSE
245 if (GetVerboseLevel()>1) {
246 G4cout << "G4IonTable::CreateIon() : create hyper ion of " << name
247 << " encoding=" << encoding << G4endl;
248 }
249#endif
250
251 // Add process manager to the ion
252 AddProcessManager(name);
253
254 return ion;
255}
256
257////////////////////
258// -- GetIon methods ------
259////////////////////
260G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int , G4int )
261{
262 return GetIon(Z, A);
263}
264
265////////////////////
266G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int J)
267{
268 return GetIon( Z, A, 0.0, J);
269}
270
271////////////////////
272G4ParticleDefinition* G4IonTable::GetIon(G4int encoding)
273{
274 G4int Z, A, L, J;
275 G4double E;
276 if (!GetNucleusByEncoding(encoding,Z,A,L,E,J) ){
277#ifdef G4VERBOSE
278 if (GetVerboseLevel()>0) {
279 G4cerr << "G4IonTable::GetIon() : illegal encoding"
280 << " CODE:" << encoding << G4endl;
281 }
282#endif
283 G4Exception( "G4IonTable::GetIon()","Illegal operation",
284 JustWarning, "illegal encoding");
285 return 0;
286 }
287 // Only ground state is supported
288 return GetIon( Z, A, L, 0.0, J);
289}
290
291////////////////////
292G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4double E, G4int J)
293{
294 if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) {
295#ifdef G4VERBOSE
296 if (GetVerboseLevel()>0) {
297 G4cerr << "G4IonTable::GetIon() : illegal atomic number/mass"
298 << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl;
299 }
300#endif
301 return 0;
302 }
303
304 // Search ions with A, Z
305 G4ParticleDefinition* ion = FindIon(Z,A,E,J);
306
307 // create ion
308 if (ion == 0) {
309 ion = CreateIon(Z, A, E, J);
310 }
311
312 return ion;
313}
314
315////////////////////
316G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int L, G4double E, G4int J)
317{
318 if (L==0) return GetIon(Z,A,E,J);
319
320 if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) {
321#ifdef G4VERBOSE
322 if (GetVerboseLevel()>0) {
323 G4cerr << "G4IonTable::GetIon() : illegal atomic number/mass"
324 << " Z =" << Z << " A = " << A << " L = " << L
325 <<" E = " << E/keV << G4endl;
326 }
327#endif
328 return 0;
329 } else if( A==2 ) {
330#ifdef G4VERBOSE
331 if (GetVerboseLevel()>0) {
332 G4cerr << "G4IonTable::GetIon() : No boud state for "
333 << " Z =" << Z << " A = " << A << " L = " << L
334 << " E = " << E/keV << G4endl;
335 }
336#endif
337 return 0;
338 }
339
340 // Search ions with A, Z
341 G4ParticleDefinition* ion = FindIon(Z,A,L,E,J);
342
343 // create ion
344 if (ion == 0) {
345 ion = CreateIon(Z, A, L, E, J);
346 }
347
348 return ion;
349}
350
351////////////////////
352G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4double E, G4int J)
353{
354 const G4double EnergyTorelance = 0.1 * keV;
355
356 if ( (A<1) || (Z<=0) || (J<0) || (E<0.0) || (A>999) ) {
357#ifdef G4VERBOSE
358 if (GetVerboseLevel()>0) {
359 G4cerr << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level "
360 << " Z =" << Z << " A = " << A << " E = " << E/keV << G4endl;
361 }
362#endif
363 G4Exception( "G4IonTable::FindIon()","Illegal operation",
364 JustWarning, "illegal atomic number/mass");
365 return 0;
366 }
367 // Search ions with A, Z ,E
368 // !! J is omitted now !!
369 const G4ParticleDefinition* ion=0;
370 G4bool isFound = false;
371
372 // -- loop over all particles in Ion table
373 G4int encoding=GetNucleusEncoding(Z, A, 0);
374 G4IonList::iterator i = fIonList->find(encoding);
375 for( ;i != fIonList->end() ; i++) {
376 ion = i->second;
377 if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break;
378
379 // excitation level
380 G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy();
381 if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) {
382 isFound = true;
383 break;
384 }
385 }
386
387 if ( isFound ){
388 return const_cast<G4ParticleDefinition*>(ion);
389 } else {
390 return 0;
391 }
392}
393
394
395////////////////////
396G4ParticleDefinition* G4IonTable::FindIon(G4int Z, G4int A, G4int L, G4double E, G4int J)
397{
398 if (L==0) return FindIon(Z,A,E,J);
399
400 const G4double EnergyTorelance = 0.1 * keV;
401
402 if (A < 2 || Z < 0 || Z > A-L || L>A || A>999 ) {
403#ifdef G4VERBOSE
404 if (GetVerboseLevel()>0) {
405 G4cerr << "G4IonTable::FindIon() : illegal atomic number/mass or excitation level "
406 << " Z =" << Z << " A = " << A << " L = " << L
407 <<" E = " << E/keV << G4endl;
408 }
409#endif
410 G4Exception( "G4IonTable::FindIon()","Illegal operation",
411 JustWarning, "illegal atomic number/mass");
412 return 0;
413 }
414 // Search ions with A, Z ,E
415 // !! J is omitted now !!
416 const G4ParticleDefinition* ion=0;
417 G4bool isFound = false;
418
419 // -- loop over all particles in Ion table
420 G4int encoding=GetNucleusEncoding(Z, A, L);
421 G4IonList::iterator i = fIonList->find(encoding);
422 for( ;i != fIonList->end() ; i++) {
423 ion = i->second;
424 if ( ( ion->GetAtomicNumber() != Z) || (ion->GetAtomicMass()!=A) ) break;
425 if( ion->GetQuarkContent(3) != L) break;
426
427 // excitation level
428 G4double anExcitaionEnergy = ((const G4Ions*)(ion))->GetExcitationEnergy();
429
430 if ( ( std::fabs(E - anExcitaionEnergy ) < EnergyTorelance ) ) {
431 isFound = true;
432 break;
433 }
434 }
435
436 if ( isFound ){
437 return const_cast<G4ParticleDefinition*>(ion);
438 } else {
439 return 0;
440 }
441}
442
443
444/////////////////
445G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4double E, G4int )
446{
447 // PDG code for Ions
448 // Nuclear codes are given as 10-digit numbers +-100ZZZAAAI.
449 //For a nucleus consisting of np protons and nn neutrons
450 // A = np + nn and Z = np.
451 // I gives the isomer level, with I = 0 corresponding
452 // to the ground state and I >0 to excitations
453
454 //!!! I = 1 is assigned fo all excitation states !!!
455 const G4double EnergyTorelance = 0.1 * keV;
456 if ( Z==1 && A==1 && E< EnergyTorelance ) {
457 //proton
458 return 2212;
459 }
460
461 G4int encoding = 1000000000;
462 encoding += Z * 10000;
463 encoding += A *10;
464 if (E>0.0) encoding += 1;
465
466 return encoding;
467}
468
469/////////////////
470G4int G4IonTable::GetNucleusEncoding(G4int Z, G4int A, G4int L,
471 G4double E, G4int )
472{
473 // get PDG code for Hyper-Nucleus Ions
474 // Nuclear codes are given as 10-digit numbers +-10LZZZAAAI.
475 //For a nucleus consisting of np protons and nn neutrons
476 // A = np + nn +nlambda and Z = np.
477 // L = nlambda
478 // I gives the isomer level, with I = 0 corresponding
479 // to the ground state and I >0 to excitations
480 //
481 //!!! I = 1 is assigned fo all excitation states in Geant4
482
483 G4int encoding = 1000000000;
484 encoding += L* 10000000;
485 encoding += Z * 10000;
486 encoding += A *10;
487 if (E>0.0) encoding += 1;
488
489 return encoding;
490}
491
492///////////////
493G4bool G4IonTable::GetNucleusByEncoding(G4int encoding,
494 G4int &Z, G4int &A,
495 G4double &E, G4int &J)
496{
497 if (encoding <= 0) {
498 // anti particle
499 return false;
500 }
501 if (encoding == 2212) {
502 // proton
503 Z = 1;
504 A = 1;
505 E=0.0;
506 J=0;
507 return true;
508 }
509
510 if (encoding % 10 != 0) {
511 //!!!not supported for excitation states !!!
512 return false;
513 }
514
515 encoding -= 1000000000;
516 Z = encoding/10000;
517 encoding -= 10000*Z;
518 A = encoding/10;
519
520 E=0.0;
521 J=0;
522
523 return true;
524}
525///////////////
526G4bool G4IonTable::GetNucleusByEncoding(G4int encoding,
527 G4int &Z, G4int &A,
528 G4int &L,
529 G4double &E, G4int &J)
530{
531 if (encoding <= 0) {
532 // anti particle
533 return false;
534 }
535 if (encoding % 10 != 0) {
536 //!!!not supported for excitation states !!!
537 return false;
538 }
539 if (encoding < 1000000000) {
540 // anti particle
541 return false;
542 }
543
544 encoding -= 1000000000;
545 L = encoding/10000000;
546 encoding -= 10000000*L;
547 Z = encoding/10000;
548 encoding -= 10000*Z;
549 A = encoding/10;
550
551 E=0.0;
552 J=0;
553
554 return true;
555}
556/////////////////
557const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4double E) const
558{
559 static G4String name;
560 name ="";
561 if ( (0< Z) && (Z <=numberOfElements) ) {
562 name = elementName[Z-1];
563 } else if (Z > numberOfElements) {
564 std::ostringstream os1;
565 os1.setf(std::ios::fixed);
566 os1 << Z ;
567 name = "E" + os1.str() + "-";
568 } else {
569 name = "?";
570 return name;
571 }
572 std::ostringstream os;
573 os.setf(std::ios::fixed);
574 os << A << '[' << std::setprecision(1) << E/keV << ']';
575 name += os.str();
576 return name;
577}
578
579/////////////////
580const G4String& G4IonTable::GetIonName(G4int Z, G4int A, G4int L, G4double E) const
581{
582 if (L==0) return GetIonName(Z, A, E);
583 static G4String name;
584 name ="";
585 for (int i =0; i<L; i++){
586 name +="L";
587 }
588 name += GetIonName(Z, A, E);
589 return name;
590}
591
592/////////////////
593G4bool G4IonTable::IsIon(const G4ParticleDefinition* particle)
594{
595 // return true if the particle is ion
596
597 static G4String nucleus("nucleus");
598 static G4String proton("proton");
599
600 // neutron is not ion
601 if ((particle->GetAtomicMass()>0) &&
602 (particle->GetAtomicNumber()>0) ){
603 if (particle->GetBaryonNumber()>0) return true;
604 else return false;
605 }
606
607
608 // particles derived from G4Ions
609 if (particle->GetParticleType() == nucleus) return true;
610
611 // proton (Hydrogen nucleus)
612 if (particle->GetParticleName() == proton) return true;
613
614 return false;
615}
616
617/////////////////
618G4bool G4IonTable::IsAntiIon(const G4ParticleDefinition* particle)
619{
620 // return true if the particle is ion
621
622 static G4String anti_nucleus("anti_nucleus");
623 static G4String anti_proton("anti_proton");
624
625 // anti_neutron is not ion
626 if ((particle->GetAtomicMass()>0) &&
627 (particle->GetAtomicNumber()>0) ){
628 if (particle->GetBaryonNumber()<0) return true;
629 else return false;
630 }
631
632 // particles derived from G4Ions
633 if (particle->GetParticleType() == anti_nucleus) return true;
634
635 // anti_proton (Anti_Hydrogen nucleus)
636 if (particle->GetParticleName() == anti_proton) return true;
637
638 return false;
639}
640
641/////////////////
642#include <algorithm>
643
644G4bool G4IonTable::IsLightIon(const G4ParticleDefinition* particle) const
645{
646 static const std::string names[] = { "proton", "alpha", "deuteron",
647 "triton", "He3"};
648
649 // return true if the particle is pre-defined ion
650 return std::find(names, names+5, particle->GetParticleName())!=names+5;
651}
652
653G4bool G4IonTable::IsLightAntiIon(const G4ParticleDefinition* particle) const
654{
655 static const std::string names[] = { "anti_proton", "anti_alpha", "anti_deuteron",
656 "anti_triton", "anti_He3"};
657
658 // return true if the particle is pre-defined ion
659 return std::find(names, names+5, particle->GetParticleName())!=names+5;
660}
661
662/////////////////
663G4ParticleDefinition* G4IonTable::GetLightIon(G4int Z, G4int A) const
664{
665 // returns pointer to pre-defined ions
666 static G4bool isInitialized = false;
667 static const G4ParticleDefinition* p_proton=0;
668 static const G4ParticleDefinition* p_deuteron=0;
669 static const G4ParticleDefinition* p_triton=0;
670 static const G4ParticleDefinition* p_alpha=0;
671 static const G4ParticleDefinition* p_He3=0;
672
673 if (!isInitialized) {
674 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton
675 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron
676 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon
677 p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("alpha"); // alpha
678 p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("He3"); // He3
679 isInitialized = true;
680 }
681
682 const G4ParticleDefinition* ion=0;
683 if ( (Z<=2) ) {
684 if ( (Z==1)&&(A==1) ) {
685 ion = p_proton;
686 } else if ( (Z==1)&&(A==2) ) {
687 ion = p_deuteron;
688 } else if ( (Z==1)&&(A==3) ) {
689 ion = p_triton;
690 } else if ( (Z==2)&&(A==4) ) {
691 ion = p_alpha;
692 } else if ( (Z==2)&&(A==3) ) {
693 ion = p_He3;
694 }
695 }
696 return const_cast<G4ParticleDefinition*>(ion);
697}
698
699/////////////////
700G4ParticleDefinition* G4IonTable::GetLightAntiIon(G4int Z, G4int A) const
701{
702 // returns pointer to pre-defined ions
703 static G4bool isInitialized = false;
704 static const G4ParticleDefinition* p_proton=0;
705 static const G4ParticleDefinition* p_deuteron=0;
706 static const G4ParticleDefinition* p_triton=0;
707 static const G4ParticleDefinition* p_alpha=0;
708 static const G4ParticleDefinition* p_He3=0;
709
710 if (!isInitialized) {
711 p_proton = G4ParticleTable::GetParticleTable()->FindParticle("anti_proton"); // proton
712 p_deuteron = G4ParticleTable::GetParticleTable()->FindParticle("anti_deuteron"); // deuteron
713 p_triton = G4ParticleTable::GetParticleTable()->FindParticle("anti_triton"); // tritoon
714 p_alpha = G4ParticleTable::GetParticleTable()->FindParticle("anti_alpha"); // alpha
715 p_He3 = G4ParticleTable::GetParticleTable()->FindParticle("anti_He3"); // He3
716 isInitialized = true;
717 }
718
719 const G4ParticleDefinition* ion=0;
720 if ( (Z<=2) ) {
721 if ( (Z==1)&&(A==1) ) {
722 ion = p_proton;
723 } else if ( (Z==1)&&(A==2) ) {
724 ion = p_deuteron;
725 } else if ( (Z==1)&&(A==3) ) {
726 ion = p_triton;
727 } else if ( (Z==2)&&(A==4) ) {
728 ion = p_alpha;
729 } else if ( (Z==2)&&(A==3) ) {
730 ion = p_He3;
731 }
732 }
733 return const_cast<G4ParticleDefinition*>(ion);
734}
735
736
737/////////////////
738// -- GetNucleusMass/GetIonMass ---
739/////////////////
740G4double G4IonTable::GetNucleusMass(G4int Z, G4int A, G4int L) const
741{
742 if ( (A<1) || (Z<0) || (L<0) ){
743#ifdef G4VERBOSE
744 if (GetVerboseLevel()>0) {
745 G4cerr << "G4IonTable::GetNucleusMass() : illegal atomic number/mass "
746 << " Z =" << Z << " A = " << A << G4endl;
747 }
748#endif
749 G4Exception( "G4IonTable::GetNucleusMass()","Illegal operation",
750 EventMustBeAborted, "illegal atomic number/mass");
751 return -1.0;
752 }
753
754 G4double mass;
755 if (L == 0) {
756 // calculate nucleus mass
757 const G4ParticleDefinition* ion=GetLightIon(Z, A);
758
759 if (ion!=0) {
760 mass = ion->GetPDGMass();
761 } else {
762 // use G4NucleiProperties::GetNuclearMass
763 mass = G4NucleiProperties::GetNuclearMass(A, Z);
764 }
765
766 } else {
767 mass = G4HyperNucleiProperties::GetNuclearMass(A, Z, L);
768 }
769 return mass;
770}
771
772//////////////////
773G4double G4IonTable::GetIonMass(G4int Z, G4int A, G4int L) const
774{
775 return GetNucleusMass(Z,A,L);
776}
777
778
779/////////////////
780// -- Methods for handling conatiner ---
781/////////////////
782void G4IonTable::Insert(const G4ParticleDefinition* particle)
783{
784 if (!IsIon(particle)) return;
785 if (Contains(particle)) return;
786
787 G4int Z = particle->GetAtomicNumber();
788 G4int A = particle->GetAtomicMass();
789 G4int L = particle->GetQuarkContent(3); //strangeness
790 G4int encoding=GetNucleusEncoding(Z, A, L);
791
792 fIonList->insert( std::pair<const G4int, const G4ParticleDefinition*>(encoding, particle) );
793
794}
795
796/////////////////
797void G4IonTable::Remove(const G4ParticleDefinition* particle)
798{
799 if (IsIon(particle)) {
800 G4int Z = particle->GetAtomicNumber();
801 G4int A = particle->GetAtomicMass();
802 G4int L = particle->GetQuarkContent(3); //strangeness
803 G4int encoding=GetNucleusEncoding(Z, A, L);
804 if (encoding !=0 ) {
805 G4IonList::iterator i = fIonList->find(encoding);
806 for( ;i != fIonList->end() ; i++) {
807 if (particle == i->second) {
808 fIonList->erase(i);
809 break;
810 }
811 }
812 }
813 } else {
814#ifdef G4VERBOSE
815 if (GetVerboseLevel()>1) {
816 G4cerr << "G4IonTable::Remove :" << particle->GetParticleName()
817 << " is not ions" << G4endl;
818 }
819#endif
820 }
821
822}
823
824
825
826/////////////////
827// -- Dump Information
828/////////////////
829void G4IonTable::DumpTable(const G4String &particle_name) const
830{
831 const G4ParticleDefinition* ion;
832 G4IonList::iterator idx;
833 for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) {
834 ion = idx->second;
835 if (( particle_name == "ALL" ) || (particle_name == "all")){
836 ion->DumpTable();
837 } else if ( particle_name == ion->GetParticleName() ) {
838 ion->DumpTable();
839 }
840 }
841}
842
843/////////////////
844const G4String G4IonTable::elementName[] = {
845 "H", "He",
846 "Li", "Be", "B", "C", "N", "O", "F", "Ne",
847 "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar",
848 "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr",
849 "Rb", "Sr", "Y", "Zr", "Nb", "Mo","Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe",
850 "Cs", "Ba",
851 "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu",
852 "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn",
853 "Fr", "Ra",
854 "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr",
855 "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg",
856 "Uub", "Uut", "Uuq","Uup","Uuh","Uus","Uuo"
857};
858
859
860/////////////////
861G4int G4IonTable::GetVerboseLevel() const
862{
863 return G4ParticleTable::GetParticleTable()->GetVerboseLevel();
864}
865
866/////////////////
867void G4IonTable::AddProcessManager(const G4String& name)
868{
869 // create command string for addProcManager
870 std::ostringstream osAdd;
871 osAdd << "/run/particle/addProcManager "<< name;
872 G4String cmdAdd = osAdd.str();
873
874 // set /control/verbose 0
875 G4int tempVerboseLevel = G4UImanager::GetUIpointer()->GetVerboseLevel();
876 G4UImanager::GetUIpointer()->SetVerboseLevel(0);
877
878 // issue /run/particle/addProcManage
879 G4UImanager::GetUIpointer()->ApplyCommand(cmdAdd);
880
881 // retreive /control/verbose
882 G4UImanager::GetUIpointer()->SetVerboseLevel(tempVerboseLevel);
883}
884
885#include <vector>
886
887////////////////////
888void G4IonTable::RegisterIsotopeTable(G4VIsotopeTable* table)
889{
890 fIsotopeTableList->push_back(table);
891}
892
893////////////////////
894G4VIsotopeTable* G4IonTable::GetIsotopeTable(size_t index) const
895{
896 G4VIsotopeTable* fIsotopeTable=0;
897 if ( index < fIsotopeTableList->size() ) {
898 fIsotopeTable = (*fIsotopeTableList)[index];
899 }
900 return fIsotopeTable;
901}
902
903
904////////////////////
905G4IsotopeProperty* G4IonTable::FindIsotope(G4int Z, G4int A, G4double E, G4int )
906{
907 if (fIsotopeTableList ==0) return 0;
908 if (fIsotopeTableList->size()==0) return 0;
909
910 // ask IsotopeTable
911 G4IsotopeProperty* property =0;
912
913 // iterate
914 for (size_t i = 0; i< fIsotopeTableList->size(); ++i) {
915 G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i];
916 G4IsotopeProperty* tmp = fIsotopeTable->GetIsotope(Z,A,E);
917 if ( tmp !=0) {
918
919#ifdef G4VERBOSE
920 if (GetVerboseLevel()>1) {
921 G4cout << "G4IonTable::FindIsotope:";
922 G4cout << " Z: " << Z;
923 G4cout << " A: " << A;
924 G4cout << " E: " << E;
925 G4cout << G4endl;
926 tmp->DumpInfo();
927 }
928#endif
929 if (property !=0) {
930 // overwrite spin/magnetic moment/decay table if not defined
931 if( property->GetiSpin() ==0) {
932 property->SetiSpin( tmp->GetiSpin() );
933 }
934 if( property->GetMagneticMoment() <= 0.0) {
935 property->SetMagneticMoment( tmp->GetMagneticMoment() );
936 }
937 if( property->GetLifeTime() <= 0.0) {
938 property->SetLifeTime( tmp->GetLifeTime() );
939 if ( (property->GetLifeTime() > 0.0)
940 && (property->GetDecayTable() ==0 ) ) {
941 property->SetDecayTable( tmp->GetDecayTable() );
942 tmp->SetDecayTable( 0 );
943 }
944 }
945 } else {
946 property = tmp;
947 }
948 }
949 }
950
951 return property;
952}
953
954
955////////////////////
956void G4IonTable::CreateAllIon()
957{
958 G4int Z;
959 G4int A;
960 G4double E=0.0;
961 G4int J=0;
962
963 for (Z=1; Z<=120; Z++) {
964 for (A=Z;A<999 && A<Z*3+10; A++) {
965 if (G4NucleiProperties::IsInStableTable(A,Z)){
966 GetIon(Z,A,E,J);
967 }
968 }
969 }
970}
971
972////////////////////
973G4ParticleDefinition* G4IonTable::GetParticle(G4int index) const
974{
975 if ( (index >=0) && (index < Entries()) ) {
976 G4IonList::iterator idx = fIonList->begin();
977 G4int counter = 0;
978 while( idx != fIonList->end() ){
979 if ( counter == index ) {
980 return const_cast<G4ParticleDefinition*>(idx->second);
981 }
982 counter++;
983 idx++;
984 }
985 }
986#ifdef G4VERBOSE
987 if (GetVerboseLevel()>1){
988 G4cerr << " G4IonTable::GetParticle"
989 << " invalid index (=" << index << ")"
990 << " entries = " << Entries() << G4endl;
991 }
992#endif
993 return 0;
994}
995
996
997
998
999
1000
1001
1002
1003
1004
1005
Note: See TracBrowser for help on using the repository browser.