File indexing completed on 2026-05-02 07:42:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include "DetectorConstruction.hh"
0038
0039 #include "G4Box.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SystemOfUnits.hh"
0044 #include "G4VPhysicalVolume.hh"
0045 #include "G4VisAttributes.hh"
0046
0047
0048
0049 DetectorConstruction::DetectorConstruction() : fpDefaultMaterial(0), fpWaterMaterial(0) {}
0050
0051
0052
0053 DetectorConstruction::~DetectorConstruction() {}
0054
0055
0056
0057 G4VPhysicalVolume* DetectorConstruction::Construct()
0058 {
0059 DefineMaterials();
0060 return ConstructVolumes();
0061 }
0062
0063
0064
0065 void DetectorConstruction::DefineMaterials()
0066 {
0067 G4NistManager* nistManager = G4NistManager::Instance();
0068
0069 nistManager->FindOrBuildMaterial("G4_WATER", false);
0070 fpWaterMaterial = G4Material::GetMaterial("G4_WATER");
0071
0072 nistManager->FindOrBuildMaterial("G4_AIR", false);
0073 fpDefaultMaterial = G4Material::GetMaterial("G4_AIR");
0074 }
0075
0076
0077
0078 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0079 {
0080
0081 G4double worldSize = 2 * micrometer;
0082
0083 G4Box* solidWorld = new G4Box("World", worldSize / 2., worldSize / 2., worldSize / 2.);
0084 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fpDefaultMaterial, "World");
0085 G4VPhysicalVolume* physiWorld =
0086 new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0087
0088
0089 G4double targetSizeXY = 1 * micrometer;
0090 G4double targetSizeZ = 0.5 * micrometer;
0091
0092 G4Box* solidTarget = new G4Box("Target", targetSizeXY / 2., targetSizeXY / 2., targetSizeZ / 2.);
0093 G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, fpWaterMaterial, "Target");
0094 new G4PVPlacement(0, G4ThreeVector(), "Target", logicTarget, physiWorld, false, 0);
0095
0096
0097 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0098 worldVisAtt->SetVisibility(true);
0099 logicWorld->SetVisAttributes(worldVisAtt);
0100
0101 G4VisAttributes* targetVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0102 targetVisAtt->SetVisibility(true);
0103 targetVisAtt->SetForceAuxEdgeVisible(true);
0104 logicTarget->SetVisAttributes(targetVisAtt);
0105
0106
0107 return physiWorld;
0108 }