G4-DESCSS/src/DetectorConstruction.cpp

91 lines
4.2 KiB
C++
Raw Normal View History

#include "DetectorConstruction.h"
#include "Material.h"
#include "G4Box.hh"
#include "G4IntersectionSolid.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SubtractionSolid.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
#include "G4UnionSolid.hh"
DetectorConstruction::DetectorConstruction() {}
DetectorConstruction::~DetectorConstruction() {}
static G4double ConstrustSectionBig(G4LogicalVolume* fMotherLogical, G4double zBias) {
G4double pRmaxBig = 4.2 / 2 * m;
G4double hzBig = 6.72 / 2 * m;
G4double hxBigBox = 2.4 / 2 * m;
G4double pRmaxBigMid = pRmaxBig - 10 * cm;
G4ThreeVector pos1 = G4ThreeVector(0, 0, -(zBias + hzBig));
G4double pos2 = -(zBias + hzBig * 2) + 9.8 * cm;
// 外壳
G4Tubs* solidShellAl1 = new G4Tubs("sectionBigShellAl1", pRmaxBig - 2, pRmaxBig, hzBig, 0, 360);
G4LogicalVolume* logicShellAl1 = new G4LogicalVolume(
solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigShellAl1");
new G4PVPlacement(0, pos1, logicShellAl1, "sectionBigShellAl1", fMotherLogical, false, 0, true);
G4Tubs* solidShellTap = new G4Tubs("sectionBigShellTap", pRmaxBig - 55, pRmaxBig - 45, hzBig, 0, 360);
G4LogicalVolume* logicShellTap = new G4LogicalVolume(
solidShellTap, G4Material::GetMaterial("Taparan"), "sectionBigShellTap");
new G4PVPlacement(0, pos1, logicShellTap, "sectionBigShellTap", fMotherLogical, false, 0, true);
G4Tubs* solidShellAl2 = new G4Tubs("sectionBigShellAl2", pRmaxBigMid, pRmaxBigMid + 5, hzBig, 0, 360);
G4LogicalVolume* logicShellAl2 = new G4LogicalVolume(
solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigShellAl2");
new G4PVPlacement(0, pos1, logicShellAl2, "sectionBigShellAl2", fMotherLogical, false, 0, true);
// 填充
G4Tubs* solidMidTubs = new G4Tubs("sectionBigMidTubs", 0, pRmaxBigMid, hzBig, 0, 360);
G4Box* solidMidBox = new G4Box("sectionBigMidBox", hxBigBox, hxBigBox, hzBig);
G4SubtractionSolid* solidMid =
new G4SubtractionSolid("sectionBigMid", solidMidTubs, solidMidBox);
G4LogicalVolume* logicMid =
new G4LogicalVolume(solidMid, G4Material::GetMaterial("G4_Al"), "sectionBigMid");
new G4PVPlacement(0, pos1, logicMid, "sectionBigMid", fMotherLogical, false, 0, true);
// 空气
G4Box* solidAir = new G4Box("sectionBigAirBox", hxBigBox, hxBigBox, hzBig);
G4LogicalVolume* logicAir =
new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), "sectionBigAir");
new G4PVPlacement(0, pos1, logicAir, "sectionBigAir", fMotherLogical, false, 0, true);
// 尾部
G4Tubs* solidTailAl1 = new G4Tubs("sectionBigTailAl1", 0, pRmaxBigMid, 2.5, 0, 360);
G4LogicalVolume* logicTailAl1 = new G4LogicalVolume(
solidTailAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigTailAl1");
new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 2.5), logicTailAl1, "sectionBigTailAl1", fMotherLogical, false, 0, true);
G4Tubs* solidTailTap = new G4Tubs("sectionBigTailTap", 0, pRmaxBigMid, 5, 0, 360);
G4LogicalVolume* logicTailTap = new G4LogicalVolume(
solidTailTap, G4Material::GetMaterial("Taparan"), "sectionBigTailTap");
new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 50), logicTailTap, "sectionBigTailTap", fMotherLogical, false, 0, true);
G4Tubs* solidTailAl2 = new G4Tubs("sectionBigTailAl2", 0, pRmaxBig, 1, 0, 360);
G4LogicalVolume* logicTailAl2 = new G4LogicalVolume(
solidTailAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "sectionBigTailAl2");
new G4PVPlacement(0, G4ThreeVector(0, 0, pos2 - 99), logicTailAl2, "sectionBigTailAl2", fMotherLogical, false, 0, true);
return zBias + hzBig;
}
G4VPhysicalVolume* DetectorConstruction::Construct() {
G4double zBias = 0.815 * m;
// Define materials
DefineMaterials();
// World
G4Box* solidWorld = new G4Box("World", 3. * m, 3. * m, 10. * m);
G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "World");
G4VPhysicalVolume* physicsWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0, true);
// 大柱段
zBias = ConstrustSectionBig(logicWorld, zBias);
return physicsWorld;
}