source: trunk/source/persistency/ascii/src/G4tgbElement.cc@ 1245

Last change on this file since 1245 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 4.4 KB
RevLine 
[1035]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,v 1.4 2008/12/18 12:59:20 gunter Exp $
[1228]28// GEANT4 tag $Name: geant4-09-03 $
[1035]29//
30//
31// class G4tgbElement
32
33// History:
34// - Created. P.Arce, CIEMAT (November 2007)
35// -------------------------------------------------------------------------
36
37#include "G4tgbElement.hh"
38#include "G4tgbMaterialMgr.hh"
39#include "G4tgrElementSimple.hh"
40#include "G4tgrElementFromIsotopes.hh"
41#include "G4tgrMessenger.hh"
42
43
44//----------------------------------------------------------------------
45G4tgbElement::G4tgbElement( G4tgrElement* hg )
46{
47 theTgrElem = hg;
48 theG4Elem = 0;
49}
50
51
52//----------------------------------------------------------------------
53G4Element* G4tgbElement::BuildG4ElementSimple()
54{
55 G4Element* elem = 0;
56
57 //-------- if G4Element not found, construct it
58 if( theG4Elem == 0 )
59 {
60 //----- construct new G4Element
61 G4tgrElementSimple* tgrElem = static_cast<G4tgrElementSimple*>(theTgrElem);
62
63 elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(),
64 tgrElem->GetZ(), tgrElem->GetA() );
65#ifdef G4VERBOSE
66 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
67 {
68 G4cout << " Constructing new G4Element: "
69 << *elem << G4endl;
70 }
71#endif
72 theG4Elem = elem;
73 }
74 else
75 {
76 elem = theG4Elem;
77 }
78
79 return elem;
80}
81
82
83//----------------------------------------------------------------------
84G4Element* G4tgbElement::BuildG4ElementFromIsotopes()
85{
86 G4Element* elem = 0;
87
88 //-------- if G4Element not found, construct it
89 if( theG4Elem == 0 )
90 {
91 //----- construct new G4Element
92 G4tgrElementFromIsotopes* tgrElem
93 = static_cast<G4tgrElementFromIsotopes*>(theTgrElem);
94
95 elem = new G4Element(tgrElem->GetName(), tgrElem->GetSymbol(),
96 tgrElem->GetNumberOfIsotopes() );
97
98 //----- add isotopes
99 G4Isotope* compIsot;
100 G4tgbMaterialMgr* mf = G4tgbMaterialMgr::GetInstance();
101 for( G4int ii = 0; ii < tgrElem->GetNumberOfIsotopes(); ii++)
102 {
103 // Look if this component is a material
104
105 compIsot = mf->FindOrBuildG4Isotope( tgrElem->GetComponent(ii) );
106 if( compIsot != 0 )
107 {
108 elem->AddIsotope( compIsot, tgrElem->GetAbundance(ii) );
109 }
110 else
111 {
112 G4String ErrMessage = "Component " + tgrElem->GetComponent(ii)
113 + " of element " + tgrElem->GetName()
114 + " is not an isotope !";
115 G4Exception("G4tgbElement::BuildG4ElementFromIsotopes()",
116 "InvalidSetup", FatalException, ErrMessage );
117 }
118 }
119 theG4Elem = elem;
120 }
121 else
122 {
123 elem = theG4Elem;
124 }
125
126
127#ifdef G4VERBOSE
128 if( G4tgrMessenger::GetVerboseLevel() >= 1 )
129 {
130 G4cout << " Constructing new G4Element from isotopes: "
131 << *elem << G4endl;
132 }
133#endif
134
135 return elem;
136}
Note: See TracBrowser for help on using the repository browser.