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 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // dnadamage2 example is derived from the chem 27 // dnadamage2 example is derived from the chem6 example 28 // chem6 example authors: W. G. Shin and S. In 28 // chem6 example authors: W. G. Shin and S. Incerti (CENBG, France) 29 // 29 // 30 // Any report or published results obtained us 30 // Any report or published results obtained using the Geant4-DNA software 31 // shall cite the following Geant4-DNA collabo 31 // shall cite the following Geant4-DNA collaboration publication: 32 // J. Appl. Phys. 125 (2019) 104301 32 // J. Appl. Phys. 125 (2019) 104301 33 // Med. Phys. 45 (2018) e722-e739 33 // Med. Phys. 45 (2018) e722-e739 34 // J. Comput. Phys. 274 (2014) 841-882 34 // J. Comput. Phys. 274 (2014) 841-882 35 // Med. Phys. 37 (2010) 4692-4708 35 // Med. Phys. 37 (2010) 4692-4708 36 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 36 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157-178 37 // The Geant4-DNA web site is available at htt 37 // The Geant4-DNA web site is available at http://geant4-dna.org 38 // 38 // 39 // Authors: J. Naoki D. Kondo (UCSF, US) 39 // Authors: J. Naoki D. Kondo (UCSF, US) 40 // J. Ramos-Mendez and B. Faddegon (U 40 // J. Ramos-Mendez and B. Faddegon (UCSF, US) 41 // 41 // 42 /// \file DetectorConstruction.cc 42 /// \file DetectorConstruction.cc 43 /// \brief Implementation of the DetectorConst 43 /// \brief Implementation of the DetectorConstruction class 44 44 45 #include "DetectorConstruction.hh" 45 #include "DetectorConstruction.hh" 46 46 47 #include "ScoreLET.hh" << 47 #include "G4NistManager.hh" 48 #include "ScoreSpecies.hh" << 49 #include "ScoreStrandBreaks.hh" << 50 << 51 #include "G4Box.hh" 48 #include "G4Box.hh" 52 #include "G4GeometryManager.hh" << 53 #include "G4LogicalVolume.hh" 49 #include "G4LogicalVolume.hh" 54 #include "G4LogicalVolumeStore.hh" << 55 #include "G4MultiFunctionalDetector.hh" << 56 #include "G4NistManager.hh" << 57 #include "G4PVPlacement.hh" 50 #include "G4PVPlacement.hh" >> 51 >> 52 #include "G4VisAttributes.hh" 58 #include "G4PhysicalConstants.hh" 53 #include "G4PhysicalConstants.hh" >> 54 #include "G4SystemOfUnits.hh" >> 55 #include "G4GeometryManager.hh" 59 #include "G4RunManager.hh" 56 #include "G4RunManager.hh" >> 57 #include "G4LogicalVolumeStore.hh" >> 58 60 #include "G4SDManager.hh" 59 #include "G4SDManager.hh" 61 #include "G4SystemOfUnits.hh" << 60 #include "G4MultiFunctionalDetector.hh" 62 #include "G4VPrimitiveScorer.hh" 61 #include "G4VPrimitiveScorer.hh" 63 #include "G4VisAttributes.hh" << 62 >> 63 #include "ScoreSpecies.hh" >> 64 #include "ScoreLET.hh" >> 65 #include "ScoreStrandBreaks.hh" 64 66 65 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 66 68 67 DetectorConstruction::DetectorConstruction() : << 69 DetectorConstruction::DetectorConstruction() >> 70 : G4VUserDetectorConstruction() 68 { 71 { 69 fDetDir = new G4UIdirectory("/det/"); 72 fDetDir = new G4UIdirectory("/det/"); 70 fDetDir->SetGuidance("Detector control."); 73 fDetDir->SetGuidance("Detector control."); 71 74 72 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/d << 75 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/det/setSize",this); 73 fSizeCmd->SetDefaultUnit("um"); 76 fSizeCmd->SetDefaultUnit("um"); 74 77 75 fpOffSetFileUI = new G4UIcmdWithAString("/de 78 fpOffSetFileUI = new G4UIcmdWithAString("/det/OffSetFile", this); 76 fpPlasmidNbUI = new G4UIcmdWithAnInteger("/d << 79 fpPlasmidNbUI = new G4UIcmdWithAnInteger("/det/NbOfPlasmids", this); 77 80 78 fpPlasmidFile = new G4UIcmdWithAString("/det 81 fpPlasmidFile = new G4UIcmdWithAString("/det/PlasmidFile", this); 79 fpUseDNA = new G4UIcmdWithABool("/det/UseDNA << 82 fpUseDNA = new G4UIcmdWithABool("/det/UseDNAVolumes", this); 80 } 83 } 81 84 82 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 83 86 84 DetectorConstruction::~DetectorConstruction() 87 DetectorConstruction::~DetectorConstruction() 85 { 88 { 86 delete fSizeCmd; 89 delete fSizeCmd; 87 delete fpOffSetFileUI; 90 delete fpOffSetFileUI; 88 delete fpPlasmidFile; 91 delete fpPlasmidFile; 89 delete fpUseDNA; 92 delete fpUseDNA; 90 } 93 } 91 94 92 //....oooOO0OOooo........oooOO0OOooo........oo 95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 93 96 94 void DetectorConstruction::SetNewValue(G4UIcom 97 void DetectorConstruction::SetNewValue(G4UIcommand* command, G4String newValue) 95 { 98 { 96 if (command == fSizeCmd) { << 99 if(command == fSizeCmd) >> 100 { 97 G4double size = fSizeCmd->GetNewDoubleValu 101 G4double size = fSizeCmd->GetNewDoubleValue(newValue); 98 SetSize(size); 102 SetSize(size); 99 } 103 } 100 104 101 if (command == fpPlasmidNbUI) { << 105 if (command == fpPlasmidNbUI) >> 106 { 102 fNbOfPlasmids = fpPlasmidNbUI->GetNewIntVa 107 fNbOfPlasmids = fpPlasmidNbUI->GetNewIntValue(newValue); 103 } 108 } 104 109 105 if (command == fpOffSetFileUI) { << 110 if (command == fpOffSetFileUI) >> 111 { 106 G4String File = newValue; 112 G4String File = newValue; 107 ReadOffsetFile(File); 113 ReadOffsetFile(File); 108 } 114 } 109 115 110 if (command == fpPlasmidFile) { << 116 if (command == fpPlasmidFile) >> 117 { 111 fPlasmidFile = newValue; 118 fPlasmidFile = newValue; 112 } 119 } 113 120 114 if (command == fpUseDNA) { << 121 if (command == fpUseDNA) >> 122 { 115 fUseDNAVolumes = fpUseDNA->GetNewBoolValue 123 fUseDNAVolumes = fpUseDNA->GetNewBoolValue(newValue); 116 } 124 } 117 } 125 } 118 126 119 //....oooOO0OOooo........oooOO0OOooo........oo 127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 120 128 121 void DetectorConstruction::SetSize(G4double si 129 void DetectorConstruction::SetSize(G4double size) 122 { 130 { >> 131 123 G4GeometryManager::GetInstance()->OpenGeomet 132 G4GeometryManager::GetInstance()->OpenGeometry(); 124 fPlasmidEnvelope->SetRadius(size / 2); << 133 fPlasmidEnvelope->SetRadius(size/2); 125 G4RunManager::GetRunManager()->GeometryHasBe 134 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 126 G4cout << "#### the geometry has been modifi 135 G4cout << "#### the geometry has been modified " << G4endl; 127 } 136 } 128 137 129 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 130 139 131 G4VPhysicalVolume* DetectorConstruction::Const 140 G4VPhysicalVolume* DetectorConstruction::Construct() 132 { 141 { 133 // Clear DNA information Containers 142 // Clear DNA information Containers 134 fSampleDNANames.clear(); 143 fSampleDNANames.clear(); 135 fSampleDNAPositions.clear(); 144 fSampleDNAPositions.clear(); 136 fSampleDNADetails.clear(); 145 fSampleDNADetails.clear(); 137 fDNANames.clear(); 146 fDNANames.clear(); 138 fDNAPositions.clear(); 147 fDNAPositions.clear(); 139 fDNADetails.clear(); 148 fDNADetails.clear(); 140 149 141 // Water is defined from NIST material datab 150 // Water is defined from NIST material database 142 G4NistManager* man = G4NistManager::Instance << 151 G4NistManager * man = G4NistManager::Instance(); 143 G4Material* normalWater = man->FindOrBuildMa << 152 G4Material* normalWater = man->FindOrBuildMaterial("G4_WATER"); 144 G4Material* waterWorld = << 153 G4Material* waterWorld = man->BuildMaterialWithNewDensity("G4_WATER_WORLD", 145 man->BuildMaterialWithNewDensity("G4_WATER << 154 "G4_WATER", >> 155 1.0*g/cm/cm/cm); 146 156 147 // 157 // 148 // World 158 // World 149 G4Box* solidWenvelope = new G4Box("SWorld", << 159 G4Box* solidWenvelope = new G4Box("SWorld", 1 * um, 1 * um, 1 * um); 150 G4LogicalVolume* logicWorld = new G4LogicalV << 160 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWenvelope, 151 G4VPhysicalVolume* physWorld = << 161 waterWorld, 152 new G4PVPlacement(0, G4ThreeVector(), "PWo << 162 "LWorld"); >> 163 G4VPhysicalVolume* physWorld = new G4PVPlacement(0, >> 164 G4ThreeVector(), >> 165 "PWorld", >> 166 logicWorld, >> 167 0, >> 168 false, >> 169 0); 153 170 154 // Molecule 171 // Molecule 155 fPlasmidEnvelope = new G4Orb("plasmidEnvelop << 172 fPlasmidEnvelope = new G4Orb("plasmidEnvelope", 0.5*fWorldSize); 156 173 157 G4LogicalVolume* tlogicPlasmid = << 174 G4LogicalVolume* tlogicPlasmid = new G4LogicalVolume(fPlasmidEnvelope, 158 new G4LogicalVolume(fPlasmidEnvelope, norm << 175 normalWater, 159 new G4PVPlacement(0, G4ThreeVector(), tlogic << 176 "PlasmidVolume"); >> 177 new G4PVPlacement(0, >> 178 G4ThreeVector(), >> 179 tlogicPlasmid, >> 180 "plasmid", >> 181 logicWorld, >> 182 false, >> 183 0); 160 184 161 // World Vis Attributes 185 // World Vis Attributes 162 G4VisAttributes worldVis(G4Colour(0.0, 0.0, << 186 G4VisAttributes worldVis(G4Colour(0.0, 0.0, 1.0) ); 163 logicWorld->SetVisAttributes(worldVis); 187 logicWorld->SetVisAttributes(worldVis); 164 188 165 PhysGeoImport GeoImport = PhysGeoImport(); 189 PhysGeoImport GeoImport = PhysGeoImport(); 166 190 167 G4LogicalVolume* logicStraightVoxel; 191 G4LogicalVolume* logicStraightVoxel; 168 192 169 logicStraightVoxel = GeoImport.CreateLogicVo 193 logicStraightVoxel = GeoImport.CreateLogicVolumeXYZ(fPlasmidFile); 170 194 171 fSampleDNANames = GeoImport.GetMoleculesName << 195 fSampleDNANames = GeoImport.GetMoleculesNames(); 172 fSampleDNAPositions = GeoImport.GetMolecules 196 fSampleDNAPositions = GeoImport.GetMoleculesPositions(); 173 fSampleDNADetails = GeoImport.GetMoleculesDe << 197 fSampleDNADetails = GeoImport.GetMoleculesDetails(); 174 198 175 for (int i = 0; i < fNbOfPlasmids; i++) { << 199 for ( int i = 0; i < fNbOfPlasmids; i++ ) { 176 if (fUseDNAVolumes) 200 if (fUseDNAVolumes) 177 new G4PVPlacement(0, fVOffset[i], logicS << 201 new G4PVPlacement(0, 178 AddDNAInformation(i, fVOffset[i]); << 202 fVOffset[i], >> 203 logicStraightVoxel, >> 204 "VoxelStraight", >> 205 logicWorld, >> 206 true, >> 207 i); >> 208 AddDNAInformation(i,fVOffset[i]); 179 } 209 } 180 210 181 // always return the physical World << 211 //always return the physical World 182 return physWorld; 212 return physWorld; 183 } 213 } 184 214 185 //....oooOO0OOooo........oooOO0OOooo........oo 215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 186 216 187 void DetectorConstruction::ConstructSDandField 217 void DetectorConstruction::ConstructSDandField() 188 { 218 { 189 G4SDManager::GetSDMpointer()->SetVerboseLeve 219 G4SDManager::GetSDMpointer()->SetVerboseLevel(1); 190 220 191 // declare World as a MultiFunctionalDetecto 221 // declare World as a MultiFunctionalDetector scorer 192 // 222 // 193 G4MultiFunctionalDetector* mfDetector = new << 223 G4MultiFunctionalDetector* mfDetector = >> 224 new G4MultiFunctionalDetector("mfDetector"); 194 225 195 // LET scorer: 226 // LET scorer: 196 // - scores restricted or unrestricted LET 227 // - scores restricted or unrestricted LET 197 228 198 ScoreLET* LET = new ScoreLET("LET"); 229 ScoreLET* LET = new ScoreLET("LET"); 199 mfDetector->RegisterPrimitive(LET); 230 mfDetector->RegisterPrimitive(LET); 200 231 201 // Species scorer: 232 // Species scorer: 202 // - scores number of species over time 233 // - scores number of species over time 203 // - compute the radiochemical yields (G va 234 // - compute the radiochemical yields (G values) 204 235 205 G4VPrimitiveScorer* primitivSpecies = new Sc 236 G4VPrimitiveScorer* primitivSpecies = new ScoreSpecies("Species"); 206 mfDetector->RegisterPrimitive(primitivSpecie 237 mfDetector->RegisterPrimitive(primitivSpecies); 207 238 208 // SB Scorer: Requires access to Geometry 239 // SB Scorer: Requires access to Geometry 209 // - scores number of Direct SB 240 // - scores number of Direct SB 210 // - scores number of Indirect SB 241 // - scores number of Indirect SB 211 242 212 G4VPrimitiveScorer* primitiveSB = new ScoreS << 243 G4VPrimitiveScorer* primitiveSB = new ScoreStrandBreaks("StrandBreaks", >> 244 this,&fWorldSize); 213 mfDetector->RegisterPrimitive(primitiveSB); 245 mfDetector->RegisterPrimitive(primitiveSB); 214 246 215 // Attach Detectors to Plasmid Volumes 247 // Attach Detectors to Plasmid Volumes 216 G4LogicalVolumeStore* theLogicalVolumes = G4 248 G4LogicalVolumeStore* theLogicalVolumes = G4LogicalVolumeStore::GetInstance(); 217 for (size_t t = 0; t < theLogicalVolumes->si << 249 for ( size_t t = 0; t < theLogicalVolumes->size(); t++ ) { 218 G4String lVolumeName = (*theLogicalVolumes 250 G4String lVolumeName = (*theLogicalVolumes)[t]->GetName(); 219 if (lVolumeName != "LWorld") { 251 if (lVolumeName != "LWorld") { 220 (*theLogicalVolumes)[t]->SetSensitiveDet 252 (*theLogicalVolumes)[t]->SetSensitiveDetector(mfDetector); 221 } 253 } 222 } 254 } 223 G4SDManager::GetSDMpointer()->AddNewDetector 255 G4SDManager::GetSDMpointer()->AddNewDetector(mfDetector); >> 256 224 } 257 } 225 258 226 //....oooOO0OOooo........oooOO0OOooo........oo 259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 227 260 228 void DetectorConstruction::ReadOffsetFile(G4St << 261 void DetectorConstruction::ReadOffsetFile(G4String file) { 229 { << 262 if (fVOffset.size() > 0) 230 if (fVOffset.size() > 0) fVOffset.clear(); << 263 fVOffset.clear(); 231 264 232 std::ifstream OffSetFile; 265 std::ifstream OffSetFile; 233 OffSetFile.open(file); 266 OffSetFile.open(file); 234 G4double x, y, z; 267 G4double x, y, z; 235 268 236 if (!OffSetFile) { 269 if (!OffSetFile) { 237 G4cout << "Plasmid Offset positions file n 270 G4cout << "Plasmid Offset positions file not found!!!" << G4endl; 238 exit(1); 271 exit(1); 239 } 272 } 240 273 241 else { 274 else { 242 while (OffSetFile >> x >> y >> z) { 275 while (OffSetFile >> x >> y >> z) { 243 fVOffset.push_back(G4ThreeVector(x * nm, << 276 fVOffset.push_back(G4ThreeVector(x*nm,y*nm,z*nm)); 244 } 277 } 245 } << 278 } 246 } 279 } 247 280 248 //....oooOO0OOooo........oooOO0OOooo........oo 281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 249 282 250 void DetectorConstruction::AddDNAInformation(G << 283 void DetectorConstruction::AddDNAInformation(G4int copy, G4ThreeVector offset) { 251 { << 284 for(size_t i = 0; i < fSampleDNANames.size(); i++) { 252 for (size_t i = 0; i < fSampleDNANames.size( << 253 fDNANames.push_back(fSampleDNANames[i]); 285 fDNANames.push_back(fSampleDNANames[i]); 254 fDNAPositions.push_back(fSampleDNAPosition 286 fDNAPositions.push_back(fSampleDNAPositions[i] + offset); 255 287 256 std::vector<G4int> Details = fSampleDNADet 288 std::vector<G4int> Details = fSampleDNADetails[i]; 257 Details[0] = copy; 289 Details[0] = copy; 258 fDNADetails.push_back(Details); 290 fDNADetails.push_back(Details); 259 } 291 } 260 } 292 } 261 293 262 //....oooOO0OOooo........oooOO0OOooo........oo 294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 263 295