Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -23,18 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAChemistryManager.hh 75583 2013-11-04 12:16:46Z gcosmo $
// $Id: G4DNAChemistryManager.hh 87375 2014-12-02 08:17:28Z gcosmo $
//
// Author: Mathieu Karamitros (kara@cenbg.in2p3.fr)
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
// The code is developed in the framework of the ESA AO7146
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
// We would be very happy hearing from you, send us your feedback! :)
//
// -------------------------------------------------------------------
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4DNACHEMISTRYMANAGER_HH
#define G4DNACHEMISTRYMANAGER_HH
@@ -43,127 +52,218 @@
#include "G4ThreeVector.hh"
#include <fstream>
#include <memory>
#include "G4UImessenger.hh"
#include "G4VStateDependent.hh"
class G4Track;
class G4DNAWaterExcitationStructure;
class G4DNAWaterIonisationStructure;
class G4Molecule;
class G4VUserChemistryList;
class G4UIcmdWithABool;
class G4UIcmdWithoutParameter;
class G4ITGun;
enum ElectronicModification
{
eIonizedMolecule,
eExcitedMolecule,
eDissociativeAttachment
eIonizedMolecule,
eExcitedMolecule,
eDissociativeAttachment
};
/**
* G4DNAChemistryManager is called from the physics models.
* It creates the water molecules and the solvated electrons and
* and send them to synchronous step manager to be treated in the chemistry stage.
* For this, the fActiveChemistry flag needs to be on.
* It is also possible to give already molecule's pointers already built.
* G4DNAChemistryManager will then be in charge of creating the track and loading
* it to the IT system.
* The user can also ask to create a file containing a information about the
* creation of water molecules and solvated electrons.
*/
* WARNING: THIS CLASS IS A PROTOTYPE
* G4DNAChemistryManager is called from the physics models.
* It creates the water molecules and the solvated electrons and
* and send them to G4ITStepManager to be treated in the chemistry stage.
* For this, the fActiveChemistry flag needs to be on.
* It is also possible to give already molecule's pointers already built.
* G4DNAChemistryManager will then be in charge of creating the track and loading
* it to the IT system.
* The user can also ask to create a file containing a information about the
* creation of water molecules and solvated electrons.
*/
class G4DNAChemistryManager
class G4DNAChemistryManager : public G4UImessenger, public G4VStateDependent
{
friend class std::auto_ptr<G4DNAChemistryManager>;
~G4DNAChemistryManager();
protected:
virtual ~G4DNAChemistryManager();
public:
static G4DNAChemistryManager* Instance();
//============================================================================
// STATIC METHODS
//============================================================================
static G4DNAChemistryManager* Instance();
static G4DNAChemistryManager* GetInstanceIfExists();
/**
* You should rather use DeleteInstance than the destructor of this class
*/
static void DeleteInstance();
/**
* You should rather use DeleteInstance than the destructor of this class
*/
static void DeleteInstance();
G4bool IsChemistryActivated();
void SetChemistryActivation(G4bool);
static G4bool IsActivated();
static void Activated(G4bool flag = true);
//============================================================================
// VIRTUAL METHODS
//============================================================================
virtual G4bool Notify(G4ApplicationState requestedState);
virtual void SetNewValue(G4UIcommand*, G4String);
//============================================================================
// INITIALIZATION AND FINALIZATION METHODS
//============================================================================
void Initialize();
inline void SetChemistryList(G4VUserChemistryList*);
inline void Deregister(G4VUserChemistryList*);
inline void ForceMasterReinitialization();
inline void TagThreadForReinitialization();
void Run();
void Clear();
void Gun(G4ITGun*, bool physicsTableToBuild = true);
inline void ForceThreadReinitialization();
inline void ForceRebuildingPhysicsTable();
//============================================================================
// FILE OPERATIONS
//============================================================================
/**
* Tells the chemMan to write into a file
* the position and electronic state of the water molecule
* and the position thermalized or not of the solvated electron
*/
void WriteInto(const G4String&, std::ios_base::openmode mode =
std::ios_base::out);
void AddEmptyLineInOuputFile();
/**
* Close the file specified with WriteInto
*/
void CloseFile();
//============================================================================
// PUSH MOLECULES
//============================================================================
/**
* Method used by DNA physics model to create a water molecule.
* The ElectronicModification is a flag telling wheter the molecule
* is ionized or excited, the electronic level is calculated by the
* model and the IncomingTrack is the track responsible for the creation
* of this molecule, for instance an electron.
*/
void CreateWaterMolecule(ElectronicModification,
G4int /*electronicLevel*/,
const G4Track* /*theIncomingTrack*/);
/**
* On the same idea as the previous method but for solvated electron.
* This method should be used by the physics model of the ElectronSolvatation
* process.
*/
void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = 0);
/**
* WARNING : In case chemistry is not activated, PushMolecule will take care
* of deleting the transfered molecule.
* Before calling this method, it is also possible to check if the chemistry
* is activated through IsChemistryActived().
* This method will create the track corresponding to the transfered molecule
* and will be in charge of loading the new track to the system.
*/
void PushMolecule(G4Molecule*& molecule,
double time,
const G4ThreeVector& position,
int parentID);
/**
* WARNING : In case chemistry is not activated, PushMoleculeAtParentTimeAndPlace
* will take care of deleting the transfered molecule.
* Before calling this method, it is also possible to check if the chemistry
* is activated through IsChemistryActived().
* This method will create the track corresponding to the transfered molecule
* and will be in charge of loading the new track to the system.
*/
void PushMoleculeAtParentTimeAndPlace(G4Molecule*& molecule,
const G4Track* /*theIncomingTrack*/);
/**
* Tells the chemMan to write into a file
* the position and electronic state of the water molecule
* and the position thermalized or not of the solvated electron
*/
void WriteInto(const G4String&, std::ios_base::openmode mode = std::ios_base::out);
inline void SetVerbose(G4int verbose)
{
fVerbose = verbose;
}
/** Close the file specified with WriteInto
*/
void CloseFile();
inline G4bool IsChemistryActived();
inline void SetChemistryActivation(G4bool);
protected:
G4DNAWaterExcitationStructure* GetExcitationLevel();
G4DNAWaterIonisationStructure* GetIonisationLevel();
void InitializeFile();
void InitializeMaster();
void InitializeThread();
/**
* Method used by DNA physics model to create a water molecule.
* The ElectronicModification is a flag telling wheter the molecule
* is ionized or excited, the electronic level is calculated by the
* model and the IncomingTrack is the track responsible for the creation
* of this molecule, for instance an electron.
*/
void CreateWaterMolecule(ElectronicModification,
G4int /*electronicLevel*/,
const G4Track* /*theIncomingTrack*/);
/**
* On the same idea as the previous method but for solvated electron.
* This method should be used by the physics model of the ElectronSolvatation
* process.
*/
void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = 0);
/**
* WARNING : In case chemistry is not activated, PushMolecule will take care
* of deleting the transfered molecule.
* Before calling this method, it is also possible to check if the chemistry is activated
* through IsChemistryActived().
* This method will create the track corresponding to the transfered molecule and will be in charge
* of loading the new track to the system.
*/
void PushMolecule(G4Molecule*& molecule,
double time, const G4ThreeVector& position, int parentID);
/**
* WARNING : In case chemistry is not activated, PushMoleculeAtParentTimeAndPlace
* will take care of deleting the transfered molecule.
* Before calling this method, it is also possible to check if the chemistry is activated
* through IsChemistryActived().
* This method will create the track corresponding to the transfered molecule and will be in charge
* of loading the new track to the system.
*/
void PushMoleculeAtParentTimeAndPlace(G4Molecule*& molecule,
const G4Track* /*theIncomingTrack*/);
void AddEmptyLineInOuputFile();
protected :
G4DNAWaterExcitationStructure* GetExcitationLevel();
G4DNAWaterIonisationStructure* GetIonisationLevel();
void InitializeFile();
G4DNAChemistryManager();
G4DNAChemistryManager();
private:
static std::auto_ptr<G4DNAChemistryManager> fInstance;
bool fActiveChemistry;
G4bool fWriteFile;
static G4ThreadLocal std::ofstream* fOutput;
G4UIdirectory* fpChemDNADirectory;
G4UIcmdWithABool* fpActivateChem;
G4UIcmdWithoutParameter* fpRunChem;
G4DNAWaterExcitationStructure* fExcitationLevel;
G4DNAWaterIonisationStructure* fIonisationLevel;
static G4DNAChemistryManager* fgInstance;
// static bool fActiveChemistry;
bool fActiveChemistry;
G4bool fFileInitialized;
G4bool fWriteFile;
static G4ThreadLocal std::ofstream* fpgOutput_tl;
static G4ThreadLocal G4bool* fpgThreadInitialized_tl;
G4bool fMasterInitialized;
G4bool fForceThreadReinitialization;
G4DNAWaterExcitationStructure* fpExcitationLevel;
G4DNAWaterIonisationStructure* fpIonisationLevel;
G4VUserChemistryList* fpUserChemistryList;
G4bool fBuildPhysicsTable;
G4bool fPhysicsTableBuilt;
G4bool fGeometryClosed;
G4int fVerbose;
};
inline G4bool G4DNAChemistryManager::IsChemistryActived()
inline void G4DNAChemistryManager::ForceRebuildingPhysicsTable()
{
return fActiveChemistry;
fPhysicsTableBuilt = false;
}
inline void G4DNAChemistryManager::SetChemistryActivation(G4bool flag)
inline void G4DNAChemistryManager::SetChemistryList(G4VUserChemistryList* chemistryList)
{
fActiveChemistry = flag;
fpUserChemistryList = chemistryList;
Activated();
}
inline void G4DNAChemistryManager::Deregister(G4VUserChemistryList* chemistryList)
{
if (fpUserChemistryList == chemistryList) fpUserChemistryList = 0;
}
inline void G4DNAChemistryManager::ForceMasterReinitialization()
{
fMasterInitialized = false;
InitializeMaster();
}
inline void G4DNAChemistryManager::ForceThreadReinitialization()
{
// TODO
fForceThreadReinitialization = true;
}
inline void G4DNAChemistryManager::TagThreadForReinitialization()
{
if (fpgThreadInitialized_tl) delete fpgThreadInitialized_tl;
}
#endif // G4DNACHEMISTRYMANAGER_HH
@@ -23,8 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNADamages.hh 66872 2013-01-15 01:25:57Z japost $
// $Id: G4DNADamages.hh 85244 2014-10-27 08:24:13Z gcosmo $
//
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4DNADAMAGES_HH
#define G4DNADAMAGES_HH 1
@@ -23,8 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAMolecularMaterial.hh 70171 2013-05-24 13:34:18Z gcosmo $
// $Id: G4DNAMolecularMaterial.hh 85244 2014-10-27 08:24:13Z gcosmo $
//
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4DNAMolecularMaterial_HH
#define G4DNAMolecularMaterial_HH
@@ -38,66 +57,77 @@ class G4Material;
struct CompareMaterial
{
// If the materials derives from a base material,
// it should be able to find the derived material using the base material.
bool operator() (const G4Material* mat1, const G4Material* mat2) const;
// If the materials derives from a base material,
// it should be able to find the derived material using the base material.
bool operator()(const G4Material* mat1, const G4Material* mat2) const;
};
typedef std::map<const G4Material*, double,CompareMaterial> ComponentMap;
typedef std::map<const G4Material*, double, CompareMaterial> ComponentMap;
// G4DNAMolecularMaterial is initialized when G4ApplicationState == G4State_Idle
class G4DNAMolecularMaterial : public G4VStateDependent
{
public:
static G4DNAMolecularMaterial* Instance();
void DeleteInstance();
void Initialize();
static G4DNAMolecularMaterial* Instance();
static void DeleteInstance();
void Initialize();
void Clear();
virtual G4bool Notify(G4ApplicationState requestedState) ;
virtual G4bool Notify(G4ApplicationState requestedState);
inline const std::vector<ComponentMap>* GetMassFractionTable() const;
inline const std::vector<ComponentMap>* GetDensityTable() const;
inline const std::vector<ComponentMap>* GetMassFractionTable() const;
inline const std::vector<ComponentMap>* GetDensityTable() const;
// const std::vector<double>* GetMassFractionTableFor(const G4Material*) const;
const std::vector<double>* GetDensityTableFor(const G4Material*) const;
const std::vector<double>* GetNumMolPerVolTableFor(const G4Material*) const;
const std::vector<double>* GetDensityTableFor(const G4Material*) const;
const std::vector<double>* GetNumMolPerVolTableFor(const G4Material*) const;
protected :
static G4DNAMolecularMaterial* fInstance;
protected:
static G4DNAMolecularMaterial* fInstance;
// static G4ThreadLocal G4DNAMolecularMaterial* fInstance;
G4DNAMolecularMaterial();
G4DNAMolecularMaterial(const G4DNAMolecularMaterial& right);
G4DNAMolecularMaterial& operator=(const G4DNAMolecularMaterial&);
virtual ~G4DNAMolecularMaterial();
void Create();
void InitializeNumMolPerVol();
void InitializeDensity();
void RecordMolecularMaterial(G4Material* parentMaterial, G4Material* molecularMaterial, G4double fraction);
void SearchMolecularMaterial(G4Material* parentMaterial, G4Material* material, double currentFraction);
G4DNAMolecularMaterial();
G4DNAMolecularMaterial(const G4DNAMolecularMaterial& right);
G4DNAMolecularMaterial& operator=(const G4DNAMolecularMaterial&);
virtual ~G4DNAMolecularMaterial();
void Create();
void InitializeNumMolPerVol();
void InitializeDensity();
void RecordMolecularMaterial(G4Material* parentMaterial,
G4Material* molecularMaterial,
G4double fraction);
void SearchMolecularMaterial(G4Material* parentMaterial,
G4Material* material,
double currentFraction);
void AddMaterial(const G4Material*, double fraction);
void AddMaterial(const G4Material*, double fraction);
void PrintNotAMolecularMaterial(const char* methodName, const G4Material* lookForMaterial) const;
void PrintNotAMolecularMaterial(const char* methodName,
const G4Material* lookForMaterial) const;
std::vector<ComponentMap>* fpCompFractionTable;
std::vector<ComponentMap>* fpCompDensityTable;
std::vector<ComponentMap>* fpCompNumMolPerVolTable;
std::vector<ComponentMap>* fpCompFractionTable;
std::vector<ComponentMap>* fpCompDensityTable;
std::vector<ComponentMap>* fpCompNumMolPerVolTable;
mutable std::map<const G4Material*,std::vector<double>*,CompareMaterial> fAskedDensityTable;
mutable std::map<const G4Material*,std::vector<double>*,CompareMaterial> fAskedNumPerVolTable;
mutable std::map<const G4Material*,bool,CompareMaterial> fWarningPrinted;
mutable std::map<const G4Material*, std::vector<double>*, CompareMaterial>
fAskedDensityTable;
mutable std::map<const G4Material*, std::vector<double>*, CompareMaterial>
fAskedNumPerVolTable;
mutable std::map<const G4Material*, bool, CompareMaterial> fWarningPrinted;
G4bool fIsInitialized;
G4bool fIsInitialized;
size_t fNMaterials;
};
inline const std::vector<ComponentMap> *G4DNAMolecularMaterial::GetMassFractionTable() const
inline const std::vector<ComponentMap>*
G4DNAMolecularMaterial::GetMassFractionTable() const
{
return fpCompFractionTable;
return fpCompFractionTable;
}
inline const std::vector<ComponentMap>* G4DNAMolecularMaterial::GetDensityTable() const
inline const std::vector<ComponentMap>*
G4DNAMolecularMaterial::GetDensityTable() const
{
return fpCompDensityTable;
return fpCompDensityTable;
}
#endif // G4DNAMolecularMaterial_HH
@@ -23,18 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAMolecularReactionTable.hh 70171 2013-05-24 13:34:18Z gcosmo $
// $Id: G4DNAMolecularReactionTable.hh 85244 2014-10-27 08:24:13Z gcosmo $
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// WARNING : This class is released as a prototype.
// It might strongly evolve or even disapear in the next releases.
// We would be very happy hearing from you, send us your feedback! :)
//
// History:
// -----------
// 10 Oct 2011 M.Karamitros created
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// -------------------------------------------------------------------
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4MolecularReactionTable_h
#define G4MolecularReactionTable_h 1
@@ -59,10 +68,14 @@ public :
G4DNAMolecularReactionData(G4double reactionRate,
const G4Molecule* reactive1,
const G4Molecule* reactive2);
G4DNAMolecularReactionData(G4double reactionRate,
const G4String& reactive1,
const G4String& reactive2);
~G4DNAMolecularReactionData();
const G4Molecule* GetReactive1() const { return fReactive1.get(); }
const G4Molecule* GetReactive2() const { return fReactive2.get(); }
const G4Molecule* GetReactive1() const { return fReactive1; }
const G4Molecule* GetReactive2() const { return fReactive2; }
G4double GetReactionRate() const {return fReactionRate;}
G4double GetReducedReactionRadius() const {return fReducedReactionRadius;}
@@ -73,6 +86,11 @@ public :
void SetReactive(const G4Molecule* reactive1, const G4Molecule* reactive2);
void AddProduct(const G4Molecule* molecule);
void SetReactive1(const G4String& reactive) ;
void SetReactive2(const G4String& reactive) ;
void SetReactive(const G4String& reactive1, const G4String& reactive2);
void AddProduct(const G4String& molecule);
G4int GetNbProducts() const
{
if(fProducts) return fProducts->size();
@@ -81,18 +99,18 @@ public :
const G4Molecule* GetProduct(G4int i) const
{
if(fProducts) return (*fProducts)[i].get();
if(fProducts) return (*fProducts)[i];
return 0;
}
protected :
G4DNAMolecularReactionData();
G4MoleculeHandle fReactive1;
G4MoleculeHandle fReactive2;
const G4Molecule* fReactive1;
const G4Molecule* fReactive2;
G4double fReactionRate;
G4double fReducedReactionRadius;
std::vector<G4MoleculeHandle>* fProducts;
std::vector<const G4Molecule*>* fProducts;
};
struct compMoleculeP
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef MOLECULEGUN_HH_
#define MOLECULEGUN_HH_
#include "G4ITGun.hh"
#include "globals.hh"
#include "G4ThreeVector.hh"
#include <vector>
class G4Track;
class G4MoleculeGunMessenger;
class G4MoleculeGun : public G4ITGun
{
public:
G4MoleculeGun();
virtual ~G4MoleculeGun();
virtual void DefineTracks();
void AddMolecule(const G4String& name,
const G4ThreeVector& position,
double time = 0);
void AddNMolecules(size_t n,
const G4String& name,
const G4ThreeVector& position,
double time = 0);
protected:
G4Track* BuildTrack(const G4String& name,
const G4ThreeVector& position,
double time = 0);
std::vector<G4Track*> fTracks;
G4MoleculeGunMessenger* fpMessenger;
};
#endif /* MOLECULEGUN_HH_ */
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef MOLECULEGUNMESSENGER_HH_
#define MOLECULEGUNMESSENGER_HH_
#include "G4UImessenger.hh"
#include "G4ThreeVector.hh"
#include <vector>
class G4MoleculeGun;
class G4UIcmdWithAString;
class G4UIcmdWith3VectorAndUnit;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAnInteger;
class G4UIdirectory;
class G4MoleculeGunMessenger : public G4UImessenger
{
public:
G4MoleculeGunMessenger();
virtual ~G4MoleculeGunMessenger();
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
virtual G4String GetCurrentValue(G4UIcommand * command);
void DefineTracks(G4MoleculeGun*);
protected:
G4UIdirectory* fpGunDir;
G4UIcmdWithAString* fpGunNewGunType;
struct MultipleGun : public G4UImessenger
{
MultipleGun(const G4String& name, G4MoleculeGunMessenger*);
virtual ~MultipleGun();
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
virtual G4String GetCurrentValue(G4UIcommand * command);
void DefineTracks(G4MoleculeGun*);
G4UIdirectory* fpGunType;
G4UIcmdWithAString* fpGunMoleculeModel;
G4UIcmdWith3VectorAndUnit* fpGunPosition;
G4UIcmdWithADoubleAndUnit* fpGunTime;
G4UIcmdWithAnInteger* fpGunN;
G4String fMoleculeName;
G4ThreeVector fPosition;
G4double fTime;
G4int fNumber;
};
MultipleGun* CreateNewType(const G4String& name);
std::vector<MultipleGun*> fMultipleGun;
};
#endif /* MOLECULEGUNMESSENGER_HH_ */
@@ -23,10 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VDNAReactionModel.hh 64057 2012-10-30 15:04:49Z gcosmo $
// $Id: G4VDNAReactionModel.hh 85244 2014-10-27 08:24:13Z gcosmo $
//
#ifndef G4VReactionModel_
#define G4VReactionModel_
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4VReactionModel_hh
#define G4VReactionModel_hh
#include "globals.hh"
#include "AddClone_def.hh"
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Author: Mathieu Karamitros, kara@cenbg.in2p3.fr
// The code is developed in the framework of the ESA AO7146
//
// We would be very happy hearing from you, send us your feedback! :)
//
// In order for Geant4-DNA to be maintained and still open-source,
// article citations are crucial.
// If you use Geant4-DNA chemistry and you publish papers about your software,
// in addition to the general paper on Geant4-DNA:
//
// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157178
//
// we would be very happy if you could please also cite the following
// reference papers on chemistry:
//
// J. Comput. Phys. 274 (2014) 841-882
// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
#ifndef G4VUSERCHEMISTRYLIST_HH_
#define G4VUSERCHEMISTRYLIST_HH_
class G4Molecule;
class G4DNAMolecularReactionTable;
class G4VITStepModel;
class G4MoleculeDefinition;
class G4VPhysicsContructor;
class G4VUserChemistryList
{
public:
G4VUserChemistryList();
virtual ~G4VUserChemistryList();
// If your user class also inherits from G4VPhysicsConstructor,
// please put this flag to true
virtual bool IsPhysicsConstructor()
{
if((G4VPhysicsContructor*)(this)) return true;
return false;
}
////////////////////////////////
// to be called from PhysicsList
virtual void ConstructMolecule()
{
;
} // PhysicsList::ConstructParticle
virtual void ConstructProcess()
{
;
} // PhysicsList::ConstructProcess
/////////////
virtual void ConstructDissociationChannels()
{
;
}
virtual void ConstructReactionTable(G4DNAMolecularReactionTable* reactionTable) = 0;
virtual void ConstructTimeStepModel(G4DNAMolecularReactionTable* reactionTable) = 0;
void BuildPhysicsTable();
protected:
void RegisterTimeStepModel(G4VITStepModel* timeStepModel,
double startingTime = 0);
void BuildPhysicsTable(G4MoleculeDefinition*);
int verboseLevel;
};
#endif /* G4VUSERCHEMISTRYLIST_HH_ */
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 73081 2013-08-16 12:58:22Z gcosmo $
# $Id: sources.cmake 80151 2014-04-03 09:42:22Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -52,23 +52,29 @@ GEANT4_DEFINE_MODULE(NAME G4emdna-utils
G4DNACrossSectionDataSet.hh
G4DNADamages.hh
G4DNAGenericIonsManager.hh
G4DNAIons.hh
G4DNAIons.hh
G4DNAMolecularMaterial.hh
G4DNAMolecularReactionTable.hh
G4DNAWaterExcitationStructure.hh
G4DNAWaterIonisationStructure.hh
G4MoleculeGun.hh
G4MoleculeGunMessenger.hh
G4VDNAReactionModel.hh
G4DNAMolecularMaterial.hh
G4VUserChemistryList.hh
SOURCES
G4DNAChemistryManager.cc
G4DNACrossSectionDataSet.cc
G4DNADamages.cc
G4DNAGenericIonsManager.cc
G4DNAIons.cc
G4DNAIons.cc
G4DNAMolecularMaterial.cc
G4DNAMolecularReactionTable.cc
G4DNAWaterExcitationStructure.cc
G4DNAWaterIonisationStructure.cc
G4MoleculeGun.cc
G4MoleculeGunMessenger.cc
G4VDNAReactionModel.cc
G4DNAMolecularMaterial.cc
G4VUserChemistryList.cc
GRANULAR_DEPENDENCIES
G4baryons
G4bosons
@@ -87,9 +93,9 @@ GEANT4_DEFINE_MODULE(NAME G4emdna-utils
G4partman
G4procman
G4track
G4emdna-man
G4emdna-molman
G4emdna-moltypes
# G4emdna-man
# G4emdna-molman
# G4emdna-moltypes
GLOBAL_DEPENDENCIES
G4geometry
G4global
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAChemistryManager.cc 75583 2013-11-04 12:16:46Z gcosmo $
// $Id: G4DNAChemistryManager.cc 87375 2014-12-02 08:17:28Z gcosmo $
//
// Author: Mathieu Karamitros (kara@cenbg.in2p3.fr)
//
@@ -37,305 +37,650 @@
// -------------------------------------------------------------------
#include "G4DNAChemistryManager.hh"
#include "G4Scheduler.hh"
#include "G4SystemOfUnits.hh"
#include "G4Molecule.hh"
#include "G4ITTrackHolder.hh"
#include "G4VITTrackHolder.hh"
#include "G4H2O.hh"
#include "G4DNAMolecularReactionTable.hh"
#include "G4DNAWaterExcitationStructure.hh"
#include "G4DNAWaterIonisationStructure.hh"
#include "G4Electron_aq.hh"
#include "G4ITManager.hh"
#include "G4MolecularConfiguration.hh"
#include "G4MoleculeCounter.hh"
#include "G4Tokenizer.hh"
#include "G4VUserChemistryList.hh"
#include "G4AutoLock.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4GeometryManager.hh"
#include "G4StateManager.hh"
#include "G4MoleculeFinder.hh"
using namespace std;
auto_ptr<G4DNAChemistryManager> G4DNAChemistryManager::fInstance ;
G4ThreadLocal std::ofstream* G4DNAChemistryManager::fOutput = 0;
G4DNAChemistryManager* G4DNAChemistryManager::fgInstance;
G4ThreadLocal std::ofstream* G4DNAChemistryManager::fpgOutput_tl = 0;
G4ThreadLocal G4bool* G4DNAChemistryManager::fpgThreadInitialized_tl = 0;
G4Mutex chemManExistence;
//bool G4DNAChemistryManager::fActiveChemistry = false;
G4DNAChemistryManager::G4DNAChemistryManager() :
fActiveChemistry(false)
G4UImessenger(), G4VStateDependent()
{
fExcitationLevel = 0;
fIonisationLevel = 0;
fWriteFile = false;
//==============================================================================
/* M.K: 24/11/2014
* To work properly, the chemistry manager should be created and initialized on
* the master thread only. If the static flag fActiveChemistry is on but the
* chemistry manager singleton
*/
//==============================================================================
// if (/*fActiveChemistry &&*/ G4Threading::IsWorkerThread()
// && G4Threading::IsMultithreadedApplication())
// {
// G4Exception("G4DNAChemistryManager::G4DNAChemistryManager",
// "G4DNAChemistryManager_MASTER_CREATION", FatalException,
// "The chemistry manager should be created and initialized on the "
// "master thread only");
// }
fpExcitationLevel = 0;
fpIonisationLevel = 0;
fWriteFile = false;
fpUserChemistryList = 0;
fMasterInitialized = false;
fpChemDNADirectory = new G4UIdirectory("/process/em/dna/chem/");
fpActivateChem = new G4UIcmdWithABool("/process/em/dna/chem/activate", this);
fpRunChem = new G4UIcmdWithoutParameter("/process/em/dna/chem/run", this);
fBuildPhysicsTable = false;
fGeometryClosed = false;
fPhysicsTableBuilt = false;
fForceThreadReinitialization = false;
fFileInitialized = false;
fVerbose = 0;
fActiveChemistry = false;
}
G4DNAChemistryManager* G4DNAChemistryManager::Instance()
G4DNAChemistryManager*
G4DNAChemistryManager::Instance()
{
if (fInstance.get() == 0)
{
G4AutoLock lock(&chemManExistence);
if(fInstance.get() == 0) // MT : double check at initialisation
{
fInstance = auto_ptr<G4DNAChemistryManager> (new G4DNAChemistryManager()) ;
}
lock.unlock();
}
return fInstance.get();
if (fgInstance == 0)
{
G4AutoLock lock(&chemManExistence);
if (fgInstance == 0) // MT : double check at initialisation
{
fgInstance = new G4DNAChemistryManager();
}
lock.unlock();
}
return fgInstance;
}
G4DNAChemistryManager*
G4DNAChemistryManager::GetInstanceIfExists()
{
return fgInstance;
}
G4DNAChemistryManager::~G4DNAChemistryManager()
{
if(fIonisationLevel) delete fIonisationLevel;
if(fExcitationLevel) delete fExcitationLevel;
G4DNAMolecularReactionTable::DeleteInstance();
G4MoleculeHandleManager::DeleteInstance();
G4MolecularConfiguration::DeleteManager();
fInstance.release();
G4MoleculeCounter::DeleteInstance();
// G4cout << "Deleting G4DNAChemistryManager" << G4endl;
Clear();
fgInstance = 0;
/*
* DEBUG : check that the chemistry manager has well been deregistered
* assert(G4StateManager::GetStateManager()->
* DeregisterDependent(this) == true);
*/
}
void G4DNAChemistryManager::Clear()
{
if (fpIonisationLevel)
{
delete fpIonisationLevel;
fpIonisationLevel = 0;
}
if (fpExcitationLevel)
{
delete fpExcitationLevel;
fpExcitationLevel = 0;
}
if (fpUserChemistryList)
{
if(fpUserChemistryList->IsPhysicsConstructor() == false)
{
delete fpUserChemistryList;
}
// else
// {
// G4cout << "G4DNAChemistryManager will not delete the chemistry list "
// "since it inherits from G4VPhysicsConstructor and it is then "
// "expected to be the responsability to the G4VModularPhysics to handle"
// " the chemistry list." << G4endl;
// }
fpUserChemistryList = 0;
}
if (fpChemDNADirectory)
{
delete fpChemDNADirectory;
fpChemDNADirectory = 0;
}
if (fpActivateChem)
{
delete fpActivateChem;
fpActivateChem = 0;
}
if(fpRunChem)
{
delete fpRunChem;
fpRunChem = 0;
}
G4DNAMolecularReactionTable::DeleteInstance();
//G4MoleculeHandleManager::DeleteInstance();
G4MolecularConfiguration::DeleteManager();
G4MoleculeCounter::DeleteInstance();
}
void G4DNAChemistryManager::DeleteInstance()
{
G4AutoLock lock(&chemManExistence);
if(fInstance.get())
{
fInstance.reset();
}
//G4cout << "G4DNAChemistryManager::DeleteInstance" << G4endl;
G4AutoLock lock(&chemManExistence);
if(fgInstance)
{
G4DNAChemistryManager* deleteMe = fgInstance;
fgInstance = 0;
lock.unlock();
delete deleteMe;
}
else
{
G4cout << "G4DNAChemistryManager already deleted" << G4endl;
}
lock.unlock();
}
G4bool G4DNAChemistryManager::Notify(G4ApplicationState requestedState)
{
if (requestedState == G4State_Quit)
{
if(fVerbose)
G4cout << "G4DNAChemistryManager::Notify ---> received G4State_Quit"
<< G4endl;
//DeleteInstance();
Clear();
}
else if(requestedState == G4State_GeomClosed)
{
fGeometryClosed = true;
}
return true;
}
void G4DNAChemistryManager::SetNewValue(G4UIcommand* command, G4String value)
{
if (command == fpActivateChem)
{
Activated(G4UIcmdWithABool::GetNewBoolValue(value));
}
else if (command == fpRunChem)
{
Run();
}
}
void G4DNAChemistryManager::Run()
{
if (fActiveChemistry)
{
InitializeThread();
if (fMasterInitialized == false)
{
G4ExceptionDescription description;
description << "Global components were not initialized.";
G4Exception("G4DNAChemistryManager::Run", "MASTER_INIT", FatalException,
description);
}
if (fpgThreadInitialized_tl == 0)
{
G4ExceptionDescription description;
description << "Thread local components were not initialized.";
G4Exception("G4DNAChemistryManager::Run", "THREAD_INIT", FatalException,
description);
}
G4Scheduler::Instance()->Process();
CloseFile();
}
}
void G4DNAChemistryManager::Gun(G4ITGun* gun, bool physicsTableToBuild)
{
fBuildPhysicsTable = physicsTableToBuild;
G4Scheduler::Instance()->SetGun(gun);
}
void G4DNAChemistryManager::Initialize()
{
//===========================================================================
// MT MODE
//===========================================================================
if(G4Threading::IsMultithreadedApplication())
{
//==========================================================================
// ON WORKER THREAD
//==========================================================================
if(G4Threading::IsWorkerThread())
{
InitializeThread(); // Will create and initialize G4ITScheduler
return;
}
//==========================================================================
// ON MASTER THREAD
//==========================================================================
else
{
InitializeMaster();
return;
}
}
//===========================================================================
// IS NOT IN MT MODE
//===========================================================================
else
{
InitializeMaster();
// In this case: InitializeThread is called when Run() is called
return;
}
}
void G4DNAChemistryManager::InitializeMaster()
{
if (fMasterInitialized == false)
{
if(fVerbose)
{
G4cout << "G4DNAChemistryManager::InitializeMaster() is called" << G4endl;
}
G4Scheduler::Instance();
// creates a concrete object of the scheduler
// and track container
if (fpUserChemistryList)
{
fpUserChemistryList->ConstructDissociationChannels();
fpUserChemistryList->ConstructReactionTable(
G4DNAMolecularReactionTable::GetReactionTable());
fMasterInitialized = true;
}
else
{
if (fActiveChemistry)
{
G4ExceptionDescription description;
description << "No user chemistry list has been provided.";
G4Exception("G4DNAChemistryManager::InitializeMaster", "NO_CHEM_LIST",
FatalException, description);
}
}
}
}
void G4DNAChemistryManager::InitializeThread()
{
if (fpgThreadInitialized_tl == 0 || fForceThreadReinitialization == true)
{
if (fpUserChemistryList)
{
if(fVerbose)
{
G4cout << "G4DNAChemistryManager::InitializeThread() is called"
<< G4endl;
}
if (fBuildPhysicsTable && fPhysicsTableBuilt == false)
{
if(fVerbose)
{
G4cout << "G4DNAChemistryManager: Build the physics tables for "
"molecules."
<< G4endl;
}
fpUserChemistryList->BuildPhysicsTable();
if (fGeometryClosed == false)
{
if(fVerbose)
{
G4cout << "G4DNAChemistryManager: Close geometry"
<< G4endl;
}
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
// G4cout << "Start closing geometry." << G4endl;
geomManager->OpenGeometry();
geomManager->CloseGeometry(true, true);
fGeometryClosed = true;
}
fPhysicsTableBuilt = true;
}
fpUserChemistryList->ConstructTimeStepModel(
G4DNAMolecularReactionTable::GetReactionTable());
G4Scheduler::Instance()->Initialize();
fpgThreadInitialized_tl = new G4bool(true);
}
else
{
G4ExceptionDescription description;
description << "No user chemistry list has been provided.";
G4Exception("G4DNAChemistryManager::InitializeThread", "NO_CHEM_LIST",
FatalException, description);
}
G4MoleculeCounter::InitializeInstance();
}
InitializeFile();
}
void G4DNAChemistryManager::InitializeFile()
{
*fOutput << std::setprecision(6) << std::scientific;
*fOutput << setw(11) << left << "#Parent ID"
<< setw(10) << "Molecule"
<< setw(14) << "Elec Modif"
<< setw(13) << "Energy (eV)"
<< setw(22) << "X pos of parent [nm]"
<< setw(22) << "Y pos of parent [nm]"
<< setw(22) << "Z pos of parent [nm]"
<< setw(14) << "X pos [nm]"
<< setw(14) << "Y pos [nm]"
<< setw(14) << "Z pos [nm]"
<< G4endl
<< setw(21) << "#"
<< setw(13) << "1)io/ex=0/1"
<< G4endl
<< setw(21) << "#"
<< setw(13) << "2)level=0...5"
<< G4endl;
if (fpgOutput_tl == 0 || fWriteFile == false || fFileInitialized)
{
return;
}
if(fVerbose)
{
G4cout << "G4DNAChemistryManager::InitializeFile() is called"
<< G4endl;
}
*fpgOutput_tl << std::setprecision(6) << std::scientific;
*fpgOutput_tl << setw(11) << left << "#Parent ID" << setw(10) << "Molecule"
<< setw(14) << "Elec Modif" << setw(13) << "Energy (eV)"
<< setw(22) << "X pos of parent [nm]" << setw(22)
<< "Y pos of parent [nm]" << setw(22) << "Z pos of parent [nm]"
<< setw(14) << "X pos [nm]" << setw(14) << "Y pos [nm]"
<< setw(14) << "Z pos [nm]" << G4endl<< setw(21) << "#"
<< setw(13) << "1)io/ex=0/1"
<< G4endl
<< setw(21) << "#"
<< setw(13) << "2)level=0...5"
<< G4endl;
fFileInitialized = true;
}
G4bool G4DNAChemistryManager::IsActivated()
{
return Instance()->fActiveChemistry;
}
void G4DNAChemistryManager::Activated(G4bool flag)
{
Instance()->fActiveChemistry = flag;
}
G4bool G4DNAChemistryManager::IsChemistryActivated()
{
return fActiveChemistry;
}
void G4DNAChemistryManager::SetChemistryActivation(G4bool flag)
{
fActiveChemistry = flag;
}
void G4DNAChemistryManager::WriteInto(const G4String& output,
ios_base::openmode mode)
ios_base::openmode mode)
{
fOutput = new std::ofstream();
fOutput->open(output.data(), mode);
fWriteFile = true;
}
if (fVerbose)
{
G4cout << "G4DNAChemistryManager: Write chemical stage into "
<< output.data() << G4endl;
}
void G4DNAChemistryManager::CloseFile()
{
if (fOutput->is_open())
{
fOutput->close();
}
fWriteFile = false;
}
G4DNAWaterExcitationStructure* G4DNAChemistryManager::GetExcitationLevel()
{
if(!fExcitationLevel)
{
fExcitationLevel = new G4DNAWaterExcitationStructure;
}
return fExcitationLevel;
}
G4DNAWaterIonisationStructure* G4DNAChemistryManager::GetIonisationLevel()
{
if(!fIonisationLevel)
{
fIonisationLevel = new G4DNAWaterIonisationStructure;
}
return fIonisationLevel;
}
void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modification,
G4int electronicLevel,
const G4Track* theIncomingTrack)
{
if(fWriteFile)
{
G4double energy = -1.;
switch (modification)
{
case eDissociativeAttachment:
energy = -1;
break;
case eExcitedMolecule :
energy = GetExcitationLevel()->ExcitationEnergy(electronicLevel);
break;
case eIonizedMolecule :
energy = GetIonisationLevel()->IonisationEnergy(electronicLevel);
break;
}
*fOutput << setw(11) << left << theIncomingTrack->GetTrackID()
<< setw(10) << "H2O"
<< left << modification
<< internal <<":"
<< right <<electronicLevel
<< left
<< setw(11) << ""
<< std::setprecision(2) << std::fixed
<< setw(13) << energy/eV
<< std::setprecision(6) << std::scientific
<< setw(22) << (theIncomingTrack->GetPosition().x())/nanometer
<< setw(22) << (theIncomingTrack->GetPosition().y())/nanometer
<< setw(22) << (theIncomingTrack->GetPosition().z())/nanometer
<< G4endl;
}
if(fActiveChemistry)
{
G4Molecule * H2O = new G4Molecule (G4H2O::Definition());
switch (modification)
{
case eDissociativeAttachment:
H2O -> AddElectron(5,1);
break;
case eExcitedMolecule :
H2O -> ExciteMolecule(electronicLevel);
break;
case eIonizedMolecule :
H2O -> IonizeMolecule(electronicLevel);
break;
}
G4Track * H2OTrack = H2O->BuildTrack(1*picosecond,
theIncomingTrack->GetPosition());
H2OTrack -> SetParentID(theIncomingTrack->GetTrackID());
H2OTrack -> SetTrackStatus(fStopButAlive);
H2OTrack -> SetKineticEnergy(0.);
G4ITTrackHolder::Instance()->PushTrack(H2OTrack);
}
}
void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* theIncomingTrack,
G4ThreeVector* finalPosition)
// finalPosition is a pointer because this argument is optional
{
if(fWriteFile)
{
*fOutput << setw(11)<< theIncomingTrack->GetTrackID()
<< setw(10)<< "e_aq"
<< setw(14)<< -1
<< std::setprecision(2) << std::fixed
<< setw(13)<< theIncomingTrack->GetKineticEnergy()/eV
<< std::setprecision(6) << std::scientific
<< setw(22)<< (theIncomingTrack->GetPosition().x())/nanometer
<< setw(22)<< (theIncomingTrack->GetPosition().y())/nanometer
<< setw(22)<< (theIncomingTrack->GetPosition().z())/nanometer ;
if(finalPosition != 0)
{
*fOutput<< setw(14)<< (finalPosition->x())/nanometer
<< setw(14)<< (finalPosition->y())/nanometer
<< setw(14)<< (finalPosition->z())/nanometer ;
}
*fOutput << G4endl;
}
if(fActiveChemistry)
{
G4Molecule* e_aq = new G4Molecule(G4Electron_aq::Definition());
G4Track * e_aqTrack(0);
if(finalPosition)
{
e_aqTrack = e_aq->BuildTrack(picosecond,*finalPosition);
}
else
{
e_aqTrack = e_aq->BuildTrack(picosecond,theIncomingTrack->GetPosition());
}
e_aqTrack -> SetTrackStatus(fAlive);
e_aqTrack -> SetParentID(theIncomingTrack->GetTrackID());
G4ITTrackHolder::Instance()->PushTrack(e_aqTrack);
G4ITManager<G4Molecule>::Instance()->Push(e_aqTrack);
}
}
void G4DNAChemistryManager::PushMolecule(G4Molecule*& molecule, double time,
const G4ThreeVector& position, int parentID)
{
if(fWriteFile)
{
*fOutput << setw(11)<< parentID
<< setw(10)<< molecule->GetName()
<< setw(14)<< -1
<< std::setprecision(2) << std::fixed
<< setw(13)<< -1
<< std::setprecision(6) << std::scientific
<< setw(22)<< (position.x())/nanometer
<< setw(22)<< (position.y())/nanometer
<< setw(22)<< (position.z())/nanometer;
*fOutput << G4endl;
}
if(fActiveChemistry)
{
G4Track* track = molecule->BuildTrack(time,position);
track -> SetTrackStatus(fAlive);
track -> SetParentID(parentID);
G4ITTrackHolder::Instance()->PushTrack(track);
G4ITManager<G4Molecule>::Instance()->Push(track);
}
else
{
delete molecule;
molecule = 0;
}
}
void G4DNAChemistryManager::PushMoleculeAtParentTimeAndPlace(G4Molecule*& molecule,
const G4Track* theIncomingTrack)
{
if(fWriteFile)
{
*fOutput << setw(11)<< theIncomingTrack->GetTrackID()
<< setw(10)<< molecule->GetName()
<< setw(14)<< -1
<< std::setprecision(2) << std::fixed
<< setw(13)<< theIncomingTrack->GetKineticEnergy()/eV
<< std::setprecision(6) << std::scientific
<< setw(22)<< (theIncomingTrack->GetPosition().x())/nanometer
<< setw(22)<< (theIncomingTrack->GetPosition().y())/nanometer
<< setw(22)<< (theIncomingTrack->GetPosition().z())/nanometer ;
*fOutput << G4endl;
}
if(fActiveChemistry)
{
G4Track* track = molecule->BuildTrack(theIncomingTrack->GetGlobalTime(),theIncomingTrack->GetPosition());
track -> SetTrackStatus(fAlive);
track -> SetParentID(theIncomingTrack->GetTrackID());
G4ITTrackHolder::Instance()->PushTrack(track);
G4ITManager<G4Molecule>::Instance()->Push(track);
}
else
{
delete molecule;
molecule = 0;
}
fpgOutput_tl = new std::ofstream();
fpgOutput_tl->open(output.data(), mode);
fWriteFile = true;
fFileInitialized = false;
}
void G4DNAChemistryManager::AddEmptyLineInOuputFile()
{
if(fWriteFile)
{
*fOutput << G4endl;
}
if (fWriteFile)
{
*fpgOutput_tl << G4endl;
}
}
void G4DNAChemistryManager::CloseFile()
{
if (fpgOutput_tl == 0) return;
if (fpgOutput_tl->is_open())
{
if (fVerbose)
{
G4cout << "G4DNAChemistryManager: Close File" << G4endl;
}
fpgOutput_tl->close();
}
}
G4DNAWaterExcitationStructure*
G4DNAChemistryManager::GetExcitationLevel()
{
if (!fpExcitationLevel)
{
fpExcitationLevel = new G4DNAWaterExcitationStructure;
}
return fpExcitationLevel;
}
G4DNAWaterIonisationStructure*
G4DNAChemistryManager::GetIonisationLevel()
{
if (!fpIonisationLevel)
{
fpIonisationLevel = new G4DNAWaterIonisationStructure;
}
return fpIonisationLevel;
}
void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modification,
G4int electronicLevel,
const G4Track* theIncomingTrack)
{
if (fWriteFile)
{
if(!fFileInitialized) InitializeFile();
G4double energy = -1.;
switch (modification)
{
case eDissociativeAttachment:
energy = 0;
break;
case eExcitedMolecule:
energy = GetExcitationLevel()->ExcitationEnergy(electronicLevel);
break;
case eIonizedMolecule:
energy = GetIonisationLevel()->IonisationEnergy(electronicLevel);
break;
}
*fpgOutput_tl << setw(11) << left << theIncomingTrack->GetTrackID()
<< setw(10) << "H2O" << left << modification << internal
<< ":" << right << electronicLevel << left << setw(11) << ""
<< std::setprecision(2) << std::fixed << setw(13)
<< energy / eV << std::setprecision(6) << std::scientific
<< setw(22)
<< (theIncomingTrack->GetPosition().x()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().y()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().z()) / nanometer
<< G4endl;
}
if(fActiveChemistry)
{
G4Molecule * H2O = new G4Molecule (G4H2O::Definition());
switch (modification)
{
case eDissociativeAttachment:
H2O -> AddElectron(5,1);
break;
case eExcitedMolecule :
H2O -> ExciteMolecule(electronicLevel);
break;
case eIonizedMolecule :
H2O -> IonizeMolecule(electronicLevel);
break;
}
G4Track * H2OTrack = H2O->BuildTrack(1*picosecond,
theIncomingTrack->GetPosition());
H2OTrack -> SetParentID(theIncomingTrack->GetTrackID());
H2OTrack -> SetTrackStatus(fStopButAlive);
H2OTrack -> SetKineticEnergy(0.);
G4VITTrackHolder::Instance()->Push(H2OTrack);
}
// else
// abort();
}
void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* theIncomingTrack,
G4ThreeVector* finalPosition)
// finalPosition is a pointer because this argument is optional
{
if (fWriteFile)
{
if(!fFileInitialized) InitializeFile();
*fpgOutput_tl << setw(11) << theIncomingTrack->GetTrackID() << setw(10)
<< "e_aq" << setw(14) << -1 << std::setprecision(2)
<< std::fixed << setw(13)
<< theIncomingTrack->GetKineticEnergy() / eV
<< std::setprecision(6) << std::scientific << setw(22)
<< (theIncomingTrack->GetPosition().x()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().y()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().z()) / nanometer;
if (finalPosition != 0)
{
*fpgOutput_tl << setw(14) << (finalPosition->x()) / nanometer << setw(14)
<< (finalPosition->y()) / nanometer << setw(14)
<< (finalPosition->z()) / nanometer;
}
*fpgOutput_tl << G4endl;
}
if(fActiveChemistry)
{
G4Molecule* e_aq = new G4Molecule(G4Electron_aq::Definition());
G4Track * e_aqTrack(0);
if(finalPosition)
{
e_aqTrack = e_aq->BuildTrack(picosecond,*finalPosition);
}
else
{
e_aqTrack = e_aq->BuildTrack(picosecond,theIncomingTrack->GetPosition());
}
e_aqTrack -> SetTrackStatus(fAlive);
e_aqTrack -> SetParentID(theIncomingTrack->GetTrackID());
G4VITTrackHolder::Instance()->Push(e_aqTrack);
}
}
void G4DNAChemistryManager::PushMolecule(G4Molecule*& molecule,
double time,
const G4ThreeVector& position,
int parentID)
{
if (fWriteFile)
{
if(!fFileInitialized) InitializeFile();
*fpgOutput_tl << setw(11) << parentID << setw(10) << molecule->GetName()
<< setw(14) << -1 << std::setprecision(2) << std::fixed
<< setw(13) << -1 << std::setprecision(6) << std::scientific
<< setw(22) << (position.x()) / nanometer << setw(22)
<< (position.y()) / nanometer << setw(22)
<< (position.z()) / nanometer;
*fpgOutput_tl << G4endl;
}
if(fActiveChemistry)
{
G4Track* track = molecule->BuildTrack(time,position);
track -> SetTrackStatus(fAlive);
track -> SetParentID(parentID);
G4VITTrackHolder::Instance()->Push(track);
}
else
{
delete molecule;
molecule = 0;
}
}
void G4DNAChemistryManager::PushMoleculeAtParentTimeAndPlace(G4Molecule*& molecule,
const G4Track* theIncomingTrack)
{
if (fWriteFile)
{
if(!fFileInitialized) InitializeFile();
*fpgOutput_tl << setw(11) << theIncomingTrack->GetTrackID() << setw(10)
<< molecule->GetName() << setw(14) << -1
<< std::setprecision(2) << std::fixed << setw(13)
<< theIncomingTrack->GetKineticEnergy() / eV
<< std::setprecision(6) << std::scientific << setw(22)
<< (theIncomingTrack->GetPosition().x()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().y()) / nanometer
<< setw(22)
<< (theIncomingTrack->GetPosition().z()) / nanometer;
*fpgOutput_tl << G4endl;
}
if(fActiveChemistry)
{
G4Track* track = molecule->BuildTrack(theIncomingTrack->GetGlobalTime(),
theIncomingTrack->GetPosition());
track -> SetTrackStatus(fAlive);
track -> SetParentID(theIncomingTrack->GetTrackID());
G4VITTrackHolder::Instance()->Push(track);
}
else
{
delete molecule;
molecule = 0;
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNADamages.cc 66872 2013-01-15 01:25:57Z japost $
// $Id: G4DNADamages.cc 85244 2014-10-27 08:24:13Z gcosmo $
//
#include "G4DNADamages.hh"
#include "G4UnitsTable.hh"
@@ -33,68 +33,64 @@ G4ThreadLocal G4DNADamages* G4DNADamages::fpInstance(0);
G4DNAIndirectHit::G4DNAIndirectHit(const G4String& baseName,
const G4Molecule* molecule,
const G4ThreeVector& position,
G4double time) : G4VDNAHit(),
fpMolecule(molecule)
G4double time) :
G4VDNAHit(), fpMolecule(molecule)
{
fBaseName = baseName;
fPosition = position;
fTime = time;
fBaseName = baseName;
fPosition = position;
fTime = time;
}
G4DNAIndirectHit::~G4DNAIndirectHit()
{
if(fpMolecule) delete fpMolecule;
fpMolecule = 0;
if (fpMolecule) delete fpMolecule;
fpMolecule = 0;
}
void G4DNAIndirectHit::Print()
{
G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
<< " at position : " << G4BestUnit(fPosition,"Length")
<< " and time : " << G4BestUnit(fTime,"Time") << G4endl;
G4cout << "Reaction : " << fpMolecule->GetName() << " + " << fBaseName
<< " at position : " << G4BestUnit(fPosition, "Length")
<< " and time : " << G4BestUnit(fTime, "Time") << G4endl;
}
G4DNADamages* G4DNADamages::Instance()
{
if(!fpInstance) new G4DNADamages();
if (!fpInstance) new G4DNADamages();
return fpInstance;
return fpInstance;
}
G4DNADamages::G4DNADamages()
{
fJustCountDamage = false;
fNIndirectDamages = 0;
fpInstance = this;
fJustCountDamage = false;
fNIndirectDamages = 0;
fpInstance = this;
}
G4DNADamages::~G4DNADamages()
{
for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
{
if(fIndirectHits[i])
delete fIndirectHits[i];
}
fIndirectHits.clear();
for (int i = 0; i < (int) fIndirectHits.size(); i++)
{
if (fIndirectHits[i]) delete fIndirectHits[i];
}
fIndirectHits.clear();
}
void G4DNADamages::DeleteInstance()
{
if(fpInstance) delete fpInstance;
fpInstance = 0;
if (fpInstance) delete fpInstance;
fpInstance = 0;
}
void G4DNADamages::Reset()
{
fNIndirectDamages = 0;
for(int i = 0 ; i <(int) fIndirectHits.size() ; i++)
{
if(fIndirectHits[i])
delete fIndirectHits[i];
}
fIndirectHits.clear();
fNIndirectDamages = 0;
for (int i = 0; i < (int) fIndirectHits.size(); i++)
{
if (fIndirectHits[i]) delete fIndirectHits[i];
}
fIndirectHits.clear();
}
void G4DNADamages::AddIndirectDamage(const G4String& baseName,
@@ -102,24 +98,25 @@ void G4DNADamages::AddIndirectDamage(const G4String& baseName,
const G4ThreeVector& position,
G4double time)
{
if(fJustCountDamage)
{
fNIndirectDamages++;
return;
}
if (fJustCountDamage)
{
fNIndirectDamages++;
return;
}
G4DNAIndirectHit* indirectHit = 0;
std::map<G4Molecule, const G4Molecule*>::iterator it = fMolMap.find(*molecule);
G4DNAIndirectHit* indirectHit = 0;
std::map<G4Molecule, const G4Molecule*>::iterator it = fMolMap.find(
*molecule);
if(it == fMolMap.end())
{
G4Molecule* mol(0);
fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
}
else
{
indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
}
fIndirectHits.push_back(indirectHit);
if (it == fMolMap.end())
{
G4Molecule* mol(0);
fMolMap[*molecule] = (mol = new G4Molecule(*molecule));
indirectHit = new G4DNAIndirectHit(baseName, mol, position, time);
}
else
{
indirectHit = new G4DNAIndirectHit(baseName, it->second, position, time);
}
fIndirectHits.push_back(indirectHit);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAGenericIonsManager.cc 73124 2013-08-19 07:53:33Z gcosmo $
// $Id: G4DNAGenericIonsManager.cc 87449 2014-12-04 14:13:06Z gunter $
#include "G4DNAGenericIonsManager.hh"
#include "G4PhysicalConstants.hh"
@@ -74,6 +74,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
G4DNAIons *carbon;
G4DNAIons *nitrogen;
G4DNAIons *oxygen;
G4DNAIons *silicon;
G4DNAIons *iron;
iron= new G4DNAIons(
@@ -85,6 +86,16 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
false, "", 0,
0.0);
silicon= new G4DNAIons(
"silicon", 28.085*GeV, 0.0*MeV, +14.0*eplus,
0, +1, 0,
0, 0, 0,
"DNAion", +14, +28, 0,
true, -1.0, 0,
false, "", 0,
0.0);
oxygen= new G4DNAIons(
"oxygen", 15.0074*GeV, 0.0*MeV, +8.0*eplus,
0, +1, 0,
@@ -160,6 +171,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
map["carbon" ]=carbon;
map["nitrogen"]=nitrogen;
map["oxygen" ]=oxygen;
map["silicon" ]=silicon;
map["iron" ]=iron;
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAMolecularMaterial.cc 70171 2013-05-24 13:34:18Z gcosmo $
// $Id: G4DNAMolecularMaterial.cc 84858 2014-10-21 16:08:22Z gcosmo $
//
#include "G4DNAMolecularMaterial.hh"
#include "G4Material.hh"
@@ -31,433 +31,515 @@
#include "G4StateManager.hh"
#include "G4Threading.hh"
#include "G4AutoLock.hh"
#include "G4StateManager.hh"
using namespace std;
G4DNAMolecularMaterial* G4DNAMolecularMaterial::fInstance(0);
//G4ThreadLocal G4DNAMolecularMaterial* G4DNAMolecularMaterial::fInstance(0);
G4Mutex aMutex=G4MUTEX_INITIALIZER;
G4Mutex aMutex = G4MUTEX_INITIALIZER;
bool CompareMaterial::operator() (const G4Material* mat1, const G4Material* mat2) const
bool CompareMaterial::operator()(const G4Material* mat1,
const G4Material* mat2) const
{
if(mat1==0 && mat2==0) return false; //(mat1 == mat2)
if(mat1==0) return true; // mat1 < mat2
if(mat2==0) return false; //mat2 < mat1
if (mat1 == 0 && mat2 == 0) return false; //(mat1 == mat2)
if (mat1 == 0) return true; // mat1 < mat2
if (mat2 == 0) return false; //mat2 < mat1
const G4Material* baseMat1 = mat1->GetBaseMaterial();
const G4Material* baseMat2 = mat2->GetBaseMaterial();
const G4Material* baseMat1 = mat1->GetBaseMaterial();
const G4Material* baseMat2 = mat2->GetBaseMaterial();
if((baseMat1 || baseMat2) == 0) // None of the materials derives from a base material
{
return mat1 < mat2;
}
else if(baseMat1 && baseMat2) // Both materials derive from a base material
{
return baseMat1 < baseMat2;
}
if ((baseMat1 || baseMat2) == 0) // None of the materials derives from a base material
{
return mat1 < mat2;
}
else if (baseMat1 && baseMat2) // Both materials derive from a base material
{
return baseMat1 < baseMat2;
}
else if(baseMat1 && (baseMat2 == 0)) // Only the material 1 derives from a base material
{
return baseMat1 < mat2;
}
// only case baseMat1==0 && baseMat2 remains
return mat1 < baseMat2;
else if (baseMat1 && (baseMat2 == 0)) // Only the material 1 derives from a base material
{
return baseMat1 < mat2;
}
// only case baseMat1==0 && baseMat2 remains
return mat1 < baseMat2;
}
G4DNAMolecularMaterial* G4DNAMolecularMaterial::Instance()
{
if(! fInstance) new G4DNAMolecularMaterial();
return fInstance;
if (!fInstance) new G4DNAMolecularMaterial();
return fInstance;
}
void G4DNAMolecularMaterial::DeleteInstance()
{
if (fInstance)
{
delete fInstance;
fInstance = 0;
}
}
void G4DNAMolecularMaterial::Create()
{
fpCompFractionTable = 0;
fpCompDensityTable = 0;
fpCompNumMolPerVolTable = 0;
fIsInitialized = false;
fInstance = this;
fpCompFractionTable = 0;
fpCompDensityTable = 0;
fpCompNumMolPerVolTable = 0;
fIsInitialized = false;
fNMaterials = 0;
fInstance = this;
}
G4DNAMolecularMaterial::G4DNAMolecularMaterial() :G4VStateDependent()
void G4DNAMolecularMaterial::Clear()
{
Create();
fInstance = this;
if (fpCompFractionTable)
{
fpCompFractionTable->clear();
delete fpCompFractionTable;
fpCompFractionTable = 0;
}
if (fpCompDensityTable)
{
fpCompDensityTable->clear();
delete fpCompDensityTable;
fpCompDensityTable = 0;
}
if (fpCompNumMolPerVolTable)
{
fpCompNumMolPerVolTable->clear();
delete fpCompNumMolPerVolTable;
fpCompNumMolPerVolTable = 0;
}
map<const G4Material*, std::vector<double>*, CompareMaterial>::iterator it;
for (it = fAskedDensityTable.begin(); it != fAskedDensityTable.end(); it++)
{
if (it->second)
{
delete it->second;
it->second = 0;
}
}
for (it = fAskedNumPerVolTable.begin(); it != fAskedNumPerVolTable.end();
it++)
{
if (it->second)
{
delete it->second;
it->second = 0;
}
}
}
G4DNAMolecularMaterial::G4DNAMolecularMaterial() :
G4VStateDependent()
{
Create();
fInstance = this;
}
G4bool G4DNAMolecularMaterial::Notify(G4ApplicationState requestedState)
{
if(requestedState == G4State_Idle) Initialize();
return true;
if (requestedState == G4State_Idle && G4StateManager::GetStateManager()
->GetPreviousState() == G4State_PreInit)
{
Initialize();
}
else if (requestedState == G4State_Quit)
{
// G4cout << "G4DNAMolecularMaterial::Notify ---> received G4State_Quit"
// << G4endl;
Clear();
//DeleteInstance();
}
return true;
}
G4DNAMolecularMaterial::G4DNAMolecularMaterial(const G4DNAMolecularMaterial& /*rhs*/) : G4VStateDependent()
G4DNAMolecularMaterial::G4DNAMolecularMaterial(
const G4DNAMolecularMaterial& /*rhs*/) :
G4VStateDependent()
{
Create();
Create();
}
G4DNAMolecularMaterial& G4DNAMolecularMaterial::operator=(const G4DNAMolecularMaterial& rhs)
G4DNAMolecularMaterial&
G4DNAMolecularMaterial::operator=(const G4DNAMolecularMaterial& rhs)
{
if(this == &rhs) return *this;
Create();
return *this;
if (this == &rhs) return *this;
Create();
return *this;
}
G4DNAMolecularMaterial::~G4DNAMolecularMaterial()
{
if(fpCompFractionTable)
{
fpCompFractionTable->clear();
delete fpCompFractionTable;
fpCompFractionTable = 0;
}
if(fpCompDensityTable)
{
fpCompDensityTable->clear();
delete fpCompDensityTable;
fpCompDensityTable = 0;
}
if(fpCompNumMolPerVolTable)
{
fpCompNumMolPerVolTable->clear();
delete fpCompNumMolPerVolTable;
fpCompNumMolPerVolTable = 0;
}
std::map<const G4Material*,std::vector<double>*,CompareMaterial>::iterator it;
for(it= fAskedDensityTable.begin() ; it != fAskedDensityTable.end() ;it++)
{
if(it->second)
{
delete it->second;
it->second = 0;
}
}
for(it= fAskedNumPerVolTable.begin() ; it != fAskedNumPerVolTable.end() ;it++)
{
if(it->second)
{
delete it->second;
it->second = 0;
}
}
}
void G4DNAMolecularMaterial::RecordMolecularMaterial(G4Material* parentMaterial, G4Material* molecularMaterial, G4double fraction)
{
ComponentMap& matComponent = (*fpCompFractionTable)[parentMaterial->GetIndex()];
if(matComponent.empty())
{
matComponent[molecularMaterial] = fraction;
return;
}
ComponentMap::iterator it = matComponent.find(molecularMaterial);
if(it == matComponent.end())
{
matComponent[molecularMaterial] = fraction;
}
else
{
matComponent[molecularMaterial] = it->second + fraction;
}
}
void G4DNAMolecularMaterial::SearchMolecularMaterial(G4Material* parentMaterial, G4Material* material, double currentFraction)
{
if(material->GetMassOfMolecule() != 0.0)
{
RecordMolecularMaterial(parentMaterial,material,currentFraction);
return;
}
G4Material* compMat(0);
G4double fraction = -1;
std::map<G4Material*,G4double> matComponent = material->GetMatComponents();
std::map<G4Material*,G4double>::iterator it = matComponent.begin();
for( ; it!=matComponent.end() ; it++)
{
compMat = it->first;
fraction = it->second;
if(compMat->GetMassOfMolecule() == 0.0)
{
SearchMolecularMaterial(parentMaterial,compMat,currentFraction*fraction);
}
else
{
RecordMolecularMaterial(parentMaterial,compMat,currentFraction*fraction);
}
compMat = 0;
fraction = -1;
}
}
void G4DNAMolecularMaterial::InitializeDensity()
{
if(fpCompFractionTable)
{
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
fpCompDensityTable = new vector<ComponentMap>(G4Material::GetMaterialTable()->size());
G4Material* parentMat;
const G4Material* compMat(0);
double massFraction = -1;
double parentDensity = -1;
for(int i = 0 ; i < int(materialTable->size()) ; i++)
{
parentMat = materialTable->at(i);
ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
ComponentMap& densityComp = (*fpCompDensityTable)[i];
parentDensity = parentMat->GetDensity();
for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
{
compMat = it->first;
massFraction = it->second;
densityComp[compMat] = massFraction*parentDensity;
compMat = 0;
massFraction = -1;
}
}
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompFractionTable is not initialized" << G4endl;
G4Exception("G4DNAMolecularMaterial::InitializeDensity","G4DNAMolecularMaterial001",
FatalException,exceptionDescription);
}
}
void G4DNAMolecularMaterial::InitializeNumMolPerVol()
{
if(fpCompDensityTable)
{
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
fpCompNumMolPerVolTable = new vector<ComponentMap>(G4Material::GetMaterialTable()->size());
const G4Material* compMat(0);
for(int i = 0 ; i < int(materialTable->size()) ; i++)
{
ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
ComponentMap& densityComp = (*fpCompDensityTable)[i];
ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
{
compMat = it->first;
numMolPerVol[compMat] = densityComp[compMat]/ compMat->GetMassOfMolecule();
compMat = 0;
}
}
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompDensityTable is not initialized" << G4endl;
G4Exception("G4DNAMolecularMaterial::InitializeNumMolPerVol","G4DNAMolecularMaterial002",
FatalException,exceptionDescription);
}
// G4cout << "Deleting G4DNAMolecularMaterial" << G4endl;
Clear();
fInstance = 0;
//assert(G4StateManager::GetStateManager()->DeregisterDependent(this) == true);
}
void G4DNAMolecularMaterial::Initialize()
{
G4AutoLock l(&aMutex);
if(fIsInitialized)
{
return;
}
G4AutoLock l(&aMutex);
if (fIsInitialized)
{
return;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
if(fpCompFractionTable==0)
{
fpCompFractionTable = new vector<ComponentMap>(materialTable->size());
}
fNMaterials = materialTable->size();
// This is to prevent segment fault if materials are created later on
// Actually this creation should not be done
G4Material* mat(0);
if (fpCompFractionTable == 0)
{
fpCompFractionTable = new vector<ComponentMap>(materialTable->size());
}
for(int i = 0 ; i < int(materialTable->size()) ; i++)
{
mat = materialTable->at(i);
SearchMolecularMaterial(mat,mat,1);
G4Material* mat(0);
mat = 0;
}
for (size_t i = 0; i < fNMaterials; i++)
{
mat = materialTable->at(i);
SearchMolecularMaterial(mat, mat, 1);
InitializeDensity();
InitializeNumMolPerVol();
mat = 0;
}
fIsInitialized = true;
InitializeDensity();
InitializeNumMolPerVol();
fIsInitialized = true;
}
const std::vector<double>* G4DNAMolecularMaterial::GetDensityTableFor(const G4Material* lookForMaterial) const
void G4DNAMolecularMaterial::InitializeDensity()
{
if(!fpCompDensityTable)
{
if(fIsInitialized)
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompDensityTable is not initialized will the singleton of G4DNAMolecularMaterial "
<< "has already been initialized."<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetDensityTableFor","G4DNAMolecularMaterial003",
FatalException,exceptionDescription);
}
if(G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The geant4 application is at the wrong state. State must be: G4State_Idle."<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetDensityTableFor",
"G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",FatalException,exceptionDescription);
}
}
std::map<const G4Material*,std::vector<double>*,CompareMaterial>::const_iterator it_askedDensityTable = fAskedDensityTable.find(lookForMaterial);
if(it_askedDensityTable != fAskedDensityTable.end())
{
return it_askedDensityTable->second;
}
if (fpCompFractionTable)
{
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
fpCompDensityTable = new vector<ComponentMap>(
G4Material::GetMaterialTable()->size());
std::vector<double>* output = new std::vector<double>(materialTable->size());
G4Material* parentMat;
const G4Material* compMat(0);
double massFraction = -1;
double parentDensity = -1;
ComponentMap::const_iterator it;
G4bool materialWasNotFound = true;
for(int i = 0 ; i < int(materialTable->size()) ; i++)
for (size_t i = 0; i < fNMaterials; i++)
{
ComponentMap& densityTable = (*fpCompDensityTable)[i];
parentMat = materialTable->at(i);
ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
ComponentMap& densityComp = (*fpCompDensityTable)[i];
it = densityTable.find(lookForMaterial);
parentDensity = parentMat->GetDensity();
if(it==densityTable.end())
{
(*output)[i] = 0.0;
}
else
{
materialWasNotFound = false;
(*output)[i] = it->second;
}
for (ComponentMap::iterator it = massFractionComp.begin();
it != massFractionComp.end(); it++)
{
compMat = it->first;
massFraction = it->second;
densityComp[compMat] = massFraction * parentDensity;
compMat = 0;
massFraction = -1;
}
}
if(materialWasNotFound)
{
PrintNotAMolecularMaterial("G4DNAMolecularMaterial::GetDensityTableFor",lookForMaterial);
}
fAskedDensityTable.insert(make_pair(lookForMaterial, output));
return output;
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompFractionTable is not initialized"
<< G4endl;
G4Exception("G4DNAMolecularMaterial::InitializeDensity",
"G4DNAMolecularMaterial001", FatalException,
exceptionDescription);
}
}
const std::vector<double>* G4DNAMolecularMaterial::GetNumMolPerVolTableFor(const G4Material* lookForMaterial) const
void G4DNAMolecularMaterial::InitializeNumMolPerVol()
{
if(!fpCompNumMolPerVolTable)
if (fpCompDensityTable)
{
fpCompNumMolPerVolTable = new vector<ComponentMap>(fNMaterials);
const G4Material* compMat(0);
for (size_t i = 0; i < fNMaterials; i++)
{
if(fIsInitialized)
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompNumMolPerVolTable is not initialized whereas the singleton of G4DNAMolecularMaterial "
<< "has already been initialized."<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor","G4DNAMolecularMaterial005",
FatalException,exceptionDescription);
}
ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
ComponentMap& densityComp = (*fpCompDensityTable)[i];
ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
if(G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
{
const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The geant4 application is at the wrong state. State must be : G4State_Idle."<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
"G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",FatalException,exceptionDescription);
}
for (ComponentMap::iterator it = massFractionComp.begin();
it != massFractionComp.end(); it++)
{
compMat = it->first;
numMolPerVol[compMat] = densityComp[compMat]
/ compMat->GetMassOfMolecule();
compMat = 0;
}
}
std::map<const G4Material*,std::vector<double>*,CompareMaterial>::const_iterator it_askedNumMolPerVolTable = fAskedNumPerVolTable.find(lookForMaterial);
if(it_askedNumMolPerVolTable != fAskedNumPerVolTable.end())
{
return it_askedNumMolPerVolTable->second;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
std::vector<double>* output = new std::vector<double>(materialTable->size());
ComponentMap::const_iterator it;
G4bool materialWasNotFound = true;
for(int i = 0 ; i < int(materialTable->size()) ; i++)
{
ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
it = densityTable.find(lookForMaterial);
if(it==densityTable.end())
{
(*output)[i] = 0.0;
}
else
{
materialWasNotFound = false;
(*output)[i] = it->second;
}
}
if(materialWasNotFound)
{
PrintNotAMolecularMaterial("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",lookForMaterial);
}
fAskedNumPerVolTable.insert(make_pair(lookForMaterial, output));
return output;
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The pointer fpCompDensityTable is not initialized"
<< G4endl;
G4Exception("G4DNAMolecularMaterial::InitializeNumMolPerVol",
"G4DNAMolecularMaterial002", FatalException,
exceptionDescription);
}
}
void G4DNAMolecularMaterial::PrintNotAMolecularMaterial(const char* methodName, const G4Material* lookForMaterial) const
void G4DNAMolecularMaterial::RecordMolecularMaterial(G4Material* parentMaterial,
G4Material* molecularMaterial,
G4double fraction)
{
std::map<const G4Material*,bool,CompareMaterial>::iterator it = fWarningPrinted.find(lookForMaterial);
ComponentMap& matComponent =
(*fpCompFractionTable)[parentMaterial->GetIndex()];
if(it == fWarningPrinted.end())
{
G4ExceptionDescription exceptionDescription;
exceptionDescription
<< "The material " << lookForMaterial->GetName()
<< " is not defined as a molecular material."<< G4endl
<< "Meaning: The elements should be added to the material using atom count rather than mass fraction (cf. G4Material)"
<< G4endl
<< "If you want to use DNA processes on liquid water, you should better use the NistManager to create the water material."
<< G4endl
<< "Since this message is displayed, it means that the DNA models will not be called."
<< "Please note that this message will only appear once even if you are using other methods of G4DNAMolecularMaterial."
<< G4endl;
if (matComponent.empty())
{
matComponent[molecularMaterial] = fraction;
return;
}
G4Exception(methodName,"MATERIAL_NOT_DEFINE_USING_ATOM_COUNT",JustWarning,exceptionDescription);
fWarningPrinted[lookForMaterial] = true;
}
ComponentMap::iterator it = matComponent.find(molecularMaterial);
if (it == matComponent.end())
{
matComponent[molecularMaterial] = fraction;
}
else
{
matComponent[molecularMaterial] = it->second + fraction;
}
}
void G4DNAMolecularMaterial::SearchMolecularMaterial(G4Material* parentMaterial,
G4Material* material,
double currentFraction)
{
if (material->GetMassOfMolecule() != 0.0)
{
RecordMolecularMaterial(parentMaterial, material, currentFraction);
return;
}
G4Material* compMat(0);
G4double fraction = -1;
std::map<G4Material*, G4double> matComponent = material->GetMatComponents();
std::map<G4Material*, G4double>::iterator it = matComponent.begin();
for (; it != matComponent.end(); it++)
{
compMat = it->first;
fraction = it->second;
if (compMat->GetMassOfMolecule() == 0.0)
{
SearchMolecularMaterial(parentMaterial, compMat,
currentFraction * fraction);
}
else
{
RecordMolecularMaterial(parentMaterial, compMat,
currentFraction * fraction);
}
compMat = 0;
fraction = -1;
}
}
const std::vector<double>*
G4DNAMolecularMaterial::
GetDensityTableFor(const G4Material* lookForMaterial) const
{
if (!fpCompDensityTable)
{
if (fIsInitialized)
{
G4ExceptionDescription exceptionDescription;
exceptionDescription
<< "The pointer fpCompDensityTable is not initialized will the "
"singleton of G4DNAMolecularMaterial "
<< "has already been initialized." << G4endl;
G4Exception("G4DNAMolecularMaterial::GetDensityTableFor",
"G4DNAMolecularMaterial003", FatalException,
exceptionDescription);
}
if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
{
const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription
<< "The geant4 application is at the wrong state. State must be: "
"G4State_Idle."
<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetDensityTableFor",
"G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException, exceptionDescription);
}
}
std::map<const G4Material*, std::vector<double>*, CompareMaterial>::
const_iterator it_askedDensityTable =
fAskedDensityTable.find(lookForMaterial);
if (it_askedDensityTable != fAskedDensityTable.end())
{
return it_askedDensityTable->second;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
std::vector<double>* output = new std::vector<double>(materialTable->size());
ComponentMap::const_iterator it;
G4bool materialWasNotFound = true;
for (size_t i = 0; i < fNMaterials; i++)
{
ComponentMap& densityTable = (*fpCompDensityTable)[i];
it = densityTable.find(lookForMaterial);
if (it == densityTable.end())
{
(*output)[i] = 0.0;
}
else
{
materialWasNotFound = false;
(*output)[i] = it->second;
}
}
if (materialWasNotFound)
{
PrintNotAMolecularMaterial("G4DNAMolecularMaterial::GetDensityTableFor",
lookForMaterial);
}
fAskedDensityTable.insert(make_pair(lookForMaterial, output));
return output;
}
const std::vector<double>* G4DNAMolecularMaterial::GetNumMolPerVolTableFor(
const G4Material* lookForMaterial) const
{
if (!fpCompNumMolPerVolTable)
{
if (fIsInitialized)
{
G4ExceptionDescription exceptionDescription;
exceptionDescription
<< "The pointer fpCompNumMolPerVolTable is not initialized whereas "
"the singleton of G4DNAMolecularMaterial "
<< "has already been initialized." << G4endl;
G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
"G4DNAMolecularMaterial005", FatalException,
exceptionDescription);
}
if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
{
const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
}
else
{
G4ExceptionDescription exceptionDescription;
exceptionDescription
<< "The geant4 application is at the wrong state. State must be : "
"G4State_Idle."
<< G4endl;
G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
"G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException, exceptionDescription);
}
}
std::map<const G4Material*, std::vector<double>*, CompareMaterial>::
const_iterator it_askedNumMolPerVolTable =
fAskedNumPerVolTable.find(lookForMaterial);
if (it_askedNumMolPerVolTable != fAskedNumPerVolTable.end())
{
return it_askedNumMolPerVolTable->second;
}
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
std::vector<double>* output = new std::vector<double>(materialTable->size());
ComponentMap::const_iterator it;
G4bool materialWasNotFound = true;
for (size_t i = 0; i < fNMaterials; i++)
{
ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
it = densityTable.find(lookForMaterial);
if (it == densityTable.end())
{
(*output)[i] = 0.0;
}
else
{
materialWasNotFound = false;
(*output)[i] = it->second;
}
}
if (materialWasNotFound)
{
PrintNotAMolecularMaterial(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor", lookForMaterial);
}
fAskedNumPerVolTable.insert(make_pair(lookForMaterial, output));
return output;
}
void G4DNAMolecularMaterial::
PrintNotAMolecularMaterial(const char* methodName,
const G4Material* lookForMaterial) const
{
std::map<const G4Material*, bool, CompareMaterial>::iterator it =
fWarningPrinted.find(lookForMaterial);
if (it == fWarningPrinted.end())
{
G4ExceptionDescription exceptionDescription;
exceptionDescription << "The material " << lookForMaterial->GetName()
<< " is not defined as a molecular material."
<< G4endl
<< "Meaning: The elements should be added to the "
"material using atom count rather than mass fraction "
"(cf. G4Material)"
<< G4endl
<< "If you want to use DNA processes on liquid water, you should better use "
"the NistManager to create the water material."
<< G4endl
<< "Since this message is displayed, it means that the DNA models will not "
"be called."
<< "Please note that this message will only appear once even if you are "
"using other methods of G4DNAMolecularMaterial."
<< G4endl;
G4Exception(methodName, "MATERIAL_NOT_DEFINE_USING_ATOM_COUNT", JustWarning,
exceptionDescription);
fWarningPrinted[lookForMaterial] = true;
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4DNAMolecularReactionTable.cc 74551 2013-10-14 12:59:14Z gcosmo $
// $Id: G4DNAMolecularReactionTable.cc 85244 2014-10-27 08:24:13Z gcosmo $
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
@@ -44,450 +44,568 @@
#include "G4UIcommand.hh"
#include "G4VDNAReactionModel.hh"
#include "G4MoleculeHandleManager.hh"
#include "G4MoleculeTable.hh"
using namespace std;
class IosFlagSaver
{
public:
explicit IosFlagSaver(std::ostream& _ios) :
ios(_ios), f(_ios.flags())
{
}
~IosFlagSaver()
{
ios.flags(f);
}
// IosFlagSaver(const IosFlagSaver &rhs) = delete;
// IosFlagSaver& operator= (const IosFlagSaver& rhs) = delete;
private:
std::ostream& ios;
std::ios::fmtflags f;
};
G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::fInstance(0);
//G4ThreadLocal G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::fInstance(0);
G4DNAMolecularReactionData::G4DNAMolecularReactionData():
fReactive1(),fReactive2(),
fReactionRate(0.),fReducedReactionRadius(0.),
G4DNAMolecularReactionData::G4DNAMolecularReactionData() :
fReactive1(),
fReactive2(),
fReactionRate(0.),
fReducedReactionRadius(0.),
fProducts(0)
{;}
{
;
}
G4DNAMolecularReactionData::G4DNAMolecularReactionData(G4double reactionRate,
const G4Molecule* reactive1,
const G4Molecule* reactive2):fProducts(0)
const G4Molecule* reactive1,
const G4Molecule* reactive2) :
fProducts(0)
{
fReactionRate = reactionRate;
SetReactive1(reactive1);
SetReactive2(reactive2);
fReactionRate = reactionRate;
SetReactive1(reactive1);
SetReactive2(reactive2);
G4double sumDiffCoeff(0.);
G4double sumDiffCoeff(0.);
if(*reactive1 == *reactive2)
{
sumDiffCoeff = reactive1->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate/(4*pi* reactive1->GetDiffusionCoefficient() * Avogadro);
}
else
{
sumDiffCoeff = reactive1->GetDiffusionCoefficient() + reactive2->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate/(4*pi* sumDiffCoeff * Avogadro);
}
if (*reactive1 == *reactive2)
{
sumDiffCoeff = reactive1->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate
/ (4 * pi * reactive1->GetDiffusionCoefficient() * Avogadro);
}
else
{
sumDiffCoeff = reactive1->GetDiffusionCoefficient()
+ reactive2->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate / (4 * pi * sumDiffCoeff * Avogadro);
}
}
G4DNAMolecularReactionData::G4DNAMolecularReactionData(G4double reactionRate,
const G4String& reactive1,
const G4String& reactive2) :
fProducts(0)
{
fReactionRate = reactionRate;
SetReactive1(reactive1);
SetReactive2(reactive2);
G4double sumDiffCoeff(0.);
if (*fReactive1 == *fReactive2)
{
sumDiffCoeff = fReactive1->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate
/ (4 * pi * fReactive1->GetDiffusionCoefficient() * Avogadro);
}
else
{
sumDiffCoeff = fReactive1->GetDiffusionCoefficient()
+ fReactive2->GetDiffusionCoefficient();
fReducedReactionRadius = fReactionRate / (4 * pi * sumDiffCoeff * Avogadro);
}
}
G4DNAMolecularReactionData::~G4DNAMolecularReactionData()
{
if(fProducts)
{
fProducts->clear() ;
delete fProducts;
fProducts = 0;
}
if (fProducts)
{
fProducts->clear();
delete fProducts;
fProducts = 0;
}
}
void G4DNAMolecularReactionData::SetReactive1(const G4Molecule* reactive)
{
fReactive1 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive);
// fReactive1 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive);
fReactive1 = reactive;
}
void G4DNAMolecularReactionData::SetReactive2(const G4Molecule* reactive)
{
fReactive2 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive);
// fReactive2 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive);
fReactive2 = reactive;
}
void G4DNAMolecularReactionData::SetReactive(const G4Molecule* reactive1,
const G4Molecule* reactive2)
const G4Molecule* reactive2)
{
fReactive1 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive1);
fReactive2 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive2);
// fReactive1 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive1);
// fReactive2 = G4MoleculeHandleManager::Instance()->GetMoleculeHandle(reactive2);
fReactive1 = reactive1;
fReactive2 = reactive2;
}
void G4DNAMolecularReactionData::AddProduct(const G4Molecule* molecule)
{
if(!fProducts) fProducts = new std::vector<G4MoleculeHandle>();
fProducts->push_back(G4MoleculeHandleManager::Instance()->GetMoleculeHandle(molecule));
// if(!fProducts) fProducts = new std::vector<G4MoleculeHandle>();
// fProducts->push_back(G4MoleculeHandleManager::Instance()->GetMoleculeHandle(molecule));
if (!fProducts) fProducts = new std::vector<const G4Molecule*>();
fProducts->push_back(molecule);
}
void G4DNAMolecularReactionData::SetReactive1(const G4String& reactive)
{
fReactive1 = G4MoleculeTable::Instance()->GetMoleculeModel(reactive);
}
void G4DNAMolecularReactionData::SetReactive2(const G4String& reactive)
{
fReactive2 = G4MoleculeTable::Instance()->GetMoleculeModel(reactive);
}
void G4DNAMolecularReactionData::SetReactive(const G4String& reactive1,
const G4String& reactive2)
{
fReactive1 = G4MoleculeTable::Instance()->GetMoleculeModel(reactive1);
fReactive2 = G4MoleculeTable::Instance()->GetMoleculeModel(reactive2);
}
void G4DNAMolecularReactionData::AddProduct(const G4String& molecule)
{
// if(!fProducts) fProducts = new std::vector<G4MoleculeHandle>();
if (!fProducts) fProducts = new std::vector<const G4Molecule*>();
fProducts->push_back(G4MoleculeTable::Instance()->GetMoleculeModel(molecule));
}
//_____________________________________________________________________________________
G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::GetReactionTable()
{
if(!fInstance)
{
fInstance = new G4DNAMolecularReactionTable();
}
return fInstance;
if (!fInstance)
{
fInstance = new G4DNAMolecularReactionTable();
}
return fInstance;
}
void G4DNAMolecularReactionTable::DeleteInstance()
{
// DEBUG
// DEBUG
// G4cout << "G4MolecularReactionTable::DeleteInstance" << G4endl;
if(fInstance)
delete fInstance;
fInstance = 0;
if (fInstance) delete fInstance;
fInstance = 0;
}
//_____________________________________________________________________________________
G4DNAMolecularReactionTable::G4DNAMolecularReactionTable() : G4ITReactionTable(),
G4DNAMolecularReactionTable::G4DNAMolecularReactionTable() :
G4ITReactionTable(),
fMoleculeHandleManager(G4MoleculeHandleManager::Instance())
{
// G4cout << "G4DNAMolecularReactionTable::G4DNAMolecularReactionTable()" << G4endl;
fVerbose = false;
return;
fVerbose = false;
return;
}
//_____________________________________________________________________________________
G4DNAMolecularReactionTable::~G4DNAMolecularReactionTable()
{
// DEBUG
// DEBUG
// G4cout << "G4MolecularReactionTable::~G4MolecularReactionTable" << G4endl;
ReactionDataMap::iterator it1 = fReactionData.begin();
std::map<const G4Molecule*,
const G4DNAMolecularReactionData*,
compMoleculeP>::iterator it2;
/*
ReactionDataMap::iterator it1 = fReactionData.begin();
for(;it1!=fReactionData.end();it1++)
{
for(it2 = it1->second.begin();it2 != it1->second.end();it2++)
{
const G4DNAMolecularReactionData* reactionData = it2->second;
if(reactionData)
{
const G4Molecule* reactive1 = reactionData->GetReactive1();
const G4Molecule* reactive2 = reactionData->GetReactive2();
std::map<const G4Molecule*,
const G4DNAMolecularReactionData*,
compMoleculeP>::iterator it2;
fReactionData[reactive1][reactive2] = 0;
fReactionData[reactive2][reactive1] = 0;
for(;it1!=fReactionData.end();it1++)
{
for(it2 = it1->second.begin();it2 != it1->second.end();it2++)
{
const G4DNAMolecularReactionData* reactionData = it2->second;
if(reactionData)
{
const G4Molecule* reactive1 = reactionData->GetReactive1();
const G4Molecule* reactive2 = reactionData->GetReactive2();
delete reactionData;
}
}
}
fReactionData[reactive1][reactive2] = 0;
fReactionData[reactive2][reactive1] = 0;
fReactionDataMV.clear();
fReactionData.clear();
fReactivesMV.clear();
delete reactionData;
}
}
}
*/
fReactionDataMV.clear();
fReactionData.clear();
fReactivesMV.clear();
}
//_____________________________________________________________________________________
void G4DNAMolecularReactionTable::SetReaction(G4DNAMolecularReactionData* reactionData)
{
const G4Molecule* reactive1 = reactionData->GetReactive1() ;
const G4Molecule* reactive2 = reactionData->GetReactive2() ;
const G4Molecule* reactive1 = reactionData->GetReactive1();
const G4Molecule* reactive2 = reactionData->GetReactive2();
fReactionData[reactive1][reactive2] = reactionData;
fReactivesMV[reactive1].push_back(reactive2);
fReactionDataMV[reactive1].push_back(reactionData);
fReactionData[reactive1][reactive2] = reactionData;
fReactivesMV[reactive1].push_back(reactive2);
fReactionDataMV[reactive1].push_back(reactionData);
if(reactive1 != reactive2)
{
fReactionData[reactive2][reactive1] = reactionData;
fReactivesMV[reactive2].push_back(reactive1);
fReactionDataMV[reactive2].push_back(reactionData);
}
if (reactive1 != reactive2)
{
fReactionData[reactive2][reactive1] = reactionData;
fReactivesMV[reactive2].push_back(reactive1);
fReactionDataMV[reactive2].push_back(reactionData);
}
}
//_____________________________________________________________________________________
void G4DNAMolecularReactionTable::SetReaction(G4double reactionRate,
const G4Molecule* reactive1,
const G4Molecule* reactive2)
const G4Molecule* reactive1,
const G4Molecule* reactive2)
{
G4DNAMolecularReactionData* reactionData = new G4DNAMolecularReactionData(reactionRate, reactive1, reactive2);
SetReaction(reactionData);
G4DNAMolecularReactionData* reactionData = new G4DNAMolecularReactionData(
reactionRate, reactive1, reactive2);
SetReaction(reactionData);
}
//_____________________________________________________________________________________
void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel)
{
// Print Reactions and Interaction radius for jump step = 3ps
// Print Reactions and Interaction radius for jump step = 3ps
if(pReactionModel)
IosFlagSaver iosfs(G4cout);
if (pReactionModel)
{
if (!(pReactionModel->GetReactionTable())) pReactionModel->SetReactionTable(
this);
}
ReactivesMV::iterator itReactives;
map<G4Molecule*, map<G4Molecule*, G4bool> > alreadyPrint;
G4cout << "Number of chemical species involved in reactions = "
<< fReactivesMV.size() << G4endl;
G4int nbPrintable = fReactivesMV.size() * fReactivesMV.size();
G4String *outputReaction = new G4String[nbPrintable];
G4String *outputReactionRate = new G4String[nbPrintable];
G4String *outputRange = new G4String[nbPrintable];
G4int n = 0;
for (itReactives = fReactivesMV.begin(); itReactives != fReactivesMV.end();
itReactives++)
{
G4Molecule* moleculeA = (G4Molecule*) itReactives->first;
const vector<const G4Molecule*>* reactivesVector = CanReactWith(moleculeA);
if (pReactionModel) pReactionModel->InitialiseToPrint(moleculeA);
G4int nbReactants = fReactivesMV[itReactives->first].size();
for (G4int iReact = 0; iReact < nbReactants; iReact++)
{
if(!(pReactionModel->GetReactionTable()))
pReactionModel -> SetReactionTable(this);
G4Molecule* moleculeB = (G4Molecule*) (*reactivesVector)[iReact];
const G4DNAMolecularReactionData* reactionData =
fReactionData[moleculeA][moleculeB];
//-----------------------------------------------------------
// Name of the reaction
if (!alreadyPrint[moleculeA][moleculeB])
{
outputReaction[n] = moleculeA->GetName() + " + " + moleculeB->GetName();
G4int nbProducts = reactionData->GetNbProducts();
if (nbProducts)
{
outputReaction[n] += " -> " + reactionData->GetProduct(0)->GetName();
for (G4int j = 1; j < nbProducts; j++)
{
outputReaction[n] += " + " + reactionData->GetProduct(j)->GetName();
}
}
else
{
outputReaction[n] += " -> No product";
}
//-----------------------------------------------------------
// Interaction Rate
outputReactionRate[n] = G4UIcommand::ConvertToString(
reactionData->GetReactionRate() / (1e-3 * m3 / (mole * s)));
//-----------------------------------------------------------
// Calculation of the Interaction Range
G4double interactionRange = -1;
if (pReactionModel) interactionRange =
pReactionModel->GetReactionRadius(iReact);
if (interactionRange != -1)
{
outputRange[n] = G4UIcommand::ConvertToString(
interactionRange / nanometer);
}
else
{
outputRange[n] = "";
}
alreadyPrint[moleculeB][moleculeA] = TRUE;
n++;
}
}
}
// G4cout<<"Number of possible reactions: "<< n << G4endl;
ReactivesMV::iterator itReactives;
////////////////////////////////////////////////////////////////////
// Tableau dynamique en fonction du nombre de caractere maximal dans
// chaque colonne
////////////////////////////////////////////////////////////////////
map<G4Molecule*,map<G4Molecule*, G4bool> > alreadyPrint;
G4int maxlengthOutputReaction = -1;
G4int maxlengthOutputReactionRate = -1;
G4cout<<"Nombre particules intervenants dans les reactions = "<< fReactivesMV.size() <<G4endl;
G4int nbPrintable = fReactivesMV.size()*fReactivesMV.size();
G4String *outputReaction = new G4String[nbPrintable];
G4String *outputReactionRate = new G4String[nbPrintable];
G4String *outputRange = new G4String[nbPrintable];
G4int n = 0;
for(itReactives = fReactivesMV.begin() ; itReactives != fReactivesMV.end() ; itReactives++)
for (G4int i = 0; i < n; i++)
{
if (maxlengthOutputReaction < (G4int) outputReaction[i].length())
{
G4Molecule* moleculeA = (G4Molecule*) itReactives->first;
const vector<const G4Molecule*>* reactivesVector = CanReactWith(moleculeA);
if(pReactionModel)
pReactionModel -> InitialiseToPrint(moleculeA);
G4int nbReactants = fReactivesMV[itReactives->first].size();
for(G4int iReact = 0 ; iReact < nbReactants ; iReact++)
{
G4Molecule* moleculeB = (G4Molecule*) (*reactivesVector)[iReact];
const G4DNAMolecularReactionData* reactionData = fReactionData[moleculeA][moleculeB];
//-----------------------------------------------------------
// Name of the reaction
if(!alreadyPrint[moleculeA][moleculeB])
{
outputReaction[n]=
moleculeA->GetName()
+" + " +
moleculeB->GetName();
G4int nbProducts = reactionData->GetNbProducts();
if(nbProducts)
{
outputReaction[n] += " -> "+ reactionData->GetProduct(0)->GetName();
for(G4int j = 1 ; j < nbProducts ; j++)
{
outputReaction[n]+=" + "+reactionData->GetProduct(j)->GetName();
}
}
else
{
outputReaction[n]+=" -> No product";
}
//-----------------------------------------------------------
// Interaction Rate
outputReactionRate[n] = G4UIcommand::ConvertToString(reactionData->GetReactionRate()/(1e-3*m3/(mole*s)));
//-----------------------------------------------------------
// Calculation of the Interaction Range
G4double interactionRange = -1;
if(pReactionModel)
interactionRange = pReactionModel->GetReactionRadius(iReact);
if(interactionRange!=-1)
{
outputRange[n] = G4UIcommand::ConvertToString(interactionRange/nanometer);
}
else
{
outputRange[n] = "";
}
alreadyPrint[moleculeB][moleculeA] = TRUE;
n++;
}
}
maxlengthOutputReaction = outputReaction[i].length();
}
G4cout<<"Number of possible reactions: "<< n << G4endl;
////////////////////////////////////////////////////////////////////
// Tableau dynamique en fonction du nombre de caractere maximal dans
// chaque colonne
////////////////////////////////////////////////////////////////////
G4int maxlengthOutputReaction = -1;
G4int maxlengthOutputReactionRate = -1;
for(G4int i = 0 ; i < n ; i++)
if (maxlengthOutputReactionRate < (G4int) outputReactionRate[i].length())
{
if(maxlengthOutputReaction < (G4int) outputReaction[i].length())
{
maxlengthOutputReaction = outputReaction[i].length();
}
if(maxlengthOutputReactionRate < (G4int)outputReactionRate[i].length())
{
maxlengthOutputReactionRate = outputReactionRate[i].length();
}
maxlengthOutputReactionRate = outputReactionRate[i].length();
}
}
maxlengthOutputReaction+=2;
maxlengthOutputReactionRate+=2;
maxlengthOutputReaction += 2;
maxlengthOutputReactionRate += 2;
if(maxlengthOutputReaction<10) maxlengthOutputReaction = 10;
if(maxlengthOutputReactionRate<30) maxlengthOutputReactionRate = 30;
if (maxlengthOutputReaction < 10) maxlengthOutputReaction = 10;
if (maxlengthOutputReactionRate < 30) maxlengthOutputReactionRate = 30;
G4String title[3];
G4String* title;
title[0] = "Reaction";
title[1] = "Reaction Rate [dm3/(mol*s)]";
title[2] = "Interaction Range for chosen reaction model";
if (pReactionModel) title = new G4String[3];
else title = new G4String[2];
G4cout<< setfill(' ')
<< setw(maxlengthOutputReaction) << left << title[0]
<< setw(maxlengthOutputReactionRate) << left << title[1]
<< setw(2) << left << title[2]
<< G4endl;
title[0] = "Reaction";
title[1] = "Reaction Rate [dm3/(mol*s)]";
if (pReactionModel) title[2] =
"Interaction Range for chosen reaction model [nm]";
G4cout << setfill(' ') << setw(maxlengthOutputReaction) << left << title[0]
<< setw(maxlengthOutputReactionRate) << left << title[1];
if (pReactionModel) G4cout << setw(2) << left << title[2];
G4cout << G4endl;
G4cout.fill('-');
if (pReactionModel) G4cout.width(
maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
+ (G4int) title[2].length());
else G4cout.width(maxlengthOutputReaction + 2 + maxlengthOutputReactionRate);
G4cout << "-" << G4endl;
G4cout.fill(' ');
for (G4int i = 0; i < n; i++)
{
G4cout << setw(maxlengthOutputReaction) << left << outputReaction[i]
<< setw(maxlengthOutputReactionRate) << left
<< outputReactionRate[i];
if (pReactionModel) G4cout << setw(2) << left << outputRange[i];
G4cout << G4endl;
G4cout.fill('-');
G4cout.width(maxlengthOutputReaction+2+maxlengthOutputReactionRate+2+(G4int)title[2].length());
G4cout<<"-"<<G4endl;
if (pReactionModel) G4cout.width(
maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
+ (G4int) title[2].length());
else G4cout.width(
maxlengthOutputReaction + 2 + maxlengthOutputReactionRate);
G4cout << "-" << G4endl;
G4cout.fill(' ');
}
for(G4int i = 0 ; i < n ; i ++)
{
G4cout<< setw(maxlengthOutputReaction)<< left << outputReaction[i]
<< setw(maxlengthOutputReactionRate) << left << outputReactionRate[i]
<< setw(2) << left <<outputRange[i]
<<G4endl;
G4cout.fill('-');
G4cout.width(maxlengthOutputReaction+2+maxlengthOutputReactionRate+2+(G4int)title[2].length());
G4cout<<"-"<<G4endl;
G4cout.fill(' ');
}
delete [] outputReaction;
delete [] outputReactionRate;
delete [] outputRange;
delete[] title;
delete[] outputReaction;
delete[] outputReactionRate;
delete[] outputRange;
}
//_____________________________________________________________________________________
// Get/Set methods
const G4DNAMolecularReactionData*
G4DNAMolecularReactionTable::GetReactionData(const G4Molecule* reactive1,
const G4Molecule* reactive2) const
const G4Molecule* reactive2) const
{
if(fReactionData.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
return 0;
}
if (fReactionData.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::GetReactionData", "",
FatalErrorInArgument, errMsg);
return 0;
}
ReactionDataMap::const_iterator it1 = fReactionData.find(reactive1);
ReactionDataMap::const_iterator it1 = fReactionData.find(reactive1);
if(it1 == fReactionData.end())
{
G4cout<<"Nom : " << reactive1->GetName()<<G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ reactive1 -> GetName();
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
}
if (it1 == fReactionData.end())
{
G4String errMsg =
"No reaction table was implemented for this molecule Definition : " + reactive1
->GetName();
// G4cout << "--- G4MolecularInteractionTable::GetReactionData ---" << G4endl;
// G4cout << errMsg << G4endl;
G4Exception("G4MolecularInteractionTable::GetReactionData", "",
FatalErrorInArgument, errMsg);
// return 0;
}
std::map<const G4Molecule*,
const G4DNAMolecularReactionData*,
compMoleculeP>::const_iterator it2 = it1->second.find(reactive2);
std::map<const G4Molecule*, const G4DNAMolecularReactionData*, compMoleculeP>::const_iterator it2 =
it1->second.find(reactive2);
if(it2 == it1->second.end())
{
G4cout<<"Nom : " << reactive2->GetName()<<G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ reactive2 -> GetName();
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
}
if (it2 == it1->second.end())
{
G4cout << "Nom : " << reactive2->GetName() << G4endl;
G4String errMsg = "No reaction table was implemented for this molecule : "
+ reactive2 -> GetName();
G4Exception("G4MolecularInteractionTable::GetReactionData","",FatalErrorInArgument, errMsg);
}
return (it2->second);
return (it2->second);
}
const std::vector<const G4Molecule*>*
G4DNAMolecularReactionTable::CanReactWith(const G4Molecule * aMolecule) const
{
if(fReactivesMV.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
return 0;
}
ReactivesMV::const_iterator itReactivesMap = fReactivesMV.find(aMolecule) ;
if(itReactivesMap == fReactivesMV.end())
{
G4cout<<"Nom : " << aMolecule->GetName()<<G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ aMolecule -> GetName();
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
return 0;
}
else
{
if(fVerbose)
{
G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
G4cout<<"You are checking reactants for : " << aMolecule->GetName()<<G4endl;
G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
std::vector<const G4Molecule*>::const_iterator itProductsVector =
itReactivesMap->second.begin();
for( ; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
{
G4cout<<(*itProductsVector)->GetName()<<G4endl;
}
}
return &(itReactivesMap->second);
}
if (fReactivesMV.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanReactWith", "",
FatalErrorInArgument, errMsg);
return 0;
}
ReactivesMV::const_iterator itReactivesMap = fReactivesMV.find(aMolecule);
if (itReactivesMap == fReactivesMV.end())
{
#ifdef G4VERBOSE
if (fVerbose)
{
G4String errMsg = "No reaction table was implemented for this molecule : "
+ aMolecule->GetName();
// G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
G4cout << "--- G4MolecularInteractionTable::GetReactionData ---" << G4endl;
G4cout << errMsg << G4endl;
}
#endif
return 0;
}
else
{
if(fVerbose)
{
G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
G4cout<<"You are checking reactants for : " << aMolecule->GetName()<<G4endl;
G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
std::vector<const G4Molecule*>::const_iterator itProductsVector =
itReactivesMap->second.begin();
for(; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
{
G4cout<<(*itProductsVector)->GetName()<<G4endl;
}
}
return &(itReactivesMap->second);
}
return 0;
}
//_____________________________________________________________________________________
const std::map<const G4Molecule*, const G4DNAMolecularReactionData*, compMoleculeP>*
const std::map<const G4Molecule*, const G4DNAMolecularReactionData*,
compMoleculeP>*
G4DNAMolecularReactionTable::GetReativesNData(const G4Molecule* molecule) const
{
if(fReactionData.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
return 0;
}
ReactionDataMap::const_iterator itReactivesMap = fReactionData.find(molecule) ;
if(itReactivesMap == fReactionData.end())
{
G4cout<<"Nom : " << molecule->GetName()<<G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ molecule -> GetName();
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
}
else
{
if(fVerbose)
{
G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
G4cout<<"You are checking reactants for : " << molecule->GetName()<<G4endl;
G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
std::map<const G4Molecule*,
const G4DNAMolecularReactionData*,
compMoleculeP>::const_iterator itProductsVector =
itReactivesMap->second.begin();
for( ; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
{
G4cout<<itProductsVector->first->GetName()<<G4endl;
}
}
return &(itReactivesMap->second);
}
if (fReactionData.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
FatalErrorInArgument, errMsg);
return 0;
}
ReactionDataMap::const_iterator itReactivesMap = fReactionData.find(molecule);
if (itReactivesMap == fReactionData.end())
{
G4cout << "Nom : " << molecule->GetName() << G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ molecule -> GetName();
G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
}
else
{
if(fVerbose)
{
G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
G4cout<<"You are checking reactants for : " << molecule->GetName()<<G4endl;
G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
std::map<const G4Molecule*,
const G4DNAMolecularReactionData*,
compMoleculeP>::const_iterator itProductsVector =
itReactivesMap->second.begin();
for(; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
{
G4cout<<itProductsVector->first->GetName()<<G4endl;
}
}
return &(itReactivesMap->second);
}
return 0;
}
const std::vector<const G4DNAMolecularReactionData*>*
G4DNAMolecularReactionTable::GetReactionData(const G4Molecule* molecule) const
{
if(fReactionDataMV.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
return 0 ;
}
ReactionDataMV::const_iterator it = fReactionDataMV.find(molecule) ;
if (fReactionDataMV.empty())
{
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanInteractWith", "",
FatalErrorInArgument, errMsg);
return 0;
}
ReactionDataMV::const_iterator it = fReactionDataMV.find(molecule);
if(it == fReactionDataMV.end())
{
G4cout<<"Nom : " << molecule->GetName()<<G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ molecule -> GetName();
G4Exception("G4MolecularInteractionTable::GetReactionData","",FatalErrorInArgument, errMsg);
return 0; // coverity
}
if (it == fReactionDataMV.end())
{
G4cout << "Nom : " << molecule->GetName() << G4endl;
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ molecule -> GetName();
G4Exception("G4MolecularInteractionTable::GetReactionData","",FatalErrorInArgument, errMsg);
return 0; // coverity
}
return &(it->second);
return &(it->second);
}
@@ -0,0 +1,92 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
* MoleculeGun.cc
*
* Created on: 29 janv. 2014
* Author: kara
*/
#include "G4MoleculeGun.hh"
#include "G4MoleculeTable.hh"
#include "G4Molecule.hh"
#include "G4MoleculeGunMessenger.hh"
#include <cassert>
G4MoleculeGun::G4MoleculeGun()
{
// TODO Auto-generated constructor stub
fpMessenger = new G4MoleculeGunMessenger();
}
G4MoleculeGun::~G4MoleculeGun()
{
// TODO Auto-generated destructor stub
if (fpMessenger) delete fpMessenger;
}
void G4MoleculeGun::DefineTracks()
{
fpMessenger->DefineTracks(this);
for (size_t i = 0; i < fTracks.size(); i++)
{
PushTrack(fTracks[i]);
}
fTracks.clear();
}
void G4MoleculeGun::AddMolecule(const G4String& name,
const G4ThreeVector& position,
double time)
{
G4Track* track = BuildTrack(name, position, time);
fTracks.push_back(track);
}
void G4MoleculeGun::AddNMolecules(size_t n,
const G4String& name,
const G4ThreeVector& position,
double time)
{
for (size_t i = 0; i < n; i++)
{
AddMolecule(name, position, time);
}
}
G4Track* G4MoleculeGun::BuildTrack(const G4String& name,
const G4ThreeVector& position,
double time)
{
G4Molecule* model = G4MoleculeTable::Instance()->GetMoleculeModel(name);
assert(model != 0);
G4Molecule* molecule = new G4Molecule(*model);
return molecule->BuildTrack(time, position);
}
@@ -0,0 +1,168 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
* MoleculeGunMessenger.cc
*
* Created on: 30 janv. 2014
* Author: kara
*/
#include "G4MoleculeGunMessenger.hh"
#include "G4MoleculeGun.hh"
#include "G4Tokenizer.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIdirectory.hh"
G4MoleculeGunMessenger::G4MoleculeGunMessenger()
{
fpGunDir = new G4UIdirectory("/process/em/dna/chem/gun/");
fpGunNewGunType = new G4UIcmdWithAString("/process/em/dna/chem/gun/newType",
this);
}
G4MoleculeGunMessenger::~G4MoleculeGunMessenger()
{
if (fpGunDir) delete fpGunDir;
if (fpGunNewGunType) delete fpGunNewGunType;
}
G4String G4MoleculeGunMessenger::GetCurrentValue(G4UIcommand* /*command*/)
{
return "";
}
G4MoleculeGunMessenger::MultipleGun* G4MoleculeGunMessenger::CreateNewType(const G4String& name)
{
MultipleGun* multiGun = new MultipleGun(name, this);
fMultipleGun.push_back(multiGun);
return multiGun;
}
void G4MoleculeGunMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if (command == fpGunNewGunType)
{
CreateNewType(newValue);
}
}
G4MoleculeGunMessenger::MultipleGun::MultipleGun(const G4String& name,
G4MoleculeGunMessenger*)
{
G4String dir("/process/em/dna/chem/gun/");
dir += name;
fpGunType = new G4UIdirectory(name);
G4String tmp = dir;
tmp += "/moleculeModel";
fpGunMoleculeModel = new G4UIcmdWithAString(tmp, this);
tmp = dir;
tmp += "/position";
fpGunPosition = new G4UIcmdWith3VectorAndUnit(tmp, this);
tmp = dir;
tmp += "/time";
fpGunTime = new G4UIcmdWithADoubleAndUnit(tmp, this);
tmp = dir;
tmp += "/number";
fpGunN = new G4UIcmdWithAnInteger(tmp, this);
fMoleculeName = "";
fTime = 0;
fNumber = 0;
}
G4MoleculeGunMessenger::MultipleGun::~MultipleGun()
{
if (fpGunMoleculeModel) delete fpGunMoleculeModel;
if (fpGunPosition) delete fpGunPosition;
if (fpGunTime) delete fpGunTime;
if (fpGunN) delete fpGunN;
}
void G4MoleculeGunMessenger::MultipleGun::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if (command == fpGunMoleculeModel)
{
fMoleculeName = newValue;
}
else if (command == fpGunPosition)
{
fPosition = fpGunPosition->GetNew3VectorValue(newValue);
}
else if (command == fpGunTime)
{
fTime = fpGunTime->GetNewDoubleValue(newValue);
}
else if (command == fpGunN)
{
fNumber = fpGunN->GetNewIntValue(newValue);
}
}
G4String G4MoleculeGunMessenger::MultipleGun::GetCurrentValue(G4UIcommand* command)
{
if (command == fpGunMoleculeModel)
{
return fMoleculeName;
}
else if (command == fpGunPosition)
{
return fpGunPosition->ConvertToStringWithBestUnit(fPosition);
}
else if (command == fpGunTime)
{
return fpGunTime->ConvertToStringWithBestUnit(fTime);
}
else if (command == fpGunN)
{
return fpGunN->ConvertToString(fNumber);
}
return "";
}
void G4MoleculeGunMessenger::DefineTracks(G4MoleculeGun* gun)
{
for (size_t i = 0; i < fMultipleGun.size(); i++)
{
fMultipleGun[i]->DefineTracks(gun);
}
}
void G4MoleculeGunMessenger::MultipleGun::DefineTracks(G4MoleculeGun* gun)
{
gun->AddNMolecules(fNumber, fMoleculeName, fPosition, fTime);
}
@@ -23,28 +23,28 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VDNAReactionModel.cc 64057 2012-10-30 15:04:49Z gcosmo $
// $Id: G4VDNAReactionModel.cc 85244 2014-10-27 08:24:13Z gcosmo $
//
#include "G4VDNAReactionModel.hh"
G4VDNAReactionModel::G4VDNAReactionModel()
{
fReactionTable = 0 ;
fReactionTable = 0;
}
G4VDNAReactionModel::G4VDNAReactionModel(const G4VDNAReactionModel& right)
{
fReactionTable = right.fReactionTable ;
fReactionTable = right.fReactionTable;
}
G4VDNAReactionModel::~G4VDNAReactionModel()
{
fReactionTable = 0;
fReactionTable = 0;
}
G4VDNAReactionModel& G4VDNAReactionModel::operator=(const G4VDNAReactionModel& right)
{
if(this == &right) return *this;
fReactionTable = right.fReactionTable ;
return *this;
if (this == &right) return *this;
fReactionTable = right.fReactionTable;
return *this;
}
@@ -0,0 +1,155 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/*
* G4VUserChemistryList.cc
*
* Created on: 23 oct. 2013
* Author: kara
*/
#include "G4VUserChemistryList.hh"
#include <G4VScheduler.hh>
#include "G4MoleculeTable.hh"
#include "G4MoleculeDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4DNAChemistryManager.hh"
G4VUserChemistryList::G4VUserChemistryList()
{
verboseLevel = 1;
}
G4VUserChemistryList::~G4VUserChemistryList()
{
G4DNAChemistryManager* chemMan = G4DNAChemistryManager::GetInstanceIfExists();
if (chemMan)
{
chemMan->Deregister(this);
}
}
void G4VUserChemistryList::RegisterTimeStepModel(G4VITStepModel* timeStepModel,
double startingTime)
{
G4VScheduler::Instance()->RegisterModel(timeStepModel, startingTime);
}
void G4VUserChemistryList::BuildPhysicsTable()
{
G4MoleculeTable* theMoleculeTable = G4MoleculeTable::Instance();
G4MoleculeDefinitionIterator iterator =
theMoleculeTable->GetDefintionIterator();
iterator.reset();
while (iterator())
{
G4MoleculeDefinition* moleculeDef = iterator.value();
BuildPhysicsTable(moleculeDef);
}
}
void G4VUserChemistryList::BuildPhysicsTable(G4MoleculeDefinition* moleculeDef)
{
//Get processes from master thread;
G4ProcessManager* pManager = moleculeDef->GetProcessManager();
if (!pManager)
{
#ifdef G4VERBOSE
if (verboseLevel > 0)
{
G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
<< " : No Process Manager for " << moleculeDef->GetParticleName()
<< G4endl;
G4cout << moleculeDef->GetParticleName()
<< " should be created in your PhysicsList" <<G4endl;
}
#endif
G4Exception("G4VUserChemistryList::BuildPhysicsTable",
"Run0271", FatalException,
"No process manager");
return;
}
G4ProcessManager* pManagerShadow = moleculeDef->GetMasterProcessManager();
G4ProcessVector* pVector = pManager->GetProcessList();
if (!pVector)
{
#ifdef G4VERBOSE
if (verboseLevel > 0)
{
G4cout << "G4VUserChemistryList::BuildPhysicsTable "
<< " : No Process Vector for " << moleculeDef->GetParticleName()
<< G4endl;
}
#endif
G4Exception("G4VUserChemistryList::BuildPhysicsTable",
"Run0272", FatalException,
"No process Vector");
return;
}
#ifdef G4VERBOSE
if (verboseLevel > 2)
{
G4cout << "G4VUserChemistryList::BuildPhysicsTable %%%%%% "
<< moleculeDef->GetParticleName() << G4endl;
G4cout << " ProcessManager : " << pManager
<< " ProcessManagerShadow : " << pManagerShadow << G4endl;
for(G4int iv1=0;iv1<pVector->size();iv1++)
{
G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName()
<< G4endl;
}
G4cout << "--------------------------------------------------------------"
<< G4endl;
G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
{
G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName()
<< G4endl;
}
}
#endif
for (G4int j = 0; j < pVector->size(); ++j)
{
//Andrea July 16th 2013 : migration to new interface...
//Infer if we are in a worker thread or master thread
//Master thread is the one in which the process manager
// and process manager shadow pointers are the same
if (pManagerShadow == pManager)
{
(*pVector)[j]->BuildPhysicsTable(*moleculeDef);
}
else
{
(*pVector)[j]->BuildWorkerPhysicsTable(*moleculeDef);
}
}
}