#include "construction.hh" #include "G4UserLimits.hh" #include "G4ProductionCuts.hh" #include "G4ProductionCutsTable.hh" MyDetectorConstruction::MyDetectorConstruction() : logicTungsten(nullptr), logicDetector(nullptr) {} MyDetectorConstruction::~MyDetectorConstruction() {} G4VPhysicalVolume *MyDetectorConstruction::Construct() { G4NistManager *nist = G4NistManager::Instance(); // define world volume //G4Material *worldMat = nist->FindOrBuildMaterial("G4_Galactic"); // Define world volume with a material named "Vacuum" G4Material* worldMat = new G4Material("Vacuum", 1., 1.01 * g / mole, 1.e-25 * g / cm3, kStateGas, 0.1 * kelvin, 1.e-19 * pascal); G4Box *solidWorld = new G4Box("solidWorld", 0.5*mm, 0.5*mm, 0.5*mm); // 1m x 1m x 1m (0.5 in each direction from center) G4LogicalVolume *logicWorld = new G4LogicalVolume(solidWorld, worldMat, "logicWorld"); G4VPhysicalVolume *physWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), logicWorld, "physWorld", 0, false, 0); // define tungsten material G4Material* tungsten = nist->FindOrBuildMaterial("G4_W"); // define tungsten slab G4Box* solidTungsten = new G4Box("Target", 0.2 * mm, 0.2 * mm, 0.1 * mm); logicTungsten = new G4LogicalVolume(solidTungsten, tungsten, "Target"); G4VPhysicalVolume* physTungsten = new G4PVPlacement(0, G4ThreeVector(0, 0, -0.1*mm), logicTungsten, "Target", logicWorld, false, 1); G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(5 * eV, 10 * MeV); G4Region* fregion = new G4Region("Target"); G4ProductionCuts* cuts = new G4ProductionCuts(); G4double defCut = 1 * nanometer; cuts->SetProductionCut(defCut, "gamma"); cuts->SetProductionCut(defCut, "e-"); cuts->SetProductionCut(defCut, "e+"); cuts->SetProductionCut(defCut, "proton"); fregion->SetProductionCuts(cuts); fregion->AddRootLogicalVolume(logicTungsten); G4Box* solidDetector = new G4Box("solidDetector", 0.5 * mm, 0.5 * mm, 0.01 * mm); logicDetector = new G4LogicalVolume(solidDetector, worldMat, "logicDetector"); G4VPhysicalVolume* physDetector = new G4PVPlacement( 0, G4ThreeVector(0, 0, 0.015 * mm), // Position it where electrons will hit logicDetector, "physDetector", logicWorld, false, 2); // G4UserLimits* stepLimit = new G4UserLimits(0.1 * nm); //logicWorld->SetUserLimits(stepLimit); //logicTungsten->SetUserLimits(stepLimit); //logicDetector->SetUserLimits(stepLimit); return physWorld; } void MyDetectorConstruction::ConstructSDandField() { MySensitiveDetector* sensDet = new MySensitiveDetector("SensitiveDetector"); if (logicDetector) { logicDetector->SetSensitiveDetector(sensDet); } }