218 lines
8.1 KiB
C++
218 lines
8.1 KiB
C++
//
|
|
// ********************************************************************
|
|
// * License and Disclaimer *
|
|
// * *
|
|
// * The Geant4 software is copyright of the Copyright Holders of *
|
|
// * the Geant4 Collaboration. It is provided under the terms and *
|
|
// * conditions of the Geant4 Software License, included in the file *
|
|
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
|
// * include a list of copyright holders. *
|
|
// * *
|
|
// * Neither the authors of this software system, nor their employing *
|
|
// * institutes,nor the agencies providing financial support for this *
|
|
// * work make any representation or warranty, express or implied, *
|
|
// * regarding this software system or assume any liability for its *
|
|
// * use. Please see the license in the file LICENSE and URL above *
|
|
// * for the full disclaimer and the limitation of liability. *
|
|
// * *
|
|
// * This code implementation is the result of the scientific and *
|
|
// * technical work of the GEANT4 collaboration. *
|
|
// * By using, copying, modifying or distributing the software (or *
|
|
// * any work based on the software) you agree to acknowledge its *
|
|
// * use in resulting scientific publications, and indicate your *
|
|
// * acceptance of all terms of the Geant4 Software license. *
|
|
// ********************************************************************
|
|
//
|
|
/// \file DetectorConstruction.cc
|
|
/// \brief Implementation of the DetectorConstruction class
|
|
|
|
#include "DetectorConstruction.hh"
|
|
|
|
#include "DetectorMessenger.hh"
|
|
|
|
#include "G4Box.hh"
|
|
#include "G4Element.hh"
|
|
#include "G4LogicalBorderSurface.hh"
|
|
#include "G4LogicalSkinSurface.hh"
|
|
#include "G4LogicalVolume.hh"
|
|
#include "G4Material.hh"
|
|
#include "G4NistManager.hh"
|
|
#include "G4OpticalSurface.hh"
|
|
#include "G4PVPlacement.hh"
|
|
#include "G4SystemOfUnits.hh"
|
|
#include "G4ThreeVector.hh"
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
DetectorConstruction::DetectorConstruction()
|
|
: G4VUserDetectorConstruction(), fDetectorMessenger(nullptr)
|
|
{
|
|
fTankMPT = new G4MaterialPropertiesTable();
|
|
fWorldMPT = new G4MaterialPropertiesTable();
|
|
fSurfaceMPT = new G4MaterialPropertiesTable();
|
|
|
|
fSurface = new G4OpticalSurface("Surface");
|
|
fSurface->SetType(dielectric_dielectric);
|
|
fSurface->SetFinish(ground);
|
|
fSurface->SetModel(unified);
|
|
fSurface->SetMaterialPropertiesTable(fSurfaceMPT);
|
|
|
|
fTankMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
|
|
fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
|
|
|
|
fDetectorMessenger = new DetectorMessenger(this);
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
DetectorConstruction::~DetectorConstruction()
|
|
{
|
|
delete fTankMPT;
|
|
delete fWorldMPT;
|
|
delete fSurfaceMPT;
|
|
delete fSurface;
|
|
delete fDetectorMessenger;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
|
|
G4VPhysicalVolume* DetectorConstruction::Construct()
|
|
{
|
|
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
|
|
fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
|
|
|
|
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
|
|
|
|
// ------------- Volumes --------------
|
|
// The experimental Hall
|
|
auto world_box = new G4Box("World", fExpHall_x, fExpHall_y, fExpHall_z);
|
|
|
|
fWorld_LV = new G4LogicalVolume(world_box, fWorldMaterial, "World");
|
|
|
|
G4VPhysicalVolume* world_PV =
|
|
new G4PVPlacement(nullptr, G4ThreeVector(), fWorld_LV, "World", nullptr, false, 0);
|
|
|
|
// The tank
|
|
auto tank_box = new G4Box("Tank", fTank_x, fTank_y, fTank_z);
|
|
|
|
fTank_LV = new G4LogicalVolume(tank_box, fTankMaterial, "Tank");
|
|
|
|
fTank = new G4PVPlacement(nullptr, G4ThreeVector(), fTank_LV, "Tank", fWorld_LV, false, 0);
|
|
|
|
// ------------- Surface --------------
|
|
|
|
auto surface = new G4LogicalBorderSurface("Surface", fTank, world_PV, fSurface);
|
|
|
|
auto opticalSurface =
|
|
dynamic_cast<G4OpticalSurface*>(surface->GetSurface(fTank, world_PV)->GetSurfaceProperty());
|
|
G4cout << "****** opticalSurface->DumpInfo:" << G4endl;
|
|
if (opticalSurface) {
|
|
opticalSurface->DumpInfo();
|
|
}
|
|
G4cout << "****** end of opticalSurface->DumpInfo" << G4endl;
|
|
|
|
return world_PV;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v)
|
|
{
|
|
fSurface->SetSigmaAlpha(v);
|
|
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
|
|
|
G4cout << "Surface sigma alpha set to: " << fSurface->GetSigmaAlpha() << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::SetSurfacePolish(G4double v)
|
|
{
|
|
fSurface->SetPolish(v);
|
|
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
|
|
|
G4cout << "Surface polish set to: " << fSurface->GetPolish() << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddTankMPV(const G4String& prop, G4MaterialPropertyVector* mpv)
|
|
{
|
|
fTankMPT->AddProperty(prop, mpv);
|
|
G4cout << "The MPT for the box is now: " << G4endl;
|
|
fTankMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddWorldMPV(const G4String& prop, G4MaterialPropertyVector* mpv)
|
|
{
|
|
fWorldMPT->AddProperty(prop, mpv);
|
|
G4cout << "The MPT for the world is now: " << G4endl;
|
|
fWorldMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddSurfaceMPV(const G4String& prop, G4MaterialPropertyVector* mpv)
|
|
{
|
|
fSurfaceMPT->AddProperty(prop, mpv);
|
|
G4cout << "The MPT for the surface is now: " << G4endl;
|
|
fSurfaceMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddTankMPC(const G4String& prop, G4double v)
|
|
{
|
|
fTankMPT->AddConstProperty(prop, v);
|
|
G4cout << "The MPT for the box is now: " << G4endl;
|
|
fTankMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddWorldMPC(const G4String& prop, G4double v)
|
|
{
|
|
fWorldMPT->AddConstProperty(prop, v);
|
|
G4cout << "The MPT for the world is now: " << G4endl;
|
|
fWorldMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::AddSurfaceMPC(const G4String& prop, G4double v)
|
|
{
|
|
fSurfaceMPT->AddConstProperty(prop, v);
|
|
G4cout << "The MPT for the surface is now: " << G4endl;
|
|
fSurfaceMPT->DumpTable();
|
|
G4cout << "............." << G4endl;
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::SetWorldMaterial(const G4String& mat)
|
|
{
|
|
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
|
|
if (pmat && fWorldMaterial != pmat) {
|
|
fWorldMaterial = pmat;
|
|
if (fWorld_LV) {
|
|
fWorld_LV->SetMaterial(fWorldMaterial);
|
|
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
|
|
}
|
|
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
|
G4cout << "World material set to " << fWorldMaterial->GetName() << G4endl;
|
|
}
|
|
}
|
|
|
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|
void DetectorConstruction::SetTankMaterial(const G4String& mat)
|
|
{
|
|
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
|
|
if (pmat && fTankMaterial != pmat) {
|
|
fTankMaterial = pmat;
|
|
if (fTank_LV) {
|
|
fTank_LV->SetMaterial(fTankMaterial);
|
|
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
|
|
fTankMaterial->GetIonisation()->SetBirksConstant(0.126 * mm / MeV);
|
|
}
|
|
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
|
G4cout << "Tank material set to " << fTankMaterial->GetName() << G4endl;
|
|
}
|
|
}
|