Geant4 11.4.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
57
58class G4Track;
59class G4Run;
62class G4Molecule;
68class G4ITGun;
69class G4VPhysChemIO;
70
77
78/**
79 * WARNING: THIS CLASS IS A PROTOTYPE
80 * G4DNAChemistryManager is called from the physics models.
81 * It creates the water molecules and the solvated electrons and
82 * and send them to G4ITStepManager to be treated in the chemistry stage.
83 * For this, the fActiveChemistry flag needs to be on.
84 * It is also possible to give already molecule's pointers already built.
85 * G4DNAChemistryManager will then be in charge of creating the track and loading
86 * it to the IT system.
87 * The user can also ask to create a file containing a information about the
88 * creation of water molecules and solvated electrons.
89 */
92{
93protected:
94 ~G4DNAChemistryManager() override;
95
96public:
97 //============================================================================
98 // STATIC METHODS
99 //============================================================================
102
103 static void DeleteInstance();
104 static G4bool IsActivated();
105
106 //============================================================================
107 // VIRTUAL METHODS
108 //============================================================================
109 // G4VStateDependent
110 G4bool Notify(G4ApplicationState requestedState) override;
111 // G4UImessenger
112 void SetNewValue(G4UIcommand*, G4String) override;
113 G4String GetCurrentValue(G4UIcommand* pCommand) override;
114
115 //============================================================================
116 // INITIALIZATION AND FINALIZATION METHODS
117 //============================================================================
120
121 /** Chemistry list is managed outside the chemistry manager (eg. constructor). */
123
124 /** Not a constructor or when used in standalone? Prefer this method. */
125 void SetChemistryList(std::unique_ptr<G4VUserChemistryList>);
126
127 // [[deprecated]] : chemistry list should never be nullptr
129
131
132 void Initialize();
133 void Run();
134 void Clear();
135
136 /**
137 * @brief Inject custom species to the simulation
138 * @details This method should be called per thread, possibly from
139 * ActionInitialisation::Build.
140 * One can decide to set the same gun for all threads.
141 * It is the user responsibility to handle the pointer deletion.
142 */
143 void SetGun(G4ITGun* pChemSpeciesGun);
144
145 void SetPhysChemIO(std::unique_ptr<G4VPhysChemIO> pPhysChemIO);
146
147 void SetVerbose(G4int verbose);
148
149 /**
150 * If the chemistry module is used in standalone (ie. without running the physics
151 * stage beforehand), the physics table still needs to be built.
152 * It is therefore necessary to flag the chemistry module as being run
153 * in standalone.
154 */
155 void UseAsStandalone(G4bool flag);
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 const G4Track *parentTrack = nullptr);
205
206 //============================================================================
207 // Methods called by RunManagers to notify of Runs & Events
208 //============================================================================
209 void BeginOfEventAction(const G4Event*);
210 void BeginOfRunAction(const G4Run*);
211 void EndOfEventAction(const G4Event*);
212 void EndOfRunAction(const G4Run*);
213
214protected:
216 void PushTrack(G4Track*);
217 void SetGlobalTemperature(G4double temperatureKelvin);
218
221 void InitializeFile();
222 void InitializeMaster();
223 void InitializeThread();
225
227
228private:
229 std::unique_ptr<G4UIdirectory> fpChemDNADirectory;
230 std::unique_ptr<G4UIcmdWithABool> fpActivateChem;
231 std::unique_ptr<G4UIcmdWithAnInteger> fpRunChem;
232 std::unique_ptr<G4UIcmdWithoutParameter> fpSkipReactionsFromChemList;
233 std::unique_ptr<G4UIcmdWithADoubleAndUnit> fpScaleForNewTemperature;
234 std::unique_ptr<G4UIcmdWithoutParameter> fpInitChem;
235
236 static G4DNAChemistryManager* fgInstance;
237 G4bool fActiveChemistry{false};
238
239 struct ThreadLocalData{
240 ThreadLocalData();
241 ~ThreadLocalData();
242 std::unique_ptr<G4VPhysChemIO> fpPhysChemIO;
243 G4bool fThreadInitialized = false;
244 };
245
246 static G4ThreadLocal ThreadLocalData* fpThreadData;
247
248 G4bool fMasterInitialized{false};
249 G4bool fForceThreadReinitialization{false};
250
251 std::unique_ptr<G4DNAWaterExcitationStructure> fpExcitationLevel;
252 std::unique_ptr<G4DNAWaterIonisationStructure> fpIonisationLevel;
253
254 std::unique_ptr<G4VUserChemistryList> fpUserChemistryList;
255 G4bool fOwnChemistryList{false};
256 G4bool fUseInStandalone{false};
257 G4bool fPhysicsTableBuilt{false};
258 G4bool fSkipReactions{false};
259
260 G4bool fGeometryClosed{false};
261
262 G4int fVerbose{0};
263};
G4ApplicationState
ElectronicModification
@ eIonizedMolecule
@ eDissociativeAttachment
@ eExcitedMolecule
CLHEP::Hep3Vector G4ThreeVector
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
void CreateSolvatedElectron(const G4Track *, G4ThreeVector *pFinalPosition=nullptr)
void EndOfEventAction(const G4Event *)
static G4DNAChemistryManager * GetInstanceIfExists()
void BeginOfEventAction(const G4Event *)
static G4DNAChemistryManager * Instance()
void UseAsStandalone(G4bool flag)
void SetChemistryList(G4VUserChemistryList &)
void PushMolecule(std::unique_ptr< G4Molecule > pMolecule, G4double time, const G4ThreeVector &position, G4int parentID, const G4Track *parentTrack=nullptr)
void SetGlobalTemperature(G4double temperatureKelvin)
void SetGun(G4ITGun *pChemSpeciesGun)
Inject custom species to the simulation.
G4DNAWaterIonisationStructure * GetIonisationLevel()
void Deregister(G4VUserChemistryList &)
G4DNAWaterExcitationStructure * GetExcitationLevel()
void EndOfRunAction(const G4Run *)
void SetNewValue(G4UIcommand *, G4String) override
G4bool Notify(G4ApplicationState requestedState) override
void SetVerbose(G4int verbose)
void BeginOfRunAction(const G4Run *)
void WriteInto(const G4String &, std::ios_base::openmode mode=std::ios_base::out)
void CreateWaterMolecule(ElectronicModification, G4int, const G4Track *)
Definition G4Run.hh:48
G4UImessenger()=default
G4VStateDependent(G4bool bottom=false)
#define G4ThreadLocal
Definition tls.hh:77