File indexing completed on 2025-02-23 09:22:08
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 #include "DetectorConstruction.hh"
0030
0031 #include "DetectorMessenger.hh"
0032
0033 #include "G4Box.hh"
0034 #include "G4Colour.hh"
0035 #include "G4GeometryManager.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4LogicalVolumeStore.hh"
0038 #include "G4Material.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4Region.hh"
0043 #include "G4RegionStore.hh"
0044 #include "G4RunManager.hh"
0045 #include "G4SolidStore.hh"
0046 #include "G4SystemOfUnits.hh"
0047 #include "G4Tubs.hh"
0048 #include "G4VisAttributes.hh"
0049
0050
0051
0052 DetectorConstruction::DetectorConstruction()
0053 : G4VUserDetectorConstruction(), fDiameter(6 * nm), fLength(10 * nm)
0054 {
0055 fDetectorMessenger = new DetectorMessenger(this);
0056 }
0057
0058
0059
0060 DetectorConstruction::~DetectorConstruction()
0061 {
0062 delete fDetectorMessenger;
0063 }
0064
0065
0066 G4VPhysicalVolume* DetectorConstruction::Construct()
0067 {
0068 return ConstructVolumes();
0069 }
0070
0071
0072
0073 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0074 {
0075
0076
0077 G4GeometryManager::GetInstance()->OpenGeometry();
0078 G4PhysicalVolumeStore::GetInstance()->Clean();
0079 G4LogicalVolumeStore::GetInstance()->Clean();
0080 G4SolidStore::GetInstance()->Clean();
0081
0082
0083 G4Material* water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
0084
0085
0086 G4double worldSize = 150 * nanometer;
0087
0088 G4VSolid* world = new G4Box("world",
0089 worldSize / 2, worldSize / 2, worldSize / 2);
0090
0091 G4LogicalVolume* worldLog = new G4LogicalVolume(world,
0092 water,
0093 "world");
0094
0095 G4VisAttributes* vis = new G4VisAttributes(G4Colour(G4Colour::Blue()));
0096 worldLog->SetVisAttributes(vis);
0097
0098 G4VPhysicalVolume* worldPhys = new G4PVPlacement(0,
0099 G4ThreeVector(),
0100 worldLog,
0101 "world",
0102 0,
0103 false,
0104 0,
0105 true);
0106
0107 G4VSolid* target = new G4Tubs("target", 0, fDiameter / 2, fLength / 2, 0, 360 * deg);
0108
0109 G4LogicalVolume* targetLog = new G4LogicalVolume(target, water, "target");
0110
0111 new G4PVPlacement(0,
0112 G4ThreeVector(),
0113 targetLog,
0114 "target",
0115 worldLog,
0116 false,
0117 0,
0118 true);
0119
0120
0121 G4Region* aRegion = G4RegionStore::GetInstance()->FindOrCreateRegion("Target");
0122 targetLog->SetRegion(aRegion);
0123 aRegion->AddRootLogicalVolume(targetLog);
0124
0125 G4VisAttributes* visTarget = new G4VisAttributes(G4Colour(G4Colour::Blue()));
0126 visTarget->SetForceSolid(true);
0127 visTarget->SetVisibility(true);
0128 targetLog->SetVisAttributes(visTarget);
0129
0130 return worldPhys;
0131 }
0132
0133
0134
0135 void DetectorConstruction::SetDiameter(G4double diameter)
0136 {
0137 fDiameter = diameter;
0138 G4RunManager::GetRunManager()->GeometryHasBeenModified();
0139 }
0140
0141
0142
0143 void DetectorConstruction::SetLength(G4double length)
0144 {
0145 fLength = length;
0146 G4RunManager::GetRunManager()->GeometryHasBeenModified();
0147 }
0148
0149
0150
0151 #include "G4RunManager.hh"
0152
0153 void DetectorConstruction::UpdateGeometry()
0154 {
0155 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
0156 }
0157
0158