#include "DetectorConstruction.hh" #include "G4Material.hh" #include "G4Tubs.hh" #include "G4Box.hh" #include "G4SubtractionSolid.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4SystemOfUnits.hh" #include "G4NistManager.hh" #include "G4VisAttributes.hh" // hide the LogicWorld #include "G4RotationMatrix.hh" #include "G4SDManager.hh" #include "DetectorSD.hh" #include "DetectorHit.hh" #include "G4VSensitiveDetector.hh" DetectorConstruction::DetectorConstruction() :G4VUserDetectorConstruction(), logicDet1(0), logicDet2(0) {} DetectorConstruction::~DetectorConstruction() {} G4VPhysicalVolume* DetectorConstruction::Construct() { //******************* Define the MAterials ************************************* G4NistManager * nist = G4NistManager::Instance(); auto Germanium = nist -> FindOrBuildMaterial ("G4_Ge") ; auto Air = nist -> FindOrBuildMaterial ("G4_AIR"); auto Led = nist -> FindOrBuildMaterial ("G4_Pb") ; G4double La_Z , La_a, Br_Z, Br_a, LaBr3_density; G4int ncomponents, natoms; La_Z = 57.; La_a = 132.905 *g/mole; Br_Z = 35.; Br_a = 79.901 *g/mole; LaBr3_density = 5.06 *g/cm3; G4Element * La = new G4Element ("Lanthanum", "La", La_Z, La_a); G4Element * Br = new G4Element ("Bromide" , "Br", Br_Z, Br_a); G4Material * LaBr3 = new G4Material("LaBr3", LaBr3_density, ncomponents = 2); LaBr3 -> AddElement(La, natoms = 1); LaBr3 -> AddElement(Br, natoms = 3); //******************* Experimental Hall (World) ****************************** auto solidWorld = new G4Box ("World", 5. *m, 5. *m, 5. *m); auto logicWorld = new G4LogicalVolume(solidWorld, Air, "World_Logic"); auto physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World_phy", 0,false,0); logicWorld -> SetVisAttributes(G4VisAttributes::GetInvisible()); //************************************ Collimator ****************************** G4double Collimator_Length, Collimator_Width, Collimator_Height, Collimator_Holediameter; Collimator_Width = 100. *mm; Collimator_Height = 100. *mm; Collimator_Length = 200. *mm; Collimator_Holediameter = 2. *mm; auto SolidCollimatorBox = new G4Box("SolidCollimatorBox", Collimator_Width, Collimator_Height, Collimator_Length); auto SolidCollimatorHole = new G4Tubs("SolidCollimatorHole", 0., Collimator_Holediameter, (Collimator_Length + 2. *mm), 0 *degree, 360 *degree); auto CollimatorSolid = new G4SubtractionSolid ("CollimatorSolid", SolidCollimatorBox, SolidCollimatorHole); auto LogicCollimator = new G4LogicalVolume (CollimatorSolid, Led, "Collimator_Logic"); new G4PVPlacement(0, G4ThreeVector(0, 0 , - 150. *cm), LogicCollimator, "Collimator_phy", logicWorld, false, 0); //********************************* Detectors ******************************** // Detector 1 G4double RminDet1, Crystal_Radius_Det1, Crystal_HalfLength_Det1, PhiminDet1, deltaPhiDet1; RminDet1 = 0.; Crystal_Radius_Det1 = 4.445 *cm; Crystal_HalfLength_Det1 = 5.08 *cm; PhiminDet1 = 0.; deltaPhiDet1 = 360 *degree; auto solidDet1 = new G4Tubs ("Det1", RminDet1, Crystal_Radius_Det1, Crystal_HalfLength_Det1, PhiminDet1, deltaPhiDet1); auto logicDet1 = new G4LogicalVolume(solidDet1, LaBr3, "Det1_Logic"); new G4PVPlacement(0, G4ThreeVector(0, 0, 150. *cm), logicDet1, "Det1_Phy", logicWorld, false, 0.); // Detector 2 G4double RminDet2, Crystal_Radius_Det2, Crystal_HalfLength_Det2, ThetaDet2, PhiDet2, PhiminDet2, deltaPhiDet2, x, y, z; RminDet2 = 0.; Crystal_Radius_Det2 = 4.1 *cm; Crystal_HalfLength_Det2 = 5.125 *cm; PhiminDet2 = 0.; deltaPhiDet2 = 360 *degree; ThetaDet2 = 90. *degree; PhiDet2 = 0. *degree; // Controle the Crystal Angle auto solidDet2 = new G4Tubs ("Det2", RminDet2, Crystal_Radius_Det2, Crystal_HalfLength_Det2, PhiminDet2, deltaPhiDet2); auto logicDet2 = new G4LogicalVolume(solidDet2, Germanium, "Det2_Logic"); auto rotDet2 = new G4RotationMatrix(); rotDet2 -> rotateZ(180. *degree -PhiDet2); rotDet2 -> rotateY(ThetaDet2); x = 20 * sin(ThetaDet2) * cos(PhiDet2) * cm; y = 20 * sin(ThetaDet2) * sin(PhiDet2) * cm; z = 20 * cos(ThetaDet2) * cm; new G4PVPlacement(rotDet2, G4ThreeVector(x, y, z), logicDet2, "Det21_Phy", logicWorld, false, 0); return physWorld; } void DetectorConstruction::ConstructSDansField() { G4SDManager* aSDManager = G4SDManager::GetSDMpointer(); G4String SDname; G4VSensitiveDetector* Detector1 = DetectorSD(SDname = "/Detector1"); aSDManager -> AddNewDetector(Detector1); logicDet1 -> SetSensitiveDetector(Detector1); G4VSensitiveDetector* Detector2 = DetectorSD(SDname = "/Detector2"); aSDManager -> AddNewDetector(Detector2); logicDet2 -> SetSensitiveDetector(Detector2); }