Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G03DetectorConstruction.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 /// \file persistency/gdml/G03/src/G03DetectorConstruction.cc
27 /// \brief Implementation of the G03DetectorConstruction class
28 //
29 //
30 // $Id: G03DetectorConstruction.cc 68025 2013-03-13 13:43:46Z gcosmo $
31 //
32 // Class G03DetectorConstruction implementation
33 //
34 // ----------------------------------------------------------------------------
35 
37 
38 // Geant4 includes
39 //
40 #include "globals.hh"
41 #include "G4Material.hh"
42 #include "G4VPhysicalVolume.hh"
43 
44 // Messenger
45 //
46 #include "G03DetectorMessenger.hh"
47 
48 // Color extension include for reading
49 //
50 #include "G03ColorReader.hh"
51 
52 // Color extension include for writing
53 //
54 #include "G03ColorWriter.hh"
55 
56 #include "G4SystemOfUnits.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fAir(0), fAluminum(0), fPb(0), fXenon(0),
63  fReader(0), fWriter(0), fParser(0),
64  fDetectorMessenger(0)
65 {
66  fReadFile = "color_extension.gdml";
67  fWriteFile = "color_extension_test.gdml";
68  fWritingChoice = 1;
69 
70  fDetectorMessenger = new G03DetectorMessenger( this );
71 
72  fReader = new G03ColorReader;
73  fWriter = new G03ColorWriter;
74  fParser = new G4GDMLParser(fReader, fWriter);
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  delete fDetectorMessenger;
82  delete fReader;
83  delete fWriter;
84  delete fParser;
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
90 {
91  // Reading of Geometry from GDML
92 
93  G4VPhysicalVolume* fWorldPhysVol;
94 
95  fParser->Read(fReadFile,false);
96  //
97  // 2nd Boolean argument "Validate" set to false.
98  // Disabling Schema validation for reading extended GDML file.
99 
100  // Prints the material information
101  //
103 
104  // Giving World Physical Volume from GDML Parser
105  //
106  fWorldPhysVol = fParser->GetWorldVolume();
107 
108  if(fWritingChoice!=0)
109  {
110  fParser->Write(fWriteFile, fWorldPhysVol, true,
111  "./SimpleExtensionSchema/SimpleExtension.xsd");
112  }
113 
114  return fWorldPhysVol;
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120 {
121  G4double a; // atomic mass
122  G4double z; // atomic number
123  G4double density,temperature,pressure;
124  G4double fractionmass;
126  G4int ncomponents;
127 
128  // Elements needed for the materials
129 
130  a = 14.01*g/mole;
131  G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a);
132 
133  a = 16.00*g/mole;
134  G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a);
135 
136  a = 26.98*g/mole;
137  G4Element* elAl = new G4Element(name="Aluminum", symbol="Al", z=13., a);
138 
139  // Print the Element information
140  //
142 
143  // Air
144  //
145  density = 1.29*mg/cm3;
146  fAir = new G4Material(name="Air", density, ncomponents=2);
147  fAir->AddElement(elN, fractionmass=0.7);
148  fAir->AddElement(elO, fractionmass=0.3);
149 
150  // Aluminum
151  //
152  density = 2.70*g/cm3;
153  fAluminum = new G4Material(name="Aluminum", density, ncomponents=1);
154  fAluminum->AddElement(elAl, fractionmass=1.0);
155 
156  // Lead
157  //
158  fPb = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
159 
160  // Xenon gas
161  //
162  fXenon = new G4Material("XenonGas", z=54., a=131.29*g/mole,
163  density= 5.458*mg/cm3, kStateGas,
164  temperature= 293.15*kelvin, pressure= 1*atmosphere);
165 
166  // Prints the material information
167  //
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172 
174 {
175  fReadFile=fname;
176  fWritingChoice=0;
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
182 {
183  fWriteFile=fname;
184  fWritingChoice=1;
185 }
GDML reader for the color attributes.
G4String symbol
Definition: TRTMaterials.hh:40
Detector messenger for the GDML extensions example.
Definition of the G03DetectorConstruction class.
G4double z
Definition: TRTMaterials.hh:39
G4VPhysicalVolume * GetWorldVolume(const G4String &setupName="Default") const
GDML writer for the color attributes.
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
int atmosphere
Definition: hepunit.py:151
void SetWriteFile(const G4String &fname)
const XML_Char * name
Definition of the G03DetectorMessenger class.
void SetReadFile(const G4String &fname)
int G4int
Definition: G4Types.hh:78
G4Element * elN
Definition: TRTMaterials.hh:44
virtual G4VPhysicalVolume * Construct()
G4double density
Definition: TRTMaterials.hh:39
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
G4Element * elO
Definition: TRTMaterials.hh:46
Definition of the G03ColorWriter class.
void Write(const G4String &filename, const G4VPhysicalVolume *pvol=0, G4bool storeReferences=true, const G4String &SchemaLocation=G4GDML_DEFAULT_SCHEMALOCATION)
Definition of the G03ColorReader class.
void Read(const G4String &filename, G4bool Validate=true)
#define G4endl
Definition: G4ios.hh:61
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:345
double G4double
Definition: G4Types.hh:76
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:395