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

Last change on this file since 1117 was 992, checked in by garnier, 15 years ago

fichiers oublies

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