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

Last change on this file since 850 was 850, checked in by garnier, 16 years ago

geant4.8.2 beta

File size: 23.4 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.51 2008/06/08 12:55:45 kurasige Exp $
28// GEANT4 tag $Name: HEAD $
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      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////////////////////
183G4ParticleDefinition* 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////////////////////
258G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int , G4int )
259{
260  return GetIon(Z, A);
261}
262
263////////////////////
264G4ParticleDefinition* G4IonTable::GetIon(G4int Z, G4int A, G4int J)
265{
266  return GetIon( Z, A, 0.0, J);
267}
268
269////////////////////
270G4ParticleDefinition* 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////////////////////
290G4ParticleDefinition* 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////////////////////
314G4ParticleDefinition* 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////////////////////
350G4ParticleDefinition* 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////////////////////
399G4ParticleDefinition* 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/////////////////
454G4int 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/////////////////
474G4int 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///////////////
497G4bool 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///////////////
521G4bool 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/////////////////
552const 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/////////////////
575const 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/////////////////
588G4bool 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
604G4bool 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/////////////////
614G4ParticleDefinition* G4IonTable::GetLightIon(G4int Z, G4int A) const
615{
616  // returns pointer to pre-defined ions
617
618  G4ParticleDefinition* ion=0;
619  if ( (Z<=2) ) {
620    if ( (Z==1)&&(A==1) ) {
621      ion = G4ParticleTable::GetParticleTable()->FindParticle("proton"); // proton
622
623    } else if ( (Z==0)&&(A==1) ) {
624      ion = G4ParticleTable::GetParticleTable()->FindParticle("neutron"); // neutron
625    } else if ( (Z==1)&&(A==2) ) {
626      ion = G4ParticleTable::GetParticleTable()->FindParticle("deuteron"); // deuteron
627    } else if ( (Z==1)&&(A==3) ) {
628      ion = G4ParticleTable::GetParticleTable()->FindParticle("triton"); // tritoon
629    } else if ( (Z==2)&&(A==4) ) {
630      ion = G4ParticleTable::GetParticleTable()->FindParticle("alpha"); // alpha
631
632    } else if ( (Z==2)&&(A==3) ) {
633      ion = G4ParticleTable::GetParticleTable()->FindParticle("He3"); // He3
634    }
635  }
636  return ion;
637}
638
639/////////////////
640// -- GetNucleusMass/GetIonMass ---
641/////////////////
642G4double  G4IonTable::GetNucleusMass(G4int Z, G4int A, G4int L) const
643{
644  if ( (A<1)  || (Z<0) || (L<0) ){
645#ifdef G4VERBOSE
646    if (GetVerboseLevel()>0) {
647      G4cout << "G4IonTable::GetNucleusMass() : illegal atomic number/mass " << G4endl;
648      G4cout << " Z =" << Z << "  A = " << A  << G4endl;
649    }
650#endif
651    G4Exception( "G4IonTable::GetNucleusMass()","Illegal operation",
652                 EventMustBeAborted, "illegal atomic number/mass");
653    return -1.0;
654  }
655
656  G4double mass;
657  if (L == 0) {
658    // calculate nucleus mass
659    G4ParticleDefinition* ion=GetLightIon(Z, A);
660   
661    if (ion!=0) {
662      mass = ion->GetPDGMass();
663    } else {
664      // use G4NucleiProperties::GetNuclearMass
665      mass = G4NucleiProperties::GetNuclearMass(A, Z);
666    }
667
668  } else {
669    mass = G4HyperNucleiProperties::GetNuclearMass(A, Z, L);
670  }
671  return mass;
672}
673
674//////////////////
675G4double  G4IonTable::GetIonMass(G4int Z, G4int A, G4int L) const
676{
677   return GetNucleusMass(Z,A,L);
678}
679
680
681/////////////////
682// -- Methods for handling conatiner  ---
683/////////////////
684void G4IonTable::Insert(G4ParticleDefinition* particle)
685{
686  if (IsIon(particle)) {
687    fIonList->push_back(particle);
688  }
689}
690
691/////////////////
692void G4IonTable::Remove(G4ParticleDefinition* particle)
693{
694  if (IsIon(particle)) {
695    G4IonList::iterator idx;
696    for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) {
697      if ( particle == *idx) {
698        fIonList->erase(idx);
699        break;
700      }
701    }
702  } else {
703#ifdef G4VERBOSE
704    if (GetVerboseLevel()>1) {
705      G4cout << "G4IonTable::Remove :" << particle->GetParticleName() ;
706      G4cout << " is not ions" << G4endl; 
707    }
708#endif
709  }
710 
711}
712
713
714
715/////////////////
716// -- Dump Information
717/////////////////
718void G4IonTable::DumpTable(const G4String &particle_name) const
719{
720  G4ParticleDefinition* ion;
721  G4IonList::iterator idx;
722  for (idx = fIonList->begin(); idx!= fIonList->end(); ++idx) {
723    ion = *idx;
724    if (( particle_name == "ALL" ) || (particle_name == "all")){
725      ion->DumpTable();
726    } else if ( particle_name == ion->GetParticleName() ) {
727      ion->DumpTable();
728    }
729  }
730}
731
732/////////////////
733const G4String G4IonTable::elementName[] = {
734  "H",                                                                                                "He", 
735  "Li", "Be",                                                             "B",  "C",  "N",  "O", "F", "Ne", 
736  "Na", "Mg",                                                             "Al", "Si", "P", "S", "Cl", "Ar", 
737  "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", 
738  "Rb", "Sr", "Y", "Zr", "Nb", "Mo","Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I",  "Xe", 
739  "Cs", "Ba", 
740              "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", 
741                   "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", 
742  "Fr", "Ra", 
743              "Ac", "Th", "Pa",  "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr",
744              "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", 
745              "Uub", "Uut", "Uuq","Uup","Uuh","Uus","Uuo"
746};
747
748
749/////////////////
750G4int G4IonTable::GetVerboseLevel() const
751{
752  return G4ParticleTable::GetParticleTable()->GetVerboseLevel();
753}
754
755/////////////////
756void  G4IonTable::AddProcessManager(const G4String& name)
757{
758  // create command string for addProcManager
759  std::ostringstream osAdd;
760  osAdd << "/run/particle/addProcManager "<< name;
761  G4String cmdAdd = osAdd.str();
762
763  // set /control/verbose 0
764  G4int tempVerboseLevel = G4UImanager::GetUIpointer()->GetVerboseLevel();
765  G4UImanager::GetUIpointer()->SetVerboseLevel(0);
766
767  // issue /run/particle/addProcManage
768  G4UImanager::GetUIpointer()->ApplyCommand(cmdAdd);
769
770  // retreive  /control/verbose
771  G4UImanager::GetUIpointer()->SetVerboseLevel(tempVerboseLevel);
772}
773
774#include <vector>    
775
776////////////////////
777void  G4IonTable::RegisterIsotopeTable(G4VIsotopeTable* table)
778{
779  fIsotopeTableList->push_back(table);
780}
781
782////////////////////
783G4VIsotopeTable* G4IonTable::GetIsotopeTable(size_t index) const
784{
785   G4VIsotopeTable* fIsotopeTable=0;
786   if ( index < fIsotopeTableList->size() ) {
787     fIsotopeTable = (*fIsotopeTableList)[index];
788   }
789   return fIsotopeTable;
790}
791
792
793////////////////////
794G4IsotopeProperty* G4IonTable::FindIsotope(G4int Z, G4int A, G4double E, G4int )
795{
796  if (fIsotopeTableList ==0) return 0;
797  if (fIsotopeTableList->size()==0) return 0;
798 
799  // ask IsotopeTable
800  G4IsotopeProperty* property =0;
801
802  // iterate
803  for (size_t i = 0; i< fIsotopeTableList->size(); ++i) {
804    G4VIsotopeTable* fIsotopeTable= (*fIsotopeTableList)[i];
805    G4IsotopeProperty* tmp = fIsotopeTable->GetIsotope(Z,A,E);
806    if ( tmp !=0) {
807     
808#ifdef G4VERBOSE
809      if (GetVerboseLevel()>1) {
810        G4cout << "G4IonTable::FindIsotope:"; 
811        G4cout << " Z: " << Z;
812        G4cout << " A: " << A;
813        G4cout << " E: " << E;
814        G4cout << G4endl; 
815        tmp->DumpInfo();
816      }
817#endif
818      if (property !=0) {
819        // overwrite spin/magnetic moment/decay table if not defined
820        if( property->GetiSpin() ==0) {
821          property->SetiSpin( tmp->GetiSpin() );
822        }
823        if( property->GetMagneticMoment() <= 0.0) {
824          property->SetMagneticMoment( tmp->GetMagneticMoment() );
825        }
826        if( property->GetLifeTime() <= 0.0) {
827          property->SetLifeTime( tmp->GetLifeTime() );
828          if (    (property->GetLifeTime() > 0.0)
829               && (property->GetDecayTable() ==0 ) ) {
830            property->SetDecayTable( tmp->GetDecayTable() );
831            tmp->SetDecayTable( 0 );
832          }
833        }
834      } else {
835        property = tmp;
836      }
837    }
838  }
839 
840  return property;
841}
842
843
844
845
846
847
848
849
850
851
852
853
854
855
Note: See TracBrowser for help on using the repository browser.