File indexing completed on 2025-02-23 09:22:00
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 "DNAGeometry.hh"
0033 #include "DetectorMessenger.hh"
0034 #include "OctreeNode.hh"
0035
0036 #include "G4Box.hh"
0037 #include "G4Color.hh"
0038 #include "G4Ellipsoid.hh"
0039 #include "G4LogicalVolume.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4SDManager.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4VisAttributes.hh"
0045
0046 #include <fstream>
0047
0048
0049
0050 DetectorConstruction::DetectorConstruction()
0051 : fpDNAGeometry(new DNAGeometry()), fpDetectorMessenger(new DetectorMessenger(this))
0052 {
0053 G4bool useParallelPhysicsWorld = false;
0054 if (useParallelPhysicsWorld) {
0055 RegisterParallelWorld(fpDNAGeometry->GetDNAWorld());
0056 }
0057 }
0058
0059
0060
0061 DetectorConstruction::~DetectorConstruction()
0062 {
0063 delete fpDetectorMessenger;
0064 }
0065
0066
0067
0068 G4VPhysicalVolume* DetectorConstruction::Construct()
0069 {
0070 BuildMaterials();
0071 return ConstructDetector();
0072 }
0073
0074
0075
0076 void DetectorConstruction::BuildMaterials()
0077 {
0078 G4NistManager* man = G4NistManager::Instance();
0079 fpWorld = man->FindOrBuildMaterial("G4_Galactic");
0080 fpWater = man->FindOrBuildMaterial("G4_WATER");
0081 }
0082
0083
0084
0085 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
0086 {
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096 G4LogicalVolume* pDnaRegionLogical;
0097
0098 G4double dnasx = fCellRadius.getX();
0099 G4double dnasy = fCellRadius.getY();
0100 G4double dnasz = fCellRadius.getZ();
0101 if ((dnasx <= 0) || (dnasy <= 0) || (dnasz <= 0)) {
0102
0103 G4cout << "No cell radius has been specified (or the radii are less than 0)." << G4endl;
0104 G4cout << "This will fill the entire world with water" << G4endl;
0105
0106 G4double wsize = 1.01 * fWorldSideLength / 2.;
0107 auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0108 auto worldLogical = new G4LogicalVolume(worldPhysical, fpWater, "world");
0109 fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0110 pDnaRegionLogical = worldLogical;
0111 }
0112 else {
0113
0114 G4double wsize = 1.01 * fWorldSideLength / 2.;
0115 auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0116 auto worldLogical = new G4LogicalVolume(worldPhysical, fpWorld, "world");
0117
0118 fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0119 auto dnaPhysical = new G4Ellipsoid("CellPhysical", dnasx, dnasy, dnasz);
0120 auto dnaLogical = new G4LogicalVolume(dnaPhysical, fpWater, "CellLogical");
0121
0122 new G4PVPlacement(nullptr, G4ThreeVector(0), "CellVolume", dnaLogical, fWorld, false, 0, false);
0123 pDnaRegionLogical = dnaLogical;
0124 }
0125
0126 this->GetDNAGeometry()->BuildDNA(pDnaRegionLogical);
0127 return fWorld;
0128 }
0129
0130