Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4DNAChemistryManager.hh 100802 2016-11-02 14:55:27Z gcosmo $
27 //
28 
29 // Author: Mathieu Karamitros
30 //
31 // The code is developed in the framework of the ESA AO7146
32 //
33 // We would be very happy hearing from you, send us your feedback! :)
34 //
35 // In order for Geant4-DNA to be maintained and still open-source,
36 // article citations are crucial.
37 // If you use Geant4-DNA chemistry and you publish papers about your software,
38 // in addition to the general paper on Geant4-DNA:
39 //
40 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
41 //
42 // we would be very happy if you could please also cite the following
43 // reference papers on chemistry:
44 //
45 // J. Comput. Phys. 274 (2014) 841-882
46 // Prog. Nucl. Sci. Tec. 2 (2011) 503-508
47 
48 #ifndef G4DNACHEMISTRYMANAGER_HH
49 #define G4DNACHEMISTRYMANAGER_HH
50 
51 #include "globals.hh"
52 #include "G4ThreeVector.hh"
53 #include <fstream>
54 #include <memory>
55 #include "G4UImessenger.hh"
56 #include "G4VStateDependent.hh"
57 
58 class G4Track;
61 class G4Molecule;
63 class G4UIcmdWithABool;
66 class G4ITGun;
67 
69 {
73 };
74 
89 {
90 protected:
91  virtual ~G4DNAChemistryManager();
92 
93 public:
94  //============================================================================
95  // STATIC METHODS
96  //============================================================================
99 
103  static void DeleteInstance();
106  static G4bool IsActivated();
107  static void Activated(G4bool flag = true);
108 
109  //============================================================================
110  // VIRTUAL METHODS
111  //============================================================================
112  virtual G4bool Notify(G4ApplicationState requestedState);
113  virtual void SetNewValue(G4UIcommand*, G4String);
114  virtual G4String GetCurrentValue(G4UIcommand * command);
115 
116  //============================================================================
117  // INITIALIZATION AND FINALIZATION METHODS
118  //============================================================================
119  void Initialize();
121  inline void Deregister(G4VUserChemistryList*);
122  void SetGlobalTemperature(double temp_K);
123 
124  inline void ForceMasterReinitialization();
125  inline void TagThreadForReinitialization();
126 
127  void Run();
128  void Clear();
129  void Gun(G4ITGun*, bool physicsTableToBuild = true);
130  inline void ForceThreadReinitialization();
131  inline void ForceRebuildingPhysicsTable();
132 
133  //============================================================================
134  // FILE OPERATIONS
135  //============================================================================
141  void WriteInto(const G4String&, std::ios_base::openmode mode =
142  std::ios_base::out);
144 
148  void CloseFile();
149 
150  //============================================================================
151  // PUSH MOLECULES
152  //============================================================================
161  G4int /*electronicLevel*/,
162  const G4Track* /*theIncomingTrack*/);
163 
169  void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
170  G4ThreeVector* finalPosition = 0);
171 
181  void PushMolecule(G4Molecule*& molecule,
182  double time,
183  const G4ThreeVector& position,
184  int parentID);
185 
195  const G4Track* /*theIncomingTrack*/);
196 
197 
198  inline void SetVerbose(G4int verbose)
199  {
200  fVerbose = verbose;
201  }
202 
203  inline void SetBuildPhysicsTable(bool flag)
204  {fBuildPhysicsTable = flag;}
205 
207  {
208  return fResetCounterWhenRunEnds;
209  }
210 
211  void ResetCounterWhenRunEnds(G4bool resetCounterWhenRunEnds)
212  {
213  fResetCounterWhenRunEnds = resetCounterWhenRunEnds;
214  }
215 
216 protected:
219  void InitializeFile();
220  void InitializeMaster();
221  void InitializeThread();
222 
224 
225 private:
226  G4UIdirectory* fpChemDNADirectory;
227  G4UIcmdWithABool* fpActivateChem;
228  G4UIcmdWithoutParameter* fpRunChem;
229  G4UIcmdWithoutParameter* fpSkipReactionsFromChemList;
230  //G4UIcmdWithADoubleAndUnit* fpGridSize;
231  G4UIcmdWithADoubleAndUnit* fpScaleForNewTemperature;
232  G4UIcmdWithoutParameter* fpInitChem;
233 
234  static G4DNAChemistryManager* fgInstance;
235 // static bool fActiveChemistry;
236  bool fActiveChemistry;
237  G4bool fFileInitialized;
238  G4bool fWriteFile;
239  static G4ThreadLocal std::ofstream* fpgOutput_tl;
240  static G4ThreadLocal G4bool* fpgThreadInitialized_tl;
241  G4bool fMasterInitialized;
242  G4bool fForceThreadReinitialization;
243 
244  G4DNAWaterExcitationStructure* fpExcitationLevel;
245  G4DNAWaterIonisationStructure* fpIonisationLevel;
246 
247  G4VUserChemistryList* fpUserChemistryList;
248  G4bool fBuildPhysicsTable;
249  G4bool fPhysicsTableBuilt;
250  G4bool fSkipReactions;
251 
252  G4bool fGeometryClosed;
253 
254  G4int fVerbose;
255  G4bool fResetCounterWhenRunEnds;
256 };
257 
259 {
260  fPhysicsTableBuilt = false;
261 }
262 
264 {
265  fpUserChemistryList = chemistryList;
266  Activated();
267 }
268 
270 {
271  if (fpUserChemistryList == chemistryList) fpUserChemistryList = 0;
272 }
273 
275 {
276  fMasterInitialized = false;
278 }
279 
281 {
282  // TODO
283  fForceThreadReinitialization = true;
284 }
285 
287 {
288  if (fpgThreadInitialized_tl) delete fpgThreadInitialized_tl;
289 }
290 
291 #endif // G4DNACHEMISTRYMANAGER_HH
void Deregister(G4VUserChemistryList *)
void WriteInto(const G4String &, std::ios_base::openmode mode=std::ios_base::out)
void PushMoleculeAtParentTimeAndPlace(G4Molecule *&molecule, const G4Track *)
void CreateSolvatedElectron(const G4Track *, G4ThreeVector *finalPosition=0)
ElectronicModification
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
G4DNAWaterExcitationStructure * GetExcitationLevel()
void SetChemistryList(G4VUserChemistryList *)
virtual G4bool Notify(G4ApplicationState requestedState)
virtual void SetNewValue(G4UIcommand *, G4String)
void PushMolecule(G4Molecule *&molecule, double time, const G4ThreeVector &position, int parentID)
G4bool IsCounterResetWhenRunEnds() const
bool G4bool
Definition: G4Types.hh:79
void SetGlobalTemperature(double temp_K)
virtual G4String GetCurrentValue(G4UIcommand *command)
void SetVerbose(G4int verbose)
static G4DNAChemistryManager * Instance()
void CreateWaterMolecule(ElectronicModification, G4int, const G4Track *)
void ResetCounterWhenRunEnds(G4bool resetCounterWhenRunEnds)
void SetBuildPhysicsTable(bool flag)
static void Activated(G4bool flag=true)
void Gun(G4ITGun *, bool physicsTableToBuild=true)
static G4DNAChemistryManager * GetInstanceIfExists()
G4DNAWaterIonisationStructure * GetIonisationLevel()
G4ApplicationState