Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
_Geant4 Version:_11.1
_Operating System:_Windows 11
_Compiler/Version:_Visualstudio 2022
_CMake Version:_3.28.0-rc1
— I just started Geant4 a few days ago. Now I am making detector placement stuffs.
I want to make a detector configuration attached picture with below code.
In this case, How can I use the G4Subtraction function to make it?
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Isotope.hh"
#include "G4Element.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4PSPopulation.hh"
#include "G4PSNofCollision.hh"
#include "G4Triton.hh"
#include "G4SubtractionSolid.hh"
#include "DetectorConstruction.hh"
DetectorConstruction::DetectorConstruction()
: G4VUserDetectorConstruction()
{
}
DetectorConstruction::~DetectorConstruction()
{
}
G4VPhysicalVolume *DetectorConstruction::Construct()
{
G4Isotope* Li6 = new G4Isotope("Li6", 3, 6, 6.015122 * g / mole);
G4Isotope* Li7 = new G4Isotope("Li7", 3, 7, 7.016 * g / mole);
G4Element* elLi = new G4Element("Lithium", "Li", 2);
elLi->AddIsotope(Li6, 1);
elLi->AddIsotope(Li7, 1);
auto density = 0.534*g / cm3;
auto a = 6.0651659 * g / mole;
auto MadeLi = new G4Material("MadeLithium", 3., a, density);
G4NistManager* nist = G4NistManager::Instance();
// materials
auto matAir = nist->FindOrBuildMaterial("G4_AIR");
auto matWater = nist->FindOrBuildMaterial("G4_WATER");
auto matBoronCarbide = nist->FindOrBuildMaterial("G4_BORON_CARBIDE");
auto matAluminum = nist->FindOrBuildMaterial("G4_ALUMINUM_OXIDE");
auto matXylene = nist->FindOrBuildMaterial("G4_XYLENE");
auto matPolycarbon = nist->FindOrBuildMaterial("G4_POLYCARBONATE");
auto matLIOX = nist->FindOrBuildMaterial("G4_LITHIUM_OXIDE");
auto matGLPL = nist->FindOrBuildMaterial("G4_GLASS_PLATE");
auto matLD = new G4Material("LD", 2.5 * g / cm3, 2);
matLD->AddMaterial(matLIOX, 0.066);
matLD->AddMaterial(matGLPL, 0.934);
auto matCardmium = nist->FindOrBuildMaterial("G4_Cd");
auto matPE = nist->FindOrBuildMaterial("G4_POLYETHYLENE");
auto matBORON = nist->FindOrBuildMaterial("G4_B");
auto matBP = new G4Material("BP",0.9547 * g / cm3, 2);
matBP->AddMaterial(matPE, 0.95);
matBP->AddMaterial(matBORON, 0.05);
// World
auto worldSize = 100. *cm;
auto worldSol = new G4Box("World", 1. * worldSize, 1. * worldSize, 1. * worldSize);
auto worldLog = new G4LogicalVolume(worldSol, matAir, "World");
auto worldPhy = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), worldLog, "World", nullptr, false, 0);
// Total case
auto outtercasePos = G4ThreeVector(.5 * 138.43 * cm, .5 * 30.7975 * cm, 2.54 * cm);
auto outtercaseSol = new G4Box("outtercase", .5 * 138.43 * cm, .5 * 30.7975 * cm, .5 * 52.07 * cm);
auto outtercaseLog = new G4LogicalVolume(outtercaseSol, matPolycarbon, "outtercase");
auto innercaseBCPos = G4ThreeVector(.5 * 138.43 * cm, .5 * 33.3375 * cm, 0 * cm);
auto innercaseBCSol = new G4Box("innercaseBC", .5 * 133.35 * cm, .5 * 28.2575 * cm, .5 * 39.37 * cm);
auto innercaseBCLog = new G4LogicalVolume(innercaseBCSol, matBP, "innercaseBC");
return worldPhy;
}
void DetectorConstruction::ConstructSDandField()
{
}