// construction.cc #include "G4Box.hh" #include "G4Tubs.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4Material.hh" #include "G4NistManager.hh" #include "G4ThreeVector.hh" #include "G4PhysicalConstants.hh" #include "G4VisAttributes.hh" #include "G4Colour.hh" #include "G4RotationMatrix.hh" #include "G4SystemOfUnits.hh" #include "construction.hh" MyDetectorConstruction::MyDetectorConstruction() {} MyDetectorConstruction::~MyDetectorConstruction() {} G4VPhysicalVolume* MyDetectorConstruction::Construct() { // Create materials and set up the geometry BuildWorld(); BuildTarget(); BuildReflector(); BuildBooster(); BuildHelium3Detector(); // Return the physical world volume return worldPhysical; } void MyDetectorConstruction::BuildWorld() { // Creating world. G4Box* worldBox = new G4Box("world", 30 * cm, 30 * cm, 30 * cm); worldLogical = new G4LogicalVolume(worldBox, G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR"), "worldLogical"); worldPhysical = new G4PVPlacement(0, G4ThreeVector(), worldLogical, "worldPhysical", 0, false, 0); } void MyDetectorConstruction::BuildTarget() { // Creating target (Am-241) at the center of the world. G4Tubs* targetTubs = new G4Tubs("target", 0.0, 2.0 * cm, 15.0 * cm, 0.0, 360.0 * deg); // Manually define the material for Am-241 G4Material* targetMaterial = new G4Material("Am241", 95, 241. * g / mole, 11.7 * g / cm3); targetLogical = new G4LogicalVolume(targetTubs, targetMaterial, "targetLogical"); targetPhysical = new G4PVPlacement(0, G4ThreeVector(), targetLogical, "targetPhysical", worldLogical, false, 0); // Set visualization attributes for the logical volumes G4VisAttributes* intersectionVis = new G4VisAttributes(G4Colour(1.0, 1.0, 0.0, 0.3)); // yellow color intersectionVis->SetForceSolid(true); targetLogical->SetVisAttributes(intersectionVis); // Set attributes for the cylinder } void MyDetectorConstruction::BuildBooster() { // Creating U booster. G4Tubs* boosterTubs = new G4Tubs("booster", 0.0, 4.0 * cm, 15.0 * cm, 0.0, 360.0 * deg); // Manually define the material for U G4Material* boosterMaterial = new G4Material("Uranium", 92, 238.0289 * g / mole, 19.05 * g / cm3); boosterLogical = new G4LogicalVolume(boosterTubs, boosterMaterial, "boosterLogical"); boosterPhysical = new G4PVPlacement(0, G4ThreeVector(), boosterLogical, "boosterPhysical", worldLogical, false, 0); // Set visualization attributes for the logical volumes G4VisAttributes* intersectionVis = new G4VisAttributes(G4Colour(1.0, 0.5, 0.0, 0.3)); // orange color intersectionVis->SetForceSolid(true); boosterLogical->SetVisAttributes(intersectionVis); // Set attributes for the cylinder } void MyDetectorConstruction::BuildReflector() { // Creating Be reflector. G4Tubs* reflectorTubs = new G4Tubs("reflector", 0.0, 10.0 * cm, 15.0 * cm, 0.0, 360.0 * deg); // Manually define the material for Be G4Material* reflectorMaterial = new G4Material("Beryllium", 4, 9.0122 * g / mole, 1.848 * g / cm3); reflectorLogical = new G4LogicalVolume(reflectorTubs, reflectorMaterial, "reflectorLogical"); reflectorPhysical = new G4PVPlacement(0, G4ThreeVector(), reflectorLogical, "reflectorPhysical", worldLogical, false, 0); // Set visualization attributes for the logical volumes G4VisAttributes* intersectionVis = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.3)); // grey color intersectionVis->SetForceSolid(true); reflectorLogical->SetVisAttributes(intersectionVis); // Set attributes for the cylinder } void MyDetectorConstruction::BuildHelium3Detector() { // Helium-3 detector G4RotationMatrix* rotCryst = new G4RotationMatrix(); rotCryst->rotateX(fCrystRotAngle); G4Tubs* crystTubs = new G4Tubs("Cryst1", 0.0, 1. * cm, 2 * cm, 0.0, 360.0 * deg); G4Material* helium3Material = new G4Material("Helium3", 1, 3.016 * g / mole, 1.51988 * bar, kStateGas, 293. * kelvin, 1.51988 * bar / (293. * kelvin * CLHEP::Avogadro * CLHEP::k_Boltzmann)); G4LogicalVolume* cryst1_log = new G4LogicalVolume(crystTubs, helium3Material, "Cryst1"); // Place the crystal at the center of the world new G4PVPlacement(rotCryst, G4ThreeVector(0., 0., 2. * cm), cryst1_log, "Cryst1", worldLogical, false, 0); // Set visualization attributes for the logical volume G4VisAttributes* cryst_vis = new G4VisAttributes(G4Colour(0.0, 0.7, 0.2)); cryst_vis->SetForceSolid(true); cryst1_log->SetVisAttributes(cryst_vis); }