// // ******************************************************************** // * DISCLAIMER * // * * // * The following disclaimer summarizes all the specific disclaimers * // * of contributors to this software. The specific disclaimers,which * // * govern, are listed with their locations in: * // * http://cern.ch/geant4/license * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. * // * * // * This code implementation is the intellectual property of the * // * GEANT4 collaboration. * // * By copying, distributing or modifying the Program (or any work * // * based on the Program) you indicate your acceptance of this * // * statement, and all its terms. * // ******************************************************************** // // // $Id: G4Element.cc,v 1.7.2.1 2001/06/28 19:10:30 gunter Exp $ // GEANT4 tag $Name: $ // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... // 26-06-96: Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban // 09-07-96: new data members added by L.Urban // 17-01-97: aesthetic rearrangement, M.Maire // 20-01-97: Compute Tsai's formula for the rad length, M.Maire // 21-01-97: remove mixture flag, M.Maire // 24-01-97: ComputeIonisationParameters(). // new data member: fTaul, M.Maire // 29-01-97: Forbidden to create Element with Z<1 or N Shell; GetBindingEnergy() (mma) // 09-03-01: assignement operator revised (mma) // 02-05-01: check identical Z in AddIsotope (marc) // 03-05-01, flux.precision(prec) at begin/end of operator<< //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... #include "G4Element.hh" #include "g4std/iomanip" G4ElementTable G4Element::theElementTable; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... // Constructor to Generate an element from scratch G4Element::G4Element(const G4String& name, const G4String& symbol, G4double zeff, G4double aeff) :fName(name),fSymbol(symbol) { if (zeff<1.) G4Exception (" ERROR from G4Element::G4Element !" " It is not allowed to create an Element with Z < 1" ); if (aeff/(g/mole) perMillion) G4cerr << name << " : WARNING from G4Element::G4Element !" " Trying to define an element as a mixture directly via effective Z." << G4endl; InitializePointers(); fZeff = zeff; fNeff = aeff/(g/mole); fAeff = aeff; fNumberOfIsotopes = 0; fNbOfAtomicShells = G4AtomicShells::GetNumberOfShells((G4int)fZeff); fAtomicShells = new G4double[fNbOfAtomicShells]; for (G4int i=0;ilength() ) { // check same Z if (fNumberOfIsotopes==0) fZeff = G4double(isotope->GetZ()); else if (G4double(isotope->GetZ()) != fZeff) G4Exception ("ERROR from G4Element::AddIsotope!" " Try to add isotopes with different Z"); //Z ok fRelativeAbundanceVector[fNumberOfIsotopes] = abundance; (*theIsotopeVector)(fNumberOfIsotopes) = isotope; ++fNumberOfIsotopes; } else G4Exception ("ERROR from G4Element::AddIsotope!" " Attempt to add more than the declared number of isotopes."); // filled. if ( fNumberOfIsotopes == theIsotopeVector->length() ) { // Compute Neff, Aeff G4double wtSum=0.0; fNeff = fAeff = 0.0; for (size_t i=0;iGetN(); fAeff += fRelativeAbundanceVector[i]*(*theIsotopeVector)(i)->GetA(); wtSum += fRelativeAbundanceVector[i]; } fNeff /= wtSum; fAeff /= wtSum; fNbOfAtomicShells = G4AtomicShells::GetNumberOfShells((G4int)fZeff); fAtomicShells = new G4double[fNbOfAtomicShells]; for (G4int j=0;j=fNbOfAtomicShells) G4Exception("Invalid argument in G4Element::GetAtomicShell"); return fAtomicShells[i]; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... G4Element::G4Element(G4Element& right) { InitializePointers(); *this = right; // Store this new element in table and set the index theElementTable.insert(this); fIndexInTable = theElementTable.index(this); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... const G4Element& G4Element::operator=(const G4Element& right) { if (this != &right) { fName = right.fName; fSymbol = right.fSymbol; fZeff = right.fZeff; fNeff = right.fNeff; fAeff = right.fAeff; if (fAtomicShells) delete [] fAtomicShells; fNbOfAtomicShells = right.fNbOfAtomicShells; fAtomicShells = new G4double[fNbOfAtomicShells]; for (G4int i=0;i 0) { theIsotopeVector = new G4IsotopeVector(fNumberOfIsotopes); fRelativeAbundanceVector = new G4double[fNumberOfIsotopes]; for (size_t i=0;ifName << G4std::setw(3) << element->fSymbol << " Z = " << G4std::setw(4) << G4std::setprecision(1) << element->fZeff << " N = " << G4std::setw(5) << G4std::setprecision(1) << element->fNeff << " A = " << G4std::setw(6) << G4std::setprecision(2) << (element->fAeff)/(g/mole) << " g/mole"; for (size_t i=0; ifNumberOfIsotopes; i++) flux << "\n ---> " << (*(element->theIsotopeVector))[i] << " abundance: " << G4std::setw(6) << G4std::setprecision(2) << (element->fRelativeAbundanceVector[i])/perCent << " %"; flux.precision(prec); flux.setf(mode,G4std::ios::floatfield); return flux; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... G4std::ostream& operator<<(G4std::ostream& flux, G4Element& element) { flux << &element; return flux; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo.... G4std::ostream& operator<<(G4std::ostream& flux, G4ElementTable ElementTable) { //Dump info for all known elements flux << "\n***** Table : Nb of elements = " << ElementTable.length() << " *****\n" << G4endl; for (size_t i=0; i