#include "MyDetectorConstruction.hh" #include "MySensitiveDetector.hh" #include "G4SDManager.hh" MyDetectorConstruction::MyDetectorConstruction() { nCols = 7; nRows = 7; DefineMaterial(); xWorld = 1.0*m; yWorld = 1.05*m; zWorld = 2.0*m; } MyDetectorConstruction::~MyDetectorConstruction() {} void MyDetectorConstruction::DefineMaterial() { G4Element* Ar = new G4Element("Argon", "Ar", 18., 39.948*g/mole); G4Element* O = new G4Element("Oxygen", "O", 8., 15.999*g/mole); G4Element* N = new G4Element("Nitrogen", "N", 7., 14.007*g/mole); G4Element* Al = new G4Element("Aluminium", "Al", 13., 26.98*g/mole); G4Element* Pb = new G4Element("Lead", "Pb", 82., 207.2*g/mole); G4Element* W = new G4Element("Tungsten", "W", 74., 183.84*g/mole); Air = new G4Material("Air", 1.214*mg/cm3, 3); Air->AddElement(N, 75*perCent); Air->AddElement(O, 24*perCent); Air->AddElement(Ar, 1*perCent); PbWO4 = new G4Material("PbWO4", 8.300*g/cm3, 3); PbWO4->AddElement(Pb, 1); PbWO4->AddElement(W, 2); PbWO4->AddElement(O, 2); } G4VPhysicalVolume *MyDetectorConstruction::Construct() { solidWorld = new G4Box("World", 0.5*xWorld, 0.5*yWorld, 0.5*zWorld); logicWorld = new G4LogicalVolume(solidWorld, Air, "World"); physWorld = new G4PVPlacement(0, G4ThreeVector(), logicWorld, "World", 0, false, 0, true); G4double xsize(2.2*cm), ysize(2.2*cm), zsize(23.6*cm); solidDetector = new G4Box("Detector", 0.5*xsize, 0.5*ysize, 0.5*zsize); logicDetector = new G4LogicalVolume(solidDetector, PbWO4, "Detector"); G4double xpos = -xsize * (nRows - 1); for (G4int i=0; i < nRows; i++) { G4double ypos = -ysize * (nCols - 1); for (G4int j=0; j < nCols; j++) { G4int copy = i * 10 + j; new G4PVPlacement(0, G4ThreeVector(xpos, ypos, 0.), logicDetector, "Detector", logicWorld, false, copy, true); ypos += ysize; } xpos += xsize; } return physWorld; } void MyDetectorConstruction::ConstructSDandField() { G4SDManager* sdManager = G4SDManager::GetSDMpointer(); MySensitiveDetector *sensDet = new MySensitiveDetector("SensitiveDetector"); sdManager->AddNewDetector(sensDet); logicDetector->SetSensitiveDetector(sensDet); }