#include "DetectorConstruction.h" #include "Material.h" #include "G4Box.hh" #include "G4Cons.hh" #include "G4IntersectionSolid.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4Sphere.hh" #include "G4SubtractionSolid.hh" #include "G4SystemOfUnits.hh" #include "G4Trd.hh" #include "G4Tubs.hh" #include "G4UnionSolid.hh" DetectorConstruction::DetectorConstruction() {} DetectorConstruction::~DetectorConstruction() {} std::ofstream dataFile("F:/Project/Geant4/DESCSS/debug.txt"); static void ConstructSectionSphere(G4LogicalVolume* fMotherLogical, G4double zBias) { G4double pRadius = 2.8 * m / 2; G4double pRadius2 = 1.2 * m; G4double pRadiusMid = pRadius - 10 * cm; G4ThreeVector pos0 = G4ThreeVector(); G4ThreeVector pos1 = G4ThreeVector(0, 0, zBias + 0.91 * m); // 大环境 G4Sphere* solidWorld = new G4Sphere("NodeWorld", 0, pRadius, 0, 360 * deg, 0, 180 * deg); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "NodeWorld"); new G4PVPlacement(0, pos1, logicWorld, "NodeWorld", fMotherLogical, false, 0, true); // 外壳 G4Sphere* solidShell = new G4Sphere("NodeShell", 0, pRadius, 0, 360 * deg, 0, 139.5 * deg); G4LogicalVolume* logicShell = new G4LogicalVolume(solidShell, G4Material::GetMaterial("Vacuum"), "NodeShell"); new G4PVPlacement(0, pos0, logicShell, "NodeShell", logicWorld, false, 0, true); G4Sphere* solidShellAl1 = new G4Sphere("NodeShellAl1", pRadius - 2, pRadius, 0, 360 * deg, 0, 139.5 * deg); G4LogicalVolume* logicShellAl1 = new G4LogicalVolume(solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "NodeShellAl1"); new G4PVPlacement(0, pos0, logicShellAl1, "NodeShellAl1", logicShell, false, 0, true); G4Sphere* solidShellTap = new G4Sphere("NodeShellTap", pRadius - 55, pRadius - 45, 0, 360 * deg, 0, 139.5 * deg); G4LogicalVolume* logicShellTap = new G4LogicalVolume(solidShellTap, G4Material::GetMaterial("Taparan"), "NodeShellTap"); new G4PVPlacement(0, pos0, logicShellTap, "NodeShellTap", logicShell, false, 0, true); G4Sphere* solidShellAl2 = new G4Sphere("NodeShellAl2", pRadiusMid, pRadiusMid + 5, 0, 360 * deg, 0, 139.5 * deg); G4LogicalVolume* logicShellAl2 = new G4LogicalVolume(solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "NodeShellAl2"); new G4PVPlacement(0, pos0, logicShellAl2, "NodeShellAl2", logicShell, false, 0, true); // 填充 G4Sphere* solidMid = new G4Sphere("NodeMid", pRadius2, pRadius, 0, 360 * deg, 0, 139.5 * deg); G4LogicalVolume* logicMid = new G4LogicalVolume(solidMid, G4Material::GetMaterial("midMaterial"), "NodeMid"); new G4PVPlacement(0, pos0, logicMid, "NodeMid", logicWorld, false, 0, true); // 空气 G4Sphere* solidAir = new G4Sphere("NodeAir", 0, pRadius2, 0, 360 * deg, 0, 180 * deg); G4LogicalVolume* logicAir = new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), "NodeAir"); new G4PVPlacement(0, pos0, logicAir, "NodeAir", logicWorld, false, 0, true); } static void ConstructSectionCons(G4String name, G4LogicalVolume* fMotherLogical, G4double zBias, G4double pRmax1, G4double pRmin1, G4double pRmax2, G4double pRmin2, G4double hz) { G4double pRminMid = pRmin1 - 10 * cm; G4double pRmaxMid = pRmax1 - 10 * cm; G4ThreeVector pos0 = G4ThreeVector(); G4ThreeVector pos1 = G4ThreeVector(0, 0, zBias); // 大环境 G4Tubs* solidWorld = new G4Tubs(name + "World", 0, pRmax1, hz, 0, 360); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), name + "World"); new G4PVPlacement(0, pos1, logicWorld, name + "World", fMotherLogical, false, 0, true); // 外壳 G4Cons* solidShell = new G4Cons(name + "Shell", 0, pRmax1, 0, pRmin1, hz, 0, 360); G4LogicalVolume* logicShell = new G4LogicalVolume(solidShell, G4Material::GetMaterial("Vacuum"), name + "Shell"); new G4PVPlacement(0, pos0, logicShell, name + "Shell", logicWorld, false, 0, true); G4Cons* solidShellAl1 = new G4Cons(name + "ShellAl1", pRmax1 - 2, pRmax1, pRmin1 - 2, pRmin1, hz, 0, 360); G4LogicalVolume* logicShellAl1 = new G4LogicalVolume(solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), name + "ShellAl1"); new G4PVPlacement(0, pos0, logicShellAl1, name + "ShellAl1", logicShell, false, 0, true); G4Cons* solidShellTap = new G4Cons(name + "ShellTap", pRmax1 - 55, pRmax1 - 45, pRmin1 - 55, pRmin1 - 45, hz, 0, 360); G4LogicalVolume* logicShellTap = new G4LogicalVolume(solidShellTap, G4Material::GetMaterial("Taparan"), name + "ShellTap"); new G4PVPlacement(0, pos0, logicShellTap, name + "ShellTap", logicShell, false, 0, true); G4Cons* solidShellAl2 = new G4Cons(name + "ShellAl2", pRmaxMid, pRmaxMid + 5, pRminMid, pRminMid + 5, hz, 0, 360); G4LogicalVolume* logicShellAl2 = new G4LogicalVolume(solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), name + "ShellAl2"); new G4PVPlacement(0, pos0, logicShellAl2, name + "ShellAl2", logicShell, false, 0, true); // 填充 G4Cons* solidMidCons = new G4Cons(name + "MidCons", 0, pRmax1, 0, pRmin1, hz, 0, 360); G4Trd* solidMidTrd = new G4Trd(name + "MidTrd", pRmax2, pRmin2, pRmax2, pRmin2, hz); G4SubtractionSolid* solidMid = new G4SubtractionSolid(name + "Mid", solidMidCons, solidMidTrd); G4LogicalVolume* logicMid = new G4LogicalVolume(solidMid, G4Material::GetMaterial("midMaterial"), name + "Mid"); new G4PVPlacement(0, pos0, logicMid, name + "Mid", logicWorld, false, 0, true); // 空气 G4Trd* solidAir = new G4Trd(name + "Air", pRmax2, pRmin2, pRmax2, pRmin2, hz); G4LogicalVolume* logicAir = new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), name + "Air"); new G4PVPlacement(0, pos0, logicAir, name + "Air", logicWorld, false, 0, true); } static void ConstructSectionSmall(G4LogicalVolume* fMotherLogical, G4double zBias) { G4double pRmax = 2.8 / 2 * m; G4double hz = 5.18 / 2 * m; G4double hxBox = 1.5 / 2 * m; G4double pRmaxMid = pRmax - 10 * cm; G4ThreeVector pos0 = G4ThreeVector(); G4ThreeVector pos1 = G4ThreeVector(0, 0, 8.5); // 大环境 G4Tubs* solidWorld = new G4Tubs("SmallWorld", 0, pRmax, hz, 0, 360); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "SmallWorld"); new G4PVPlacement(0, G4ThreeVector(0, 0, zBias + hz), logicWorld, "SmallWorld", fMotherLogical, false, 0, true); // 外壳 2mm铝 + 10mm芳纶 + 5mm铝 G4Tubs* solidShell = new G4Tubs("SmallShell", pRmaxMid, pRmax, hz, 0, 360); G4LogicalVolume* logicShell = new G4LogicalVolume(solidShell, G4Material::GetMaterial("Vacuum"), "SmallShell"); new G4PVPlacement(0, pos1, logicShell, "SmallShell", logicWorld, false, 0, true); G4Tubs* solidShellAl1 = new G4Tubs("SmallShellAl1", pRmax - 2, pRmax, hz, 0, 360); G4LogicalVolume* logicShellAl1 = new G4LogicalVolume(solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "SmallShellAl1"); new G4PVPlacement(0, pos0, logicShellAl1, "SmallShellAl1", logicShell, false, 0, true); G4Tubs* solidShellTap = new G4Tubs("SmallShellTap", pRmax - 55, pRmax - 45, hz, 0, 360); G4LogicalVolume* logicShellTap = new G4LogicalVolume(solidShellTap, G4Material::GetMaterial("Taparan"), "SmallShellTap"); new G4PVPlacement(0, pos0, logicShellTap, "SmallShellTap", logicShell, false, 0, true); G4Tubs* solidShellAl2 = new G4Tubs("SmallShellAl2", pRmaxMid, pRmaxMid + 5, hz, 0, 360); G4LogicalVolume* logicShellAl2 = new G4LogicalVolume(solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "SmallShellAl2"); new G4PVPlacement(0, pos0, logicShellAl2, "SmallShellAl2", logicShell, false, 0, true); // 填充 G4Tubs* solidMidTubs = new G4Tubs("SmallMidTubs", 0, pRmaxMid, hz, 0, 360); G4Box* solidMidBox = new G4Box("SmallMidBox", hxBox, hxBox, hz); G4SubtractionSolid* solidMid = new G4SubtractionSolid("SmallMid", solidMidTubs, solidMidBox); G4LogicalVolume* logicMid = new G4LogicalVolume(solidMid, G4Material::GetMaterial("midMaterial"), "SmallMid"); new G4PVPlacement(0, pos1, logicMid, "SmallMid", logicWorld, false, 0, true); // 空气 G4Box* solidAir = new G4Box("SmallAirBox", hxBox, hxBox, hz); G4LogicalVolume* logicAir = new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), "SmallAir"); new G4PVPlacement(0, pos1, logicAir, "SmallAir", logicWorld, false, 0, true); } static void ConstructSectionBig(G4LogicalVolume* fMotherLogical, G4double zBias) { G4double pRmax = 4.2 / 2 * m; G4double hz = 6.72 / 2 * m; G4double hxBox = 2.4 / 2 * m; G4double pRmaxMid = pRmax - 10 * cm; G4ThreeVector pos0 = G4ThreeVector(); G4ThreeVector pos1 = G4ThreeVector(0, 0, 8.5); // 大环境 G4Tubs* solidWorld = new G4Tubs("BigWorld", 0, pRmax, hz + 8.5, 0, 360); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "BigWorld"); new G4PVPlacement(0, G4ThreeVector(0, 0, -(zBias + hz + 8.5)), logicWorld, "BigWorld", fMotherLogical, false, 0, true); // 外壳 2mm铝 + 10mm芳纶 + 5mm铝 G4Tubs* solidShell = new G4Tubs("BigShell", pRmaxMid, pRmax, hz, 0, 360); G4LogicalVolume* logicShell = new G4LogicalVolume(solidShell, G4Material::GetMaterial("Vacuum"), "BigShell"); new G4PVPlacement(0, pos1, logicShell, "BigShell", logicWorld, false, 0, true); G4Tubs* solidShellAl1 = new G4Tubs("BigShellAl1", pRmax - 2, pRmax, hz, 0, 360); G4LogicalVolume* logicShellAl1 = new G4LogicalVolume(solidShellAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "BigShellAl1"); new G4PVPlacement(0, pos0, logicShellAl1, "BigShellAl1", logicShell, false, 0, true); G4Tubs* solidShellTap = new G4Tubs("BigShellTap", pRmax - 55, pRmax - 45, hz, 0, 360); G4LogicalVolume* logicShellTap = new G4LogicalVolume(solidShellTap, G4Material::GetMaterial("Taparan"), "BigShellTap"); new G4PVPlacement(0, pos0, logicShellTap, "BigShellTap", logicShell, false, 0, true); G4Tubs* solidShellAl2 = new G4Tubs("BigShellAl2", pRmaxMid, pRmaxMid + 5, hz, 0, 360); G4LogicalVolume* logicShellAl2 = new G4LogicalVolume(solidShellAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "BigShellAl2"); new G4PVPlacement(0, pos0, logicShellAl2, "BigShellAl2", logicShell, false, 0, true); // 填充 G4Tubs* solidMidTubs = new G4Tubs("BigMidTubs", 0, pRmaxMid, hz, 0, 360); G4Box* solidMidBox = new G4Box("BigMidBox", hxBox, hxBox, hz); G4SubtractionSolid* solidMid = new G4SubtractionSolid("BigMid", solidMidTubs, solidMidBox); G4LogicalVolume* logicMid = new G4LogicalVolume(solidMid, G4Material::GetMaterial("midMaterial"), "BigMid"); new G4PVPlacement(0, pos1, logicMid, "BigMid", logicWorld, false, 0, true); // 空气 G4Box* solidAir = new G4Box("BigAirBox", hxBox, hxBox, hz); G4LogicalVolume* logicAir = new G4LogicalVolume(solidAir, G4Material::GetMaterial("G4_AIR"), "BigAir"); new G4PVPlacement(0, pos1, logicAir, "BigAir", logicWorld, false, 0, true); // 尾部 5mm铝 + 10mm芳纶 + 2mm铝 G4Tubs* solidTail = new G4Tubs("BigTail", 0, pRmax, 8.5, 0, 360); G4LogicalVolume* logicTail = new G4LogicalVolume(solidTail, G4Material::GetMaterial("Vacuum"), "BigTail"); new G4PVPlacement(0, G4ThreeVector(0, 0, -(hz + 8.5)), logicTail, "BigTail", logicWorld, false, 0, true); G4Tubs* solidTailAl1 = new G4Tubs("BigTailAl1", 0, pRmax, 2.5, 0, 360); G4LogicalVolume* logicTailAl1 = new G4LogicalVolume(solidTailAl1, G4Material::GetMaterial("AluminumAlloySeries5"), "BigTailAl1"); new G4PVPlacement(0, G4ThreeVector(0, 0, 6), logicTailAl1, "BigTailAl1", logicTail, false, 0, true); G4Tubs* solidTailTap = new G4Tubs("BigTailTap", 0, pRmax, 5, 0, 360); G4LogicalVolume* logicTailTap = new G4LogicalVolume(solidTailTap, G4Material::GetMaterial("Taparan"), "BigTailTap"); new G4PVPlacement(0, G4ThreeVector(0, 0, -1.5), logicTailTap, "BigTailTap", logicTail, false, 0, true); G4Tubs* solidTailAl2 = new G4Tubs("BigTailAl2", 0, pRmax, 1, 0, 360); G4LogicalVolume* logicTailAl2 = new G4LogicalVolume(solidTailAl2, G4Material::GetMaterial("AluminumAlloySeries5"), "BigTailAl2"); new G4PVPlacement(0, G4ThreeVector(0, 0, -7.5), logicTailAl2, "BigTailAl2", logicTail, false, 0, true); } G4VPhysicalVolume* DetectorConstruction::Construct() { // Define materials DefineMaterials(); // World G4Sphere* solidWorld = new G4Sphere("World", 0, 15. * m, 0, 360 * deg, 0, 180 * deg); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, G4Material::GetMaterial("Vacuum"), "World"); G4VPhysicalVolume* physicsWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0, true); // 节点舱 ConstructSectionSphere(logicWorld, (5.18 + 0.33) * m); // 过渡段 1 ConstructSectionCons("Trans1", logicWorld, 5.18 * m + 0.33 * m / 2, 2.8 * m / 2, 2.13 * m / 2, 1.5 * m / 2, 1.22 * m / 2, 0.33 * m / 2); // 小柱段 ConstructSectionSmall(logicWorld, 0); // 过渡段 2 ConstructSectionCons("Trans2", logicWorld, -0.815 * m / 2, 4.2 * m / 2, 2.8 * m / 2, 2.4 * m / 2, 1.5 * m / 2, 0.815 * m / 2); // 大柱段 ConstructSectionBig(logicWorld, 0.815 * m); dataFile << logicWorld->GetMass() / kg << std::endl; return physicsWorld; }