ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4DNADamage.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4DNADamage.cc
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 //
27 #include "G4DNADamage.hh"
28 #include "G4UnitsTable.hh"
29 
31 
33  const G4Molecule* molecule,
34  const G4ThreeVector& position,
35  G4double time) :
36  G4VDNAHit(), fpMolecule(molecule)
37 {
38  fBaseName = baseName;
40  fTime = time;
41 }
42 
44 {
45  if (fpMolecule) delete fpMolecule;
46  fpMolecule = 0;
47 }
48 
50 {
51  G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
52  << " at position : " << G4BestUnit(fPosition, "Length")
53  << " and time : " << G4BestUnit(fTime, "Time") << G4endl;
54 }
55 
57 {
58  if (!fpInstance) new G4DNADamage();
59 
60  return fpInstance;
61 }
62 
64 {
65  fJustCountDamage = false;
66  fNIndirectDamage = 0;
67  fpInstance = this;
68 }
69 
71 {
72  for (int i = 0; i < (int) fIndirectHits.size(); i++)
73  {
74  if (fIndirectHits[i]) delete fIndirectHits[i];
75  }
76  fIndirectHits.clear();
77 }
78 
80 {
81  if (fpInstance) delete fpInstance;
82  fpInstance = 0;
83 }
84 
86 {
87  fNIndirectDamage = 0;
88  for (int i = 0; i < (int) fIndirectHits.size(); i++)
89  {
90  if (fIndirectHits[i]) delete fIndirectHits[i];
91  }
92  fIndirectHits.clear();
93 }
94 
96  const G4Molecule* molecule,
97  const G4ThreeVector& position,
98  G4double time)
99 {
100  if (fJustCountDamage)
101  {
103  return;
104  }
105 
106  G4DNAIndirectHit* indirectHit = 0;
107  std::map<G4Molecule, const G4Molecule*>::iterator it =
108  fMolMap.find(*molecule);
109 
110  if (it == fMolMap.end())
111  {
112  G4Molecule* mol(0);
113  fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
114  indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
115  }
116  else
117  {
118  indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
119  }
120  fIndirectHits.push_back(indirectHit);
121 }