#include "DetectorConstruction.hh" #include "OneHit.hh" #include "OptFileManager.hh" #include "SensitiveDetector.hh" #include "G4LogicalBorderSurface.hh" #include "G4RunManager.hh" #include "G4NistManager.hh" #include "G4Box.hh" #include "G4Cons.hh" #include "G4Orb.hh" #include "G4Sphere.hh" #include "G4Trd.hh" #include "G4LogicalVolume.hh" #include "G4PVPlacement.hh" #include "G4SystemOfUnits.hh" #include "G4SDManager.hh" #include "G4VisAttributes.hh" #include "G4SubtractionSolid.hh" #include "G4UnionSolid.hh" #include "G4NistManager.hh" #include // Option to switch on/off checking of volume overlaps G4bool checkOverlaps = true; DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction() {} DetectorConstruction::~DetectorConstruction() {} G4VPhysicalVolume* DetectorConstruction::Construct() { //---------------------------// // *** Global parameters *** // //---------------------------// // World dimensions G4double world_sizeX = 20 * cm; G4double world_sizeY = 20 * cm; G4double world_sizeZ = 20 * cm; // Scintillator dimensions G4double ScintillatorX = 6 * mm; G4double ScintillatorY = 6 * mm; G4double ScintillatorZ = 4 * cm; //---------------------------// // *** Materials *** // //---------------------------// // Define LYSO material G4Element* Lu = new G4Element("Lutetium", "Lu", 71., 174.97 * g / mole); G4Element* Y = new G4Element("Yttrium", "Y", 39., 88.90585 * g / mole); G4Element* Si = new G4Element("Silicon", "Si", 14., 28.0855 * g / mole); G4Element* O = new G4Element("Oxygen", "O", 8., 15.9994 * g / mole); G4Material* LYSO = new G4Material("LYSO", 7.1 * g / cm3, 4); LYSO->AddElement(Lu, 71.43 * perCent); LYSO->AddElement(Y, 4.03 * perCent); LYSO->AddElement(Si, 6.37 * perCent); LYSO->AddElement(O, 18.17 * perCent); //---------------------------// // *** Geometry *** // //---------------------------// // Create the world volume G4NistManager* nist = G4NistManager::Instance(); G4Material* worldMat = nist->FindOrBuildMaterial("G4_AIR"); G4Box* solidWorld = new G4Box("World", 0.5 * world_sizeX, 0.5 * world_sizeY, 0.5 * world_sizeZ); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, worldMat, "World"); G4VPhysicalVolume* physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0, checkOverlaps); // Create the scintillator G4Box* solidScintillator = new G4Box("Scintillator", 0.5 * ScintillatorX, 0.5 * ScintillatorY, 0.5 * ScintillatorZ); G4LogicalVolume* logicScintillator = new G4LogicalVolume(solidScintillator, LYSO, "Scintillator"); new G4PVPlacement(0, G4ThreeVector(), logicScintillator, "Scintillator", logicWorld, false, 0, checkOverlaps); // Visualization attributes G4VisAttributes* ScintillatorVis = new G4VisAttributes(G4Colour(0.9, 0.9, 0.9)); ScintillatorVis->SetVisibility(true); ScintillatorVis->SetForceSolid(true); logicScintillator->SetVisAttributes(ScintillatorVis); //---------------------------// // *** Sensitive Detector *** // //---------------------------// G4SDManager* SD_manager = G4SDManager::GetSDMpointer(); G4String SDModuleName = "/SensitiveDetector"; SensitiveDetector* sensitiveModule = new SensitiveDetector(SDModuleName, "HitCollection"); SD_manager->AddNewDetector(sensitiveModule); logicScintillator->SetSensitiveDetector(sensitiveModule); return physWorld; } void DetectorConstruction::ConstructSDandField() { SensitiveDetector *sensDet = new SensitiveDetector("SensitiveDetector", "HitCollection"); if(logicScintillator != NULL) logicScintillator->SetSensitiveDetector(sensDet); }