Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:37

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 persistency/gdml/G03/src/G03DetectorConstruction.cc
0027 /// \brief Implementation of the G03DetectorConstruction class
0028 //
0029 //
0030 //
0031 // Class G03DetectorConstruction implementation
0032 //
0033 // ----------------------------------------------------------------------------
0034 
0035 #include "G03DetectorConstruction.hh"
0036 
0037 // Geant4 includes
0038 //
0039 #include "G4Material.hh"
0040 #include "G4VPhysicalVolume.hh"
0041 #include "globals.hh"
0042 
0043 // Messenger
0044 //
0045 #include "G03DetectorMessenger.hh"
0046 
0047 // Color extension include for reading
0048 //
0049 #include "G03ColorReader.hh"
0050 
0051 // Color extension include for writing
0052 //
0053 #include "G03ColorWriter.hh"
0054 
0055 #include "G4SystemOfUnits.hh"
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 G03DetectorConstruction::G03DetectorConstruction()
0060   : G4VUserDetectorConstruction(),
0061     fAir(0),
0062     fAluminum(0),
0063     fPb(0),
0064     fXenon(0),
0065     fReader(0),
0066     fWriter(0),
0067     fParser(0),
0068     fDetectorMessenger(0)
0069 {
0070   fReadFile = "color_extension.gdml";
0071   fWriteFile = "color_extension_test.gdml";
0072   fWritingChoice = 1;
0073 
0074   fDetectorMessenger = new G03DetectorMessenger(this);
0075 
0076   fReader = new G03ColorReader;
0077   fWriter = new G03ColorWriter;
0078   fParser = new G4GDMLParser(fReader, fWriter);
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 G03DetectorConstruction::~G03DetectorConstruction()
0084 {
0085   delete fDetectorMessenger;
0086   delete fReader;
0087   delete fWriter;
0088   delete fParser;
0089 }
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 
0093 G4VPhysicalVolume* G03DetectorConstruction::Construct()
0094 {
0095   // Reading of Geometry from GDML
0096 
0097   G4VPhysicalVolume* fWorldPhysVol;
0098 
0099   fParser->Read(fReadFile, false);
0100   //
0101   // 2nd Boolean argument "Validate" set to false.
0102   // Disabling Schema validation for reading extended GDML file.
0103 
0104   // Prints the material information
0105   //
0106   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0107 
0108   // Giving World Physical Volume from GDML Parser
0109   //
0110   fWorldPhysVol = fParser->GetWorldVolume();
0111 
0112   if (fWritingChoice != 0) {
0113     fParser->Write(fWriteFile, fWorldPhysVol, true, "./SimpleExtensionSchema/SimpleExtension.xsd");
0114   }
0115 
0116   return fWorldPhysVol;
0117 }
0118 
0119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0120 
0121 void G03DetectorConstruction::ListOfMaterials()
0122 {
0123   G4double a;  // atomic mass
0124   G4double z;  // atomic number
0125   G4double density, temperature, pressure;
0126   G4double fractionmass;
0127   G4String name, symbol;
0128   G4int ncomponents;
0129 
0130   // Elements needed for the materials
0131 
0132   a = 14.01 * g / mole;
0133   G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0134 
0135   a = 16.00 * g / mole;
0136   G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0137 
0138   a = 26.98 * g / mole;
0139   G4Element* elAl = new G4Element(name = "Aluminum", symbol = "Al", z = 13., a);
0140 
0141   // Print the Element information
0142   //
0143   G4cout << *(G4Element::GetElementTable()) << G4endl;
0144 
0145   // Air
0146   //
0147   density = 1.29 * mg / cm3;
0148   fAir = new G4Material(name = "Air", density, ncomponents = 2);
0149   fAir->AddElement(elN, fractionmass = 0.7);
0150   fAir->AddElement(elO, fractionmass = 0.3);
0151 
0152   // Aluminum
0153   //
0154   density = 2.70 * g / cm3;
0155   fAluminum = new G4Material(name = "Aluminum", density, ncomponents = 1);
0156   fAluminum->AddElement(elAl, fractionmass = 1.0);
0157 
0158   // Lead
0159   //
0160   fPb = new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0161 
0162   // Xenon gas
0163   //
0164   fXenon = new G4Material("XenonGas", z = 54., a = 131.29 * g / mole, density = 5.458 * mg / cm3,
0165                           kStateGas, temperature = 293.15 * kelvin, pressure = 1 * atmosphere);
0166 
0167   // Prints the material information
0168   //
0169   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0170 }
0171 
0172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0173 
0174 void G03DetectorConstruction::SetReadFile(const G4String& fname)
0175 {
0176   fReadFile = fname;
0177   fWritingChoice = 0;
0178 }
0179 
0180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0181 
0182 void G03DetectorConstruction::SetWriteFile(const G4String& fname)
0183 {
0184   fWriteFile = fname;
0185   fWritingChoice = 1;
0186 }