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: G4tgbElement.cc 69803 2013-05-15 15:24:50Z gcosmo $ 00028 // 00029 // 00030 // class G4tgbElement 00031 00032 // History: 00033 // - Created. P.Arce, CIEMAT (November 2007) 00034 // ------------------------------------------------------------------------- 00035 00036 #include "G4tgbElement.hh" 00037 #include "G4tgbMaterialMgr.hh" 00038 #include "G4tgrElementSimple.hh" 00039 #include "G4tgrElementFromIsotopes.hh" 00040 #include "G4tgrMessenger.hh" 00041 00042 00043 //---------------------------------------------------------------------- 00044 G4tgbElement::G4tgbElement( G4tgrElement* hg ) 00045 { 00046 theTgrElem = hg; 00047 theG4Elem = 0; 00048 } 00049 00050 00051 //---------------------------------------------------------------------- 00052 G4Element* G4tgbElement::BuildG4ElementSimple() 00053 { 00054 G4Element* elem = 0; 00055 00056 //-------- if G4Element not found, construct it 00057 if( theG4Elem == 0 ) 00058 { 00059 //----- construct new G4Element 00060 G4tgrElementSimple* tgrElem = static_cast<G4tgrElementSimple*>(theTgrElem); 00061 00062 elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(), 00063 tgrElem->GetZ(), tgrElem->GetA() ); 00064 #ifdef G4VERBOSE 00065 if( G4tgrMessenger::GetVerboseLevel() >= 1 ) 00066 { 00067 G4cout << " Constructing new G4Element: " 00068 << *elem << G4endl; 00069 } 00070 #endif 00071 theG4Elem = elem; 00072 } 00073 else 00074 { 00075 elem = theG4Elem; 00076 } 00077 00078 return elem; 00079 } 00080 00081 00082 //---------------------------------------------------------------------- 00083 G4Element* G4tgbElement::BuildG4ElementFromIsotopes() 00084 { 00085 G4Element* elem = 0; 00086 00087 //-------- if G4Element not found, construct it 00088 if( theG4Elem == 0 ) 00089 { 00090 //----- construct new G4Element 00091 G4tgrElementFromIsotopes* tgrElem 00092 = static_cast<G4tgrElementFromIsotopes*>(theTgrElem); 00093 00094 elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(), 00095 tgrElem->GetNumberOfIsotopes() ); 00096 00097 //----- add isotopes 00098 G4Isotope* compIsot; 00099 G4tgbMaterialMgr* mf = G4tgbMaterialMgr::GetInstance(); 00100 for( G4int ii = 0; ii < tgrElem->GetNumberOfIsotopes(); ii++) 00101 { 00102 // Look if this component is a material 00103 00104 compIsot = mf->FindOrBuildG4Isotope( tgrElem->GetComponent(ii) ); 00105 if( compIsot != 0 ) 00106 { 00107 elem->AddIsotope( compIsot, tgrElem->GetAbundance(ii) ); 00108 } 00109 else 00110 { 00111 G4String ErrMessage = "Component " + tgrElem->GetComponent(ii) 00112 + " of element " + tgrElem->GetName() 00113 + " is not an isotope !"; 00114 G4Exception("G4tgbElement::BuildG4ElementFromIsotopes()", 00115 "InvalidSetup", FatalException, ErrMessage ); 00116 } 00117 } 00118 theG4Elem = elem; 00119 } 00120 else 00121 { 00122 elem = theG4Elem; 00123 } 00124 00125 00126 #ifdef G4VERBOSE 00127 if( G4tgrMessenger::GetVerboseLevel() >= 1 ) 00128 { 00129 G4cout << " Constructing new G4Element from isotopes: " 00130 << *elem << G4endl; 00131 } 00132 #endif 00133 00134 return elem; 00135 }