Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAChemistryManager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27
28// Author: Mathieu Karamitros
29//
30// The code is developed in the framework of the ESA AO7146
31//
32// We would be very happy hearing from you, send us your feedback! :)
33//
34// In order for Geant4-DNA to be maintained and still open-source,
35// article citations are crucial.
36// If you use Geant4-DNA chemistry and you publish papers about your software,
37// in addition to the general paper on Geant4-DNA:
38//
39// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
40//
41// we would be very happy if you could please also cite the following
42// reference papers on chemistry:
43//
44// J. Comput. Phys. 274 (2014) 841-882
45// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
46
47#pragma once
48
49#include "globals.hh"
50#include "G4ThreeVector.hh"
51#include <fstream>
52#include <memory>
53#include "G4UImessenger.hh"
54#include "G4VStateDependent.hh"
55
56class G4Track;
59class G4Molecule;
65class G4ITGun;
66class G4VPhysChemIO;
67
69{
73};
74
75/**
76 * WARNING: THIS CLASS IS A PROTOTYPE
77 * G4DNAChemistryManager is called from the physics models.
78 * It creates the water molecules and the solvated electrons and
79 * and send them to G4ITStepManager to be treated in the chemistry stage.
80 * For this, the fActiveChemistry flag needs to be on.
81 * It is also possible to give already molecule's pointers already built.
82 * G4DNAChemistryManager will then be in charge of creating the track and loading
83 * it to the IT system.
84 * The user can also ask to create a file containing a information about the
85 * creation of water molecules and solvated electrons.
86 */
89{
90protected:
91 ~G4DNAChemistryManager() override;
92
93public:
94 //============================================================================
95 // STATIC METHODS
96 //============================================================================
99
100 static void DeleteInstance();
101 static G4bool IsActivated();
102
103 //============================================================================
104 // VIRTUAL METHODS
105 //============================================================================
106 // G4VStateDependent
107 G4bool Notify(G4ApplicationState requestedState) override;
108 // G4UImessenger
109 void SetNewValue(G4UIcommand*, G4String) override;
110 G4String GetCurrentValue(G4UIcommand* pCommand) override;
111
112 //============================================================================
113 // INITIALIZATION AND FINALIZATION METHODS
114 //============================================================================
117
118 /** Chemistry list is managed outside the chemistry manager (eg. constructor). */
120
121 /** Not a constructor or when used in standalone? Prefer this method. */
122 void SetChemistryList(std::unique_ptr<G4VUserChemistryList>);
123
124 // [[deprecated]] : chemistry list should never be nullptr
126
128
129 void Initialize();
130 void Run();
131 void Clear();
132
133 /**
134 * @brief Inject custom species to the simulation
135 * @details This method should be called per thread, possibly from
136 * ActionInitialisation::Build.
137 * One can decide to set the same gun for all threads.
138 * It is the user responsibility to handle the pointer deletion.
139 */
140 void SetGun(G4ITGun* pChemSpeciesGun);
141
142 void SetPhysChemIO(std::unique_ptr<G4VPhysChemIO> pPhysChemIO);
143
144 void SetVerbose(G4int verbose);
145
146 /**
147 * If the chemistry module is used in standalone (ie. without running the physics
148 * stage beforehand), the physics table still needs to be built.
149 * It is therefore necessary to flag the chemistry module as being run
150 * in standalone.
151 */
152 void UseAsStandalone(G4bool flag);
154
155 void ResetCounterWhenRunEnds(G4bool resetCounterWhenRunEnds);
156
161
162 //============================================================================
163 // FILE OPERATIONS
164 //============================================================================
165 /**
166 * Tells the chemMan to write into a file
167 * the position and electronic state of the water molecule
168 * and the position thermalized or not of the solvated electron
169 */
170 void WriteInto(const G4String&, std::ios_base::openmode mode =
171 std::ios_base::out);
173
174 /**
175 * Close the file specified with WriteInto
176 */
177 void CloseFile();
178
179 //============================================================================
180 // PUSH MOLECULES
181 //============================================================================
182 /**
183 * Method used by DNA physics model to create a water molecule.
184 * The ElectronicModification is a flag telling whether the molecule
185 * is ionized or excited, the electronic level is calculated by the
186 * model and the IncomingTrack is the track responsible for the creation
187 * of this molecule (electron, proton...).
188 */
190 G4int /*electronicLevel*/,
191 const G4Track* /*pIncomingTrack*/);
192
193 /**
194 * This method should be used by the physics model of the ElectronSolvatation
195 * process.
196 */
197 void CreateSolvatedElectron(const G4Track* /*pIncomingTrack*/,
198 G4ThreeVector* pFinalPosition = nullptr);
199
200 void PushMolecule(std::unique_ptr<G4Molecule> pMolecule,
201 G4double time,
202 const G4ThreeVector& position,
203 G4int parentID);
204
205protected:
207 void PushTrack(G4Track*);
208 void SetGlobalTemperature(G4double temperatureKelvin);
209
212 void InitializeFile();
213 void InitializeMaster();
214 void InitializeThread();
216
218
219private:
220 std::unique_ptr<G4UIdirectory> fpChemDNADirectory;
221 std::unique_ptr<G4UIcmdWithABool> fpActivateChem;
222 std::unique_ptr<G4UIcmdWithAnInteger> fpRunChem;
223 std::unique_ptr<G4UIcmdWithoutParameter> fpSkipReactionsFromChemList;
224 std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpScaleForNewTemperature;
225 std::unique_ptr<G4UIcmdWithoutParameter> fpInitChem;
226
227 static G4DNAChemistryManager* fgInstance;
228 G4bool fActiveChemistry;
229
230 struct ThreadLocalData{
231 ThreadLocalData();
232 ~ThreadLocalData();
233 std::unique_ptr<G4VPhysChemIO> fpPhysChemIO;
234 G4bool fThreadInitialized = false;
235 };
236
237 static G4ThreadLocal ThreadLocalData* fpThreadData;
238
239 G4bool fMasterInitialized;
240 G4bool fForceThreadReinitialization;
241
242 std::unique_ptr<G4DNAWaterExcitationStructure> fpExcitationLevel;
243 std::unique_ptr<G4DNAWaterIonisationStructure> fpIonisationLevel;
244
245 std::unique_ptr<G4VUserChemistryList> fpUserChemistryList;
246 G4bool fOwnChemistryList;
247 G4bool fUseInStandalone;
248 G4bool fPhysicsTableBuilt;
249 G4bool fSkipReactions;
250
251 G4bool fGeometryClosed;
252
253 G4int fVerbose;
254 G4bool fResetCounterWhenRunEnds;
255};
G4ApplicationState
ElectronicModification
@ eIonizedMolecule
@ eDissociativeAttachment
@ eExcitedMolecule
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void SetPhysChemIO(std::unique_ptr< G4VPhysChemIO > pPhysChemIO)
G4String GetCurrentValue(G4UIcommand *pCommand) override
G4bool IsCounterResetWhenRunEnds() const
void CreateSolvatedElectron(const G4Track *, G4ThreeVector *pFinalPosition=nullptr)
static G4DNAChemistryManager * GetInstanceIfExists()
static G4DNAChemistryManager * Instance()
void UseAsStandalone(G4bool flag)
void SetChemistryList(G4VUserChemistryList &)
void PushMolecule(std::unique_ptr< G4Molecule > pMolecule, G4double time, const G4ThreeVector &position, G4int parentID)
void ResetCounterWhenRunEnds(G4bool resetCounterWhenRunEnds)
void SetGlobalTemperature(G4double temperatureKelvin)
void SetGun(G4ITGun *pChemSpeciesGun)
Inject custom species to the simulation.
G4DNAWaterIonisationStructure * GetIonisationLevel()
void Deregister(G4VUserChemistryList &)
G4DNAWaterExcitationStructure * GetExcitationLevel()
void SetNewValue(G4UIcommand *, G4String) override
G4bool Notify(G4ApplicationState requestedState) override
void SetVerbose(G4int verbose)
void WriteInto(const G4String &, std::ios_base::openmode mode=std::ios_base::out)
void CreateWaterMolecule(ElectronicModification, G4int, const G4Track *)
#define G4ThreadLocal
Definition: tls.hh:77