Geant4  10.03
G4DNADamage.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: G4DNADamage.cc 85152 2014-10-24 16:07:37Z matkara $
27 //
28 #include "G4DNADamage.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 G4DNADamage();
60 
61  return fpInstance;
62 }
63 
65 {
66  fJustCountDamage = false;
67  fNIndirectDamage = 0;
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 {
88  fNIndirectDamage = 0;
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 =
109  fMolMap.find(*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 G4ThreadLocal G4DNADamage * fpInstance
Definition: G4DNADamage.hh:115
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector fPosition
Definition: G4DNADamage.hh:75
virtual void AddIndirectDamage(const G4String &baseName, const G4Molecule *molecule, const G4ThreeVector &position, double time)
Definition: G4DNADamage.cc:96
virtual void Reset()
Definition: G4DNADamage.cc:86
std::vector< G4DNAIndirectHit * > fIndirectHits
Definition: G4DNADamage.hh:120
static G4DNADamage * Instance()
Definition: G4DNADamage.cc:57
G4String fBaseName
Definition: G4DNADamage.hh:77
const G4Molecule * fpMolecule
Definition: G4DNADamage.hh:74
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
#define G4ThreadLocal
Definition: tls.hh:89
std::map< G4Molecule, const G4Molecule * > fMolMap
Definition: G4DNADamage.hh:121
const G4String & GetName() const
Returns the name of the molecule.
Definition: G4Molecule.cc:349
G4int fNIndirectDamage
Definition: G4DNADamage.hh:119
#define position
Definition: xmlparse.cc:622
G4GLOB_DLL std::ostream G4cout
G4bool fJustCountDamage
Definition: G4DNADamage.hh:118
virtual ~G4DNADamage()
Definition: G4DNADamage.cc:71
static void DeleteInstance()
Definition: G4DNADamage.cc:80
G4DNAIndirectHit(const G4String &baseName, const G4Molecule *molecule, const G4ThreeVector &position, G4double time)
Definition: G4DNADamage.cc:33
virtual ~G4DNAIndirectHit()
Definition: G4DNADamage.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:94
double G4double
Definition: G4Types.hh:76