00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "G4DNADamages.hh"
00029 #include "G4UnitsTable.hh"
00030
00031 G4DNADamages* G4DNADamages::fpInstance(0);
00032
00033 G4DNAIndirectHit::G4DNAIndirectHit(const G4String& baseName,
00034 const G4Molecule* molecule,
00035 const G4ThreeVector& position,
00036 G4double time) : G4VDNAHit(),
00037 fpMolecule(molecule)
00038 {
00039 fBaseName = baseName;
00040 fPosition = position;
00041 fTime = time;
00042 }
00043
00044
00045 G4DNAIndirectHit::~G4DNAIndirectHit()
00046 {
00047 if(fpMolecule) delete fpMolecule;
00048 fpMolecule = 0;
00049 }
00050
00051 void G4DNAIndirectHit::Print()
00052 {
00053 G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
00054 << " at position : " << G4BestUnit(fPosition,"Length")
00055 << " and time : " << G4BestUnit(fTime,"Time") << G4endl;
00056 }
00057
00058
00059 G4DNADamages* G4DNADamages::Instance()
00060 {
00061 if(!fpInstance) new G4DNADamages();
00062
00063 return fpInstance;
00064 }
00065
00066 G4DNADamages::G4DNADamages()
00067 {
00068 fJustCountDamage = false;
00069 fNIndirectDamages = 0;
00070 fpInstance = this;
00071 }
00072
00073 G4DNADamages::~G4DNADamages()
00074 {
00075 for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
00076 {
00077 if(fIndirectHits[i])
00078 delete fIndirectHits[i];
00079 }
00080 fIndirectHits.clear();
00081 }
00082
00083 void G4DNADamages::DeleteInstance()
00084 {
00085 if(fpInstance) delete fpInstance;
00086 fpInstance = 0;
00087 }
00088
00089 void G4DNADamages::Reset()
00090 {
00091 fNIndirectDamages = 0;
00092 for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
00093 {
00094 if(fIndirectHits[i])
00095 delete fIndirectHits[i];
00096 }
00097 fIndirectHits.clear();
00098 }
00099
00100 void G4DNADamages::AddIndirectDamage(const G4String& baseName,
00101 const G4Molecule* molecule,
00102 const G4ThreeVector& position,
00103 G4double time)
00104 {
00105 if(fJustCountDamage)
00106 {
00107 fNIndirectDamages++;
00108 return;
00109 }
00110
00111 G4DNAIndirectHit* indirectHit = 0;
00112 std::map<G4Molecule, const G4Molecule*>::iterator it = fMolMap.find(*molecule);
00113
00114 if(it == fMolMap.end())
00115 {
00116 G4Molecule* mol(0);
00117 fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
00118 indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
00119 }
00120 else
00121 {
00122 indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
00123 }
00124 fIndirectHits.push_back(indirectHit);
00125 }