Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/persistency/gdml/G03/src/G03DetectorConstruction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file G03DetectorConstruction.cc
0027 /// \brief Implementation of the G03DetectorConstruction class
0028 
0029 // Class G03DetectorConstruction implementation
0030 //
0031 // ----------------------------------------------------------------------------
0032 
0033 #include "G03DetectorConstruction.hh"
0034 
0035 // Geant4 includes
0036 //
0037 #include "G4Material.hh"
0038 #include "G4VPhysicalVolume.hh"
0039 #include "globals.hh"
0040 
0041 // Messenger
0042 //
0043 #include "G03DetectorMessenger.hh"
0044 
0045 // Color extension include for reading
0046 //
0047 #include "G03ColorReader.hh"
0048 
0049 // Color extension include for writing
0050 //
0051 #include "G03ColorWriter.hh"
0052 
0053 #include "G4SystemOfUnits.hh"
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0056 
0057 G03DetectorConstruction::G03DetectorConstruction()
0058   : G4VUserDetectorConstruction(),
0059     fAir(0),
0060     fAluminum(0),
0061     fPb(0),
0062     fXenon(0),
0063     fReader(0),
0064     fWriter(0),
0065     fParser(0),
0066     fDetectorMessenger(0)
0067 {
0068   fReadFile = "color_extension.gdml";
0069   fWriteFile = "color_extension_test.gdml";
0070   fWritingChoice = 1;
0071 
0072   fDetectorMessenger = new G03DetectorMessenger(this);
0073 
0074   fReader = new G03ColorReader;
0075   fWriter = new G03ColorWriter;
0076   fParser = new G4GDMLParser(fReader, fWriter);
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0080 
0081 G03DetectorConstruction::~G03DetectorConstruction()
0082 {
0083   delete fDetectorMessenger;
0084   delete fReader;
0085   delete fWriter;
0086   delete fParser;
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 G4VPhysicalVolume* G03DetectorConstruction::Construct()
0092 {
0093   // Reading of Geometry from GDML
0094 
0095   G4VPhysicalVolume* fWorldPhysVol;
0096 
0097   fParser->Read(fReadFile, false);
0098   //
0099   // 2nd Boolean argument "Validate" set to false.
0100   // Disabling Schema validation for reading extended GDML file.
0101 
0102   // Prints the material information
0103   //
0104   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0105 
0106   // Giving World Physical Volume from GDML Parser
0107   //
0108   fWorldPhysVol = fParser->GetWorldVolume();
0109 
0110   if (fWritingChoice != 0) {
0111     fParser->Write(fWriteFile, fWorldPhysVol, true, "./SimpleExtensionSchema/SimpleExtension.xsd");
0112   }
0113 
0114   return fWorldPhysVol;
0115 }
0116 
0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0118 
0119 void G03DetectorConstruction::ListOfMaterials()
0120 {
0121   G4double a;  // atomic mass
0122   G4double z;  // atomic number
0123   G4double density, temperature, pressure;
0124   G4double fractionmass;
0125   G4String name, symbol;
0126   G4int ncomponents;
0127 
0128   // Elements needed for the materials
0129 
0130   a = 14.01 * g / mole;
0131   G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0132 
0133   a = 16.00 * g / mole;
0134   G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0135 
0136   a = 26.98 * g / mole;
0137   G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a);
0138 
0139   // Print the Element information
0140   //
0141   G4cout << *(G4Element::GetElementTable()) << G4endl;
0142 
0143   // Air
0144   //
0145   density = 1.29 * mg / cm3;
0146   fAir = new G4Material(name = "Air", density, ncomponents = 2);
0147   fAir->AddElement(elN, fractionmass = 0.7);
0148   fAir->AddElement(elO, fractionmass = 0.3);
0149 
0150   // Aluminum
0151   //
0152   density = 2.70 * g / cm3;
0153   fAluminum = new G4Material(name = "Aluminum", density, ncomponents = 1);
0154   fAluminum->AddElement(elAl, fractionmass = 1.0);
0155 
0156   // Lead
0157   //
0158   fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0159 
0160   // Xenon gas
0161   //
0162   fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
0163                           kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
0164 
0165   // Prints the material information
0166   //
0167   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0168 }
0169 
0170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0171 
0172 void G03DetectorConstruction::SetReadFile(const G4String& fname)
0173 {
0174   fReadFile = fname;
0175   fWritingChoice = 0;
0176 }
0177 
0178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0179 
0180 void G03DetectorConstruction::SetWriteFile(const G4String& fname)
0181 {
0182   fWriteFile = fname;
0183   fWritingChoice = 1;
0184 }