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 // 26 // 27 #include "G4DNADamage.hh" 27 #include "G4DNADamage.hh" 28 #include "G4UnitsTable.hh" 28 #include "G4UnitsTable.hh" 29 29 30 G4ThreadLocal G4DNADamage* G4DNADamage::fpInst << 30 G4ThreadLocal G4DNADamage* G4DNADamage::fpInstance(0); 31 31 32 G4DNAIndirectHit::G4DNAIndirectHit(const G4Str 32 G4DNAIndirectHit::G4DNAIndirectHit(const G4String& baseName, 33 const G4Mol 33 const G4Molecule* molecule, 34 const G4Thr 34 const G4ThreeVector& position, 35 G4double ti 35 G4double time) : 36 fpMolecule(molecule) << 36 G4VDNAHit(), fpMolecule(molecule) 37 { 37 { 38 fBaseName = baseName; 38 fBaseName = baseName; 39 fPosition = position; 39 fPosition = position; 40 fTime = time; 40 fTime = time; 41 } 41 } 42 42 43 G4DNAIndirectHit::~G4DNAIndirectHit() 43 G4DNAIndirectHit::~G4DNAIndirectHit() 44 { 44 { 45 delete fpMolecule; << 45 if (fpMolecule) delete fpMolecule; 46 fpMolecule = nullptr; << 46 fpMolecule = 0; 47 } 47 } 48 48 49 void G4DNAIndirectHit::Print() 49 void G4DNAIndirectHit::Print() 50 { 50 { 51 G4cout << "Reaction : " << fpMolecule->GetNa 51 G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName 52 << " at position : " << G4BestUnit(fP 52 << " at position : " << G4BestUnit(fPosition, "Length") 53 << " and time : " << G4BestUnit(fTime 53 << " and time : " << G4BestUnit(fTime, "Time") << G4endl; 54 } 54 } 55 55 56 G4DNADamage* G4DNADamage::Instance() 56 G4DNADamage* G4DNADamage::Instance() 57 { 57 { 58 if (fpInstance == nullptr) new G4DNADamage() << 58 if (!fpInstance) new G4DNADamage(); 59 59 60 return fpInstance; 60 return fpInstance; 61 } 61 } 62 62 63 G4DNADamage::G4DNADamage() 63 G4DNADamage::G4DNADamage() 64 { 64 { 65 fJustCountDamage = false; 65 fJustCountDamage = false; 66 fNIndirectDamage = 0; 66 fNIndirectDamage = 0; 67 fpInstance = this; 67 fpInstance = this; 68 } 68 } 69 69 70 G4DNADamage::~G4DNADamage() 70 G4DNADamage::~G4DNADamage() 71 { 71 { 72 for (auto & fIndirectHit : fIndirectHits) << 72 for (int i = 0; i < (int) fIndirectHits.size(); i++) 73 { 73 { 74 delete fIndirectHit; << 74 if (fIndirectHits[i]) delete fIndirectHits[i]; 75 } 75 } 76 fIndirectHits.clear(); 76 fIndirectHits.clear(); 77 } 77 } 78 78 79 void G4DNADamage::DeleteInstance() 79 void G4DNADamage::DeleteInstance() 80 { 80 { 81 delete fpInstance; << 81 if (fpInstance) delete fpInstance; 82 fpInstance = nullptr; << 82 fpInstance = 0; 83 } 83 } 84 84 85 void G4DNADamage::Reset() 85 void G4DNADamage::Reset() 86 { 86 { 87 fNIndirectDamage = 0; 87 fNIndirectDamage = 0; 88 for (auto & fIndirectHit : fIndirectHits) << 88 for (int i = 0; i < (int) fIndirectHits.size(); i++) 89 { 89 { 90 delete fIndirectHit; << 90 if (fIndirectHits[i]) delete fIndirectHits[i]; 91 } 91 } 92 fIndirectHits.clear(); 92 fIndirectHits.clear(); 93 } 93 } 94 94 95 void G4DNADamage::AddIndirectDamage(const G4St 95 void G4DNADamage::AddIndirectDamage(const G4String& baseName, 96 const G4Mo 96 const G4Molecule* molecule, 97 const G4Th 97 const G4ThreeVector& position, 98 G4double t 98 G4double time) 99 { 99 { 100 if (fJustCountDamage) 100 if (fJustCountDamage) 101 { 101 { 102 fNIndirectDamage++; 102 fNIndirectDamage++; 103 return; 103 return; 104 } 104 } 105 105 106 G4DNAIndirectHit* indirectHit = nullptr; << 106 G4DNAIndirectHit* indirectHit = 0; 107 auto it = fMolMap.find(*molecule); << 107 std::map<G4Molecule, const G4Molecule*>::iterator it = >> 108 fMolMap.find(*molecule); 108 109 109 if (it == fMolMap.cend()) << 110 if (it == fMolMap.end()) 110 { 111 { 111 G4Molecule* mol(nullptr); << 112 G4Molecule* mol(0); 112 fMolMap[*molecule] = (mol = new G4Molecule 113 fMolMap[*molecule] = (mol = new G4Molecule(*molecule)); 113 indirectHit = new G4DNAIndirectHit(baseNam 114 indirectHit = new G4DNAIndirectHit(baseName, mol, position, time); 114 } 115 } 115 else 116 else 116 { 117 { 117 indirectHit = new G4DNAIndirectHit(baseNam 118 indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time); 118 } 119 } 119 fIndirectHits.push_back(indirectHit); 120 fIndirectHits.push_back(indirectHit); 120 } 121 } 121 122