// // NOTE: this code is incomplete and contains intermediate solutions that are // not necessarily fully correct. But we will continue form this state // #include "YourDetectorConstruction.hh" // geonetry definition #include "G4Box.hh" // for matrial #include "G4Material.hh" #include "G4NistManager.hh" // for units #include "G4SystemOfUnits.hh" YourDetectorConstruction::YourDetectorConstruction() : G4VUserDetectorConctruction(), fTargetMaterial(nullptr), fTargetShape(nullptr), fWorldShape(nullptr), fTargetLogical(nullptr){ const G4String matName = "G4_Si"; SetTargetMaterial(matName); fTargetThickness = 1.0*CLHEP::cm; ComputeParameters(); } YourDetectorConstruction::~YourDetectorConstruction() { } void YourDetectorConstruction::SetTargetMaterial(const G4String& name) { fTargetMaterial = G4NistManager::Instance()->FindOrBuildMaterial(name); if (fTargetMaterial == nullptr) { G4cerr << " *** ERROR YourDetectorConstruction: unknown material = " << name << G4endl; exit(-1); } if (fTargetLogical != nullptr) { fTargetLogical->SetMaterial(fTargetMaterial); G4RunManager::GetRunManager()->PhysicsHasBeenModified(); } } void YourDetectorConstruction::SetTargetThickness(G4double val) { fTargetThickness = val; ComputeParameters(); } void YourDetectorConstruction::ComputeParameters() { fTargetYZSize = 5.0*fTargetThickness; fWorldXSize = 1.5*fTargetThickness; fWorldYZSize = 1.5*fTargetYZSize; // compute gun x position fGunPosition = -0.25*(fWorldXSize + fTargetThickness); // if (fWorldShape != nullptr) { fWorldShape->SetXHalfLength(0.5*fWorldXSize); fWorldShape->SetYHalfLength(0.5*fWorldYZSize); fWorldShape->SetZHalfLength(0.5*fWorldYZSize); fTargetShape->SetXHalfLength(0.5*fTargetThickness); fTargetShape->SetYHalfLength(0.5*fTargetYZSize); fTargetShape->SetZHalfLength(0.5*fTargetYZSize); } } G4VPhysicalVolume* YourDetectorConstruction::Construct() { // create material for the world const G4Material* wMat = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic"); // world fWorldShape = new G4Box("solid-world", 0.5*fWorldXSize, 0.5*fWorldYZSize, 0.5*fWorldYZSize); G4LogicalVolume* wLogical = new G4LogicalVolume(fWorldShape, wMat, "logic-world"); G4VPhysicalVolume* wPhys = new G4PVPlacement(nullptr, G4ThreeVector(0,0,0), wLogical, "World", nullptr, false, 0); // // target fTargetShape = new G4Box("solid-target", 0.5*fTargetThickness, 0.5*fTargetYZSize, 0.5*fTargetYZSize); fTargetLogical = new G4LogicalVolume(fTargetShape, fTargetMaterial, "logic-target"); G4VPhysicalVolume* tPhys = new G4PVPlacement(nullptr, G4ThreeVector(0,0,0), tLogical, "Target", wLogical, false, 0); return wPhys; }