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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /g3tog4/src/G3EleTable.cc (Version 11.3.0) and /g3tog4/src/G3EleTable.cc (Version 8.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: G3EleTable.cc,v 1.16 2006/06/29 18:12:55 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-08-01-patch-01 $
 27 //                                                 29 //
 28                                                    30 
 29 #include <sstream>                             << 
 30                                                << 
 31 #include "G3EleTable.hh"                       << 
 32                                                << 
 33 #include "G4Types.hh"                              31 #include "G4Types.hh"
 34 #include "G4PhysicalConstants.hh"              <<  32 #include <sstream>
 35 #include "G4SystemOfUnits.hh"                  << 
 36 #include "G4ios.hh"                                33 #include "G4ios.hh"
                                                   >>  34 #include "G3EleTable.hh"
 37                                                    35 
 38 G3EleTable::G3EleTable()                       <<  36 G3EleTable::G3EleTable() :_MaxEle(109){
 39 {                                              <<  37   _EleNames = new char*[_MaxEle];
 40   // create an array of pointers to elements       38   // create an array of pointers to elements
 41   _Ele = new G4Element*[_MaxEle];                  39   _Ele = new G4Element*[_MaxEle];
 42   LoadUp();                                        40   LoadUp();
 43 }                                                  41 }
 44                                                    42 
 45 G3EleTable::~G3EleTable()                      <<  43 G3EleTable::~G3EleTable(){
 46 {                                              <<  44   delete [] _EleNames;
 47   delete [] _Ele;                                  45   delete [] _Ele;
 48 }                                                  46 }
 49                                                    47 
 50 G4Element*                                         48 G4Element* 
 51 G3EleTable::GetEle(G4double Z)                 <<  49 G3EleTable::GetEle(G4double Z){
 52 {                                              <<  50   G4double A;
 53   G4double A = 0.;                             << 
 54   char name[20], sym[3];                           51   char name[20], sym[3];
 55   G4int index = (G4int) Z-1;                       52   G4int index = (G4int) Z-1;
 56   if (!parse(Z, name, sym, A))                 <<  53   if (!parse(Z, name, sym, A)) {
 57   {                                            <<  54     G4String nm(name);
 58     G4String na(name);                         << 
 59     G4String sy(sym);                              55     G4String sy(sym);
 60     if (_Ele[index] == nullptr)                <<  56     if (_Ele[index] == 0) {
 61     {                                          << 
 62       if ( A == 0. )                           << 
 63       {                                        << 
 64         // Cannot create element with A = 0.   << 
 65         G4String text = "Failed to get element << 
 66         G4Exception("G3EleTable::GetEle", "G3t << 
 67       }                                        << 
 68       // add an element to the element table h     57       // add an element to the element table here
 69       _Ele[index] = new G4Element(na, sy, Z, A <<  58       _Ele[index] = new G4Element(nm, sy, Z, A*g/mole);
 70     }                                              59     }
 71   }                                                60   }
 72   return _Ele[index];                              61   return _Ele[index];
 73 }                                                  62 }
 74                                                    63 
 75 G4int                                              64 G4int 
 76 G3EleTable::parse(G4double& Z, char* name, cha <<  65 G3EleTable::parse(G4double& Z, char* name, char* sym, G4double& A){ 
 77 {                                              <<  66  G4int rc = 0;
 78   G4int rc = 0;                                <<  67   if (Z>0 && Z <=_MaxEle){
 79   if (Z>0 && Z <=_MaxEle)                      << 
 80   {                                            << 
 81     G4int z = (G4int) Z-1;                         68     G4int z = (G4int) Z-1;
 82     G4String str(_EleNames[z]);                <<  69     std::istringstream in(_EleNames[z]);
 83     char* cstr = new char [str.length()+1];    <<  70     in >> name >> sym >> A;
 84     std::strcpy(cstr, str.c_str());            <<  71   } else {
 85     char* p = std::strtok(cstr," ");           << 
 86     std::strcpy(name, p);                      << 
 87     p = std::strtok(NULL," ");                 << 
 88     std::strcpy(sym, p);                       << 
 89     p = std::strtok(NULL," ");                 << 
 90     std::istringstream in(p);                  << 
 91     in >> A;                                   << 
 92     delete [] cstr;                            << 
 93   }                                            << 
 94   else                                         << 
 95   {                                            << 
 96     rc = -1;                                       72     rc = -1;
 97   }                                                73   }
 98   return rc;                                       74   return rc;
 99 }                                                  75 }
100                                                    76 
101 void                                               77 void
102 G3EleTable::LoadUp()                           <<  78 G3EleTable::LoadUp(){
103 {                                              <<  79   G4int i=0;
                                                   >>  80   _EleNames[i]=(char *)"Hydrogen H 1.00794"; i++;
                                                   >>  81   _EleNames[i]=(char *)"Helium He 4.0026"; i++;
                                                   >>  82   _EleNames[i]=(char *)"Lithium Li 6.941"; i++;
                                                   >>  83   _EleNames[i]=(char *)"Beryllium Be 9.012182"; i++;
                                                   >>  84   _EleNames[i]=(char *)"Boron B 10.811"; i++;
                                                   >>  85   _EleNames[i]=(char *)"Carbon C 12.011"; i++;
                                                   >>  86   _EleNames[i]=(char *)"Nitrogen N 14.00674"; i++;
                                                   >>  87   _EleNames[i]=(char *)"Oxygen O 15.9994"; i++;
                                                   >>  88   _EleNames[i]=(char *)"Fluorine F 18.9984032"; i++;
                                                   >>  89   _EleNames[i]=(char *)"Neon Ne 20.1797"; i++;
                                                   >>  90 
                                                   >>  91   _EleNames[i]=(char *)"Sodium Na 22.989768"; i++;
                                                   >>  92   _EleNames[i]=(char *)"Magnesium Mg 24.3050"; i++;
                                                   >>  93   _EleNames[i]=(char *)"Aluminum Al 26.981539"; i++;
                                                   >>  94   _EleNames[i]=(char *)"Silicon Si 28.0855"; i++;
                                                   >>  95   _EleNames[i]=(char *)"Phosphorus P 30.973762"; i++;
                                                   >>  96   _EleNames[i]=(char *)"Sulfur S 32.066"; i++;
                                                   >>  97   _EleNames[i]=(char *)"Chlorine Cl 35.4527"; i++;
                                                   >>  98   _EleNames[i]=(char *)"Argon Ar 39.948"; i++;
                                                   >>  99   _EleNames[i]=(char *)"Potassium K 39.0983"; i++;
                                                   >> 100   _EleNames[i]=(char *)"Calcium Ca 40.078"; i++;
                                                   >> 101 
                                                   >> 102   _EleNames[i]=(char *)"Scandium Sc 44.955910"; i++;
                                                   >> 103   _EleNames[i]=(char *)"Titanium Ti 47.867"; i++;
                                                   >> 104   _EleNames[i]=(char *)"Vanadium V 50.9415"; i++;
                                                   >> 105   _EleNames[i]=(char *)"Chromium Cr 51.9961"; i++;
                                                   >> 106   _EleNames[i]=(char *)"Manganese Mn 54.93805"; i++;
                                                   >> 107   _EleNames[i]=(char *)"Iron Fe 55.845"; i++;
                                                   >> 108   _EleNames[i]=(char *)"Cobalt Co 58.93320"; i++;
                                                   >> 109   _EleNames[i]=(char *)"Nickel Ni 58.6934"; i++;
                                                   >> 110   _EleNames[i]=(char *)"Copper Cu 63.546"; i++;
                                                   >> 111   _EleNames[i]=(char *)"Zinc Zn 65.39"; i++;
                                                   >> 112 
                                                   >> 113   _EleNames[i]=(char *)"Gallium Ga 69.723"; i++;
                                                   >> 114   _EleNames[i]=(char *)"Germanium Ge 72.61"; i++;
                                                   >> 115   _EleNames[i]=(char *)"Arsenic As 74.92159"; i++;
                                                   >> 116   _EleNames[i]=(char *)"Selenium Se 78.96"; i++;
                                                   >> 117   _EleNames[i]=(char *)"Bromine Br 79.904"; i++;
                                                   >> 118   _EleNames[i]=(char *)"Krypton Kr 83.80"; i++;
                                                   >> 119   _EleNames[i]=(char *)"Rubidium Rb 85.4678"; i++;
                                                   >> 120   _EleNames[i]=(char *)"Strontium Sr 87.62"; i++;
                                                   >> 121   _EleNames[i]=(char *)"Yttrium Y 88.90585"; i++;
                                                   >> 122   _EleNames[i]=(char *)"Zirconium Zr 91.224"; i++;
                                                   >> 123 
                                                   >> 124   _EleNames[i]=(char *)"Niobium Nb 92.90638"; i++;
                                                   >> 125   _EleNames[i]=(char *)"Molybdenum Mo 95.94"; i++;
                                                   >> 126   _EleNames[i]=(char *)"Technetium Tc 97.907215"; i++;
                                                   >> 127   _EleNames[i]=(char *)"Ruthenium Ru 101.07"; i++;
                                                   >> 128   _EleNames[i]=(char *)"Rhodium Rh 102.90550"; i++;
                                                   >> 129   _EleNames[i]=(char *)"Palladium Pd 106.42"; i++;
                                                   >> 130   _EleNames[i]=(char *)"Silver Ag 107.8682"; i++;
                                                   >> 131   _EleNames[i]=(char *)"Cadmium Cd 112.41"; i++;
                                                   >> 132   _EleNames[i]=(char *)"Indium In 114.818"; i++;
                                                   >> 133   _EleNames[i]=(char *)"Tin Sn 118.710"; i++;
                                                   >> 134 
                                                   >> 135   _EleNames[i]=(char *)"Antimony Sb 121.760"; i++;
                                                   >> 136   _EleNames[i]=(char *)"Tellurium Te 127.60"; i++;
                                                   >> 137   _EleNames[i]=(char *)"Iodine I 126.90447"; i++;
                                                   >> 138   _EleNames[i]=(char *)"Xenon Xe 131.29"; i++;
                                                   >> 139   _EleNames[i]=(char *)"Cesium Cs 132.90543"; i++;
                                                   >> 140   _EleNames[i]=(char *)"Barium Ba 137.27"; i++;
                                                   >> 141   _EleNames[i]=(char *)"Lanthanum La 138.9055"; i++;
                                                   >> 142   _EleNames[i]=(char *)"Cerium Ce 140.115"; i++;
                                                   >> 143   _EleNames[i]=(char *)"Praeseodymium Pr 140.90765"; i++;
                                                   >> 144   _EleNames[i]=(char *)"NeoDymium Nd 144.24"; i++;
                                                   >> 145   
                                                   >> 146   _EleNames[i]=(char *)"Promethium Pm 144.912745"; i++;
                                                   >> 147   _EleNames[i]=(char *)"Samarium Sm 150.36"; i++;
                                                   >> 148   _EleNames[i]=(char *)"Europium Eu 151.965"; i++;
                                                   >> 149   _EleNames[i]=(char *)"Gadolinium Gd 157.25"; i++;
                                                   >> 150   _EleNames[i]=(char *)"Terbium Tb 158.92534"; i++;
                                                   >> 151   _EleNames[i]=(char *)"Dysprosium Dy 162.50"; i++;
                                                   >> 152   _EleNames[i]=(char *)"Holmium Ho 164.93032"; i++;
                                                   >> 153   _EleNames[i]=(char *)"Erbium Er 167.26"; i++;
                                                   >> 154   _EleNames[i]=(char *)"Thulium Tm 168.93421"; i++;
                                                   >> 155   _EleNames[i]=(char *)"Ytterbium Yb 173.04"; i++;
                                                   >> 156 
                                                   >> 157   _EleNames[i]=(char *)"Lutetium Lu 174.967"; i++;
                                                   >> 158   _EleNames[i]=(char *)"Hafnium Hf 178.49"; i++;
                                                   >> 159   _EleNames[i]=(char *)"Tantalum Ta 180.9479"; i++;
                                                   >> 160   _EleNames[i]=(char *)"Tungsten W 183.84"; i++;
                                                   >> 161   _EleNames[i]=(char *)"Rhenium Re 186.207"; i++;
                                                   >> 162   _EleNames[i]=(char *)"Osmium Os 190.23"; i++;
                                                   >> 163   _EleNames[i]=(char *)"Iridium Ir 192.217"; i++;
                                                   >> 164   _EleNames[i]=(char *)"Platinum Pt 195.08"; i++;
                                                   >> 165   _EleNames[i]=(char *)"Gold Au 196.96654"; i++;
                                                   >> 166   _EleNames[i]=(char *)"Mercury Hg 200.59"; i++;
                                                   >> 167 
                                                   >> 168   _EleNames[i]=(char *)"Thallium Tl 204.3833"; i++;
                                                   >> 169   _EleNames[i]=(char *)"Lead Pb 207.2"; i++;
                                                   >> 170   _EleNames[i]=(char *)"Bismuth Bi 208.98037"; i++;
                                                   >> 171   _EleNames[i]=(char *)"Polonium Po 208.982415"; i++;
                                                   >> 172   _EleNames[i]=(char *)"Astatine At 209.987131"; i++;
                                                   >> 173   _EleNames[i]=(char *)"Radon Rn 222.017570"; i++;
                                                   >> 174   _EleNames[i]=(char *)"Francium Fr 223.019731"; i++;
                                                   >> 175   _EleNames[i]=(char *)"Radium Ra 226.025402"; i++;
                                                   >> 176   _EleNames[i]=(char *)"Actinium Ac 227.027747"; i++;
                                                   >> 177   _EleNames[i]=(char *)"Thorium Th 232.0381"; i++;
                                                   >> 178 
                                                   >> 179   _EleNames[i]=(char *)"Protactinium Pa 231.03588"; i++;
                                                   >> 180   _EleNames[i]=(char *)"Uranium U 238.0289"; i++;
                                                   >> 181   _EleNames[i]=(char *)"Neptunium Np 237.048166"; i++;
                                                   >> 182   _EleNames[i]=(char *)"Plutonium Pu 244.064197"; i++;
                                                   >> 183   _EleNames[i]=(char *)"Americium Am 243.061372"; i++;
                                                   >> 184   _EleNames[i]=(char *)"Curium Cm 247.070346"; i++;
                                                   >> 185   _EleNames[i]=(char *)"Berkelium Bk 247.070298"; i++;
                                                   >> 186   _EleNames[i]=(char *)"Californium Cf 251.079579"; i++;
                                                   >> 187   _EleNames[i]=(char *)"Einsteinium Es 252.08297"; i++;
                                                   >> 188   _EleNames[i]=(char *)"Fermium Fm 257.095096"; i++;
                                                   >> 189 
                                                   >> 190   _EleNames[i]=(char *)"Mendelevium Md 258.098427"; i++;
                                                   >> 191   _EleNames[i]=(char *)"Nobelium No 259.1011"; i++;
                                                   >> 192   _EleNames[i]=(char *)"Lawrencium Lr 262.1098"; i++;
                                                   >> 193   _EleNames[i]=(char *)"Rutherfordium Rf 261.1089";  i++;
                                                   >> 194   _EleNames[i]=(char *)"Hahnium Ha 262.1144";  i++;
                                                   >> 195   _EleNames[i]=(char *)"Seaborgium Sg 263.1186";  i++;
                                                   >> 196   _EleNames[i]=(char *)"Nielsborium Ns 262.1231";  i++;
                                                   >> 197   _EleNames[i]=(char *)"Hassium Hs 265.1306";  i++;
                                                   >> 198   _EleNames[i]=(char *)"Meitnerium Mt 266.1378";  i++;
                                                   >> 199 
104   // initialize element pointers to 0             200   // initialize element pointers to 0
105   for (G4int j=0; j<_MaxEle; ++j)              << 201   for (G4int j=0; j<i; j++) {
106   {                                            << 202     _Ele[j]=0;
107     _Ele[j]=nullptr;                           << 
108   }                                               203   }
109 }                                                 204 }
                                                   >> 205 
                                                   >> 206 
110                                                   207