Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user