Geant4  9.6.p02
 All Classes 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 //
28 //
29 //
30 // $Id$
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 
61  : fAir(0), fAluminum(0), fPb(0), fXenon(0)
62 {
63  fReadFile = "color_extension.gdml";
64  fWriteFile = "color_extension_test.gdml";
65  fWritingChoice = 1;
66 
67  fDetectorMessenger = new G03DetectorMessenger( this );
68 
69  fReader = new G03ColorReader;
70  fWriter = new G03ColorWriter;
71  fParser = new G4GDMLParser(fReader, fWriter);
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  delete fDetectorMessenger;
79  delete fReader;
80  delete fWriter;
81  delete fParser;
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  // Reading of Geometry from GDML
89 
90  G4VPhysicalVolume* fWorldPhysVol;
91 
92  fParser->Read(fReadFile,false);
93  //
94  // 2nd Boolean argument "Validate" set to false.
95  // Disabling Schema validation for reading extended GDML file.
96 
97  // Prints the material information
98  //
100 
101  // Giving World Physical Volume from GDML Parser
102  //
103  fWorldPhysVol = fParser->GetWorldVolume();
104 
105  if(fWritingChoice!=0)
106  {
107  fParser->Write(fWriteFile, fWorldPhysVol, true,
108  "./SimpleExtensionSchema/SimpleExtension.xsd");
109  }
110 
111  return fWorldPhysVol;
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118  G4double a; // atomic mass
119  G4double z; // atomic number
120  G4double density,temperature,pressure;
121  G4double fractionmass;
123  G4int ncomponents;
124 
125  // Elements needed for the materials
126 
127  a = 14.01*g/mole;
128  G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a);
129 
130  a = 16.00*g/mole;
131  G4Element* elO = new G4Element(name="Oxygen", symbol="O", z=8., a);
132 
133  a = 26.98*g/mole;
134  G4Element* elAl = new G4Element(name="Aluminum", symbol="Al", z=13., a);
135 
136  // Print the Element information
137  //
139 
140  // Air
141  //
142  density = 1.29*mg/cm3;
143  fAir = new G4Material(name="Air", density, ncomponents=2);
144  fAir->AddElement(elN, fractionmass=0.7);
145  fAir->AddElement(elO, fractionmass=0.3);
146 
147  // Aluminum
148  //
149  density = 2.70*g/cm3;
150  fAluminum = new G4Material(name="Aluminum", density, ncomponents=1);
151  fAluminum->AddElement(elAl, fractionmass=1.0);
152 
153  // Lead
154  //
155  fPb = new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
156 
157  // Xenon gas
158  //
159  fXenon = new G4Material("XenonGas", z=54., a=131.29*g/mole,
160  density= 5.458*mg/cm3, kStateGas,
161  temperature= 293.15*kelvin, pressure= 1*atmosphere);
162 
163  // Prints the material information
164  //
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {
172  fReadFile=fname;
173  fWritingChoice=0;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177 
179 {
180  fWriteFile=fname;
181  fWritingChoice=1;
182 }