Geant4_10
G4tgbElement.cc
Go to the documentation of this file.
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: G4tgbElement.cc 66363 2012-12-18 09:12:54Z gcosmo $
28 //
29 //
30 // class G4tgbElement
31 
32 // History:
33 // - Created. P.Arce, CIEMAT (November 2007)
34 // -------------------------------------------------------------------------
35 
36 #include "G4tgbElement.hh"
37 #include "G4tgbMaterialMgr.hh"
38 #include "G4tgrElementSimple.hh"
40 #include "G4tgrMessenger.hh"
41 
42 
43 //----------------------------------------------------------------------
45 {
46  theTgrElem = hg;
47  theG4Elem = 0;
48 }
49 
50 
51 //----------------------------------------------------------------------
53 {
54  G4Element* elem = 0;
55 
56  //-------- if G4Element not found, construct it
57  if( theG4Elem == 0 )
58  {
59  //----- construct new G4Element
60  G4tgrElementSimple* tgrElem = static_cast<G4tgrElementSimple*>(theTgrElem);
61 
62  elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(),
63  tgrElem->GetZ(), tgrElem->GetA() );
64 #ifdef G4VERBOSE
66  {
67  G4cout << " Constructing new G4Element: "
68  << *elem << G4endl;
69  }
70 #endif
71  theG4Elem = elem;
72  }
73  else
74  {
75  elem = theG4Elem;
76  }
77 
78  return elem;
79 }
80 
81 
82 //----------------------------------------------------------------------
84 {
85  G4Element* elem = 0;
86 
87  //-------- if G4Element not found, construct it
88  if( theG4Elem == 0 )
89  {
90  //----- construct new G4Element
92  = static_cast<G4tgrElementFromIsotopes*>(theTgrElem);
93 
94  elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(),
95  tgrElem->GetNumberOfIsotopes() );
96 
97  //----- add isotopes
98  G4Isotope* compIsot;
100  for( G4int ii = 0; ii < tgrElem->GetNumberOfIsotopes(); ii++)
101  {
102  // Look if this component is a material
103 
104  compIsot = mf->FindOrBuildG4Isotope( tgrElem->GetComponent(ii) );
105  if( compIsot != 0 )
106  {
107  elem->AddIsotope( compIsot, tgrElem->GetAbundance(ii) );
108  }
109  else
110  {
111  G4String ErrMessage = "Component " + tgrElem->GetComponent(ii)
112  + " of element " + tgrElem->GetName()
113  + " is not an isotope !";
114  G4Exception("G4tgbElement::BuildG4ElementFromIsotopes()",
115  "InvalidSetup", FatalException, ErrMessage );
116  }
117  }
118  theG4Elem = elem;
119  }
120  else
121  {
122  elem = theG4Elem;
123  }
124 
125 
126 #ifdef G4VERBOSE
128  {
129  G4cout << " Constructing new G4Element from isotopes: "
130  << *elem << G4endl;
131  }
132 #endif
133 
134  return elem;
135 }
G4Isotope * FindOrBuildG4Isotope(const G4String &name)
const G4String & GetSymbol() const
Definition: G4tgrElement.hh:53
const G4String & GetComponent(G4int n) const
G4double GetZ() const
G4Element * BuildG4ElementSimple()
Definition: G4tgbElement.cc:52
int G4int
Definition: G4Types.hh:78
G4double GetAbundance(G4int n) const
G4GLOB_DLL std::ostream G4cout
static G4int GetVerboseLevel()
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:151
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double GetA() const
#define G4endl
Definition: G4ios.hh:61
G4Element * BuildG4ElementFromIsotopes()
Definition: G4tgbElement.cc:83
const G4String & GetName() const
Definition: G4tgrElement.hh:52
static G4tgbMaterialMgr * GetInstance()