Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // This example is provided by the Geant4-DNA 27 // dnadamage2 example is derived from the chem 28 // chem6 example authors: W. G. Shin and S. In 29 // 30 // Any report or published results obtained us 31 // shall cite the following Geant4-DNA collabo 32 // J. Appl. Phys. 125 (2019) 104301 33 // Med. Phys. 45 (2018) e722-e739 34 // J. Comput. Phys. 274 (2014) 841-882 35 // Med. Phys. 37 (2010) 4692-4708 36 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 37 // The Geant4-DNA web site is available at htt 38 // 39 // Authors: J. Naoki D. Kondo (UCSF, US) 40 // J. Ramos-Mendez and B. Faddegon (U 41 // 42 /// \file DetectorConstruction.cc 43 /// \brief Implementation of the DetectorConst 44 45 #include "DetectorConstruction.hh" 46 47 #include "ScoreLET.hh" 48 #include "ScoreSpecies.hh" 49 #include "ScoreStrandBreaks.hh" 50 51 #include "G4Box.hh" 52 #include "G4GeometryManager.hh" 53 #include "G4LogicalVolume.hh" 54 #include "G4LogicalVolumeStore.hh" 55 #include "G4MultiFunctionalDetector.hh" 56 #include "G4NistManager.hh" 57 #include "G4PVPlacement.hh" 58 #include "G4PhysicalConstants.hh" 59 #include "G4RunManager.hh" 60 #include "G4SDManager.hh" 61 #include "G4SystemOfUnits.hh" 62 #include "G4VPrimitiveScorer.hh" 63 #include "G4VisAttributes.hh" 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 66 67 DetectorConstruction::DetectorConstruction() : 68 { 69 fDetDir = new G4UIdirectory("/det/"); 70 fDetDir->SetGuidance("Detector control."); 71 72 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/d 73 fSizeCmd->SetDefaultUnit("um"); 74 75 fpOffSetFileUI = new G4UIcmdWithAString("/de 76 fpPlasmidNbUI = new G4UIcmdWithAnInteger("/d 77 78 fpPlasmidFile = new G4UIcmdWithAString("/det 79 fpUseDNA = new G4UIcmdWithABool("/det/UseDNA 80 } 81 82 //....oooOO0OOooo........oooOO0OOooo........oo 83 84 DetectorConstruction::~DetectorConstruction() 85 { 86 delete fSizeCmd; 87 delete fpOffSetFileUI; 88 delete fpPlasmidFile; 89 delete fpUseDNA; 90 } 91 92 //....oooOO0OOooo........oooOO0OOooo........oo 93 94 void DetectorConstruction::SetNewValue(G4UIcom 95 { 96 if (command == fSizeCmd) { 97 G4double size = fSizeCmd->GetNewDoubleValu 98 SetSize(size); 99 } 100 101 if (command == fpPlasmidNbUI) { 102 fNbOfPlasmids = fpPlasmidNbUI->GetNewIntVa 103 } 104 105 if (command == fpOffSetFileUI) { 106 G4String File = newValue; 107 ReadOffsetFile(File); 108 } 109 110 if (command == fpPlasmidFile) { 111 fPlasmidFile = newValue; 112 } 113 114 if (command == fpUseDNA) { 115 fUseDNAVolumes = fpUseDNA->GetNewBoolValue 116 } 117 } 118 119 //....oooOO0OOooo........oooOO0OOooo........oo 120 121 void DetectorConstruction::SetSize(G4double si 122 { 123 G4GeometryManager::GetInstance()->OpenGeomet 124 fPlasmidEnvelope->SetRadius(size / 2); 125 G4RunManager::GetRunManager()->GeometryHasBe 126 G4cout << "#### the geometry has been modifi 127 } 128 129 //....oooOO0OOooo........oooOO0OOooo........oo 130 131 G4VPhysicalVolume* DetectorConstruction::Const 132 { 133 // Clear DNA information Containers 134 fSampleDNANames.clear(); 135 fSampleDNAPositions.clear(); 136 fSampleDNADetails.clear(); 137 fDNANames.clear(); 138 fDNAPositions.clear(); 139 fDNADetails.clear(); 140 141 // Water is defined from NIST material datab 142 G4NistManager* man = G4NistManager::Instance 143 G4Material* normalWater = man->FindOrBuildMa 144 G4Material* waterWorld = 145 man->BuildMaterialWithNewDensity("G4_WATER 146 147 // 148 // World 149 G4Box* solidWenvelope = new G4Box("SWorld", 150 G4LogicalVolume* logicWorld = new G4LogicalV 151 G4VPhysicalVolume* physWorld = 152 new G4PVPlacement(0, G4ThreeVector(), "PWo 153 154 // Molecule 155 fPlasmidEnvelope = new G4Orb("plasmidEnvelop 156 157 G4LogicalVolume* tlogicPlasmid = 158 new G4LogicalVolume(fPlasmidEnvelope, norm 159 new G4PVPlacement(0, G4ThreeVector(), tlogic 160 161 // World Vis Attributes 162 G4VisAttributes worldVis(G4Colour(0.0, 0.0, 163 logicWorld->SetVisAttributes(worldVis); 164 165 PhysGeoImport GeoImport = PhysGeoImport(); 166 167 G4LogicalVolume* logicStraightVoxel; 168 169 logicStraightVoxel = GeoImport.CreateLogicVo 170 171 fSampleDNANames = GeoImport.GetMoleculesName 172 fSampleDNAPositions = GeoImport.GetMolecules 173 fSampleDNADetails = GeoImport.GetMoleculesDe 174 175 for (int i = 0; i < fNbOfPlasmids; i++) { 176 if (fUseDNAVolumes) 177 new G4PVPlacement(0, fVOffset[i], logicS 178 AddDNAInformation(i, fVOffset[i]); 179 } 180 181 // always return the physical World 182 return physWorld; 183 } 184 185 //....oooOO0OOooo........oooOO0OOooo........oo 186 187 void DetectorConstruction::ConstructSDandField 188 { 189 G4SDManager::GetSDMpointer()->SetVerboseLeve 190 191 // declare World as a MultiFunctionalDetecto 192 // 193 G4MultiFunctionalDetector* mfDetector = new 194 195 // LET scorer: 196 // - scores restricted or unrestricted LET 197 198 ScoreLET* LET = new ScoreLET("LET"); 199 mfDetector->RegisterPrimitive(LET); 200 201 // Species scorer: 202 // - scores number of species over time 203 // - compute the radiochemical yields (G va 204 205 G4VPrimitiveScorer* primitivSpecies = new Sc 206 mfDetector->RegisterPrimitive(primitivSpecie 207 208 // SB Scorer: Requires access to Geometry 209 // - scores number of Direct SB 210 // - scores number of Indirect SB 211 212 G4VPrimitiveScorer* primitiveSB = new ScoreS 213 mfDetector->RegisterPrimitive(primitiveSB); 214 215 // Attach Detectors to Plasmid Volumes 216 G4LogicalVolumeStore* theLogicalVolumes = G4 217 for (size_t t = 0; t < theLogicalVolumes->si 218 G4String lVolumeName = (*theLogicalVolumes 219 if (lVolumeName != "LWorld") { 220 (*theLogicalVolumes)[t]->SetSensitiveDet 221 } 222 } 223 G4SDManager::GetSDMpointer()->AddNewDetector 224 } 225 226 //....oooOO0OOooo........oooOO0OOooo........oo 227 228 void DetectorConstruction::ReadOffsetFile(G4St 229 { 230 if (fVOffset.size() > 0) fVOffset.clear(); 231 232 std::ifstream OffSetFile; 233 OffSetFile.open(file); 234 G4double x, y, z; 235 236 if (!OffSetFile) { 237 G4cout << "Plasmid Offset positions file n 238 exit(1); 239 } 240 241 else { 242 while (OffSetFile >> x >> y >> z) { 243 fVOffset.push_back(G4ThreeVector(x * nm, 244 } 245 } 246 } 247 248 //....oooOO0OOooo........oooOO0OOooo........oo 249 250 void DetectorConstruction::AddDNAInformation(G 251 { 252 for (size_t i = 0; i < fSampleDNANames.size( 253 fDNANames.push_back(fSampleDNANames[i]); 254 fDNAPositions.push_back(fSampleDNAPosition 255 256 std::vector<G4int> Details = fSampleDNADet 257 Details[0] = copy; 258 fDNADetails.push_back(Details); 259 } 260 } 261 262 //....oooOO0OOooo........oooOO0OOooo........oo 263