File indexing completed on 2025-02-23 09:21:51
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 #include "DetectorConstruction.hh"
0037
0038 #include "G4Box.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4RunManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4VisAttributes.hh"
0045
0046
0047
0048 DetectorConstruction::DetectorConstruction() : fpDefaultMaterial(0), fpWaterMaterial(0) {}
0049
0050
0051
0052 DetectorConstruction::~DetectorConstruction() {}
0053
0054
0055
0056 G4VPhysicalVolume* DetectorConstruction::Construct()
0057 {
0058 DefineMaterials();
0059 return ConstructVolumes();
0060 }
0061
0062
0063
0064 void DetectorConstruction::DefineMaterials()
0065 {
0066 G4NistManager* nistManager = G4NistManager::Instance();
0067
0068 nistManager->FindOrBuildMaterial("G4_WATER", false);
0069 fpWaterMaterial = G4Material::GetMaterial("G4_WATER");
0070
0071 nistManager->FindOrBuildMaterial("G4_AIR", false);
0072 fpDefaultMaterial = G4Material::GetMaterial("G4_AIR");
0073 }
0074
0075
0076
0077 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0078 {
0079
0080 G4double worldSize = 2 * micrometer;
0081
0082 G4Box* solidWorld = new G4Box("World", worldSize / 2., worldSize / 2., worldSize / 2.);
0083 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fpDefaultMaterial, "World");
0084 G4VPhysicalVolume* physiWorld =
0085 new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0086
0087
0088 G4double targetSizeXY = 1 * micrometer;
0089 G4double targetSizeZ = 0.5 * micrometer;
0090
0091 G4Box* solidTarget = new G4Box("Target", targetSizeXY / 2., targetSizeXY / 2., targetSizeZ / 2.);
0092 G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget, fpWaterMaterial, "Target");
0093 new G4PVPlacement(0, G4ThreeVector(), "Target", logicTarget, physiWorld, false, 0);
0094
0095
0096 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0097 worldVisAtt->SetVisibility(true);
0098 logicWorld->SetVisAttributes(worldVisAtt);
0099
0100 G4VisAttributes* targetVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
0101 targetVisAtt->SetVisibility(true);
0102 targetVisAtt->SetForceAuxEdgeVisible(true);
0103 logicTarget->SetVisAttributes(targetVisAtt);
0104
0105
0106 return physiWorld;
0107 }