Warning, file /geant4/examples/extended/medical/dna/UHDR/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 #include "DetectorConstruction.hh"
0027
0028 #include "ChemistryWorld.hh"
0029 #include "PeriodicBoundaryBuilder.hh"
0030 #include "Scorer.hh"
0031
0032 #include "G4Box.hh"
0033 #include "G4Electron_aq.hh"
0034 #include "G4LogicalVolume.hh"
0035 #include "G4MultiFunctionalDetector.hh"
0036 #include "G4NistManager.hh"
0037 #include "G4PVPlacement.hh"
0038 #include "G4SDManager.hh"
0039 #include "G4UnitsTable.hh"
0040 #include "G4VPrimitiveScorer.hh"
0041 #include "G4VisAttributes.hh"
0042
0043
0044
0045 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction()
0046 {
0047 fpChemistryWorld = std::make_unique<ChemistryWorld>();
0048 fpChemistryWorld->ConstructChemistryBoundary();
0049 DefineCommands();
0050 }
0051
0052
0053
0054 G4VPhysicalVolume* DetectorConstruction::Construct()
0055 {
0056 auto water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
0057 auto boudingBox = fpChemistryWorld->GetChemistryBoundary();
0058 G4double world_sizeXYZ = 2 * boudingBox->halfSideLengthInY();
0059
0060 G4cout << "Volume size : " << G4BestUnit(world_sizeXYZ, "Length") << G4endl;
0061
0062 G4double buffer;
0063 if (fPBC) {
0064 G4cout << "PeriodicBoundaryCondition is applied " << G4endl;
0065 buffer = 0.01 * nanometer;
0066 }
0067 else {
0068 buffer = 0;
0069 G4cout << "PeriodicBoundaryCondition is not applied " << G4endl;
0070 }
0071
0072 auto solidWorld = new G4Box("World", 0.5 * (world_sizeXYZ - buffer),
0073 0.5 * (world_sizeXYZ - buffer), 0.5 * (world_sizeXYZ - buffer));
0074
0075 auto logicWorld = new G4LogicalVolume(solidWorld, water, "World");
0076
0077 if (fPBC) {
0078 auto pbb = std::make_unique<PeriodicBoundaryBuilder>();
0079 fpPBCLogicVolume = pbb->Construct(logicWorld);
0080 }
0081
0082 fpPhysWorld = new G4PVPlacement(nullptr,
0083 G4ThreeVector(),
0084 logicWorld,
0085 "World",
0086 nullptr,
0087 false,
0088 0,
0089 true);
0090
0091 return fpPhysWorld;
0092 }
0093
0094
0095
0096 void DetectorConstruction::ConstructSDandField()
0097 {
0098 G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
0099 auto mfDetector = new G4MultiFunctionalDetector("mfDetector");
0100
0101 G4VPrimitiveScorer* pDose = new Scorer<Dose>();
0102 dynamic_cast<Scorer<Dose>*>(pDose)->SetChemistryWorld(fpChemistryWorld.get());
0103 mfDetector->RegisterPrimitive(pDose);
0104 G4VPrimitiveScorer* gValues = new Scorer<Gvalues>();
0105 dynamic_cast<Scorer<Gvalues>*>(gValues)->SetChemistryWorld(fpChemistryWorld.get());
0106 mfDetector->RegisterPrimitive(gValues);
0107 G4SDManager::GetSDMpointer()->AddNewDetector(mfDetector);
0108 G4String SDName;
0109 if (fPBC) {
0110 SDName = fpPBCLogicVolume->GetName();
0111 }
0112 else {
0113 SDName = fpPhysWorld->GetName();
0114 }
0115 SetSensitiveDetector(SDName, mfDetector);
0116 }
0117
0118
0119
0120 void DetectorConstruction::DefineCommands()
0121 {
0122 fPBCMessenger =
0123 std::make_unique<G4GenericMessenger>(this, "/UHDR/Detector/", "Periodic Boundary Condition");
0124 auto& PBC = fPBCMessenger->DeclareProperty("PBC", fPBC);
0125 PBC.SetParameterName("PeriodicBoundaryCondition", true);
0126 PBC.SetDefaultValue("false");
0127 }
0128
0129