Warning, file /geant4/examples/advanced/dna/moleculardna/src/DetectorConstruction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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(G4int vis)
0051 : fpDNAGeometry(new DNAGeometry()), fpDetectorMessenger(new DetectorMessenger(this))
0052 {
0053 if (vis == 1) {
0054 RegisterParallelWorld(fpDNAGeometry->GetDNAWorld());
0055 }
0056 }
0057
0058
0059
0060 DetectorConstruction::~DetectorConstruction()
0061 {
0062 delete fpDetectorMessenger;
0063 }
0064
0065
0066
0067 G4VPhysicalVolume* DetectorConstruction::Construct()
0068 {
0069 BuildMaterials();
0070 return ConstructDetector();
0071 }
0072
0073
0074
0075 void DetectorConstruction::BuildMaterials()
0076 {
0077 G4NistManager* man = G4NistManager::Instance();
0078 fpWorld = man->FindOrBuildMaterial("G4_Galactic");
0079 fpWater = man->FindOrBuildMaterial("G4_WATER");
0080 }
0081
0082
0083
0084 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
0085 {
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095 G4LogicalVolume* pDnaRegionLogical;
0096
0097 G4double dnasx = fCellRadius.getX();
0098 G4double dnasy = fCellRadius.getY();
0099 G4double dnasz = fCellRadius.getZ();
0100 if ((dnasx <= 0) || (dnasy <= 0) || (dnasz <= 0)) {
0101
0102 G4cout << "No cell radius has been specified (or the radii are less than 0)." << G4endl;
0103 G4cout << "This will fill the entire world with water" << G4endl;
0104
0105 G4double wsize = 1.01 * fWorldSideLength / 2.;
0106 auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0107 auto worldLogical = new G4LogicalVolume(worldPhysical, fpWater, "world");
0108 fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0109 pDnaRegionLogical = worldLogical;
0110 }
0111 else {
0112
0113 G4double wsize = 1.01 * fWorldSideLength / 2.;
0114 auto worldPhysical = new G4Box("WorldPhysical", wsize, wsize, wsize);
0115 auto worldLogical = new G4LogicalVolume(worldPhysical, fpWorld, "world");
0116
0117 fWorld = new G4PVPlacement(nullptr, G4ThreeVector(0), worldLogical, "world", nullptr, false, 0);
0118 auto dnaPhysical = new G4Ellipsoid("CellPhysical", dnasx, dnasy, dnasz);
0119 auto dnaLogical = new G4LogicalVolume(dnaPhysical, fpWater, "CellLogical");
0120
0121 new G4PVPlacement(nullptr, G4ThreeVector(0), "CellVolume", dnaLogical, fWorld, false, 0, false);
0122 pDnaRegionLogical = dnaLogical;
0123 }
0124
0125 this->GetDNAGeometry()->BuildDNA(pDnaRegionLogical);
0126 return fWorld;
0127 }
0128
0129