G4DNADamages.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id: G4DNADamages.cc 65022 2012-11-12 16:43:12Z gcosmo $
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 }

Generated on Mon May 27 17:48:02 2013 for Geant4 by  doxygen 1.4.7