Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 25 26 #include "DetectorConstruction.hh" 26 #include "DetectorConstruction.hh" 27 << 28 #include "ChemistryWorld.hh" 27 #include "ChemistryWorld.hh" 29 #include "PeriodicBoundaryBuilder.hh" << 30 #include "Scorer.hh" << 31 << 32 #include "G4Box.hh" 28 #include "G4Box.hh" 33 #include "G4Electron_aq.hh" 29 #include "G4Electron_aq.hh" 34 #include "G4LogicalVolume.hh" 30 #include "G4LogicalVolume.hh" 35 #include "G4MultiFunctionalDetector.hh" 31 #include "G4MultiFunctionalDetector.hh" 36 #include "G4NistManager.hh" 32 #include "G4NistManager.hh" 37 #include "G4PVPlacement.hh" 33 #include "G4PVPlacement.hh" 38 #include "G4SDManager.hh" 34 #include "G4SDManager.hh" 39 #include "G4UnitsTable.hh" 35 #include "G4UnitsTable.hh" >> 36 #include "G4VChemistryWorld.hh" 40 #include "G4VPrimitiveScorer.hh" 37 #include "G4VPrimitiveScorer.hh" 41 #include "G4VisAttributes.hh" 38 #include "G4VisAttributes.hh" >> 39 #include "Scorer.hh" 42 40 43 //....oooOO0OOooo........oooOO0OOooo........oo << 41 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction() { 44 << 45 DetectorConstruction::DetectorConstruction() : << 46 { << 47 fpChemistryWorld = std::make_unique<Chemistr 42 fpChemistryWorld = std::make_unique<ChemistryWorld>(); 48 fpChemistryWorld->ConstructChemistryBoundary 43 fpChemistryWorld->ConstructChemistryBoundary(); 49 DefineCommands(); << 50 } 44 } 51 45 52 //....oooOO0OOooo........oooOO0OOooo........oo << 46 G4VPhysicalVolume *DetectorConstruction::Construct() { 53 << 54 G4VPhysicalVolume* DetectorConstruction::Const << 55 { << 56 auto water = G4NistManager::Instance()->Find 47 auto water = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER"); 57 auto boudingBox = fpChemistryWorld->GetChemi 48 auto boudingBox = fpChemistryWorld->GetChemistryBoundary(); 58 G4double world_sizeXYZ = 2 * boudingBox->hal 49 G4double world_sizeXYZ = 2 * boudingBox->halfSideLengthInY(); 59 50 60 G4cout << "Volume size : " << G4BestUnit(wor << 51 G4cout << "DetectorConstruction::world_sizeXYZ : " 61 << 52 << G4BestUnit(world_sizeXYZ, "Length") << G4endl; 62 G4double buffer; << 63 if (fPBC) { << 64 G4cout << "PeriodicBoundaryCondition is ap << 65 buffer = 0.01 * nanometer; << 66 } << 67 else { << 68 buffer = 0; << 69 G4cout << "PeriodicBoundaryCondition is no << 70 } << 71 53 72 auto solidWorld = new G4Box("World", 0.5 * ( << 54 auto solidWorld = new G4Box("World", 0.5 * world_sizeXYZ, 0.5 * world_sizeXYZ, 73 0.5 * (world_siz << 55 0.5 * world_sizeXYZ); 74 56 75 auto logicWorld = new G4LogicalVolume(solidW 57 auto logicWorld = new G4LogicalVolume(solidWorld, water, "World"); 76 58 77 if (fPBC) { << 59 G4VPhysicalVolume *physWorld = 78 auto pbb = std::make_unique<PeriodicBounda << 60 new G4PVPlacement(nullptr, // no rotation 79 fpPBCLogicVolume = pbb->Construct(logicWor << 61 G4ThreeVector(), // its position at (0,0,0) 80 } << 62 logicWorld, // its logical volume 81 << 63 "World", // its name 82 fpPhysWorld = new G4PVPlacement(nullptr, // << 64 nullptr, // its mother volume 83 G4ThreeVecto << 65 false, // no boolean operation 84 logicWorld, << 66 0, // copy number 85 "World", // << 67 true); // checking overlaps 86 nullptr, // << 87 false, // n << 88 0, // copy << 89 true); // c << 90 68 91 return fpPhysWorld; << 69 return physWorld; 92 } 70 } 93 71 94 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 95 73 96 void DetectorConstruction::ConstructSDandField << 74 void DetectorConstruction::ConstructSDandField() { 97 { << 98 G4SDManager::GetSDMpointer()->SetVerboseLeve 75 G4SDManager::GetSDMpointer()->SetVerboseLevel(1); 99 auto mfDetector = new G4MultiFunctionalDetec 76 auto mfDetector = new G4MultiFunctionalDetector("mfDetector"); 100 // the order of G4VPrimitiveScorer to define << 77 //the order of G4VPrimitiveScorer to define ID number 101 G4VPrimitiveScorer* pDose = new Scorer<Dose> << 78 G4VPrimitiveScorer *pDose = new Scorer<Dose>(); 102 dynamic_cast<Scorer<Dose>*>(pDose)->SetChemi << 79 dynamic_cast<Scorer<Dose> *>(pDose)->SetChemistryWorld( >> 80 fpChemistryWorld.get()); 103 mfDetector->RegisterPrimitive(pDose); 81 mfDetector->RegisterPrimitive(pDose); 104 G4VPrimitiveScorer* gValues = new Scorer<Gva << 82 G4VPrimitiveScorer *gValues = new Scorer<Gvalues>(); 105 dynamic_cast<Scorer<Gvalues>*>(gValues)->Set << 83 dynamic_cast<Scorer<Gvalues> *>(gValues)->SetChemistryWorld( >> 84 fpChemistryWorld.get()); 106 mfDetector->RegisterPrimitive(gValues); 85 mfDetector->RegisterPrimitive(gValues); 107 G4SDManager::GetSDMpointer()->AddNewDetector 86 G4SDManager::GetSDMpointer()->AddNewDetector(mfDetector); 108 G4String SDName; << 87 SetSensitiveDetector("World", mfDetector); 109 if (fPBC) { << 110 SDName = fpPBCLogicVolume->GetName(); << 111 } << 112 else { << 113 SDName = fpPhysWorld->GetName(); << 114 } << 115 SetSensitiveDetector(SDName, mfDetector); << 116 } << 117 << 118 //....oooOO0OOooo........oooOO0OOooo........oo << 119 << 120 void DetectorConstruction::DefineCommands() << 121 { << 122 fPBCMessenger = << 123 std::make_unique<G4GenericMessenger>(this, << 124 auto& PBC = fPBCMessenger->DeclareProperty(" << 125 PBC.SetParameterName("PeriodicBoundaryCondit << 126 PBC.SetDefaultValue("false"); << 127 } 88 } 128 89 129 //....oooOO0OOooo........oooOO0OOooo........oo 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 130 91