G4Isotope.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4Isotope.cc 67044 2013-01-30 08:50:06Z gcosmo $
00028 //
00029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00030 
00031 // 26.06.96: Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban
00032 // 29.01.97: Forbidden to create Isotope with Z<1 or N<Z, M.Maire
00033 // 03.05.01: flux.precision(prec) at begin/end of operator<<
00034 // 17.07.01: migration to STL. M. Verderi.
00035 // 13.09.01: suppression of the data member fIndexInTable
00036 // 14.09.01: fCountUse: nb of elements which use this isotope 
00037 // 26.02.02: fIndexInTable renewed
00038 // 17.10.06: if fA is not defined in the constructor, it is computed from
00039 //           NistManager v.Ivanchenko
00040 // 25.10.11: new scheme for G4Exception  (mma)
00041 
00042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00043 
00044 #include <iomanip>
00045 
00046 #include "G4Isotope.hh"
00047 #include "G4NistManager.hh"
00048 #include "G4PhysicalConstants.hh"
00049 #include "G4SystemOfUnits.hh"
00050 
00051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00052 
00053 G4IsotopeTable G4Isotope::theIsotopeTable;
00054 
00055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00056 
00057 // Create an isotope
00058 //
00059 G4Isotope::G4Isotope(const G4String& Name,G4int Z,G4int N,G4double A,G4int il)
00060 : fName(Name), fZ(Z), fN(N), fA(A), fm(il), fCountUse(0)
00061 {
00062   if (Z<1) { 
00063     G4ExceptionDescription ed;
00064     ed << "Wrong Isotope " << Name << " Z= " << Z << G4endl;
00065     G4Exception ("G4Isotope::G4Isotope()", "mat001", FatalException, ed);
00066   }
00067   if (N<Z) {
00068     G4ExceptionDescription ed;
00069     ed << "Wrong Isotope " << Name << " Z= " << Z << " > N= " << N << G4endl;
00070     G4Exception ("G4Isotope::G4Isotope()", "mat002", FatalException, ed);
00071   }
00072   if (A<=0.0) {
00073     fA = (G4NistManager::Instance()->GetAtomicMass(Z,N))*g/(mole*amu_c2);  
00074   }
00075   theIsotopeTable.push_back(this);
00076   fIndexInTable = theIsotopeTable.size() - 1;
00077 }
00078 
00079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00080 
00081 // Fake default constructor - sets only member data and allocates memory
00082 //                            for usage restricted to object persistency
00083 
00084 G4Isotope::G4Isotope(__void__&)
00085   : fZ(0), fN(0), fA(0), fm(0), fCountUse(0), fIndexInTable(0)
00086 {
00087 }
00088 
00089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00090 
00091 G4Isotope::~G4Isotope()
00092 {
00093   theIsotopeTable[fIndexInTable] = 0;
00094 }  
00095 
00096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00097 
00098 G4Isotope::G4Isotope(G4Isotope& right)
00099 {
00100   *this = right;
00101   
00102   //insert this new isotope in table
00103   theIsotopeTable.push_back(this);
00104   fIndexInTable = theIsotopeTable.size() - 1;
00105 }
00106 
00107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00108 
00109 G4Isotope & G4Isotope::operator=(const G4Isotope& right)
00110 {
00111   if (this != &right)
00112   {
00113     fName = right.fName;
00114     fZ = right.fZ;
00115     fN = right.fN;
00116     fA = right.fA;
00117     fm = right.fm;    
00118     fCountUse = right.fCountUse;
00119   }
00120   return *this;
00121 }
00122 
00123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00124 
00125 G4int G4Isotope::operator==(const G4Isotope &right) const
00126 {
00127   return (this == (G4Isotope *) &right);
00128 }
00129 
00130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00131 
00132 G4int G4Isotope::operator!=(const G4Isotope &right) const
00133 {
00134   return (this != (G4Isotope *) &right);
00135 }
00136 
00137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00138 
00139 std::ostream& operator<<(std::ostream& flux, G4Isotope* isotope)
00140 {
00141   std::ios::fmtflags mode = flux.flags();
00142   flux.setf(std::ios::fixed,std::ios::floatfield);
00143   G4long prec = flux.precision(3);
00144     
00145   flux
00146     << " Isotope: " << std::setw(5) << isotope->fName 
00147     << "   Z = " << std::setw(2)    << isotope->fZ 
00148     << "   N = " << std::setw(3)    << isotope->fN
00149     << "   A = " << std::setw(6) << std::setprecision(2) 
00150     << (isotope->fA)/(g/mole) << " g/mole";
00151 
00152   flux.precision(prec);       
00153   flux.setf(mode,std::ios::floatfield);       
00154   return flux;
00155 }
00156 
00157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00158 
00159 std::ostream& operator<<(std::ostream& flux, G4Isotope& isotope)
00160 {
00161   flux << &isotope;        
00162   return flux;
00163 }
00164 
00165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00166      
00167 std::ostream& operator<<(std::ostream& flux, G4IsotopeTable IsotopeTable)
00168 {
00169  //Dump info for all known isotopes
00170    flux 
00171      << "\n***** Table : Nb of isotopes = " << IsotopeTable.size() 
00172      << " *****\n" << G4endl;
00173         
00174    for (size_t i=0; i<IsotopeTable.size(); i++)
00175      flux << IsotopeTable[i] << G4endl;
00176 
00177    return flux;
00178 }
00179       
00180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00181 
00182 const G4IsotopeTable* G4Isotope::GetIsotopeTable()
00183 {
00184   return &theIsotopeTable;
00185 }
00186 
00187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00188 
00189 size_t G4Isotope::GetNumberOfIsotopes()
00190 {
00191   return theIsotopeTable.size();
00192 }
00193 
00194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
00195 
00196 G4Isotope* G4Isotope::GetIsotope(const G4String& isotopeName, G4bool warning)
00197 {  
00198   // search the isotope by its name 
00199   for (size_t J=0 ; J<theIsotopeTable.size() ; J++)
00200    {
00201      if (theIsotopeTable[J]->GetName() == isotopeName)
00202        { return theIsotopeTable[J]; }
00203    }
00204    
00205   // the isotope does not exist in the table
00206   if (warning) {
00207     G4cout << "\n---> warning from G4Isotope::GetIsotope(). The isotope: "
00208            << isotopeName << " does not exist in the table. Return NULL pointer."
00209            << G4endl;
00210   }     
00211   return 0;          
00212 }
00213 
00214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

Generated on Mon May 27 17:48:41 2013 for Geant4 by  doxygen 1.4.7