#include "mgDetectorConstruction.hh" #include "G4Material.hh" #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4Orb.hh" #include "G4Box.hh" #include "G4Sphere.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4AutoDelete.hh" #include "G4GeometryTolerance.hh" #include "G4GeometryManager.hh" #include "G4UserLimits.hh" #include "G4VisAttributes.hh" #include "G4Colour.hh" #include "G4SystemOfUnits.hh" mgDetectorConstruction::mgDetectorConstruction() : G4VUserDetectorConstruction(), fLogicSphere(NULL), fLogicShell(NULL), fSphereMaterial(NULL), fShellMaterial(NULL), fCheckOverlaps(true) { } mgDetectorConstruction::~mgDetectorConstruction() { } G4VPhysicalVolume* mgDetectorConstruction::Construct() { //Define Materials DefineMaterials(); //Define Volumes return DefineVolumes(); } void mgDetectorConstruction::DefineMaterials() { //Material Definitions G4NistManager* manager = G4NistManager::Instance(); //Define Air for the shell fShellMaterial = manager->FindOrBuildMaterial("G4_AIR"); //Define Lead for the sphere //G4double density = 0.83*g/cm3; //fSphereMaterial = manager->BuildMaterialWithNewDensity("BufferOil","G4_PARAFFIN",density);//BuildMaterialWithNewDensity("SuperHydrogen","G4_H",density); fSphereMaterial = manager->FindOrBuildMaterial("G4_Fe"); //Print Materials (debugging) G4cout << *(G4Material::GetMaterialTable()) << G4endl; } G4VPhysicalVolume* mgDetectorConstruction::DefineVolumes() { G4Material* air = G4Material::GetMaterial("G4_AIR"); G4double sphereRad = 10*cm; G4double shellthickness = 1*mm; G4double WorldRad = 11*cm; // G4double innerShRad = sphereRad; G4double outerShRad = sphereRad + shellthickness; G4Orb* worldOrb = new G4Orb("world", WorldRad); G4LogicalVolume* logicWorld = new G4LogicalVolume(worldOrb, air, "world"); G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "world", 0, false, 0, fCheckOverlaps); G4Orb* sphereOrb = new G4Orb("Sphere", sphereRad);//G4Box("Sphere", 100*cm, 100*cm, 50*cm); fLogicSphere = new G4LogicalVolume(sphereOrb, fSphereMaterial, "Sphere"); new G4PVPlacement(0, G4ThreeVector(), fLogicSphere, "Sphere", logicWorld, false, 0, fCheckOverlaps); G4Sphere* shellSphere = new G4Sphere("Sphere", sphereRad, outerShRad, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell = new G4LogicalVolume(shellSphere, fShellMaterial, "Shell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell, "Shell", logicWorld, false, 0, fCheckOverlaps); return physWorld; } void mgDetectorConstruction::SetSphereMaterial(G4String materialname) { G4NistManager* manager = G4NistManager::Instance(); G4Material* newMaterial = manager->FindOrBuildMaterial(materialname); if (fSphereMaterial != newMaterial) { if (newMaterial) { fSphereMaterial = newMaterial; if (fLogicSphere) fLogicSphere->SetMaterial(fSphereMaterial); G4cout << G4endl << "---------------> The Target is now " << materialname < WARNING from SetTargetMaterial : " << materialname <<" not found" <