Geant4  10.01.p02
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 85244 2014-10-27 08:24:13Z gcosmo $
27 //
28 #include "G4DNADamages.hh"
29 #include "G4UnitsTable.hh"
30 
32 
34  const G4Molecule* molecule,
35  const G4ThreeVector& position,
36  G4double time) :
37  G4VDNAHit(), fpMolecule(molecule)
38 {
39  fBaseName = baseName;
41  fTime = time;
42 }
43 
45 {
46  if (fpMolecule) delete fpMolecule;
47  fpMolecule = 0;
48 }
49 
51 {
52  G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
53  << " at position : " << G4BestUnit(fPosition, "Length")
54  << " and time : " << G4BestUnit(fTime, "Time") << G4endl;
55 }
56 
58 {
59  if (!fpInstance) new G4DNADamages();
60 
61  return fpInstance;
62 }
63 
65 {
66  fJustCountDamage = false;
68  fpInstance = this;
69 }
70 
72 {
73  for (int i = 0; i < (int) fIndirectHits.size(); i++)
74  {
75  if (fIndirectHits[i]) delete fIndirectHits[i];
76  }
77  fIndirectHits.clear();
78 }
79 
81 {
82  if (fpInstance) delete fpInstance;
83  fpInstance = 0;
84 }
85 
87 {
89  for (int i = 0; i < (int) fIndirectHits.size(); i++)
90  {
91  if (fIndirectHits[i]) delete fIndirectHits[i];
92  }
93  fIndirectHits.clear();
94 }
95 
97  const G4Molecule* molecule,
98  const G4ThreeVector& position,
99  G4double time)
100 {
101  if (fJustCountDamage)
102  {
104  return;
105  }
106 
107  G4DNAIndirectHit* indirectHit = 0;
108  std::map<G4Molecule, const G4Molecule*>::iterator it = fMolMap.find(
109  *molecule);
110 
111  if (it == fMolMap.end())
112  {
113  G4Molecule* mol(0);
114  fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
115  indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
116  }
117  else
118  {
119  indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
120  }
121  fIndirectHits.push_back(indirectHit);
122 }
static G4DNADamages * Instance()
Definition: G4DNADamages.cc:57
virtual ~G4DNADamages()
Definition: G4DNADamages.cc:71
CLHEP::Hep3Vector G4ThreeVector
std::map< G4Molecule, const G4Molecule * > fMolMap
G4ThreeVector fPosition
Definition: G4DNADamages.hh:75
virtual void Reset()
Definition: G4DNADamages.cc:86
std::vector< G4DNAIndirectHit * > fIndirectHits
G4String fBaseName
Definition: G4DNADamages.hh:77
const G4Molecule * fpMolecule
Definition: G4DNADamages.hh:74
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
#define G4ThreadLocal
Definition: tls.hh:89
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:303
#define position
Definition: xmlparse.cc:605
G4GLOB_DLL std::ostream G4cout
static G4ThreadLocal G4DNADamages * fpInstance
G4DNAIndirectHit(const G4String &baseName, const G4Molecule *molecule, const G4ThreeVector &position, G4double time)
Definition: G4DNADamages.cc:33
G4bool fJustCountDamage
static void DeleteInstance()
Definition: G4DNADamages.cc:80
G4int fNIndirectDamages
virtual ~G4DNAIndirectHit()
Definition: G4DNADamages.cc:44
#define G4endl
Definition: G4ios.hh:61
Class Description The dynamic molecule holds all the data that change for a molecule It has a pointer...
Definition: G4Molecule.hh:93
double G4double
Definition: G4Types.hh:76
virtual void AddIndirectDamage(const G4String &baseName, const G4Molecule *molecule, const G4ThreeVector &position, double time)
Definition: G4DNADamages.cc:96