#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), fLogicShell1(NULL), fLogicShell2(NULL), fLogicShell3(NULL), fLogicShell4(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 Vacuum for the shells G4double vacden = 0.00001*g/m3; vacuum = manager->BuildMaterialWithNewDensity("Vacuum","G4_AIR",vacden); //Define Buffer material for the buffer and detector G4double density = 0.83*g/cm3; fSphereMaterial = manager->BuildMaterialWithNewDensity("BufferOil","G4_PARAFFIN",density); //define water and iron fShellMaterial = manager->FindOrBuildMaterial("G4_WATER"); iron = manager->FindOrBuildMaterial("G4_Fe"); //Print Materials (debugging) G4cout << *(G4Material::GetMaterialTable()) << G4endl; } G4VPhysicalVolume* mgDetectorConstruction::DefineVolumes() { G4double sphereRad = 650*cm; G4double bufferRad = 900*cm; G4double waterRad = 1000*cm; G4double WorldRad = 12*m; G4double fShell = 650.001*cm; G4double sShell = 900.001*cm; G4double tShell = 1199.999*cm; //define shell radii for various layers //define world G4Orb* worldOrb = new G4Orb("world", WorldRad); G4LogicalVolume* logicWorld = new G4LogicalVolume(worldOrb, vacuum, "world"); G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "world", 0, false, 0, fCheckOverlaps); G4Orb* sphereOrb = new G4Orb("Sphere", sphereRad); fLogicSphere = new G4LogicalVolume(sphereOrb, fSphereMaterial, "Sphere"); new G4PVPlacement(0, G4ThreeVector(), fLogicSphere, "Sphere", logicWorld, false, 0, fCheckOverlaps); G4Sphere* firstShell = new G4Sphere("firstShell", sphereRad, fShell, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell = new G4LogicalVolume(firstShell, vacuum, "firstShell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell, "firstShell", logicWorld, false, 0, fCheckOverlaps); G4Sphere* buffShell = new G4Sphere("buffShell", fShell, bufferRad, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell1 = new G4LogicalVolume(buffShell, fSphereMaterial, "buffShell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell1, "buffShell", logicWorld, false, 0, fCheckOverlaps); G4Sphere* secondShell = new G4Sphere("secondShell", bufferRad, sShell, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell2 = new G4LogicalVolume(secondShell, vacuum, "secondShell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell2, "secondShell", logicWorld, false, 0, fCheckOverlaps); G4Sphere* waterShell = new G4Sphere("waterShell", sShell, waterRad, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell3 = new G4LogicalVolume(waterShell, fShellMaterial, "waterShell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell3, "waterShell", logicWorld, false, 0, fCheckOverlaps); G4Sphere* thirdShell = new G4Sphere("thirdShell", tShell, WorldRad, 0.*deg, 360.*deg, 0.*deg, 180.*deg); fLogicShell4 = new G4LogicalVolume(thirdShell, vacuum, "thirdShell"); new G4PVPlacement(0, G4ThreeVector(), fLogicShell4, "thirdShell", logicWorld, false, 0, fCheckOverlaps); G4Box* IronPlate = new G4Box("IronPlate", 10*cm, 250*cm, 250*cm); G4LogicalVolume* fLogicBox = new G4LogicalVolume(IronPlate, iron, "IronPlate"); new G4PVPlacement(0, G4ThreeVector(-1010*cm, 0, 0), fLogicBox, "IronPlate", 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" <