Back to home page

EIC code displayed by LXR

 
 

    


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

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 medical/fanoCavity2/src/DetectorConstruction.cc
0027 /// \brief Implementation of the DetectorConstruction class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "DetectorConstruction.hh"
0034 
0035 #include "DetectorMessenger.hh"
0036 
0037 #include "G4GeometryManager.hh"
0038 #include "G4LogicalVolume.hh"
0039 #include "G4LogicalVolumeStore.hh"
0040 #include "G4Material.hh"
0041 #include "G4NistManager.hh"
0042 #include "G4PVPlacement.hh"
0043 #include "G4PhysicalConstants.hh"
0044 #include "G4PhysicalVolumeStore.hh"
0045 #include "G4SolidStore.hh"
0046 #include "G4SystemOfUnits.hh"
0047 #include "G4Tubs.hh"
0048 #include "G4UnitsTable.hh"
0049 #include "G4VPhysicalVolume.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 DetectorConstruction::DetectorConstruction() : fWall(nullptr), fCavity(nullptr)
0054 {
0055   // default parameter values
0056   fWallThickness = 5 * cm;
0057   fCavityThickness = 2 * mm;
0058   fCavityRadius = 10 * m;
0059 
0060   DefineMaterials();
0061   SetWallMaterial("G4_WATER");
0062   SetCavityMaterial("g4Water_gas");
0063 
0064   // create commands for interactive definition of the detector
0065   fDetectorMessenger = new DetectorMessenger(this);
0066 }
0067 
0068 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0069 
0070 DetectorConstruction::~DetectorConstruction()
0071 {
0072   delete fDetectorMessenger;
0073 }
0074 
0075 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0076 
0077 void DetectorConstruction::DefineMaterials()
0078 {
0079   G4double z, a;
0080 
0081   G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole);
0082   G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
0083 
0084   G4Material* H2O = new G4Material("Water", 1.0 * g / cm3, 2);
0085   H2O->AddElement(H, 2);
0086   H2O->AddElement(O, 1);
0087   H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0088 
0089   G4Material* gas = new G4Material("Water_gas", 1.0 * mg / cm3, 2);
0090   gas->AddElement(H, 2);
0091   gas->AddElement(O, 1);
0092   gas->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0093 
0094   new G4Material("Graphite", 6, 12.01 * g / mole, 2.265 * g / cm3);
0095   new G4Material("Graphite_gas", 6, 12.01 * g / mole, 2.265 * mg / cm3);
0096 
0097   new G4Material("Aluminium", 13, 26.98 * g / mole, 2.700 * g / cm3);
0098   new G4Material("Aluminium_gas", 13, 26.98 * g / mole, 2.700 * mg / cm3);
0099 
0100   // alternatively, use G4 data base
0101   //
0102   G4NistManager* nist = G4NistManager::Instance();
0103 
0104   nist->FindOrBuildMaterial("G4_WATER");
0105   nist->BuildMaterialWithNewDensity("g4Water_gas", "G4_WATER", 1.0 * mg / cm3);
0106 
0107   // printout
0108   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0112 
0113 G4VPhysicalVolume* DetectorConstruction::Construct()
0114 {
0115   if (fWall) {
0116     return fWall;
0117   }
0118 
0119   // Chamber
0120   //
0121   fTotalThickness = fCavityThickness + 2 * fWallThickness;
0122   fWallRadius = fCavityRadius;
0123 
0124   G4Tubs* sChamber = new G4Tubs("Chamber",  // name
0125                                 0., fWallRadius, 0.5 * fTotalThickness, 0., twopi);  // size
0126 
0127   G4LogicalVolume* lChamber = new G4LogicalVolume(sChamber,  // solid
0128                                                   fWallMaterial,  // material
0129                                                   "Chamber");  // name
0130 
0131   fWall = new G4PVPlacement(0,  // no rotation
0132                             G4ThreeVector(),  // at (0,0,0)
0133                             lChamber,  // logical volume
0134                             "Wall",  // name
0135                             0,  // mother  volume
0136                             false,  // no boolean operation
0137                             0);  // copy number
0138 
0139   // Cavity
0140   //
0141   G4Tubs* sCavity = new G4Tubs("Cavity", 0., fCavityRadius, 0.5 * fCavityThickness, 0., twopi);
0142 
0143   G4LogicalVolume* lCavity = new G4LogicalVolume(sCavity,  // shape
0144                                                  fCavityMaterial,  // material
0145                                                  "Cavity");  // name
0146 
0147   fCavity = new G4PVPlacement(0,  // no rotation
0148                               G4ThreeVector(),  // at (0,0,0)
0149                               lCavity,  // logical volume
0150                               "Cavity",  // name
0151                               lChamber,  // mother  volume
0152                               false,  // no boolean operation
0153                               1);  // copy number
0154 
0155   PrintParameters();
0156 
0157   //
0158   // always return the root volume
0159   //
0160   return fWall;
0161 }
0162 
0163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0164 
0165 void DetectorConstruction::PrintParameters()
0166 {
0167   G4cout << "\n---------------------------------------------------------\n";
0168   G4cout << "---> The Wall is " << G4BestUnit(fWallThickness, "Length") << " of "
0169          << fWallMaterial->GetName() << " ( "
0170          << G4BestUnit(fWallMaterial->GetDensity(), "Volumic Mass") << " )\n";
0171   G4cout << "     The Cavity is " << G4BestUnit(fCavityThickness, "Length") << " of "
0172          << fCavityMaterial->GetName() << " ( "
0173          << G4BestUnit(fCavityMaterial->GetDensity(), "Volumic Mass") << " )";
0174   G4cout << "\n---------------------------------------------------------\n";
0175   G4cout << G4endl;
0176 }
0177 
0178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0179 
0180 void DetectorConstruction::SetWallThickness(G4double value)
0181 {
0182   fWallThickness = value;
0183 }
0184 
0185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0186 
0187 void DetectorConstruction::SetWallMaterial(const G4String& materialChoice)
0188 {
0189   // search the material by its name
0190   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0191   if (pttoMaterial) fWallMaterial = pttoMaterial;
0192 }
0193 
0194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0195 
0196 void DetectorConstruction::SetCavityThickness(G4double value)
0197 {
0198   fCavityThickness = value;
0199 }
0200 
0201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0202 
0203 void DetectorConstruction::SetCavityRadius(G4double value)
0204 {
0205   fCavityRadius = value;
0206 }
0207 
0208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0209 
0210 void DetectorConstruction::SetCavityMaterial(const G4String& materialChoice)
0211 {
0212   // search the material by its name
0213   G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0214   if (pttoMaterial) fCavityMaterial = pttoMaterial;
0215 }
0216 
0217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......