File indexing completed on 2025-10-14 08:09:01
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 #include "DetectorConstruction.hh"
0031
0032 #include "VoxelParam.hh"
0033 #include "VoxelSD.hh"
0034
0035 #include "G4Box.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4PVParameterised.hh"
0039 #include "G4PVPlacement.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4VisAttributes.hh"
0042
0043 typedef G4LogicalVolume G4LV;
0044 typedef G4PVPlacement G4PVP;
0045 typedef G4VisAttributes G4VA;
0046
0047
0048 DetectorConstruction::DetectorConstruction() : flv_voxel(NULL) {}
0049
0050
0051 DetectorConstruction::~DetectorConstruction() {}
0052
0053
0054 G4VPhysicalVolume* DetectorConstruction::Construct()
0055 {
0056 G4NistManager* nistManager = G4NistManager::Instance();
0057 G4VisAttributes* va;
0058
0059
0060 const G4double DXYZ_WORLD = 200. * cm;
0061 G4Box* sld_world = new G4Box("world", DXYZ_WORLD / 2., DXYZ_WORLD / 2., DXYZ_WORLD / 2.);
0062
0063 G4Material* vacuum = nistManager->FindOrBuildMaterial("G4_Galactic");
0064 G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
0065 G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA", lv_world, 0, false, 0);
0066
0067 va = new G4VA(G4Color(1., 1., 1.));
0068 va->SetVisibility(false);
0069 lv_world->SetVisAttributes(va);
0070
0071
0072 const G4double DXY_PHANTOM = 20. * cm;
0073 const G4double DZ_PHANTOM = 50. * cm;
0074
0075 G4Box* sld_phantom = new G4Box("phantom", DXY_PHANTOM / 2., DXY_PHANTOM / 2., DZ_PHANTOM / 2.);
0076
0077 G4Material* water = nistManager->FindOrBuildMaterial("G4_WATER");
0078 G4LV* lv_phantom = new G4LogicalVolume(sld_phantom, water, "phantom");
0079
0080 va = new G4VA(G4Color(0., 1., 1.));
0081 lv_phantom->SetVisAttributes(va);
0082
0083 new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
0084
0085
0086 const G4double DXY_VXP = 20. * cm;
0087 const G4double DZ_VXP = 1. * mm;
0088
0089 G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP / 2., DXY_VXP / 2., DZ_VXP / 2.);
0090 G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
0091
0092 va = new G4VA(G4Color(1., 0., 0.));
0093 va->SetVisibility(false);
0094 lv_vxp->SetVisAttributes(va);
0095
0096 for (G4int iz = 0; iz < 500; iz++) {
0097 G4double z0 = -DZ_PHANTOM / 2. + (iz + 0.5) * DZ_VXP;
0098 new G4PVP(0, G4ThreeVector(0., 0., z0), lv_vxp, "vxplane", lv_phantom, false, 1000 + iz);
0099 }
0100
0101
0102 G4Box* sld_voxel = new G4Box("voxel", 1., 1., 1.);
0103 flv_voxel = new G4LV(sld_voxel, water, "voxel");
0104
0105 va = new G4VA(G4Color(0., 1., 1.));
0106 va->SetVisibility(false);
0107 flv_voxel->SetVisAttributes(va);
0108
0109 const G4int nvoxels = 100 * 100;
0110 new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels, new VoxelParam());
0111
0112 return world;
0113 }
0114
0115
0116 void DetectorConstruction::ConstructSDandField()
0117 {
0118 flv_voxel->SetSensitiveDetector(new VoxelSD("voxel"));
0119 }