Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DNADamages.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4DNADamages.cc 65022 2012-11-12 16:43:12Z gcosmo $
27 //
28 #include "G4DNADamages.hh"
29 #include "G4UnitsTable.hh"
30 
32 
34  const G4Molecule* molecule,
35  const G4ThreeVector& position,
36  G4double time) : G4VDNAHit(),
37  fpMolecule(molecule)
38 {
39  fBaseName = baseName;
41  fTime = time;
42 }
43 
44 
46 {
47  if(fpMolecule) delete fpMolecule;
48  fpMolecule = 0;
49 }
50 
52 {
53  G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
54  << " at position : " << G4BestUnit(fPosition,"Length")
55  << " and time : " << G4BestUnit(fTime,"Time") << G4endl;
56 }
57 
58 
60 {
61  if(!fpInstance) new G4DNADamages();
62 
63  return fpInstance;
64 }
65 
67 {
68  fJustCountDamage = false;
70  fpInstance = this;
71 }
72 
74 {
75  for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
76  {
77  if(fIndirectHits[i])
78  delete fIndirectHits[i];
79  }
80  fIndirectHits.clear();
81 }
82 
84 {
85  if(fpInstance) delete fpInstance;
86  fpInstance = 0;
87 }
88 
90 {
92  for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
93  {
94  if(fIndirectHits[i])
95  delete fIndirectHits[i];
96  }
97  fIndirectHits.clear();
98 }
99 
101  const G4Molecule* molecule,
102  const G4ThreeVector& position,
103  G4double time)
104 {
105  if(fJustCountDamage)
106  {
108  return;
109  }
110 
111  G4DNAIndirectHit* indirectHit = 0;
112  std::map<G4Molecule, const G4Molecule*>::iterator it = fMolMap.find(*molecule);
113 
114  if(it == fMolMap.end())
115  {
116  G4Molecule* mol(0);
117  fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
118  indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
119  }
120  else
121  {
122  indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
123  }
124  fIndirectHits.push_back(indirectHit);
125 }