Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/dna/utils/src/G4DNAChemistryManager.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/dna/utils/src/G4DNAChemistryManager.cc (Version 11.3.0) and /processes/electromagnetic/dna/utils/src/G4DNAChemistryManager.cc (Version 9.5.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 // Author: Mathieu Karamitros (kara@cenbg.in2p     27 // Author: Mathieu Karamitros (kara@cenbg.in2p3.fr)
 28 //                                                 28 //
 29 // WARNING : This class is released as a proto     29 // WARNING : This class is released as a prototype.
 30 // It might strongly evolve or even disappear  <<  30 // It might strongly evolve or even disapear in the next releases.
 31 //                                                 31 //
 32 // History:                                        32 // History:
 33 // -----------                                     33 // -----------
 34 // 10 Oct 2011 M.Karamitros created                34 // 10 Oct 2011 M.Karamitros created
 35 //                                                 35 //
 36 // -------------------------------------------     36 // -------------------------------------------------------------------
 37                                                    37 
 38 #include "G4DNAChemistryManager.hh"                38 #include "G4DNAChemistryManager.hh"
 39                                                <<  39 #include "G4Molecule.hh"
 40 #include "G4AutoLock.hh"                       <<  40 #include "G4ITStepManager.hh"
                                                   >>  41 #include "G4H2O.hh"
 41 #include "G4DNAMolecularReactionTable.hh"          42 #include "G4DNAMolecularReactionTable.hh"
 42 #include "G4DNAWaterExcitationStructure.hh"    <<  43 #include "G4WaterExcitationStructure.hh"
 43 #include "G4DNAWaterIonisationStructure.hh"    <<  44 #include "G4WaterIonisationStructure.hh"
 44 #include "G4Electron_aq.hh"                        45 #include "G4Electron_aq.hh"
 45 #include "G4GeometryManager.hh"                <<  46 #include "G4ITManager.hh"
 46 #include "G4H2O.hh"                            << 
 47 #include "G4MolecularConfiguration.hh"             47 #include "G4MolecularConfiguration.hh"
 48 #include "G4Molecule.hh"                       << 
 49 #include "G4MoleculeFinder.hh"                 << 
 50 #include "G4MoleculeTable.hh"                  << 
 51 #include "G4PhysChemIO.hh"                     << 
 52 #include "G4Scheduler.hh"                      << 
 53 #include "G4StateManager.hh"                   << 
 54 #include "G4SystemOfUnits.hh"                  << 
 55 #include "G4UIcmdWithABool.hh"                 << 
 56 #include "G4UIcmdWithADoubleAndUnit.hh"        << 
 57 #include "G4UIcmdWithAnInteger.hh"             << 
 58 #include "G4UIcmdWithoutParameter.hh"          << 
 59 #include "G4VITTrackHolder.hh"                 << 
 60 #include "G4VMoleculeCounter.hh"               << 
 61 #include "G4VUserChemistryList.hh"             << 
 62 #include "G4VUserPulseInfo.hh"                 << 
 63                                                << 
 64 #include <memory>                              << 
 65                                                << 
 66 G4DNAChemistryManager* G4DNAChemistryManager:: << 
 67                                                << 
 68 G4ThreadLocal G4DNAChemistryManager::ThreadLoc << 
 69     G4DNAChemistryManager::fpThreadData = null << 
 70                                                << 
 71 G4Mutex chemManExistence;                      << 
 72                                                << 
 73 //-------------------------------------------- << 
 74                                                << 
 75 G4DNAChemistryManager::ThreadLocalData::Thread << 
 76 {                                              << 
 77     fpPhysChemIO = nullptr;                    << 
 78     fThreadInitialized = false;                << 
 79 }                                              << 
 80                                                << 
 81 //-------------------------------------------- << 
 82                                                    48 
 83 G4DNAChemistryManager::ThreadLocalData::~Threa <<  49 using namespace std;
 84 {                                              << 
 85     fpThreadData = nullptr;                    << 
 86 }                                              << 
 87                                                << 
 88 //-------------------------------------------- << 
 89                                                << 
 90 void G4DNAChemistryManager::SetPhysChemIO(std: << 
 91 {                                              << 
 92     fpThreadData->fpPhysChemIO = std::move(pPh << 
 93 }                                              << 
 94                                                    50 
 95 //-------------------------------------------- <<  51 auto_ptr<G4DNAChemistryManager> G4DNAChemistryManager::fInstance(0);
 96                                                    52 
 97 //-------------------------------------------- <<  53 G4DNAChemistryManager::G4DNAChemistryManager() :
 98 /*                                             <<  54     fActiveChemistry(false)
 99  * The chemistry manager is shared between thr << 
100  * It is initialized both on the master thread << 
101  */                                            << 
102 //-------------------------------------------- << 
103 G4DNAChemistryManager::G4DNAChemistryManager() << 
104         :                                      << 
105          fpChemDNADirectory(new G4UIdirectory( << 
106         , fpActivateChem(new G4UIcmdWithABool( << 
107         , fpRunChem(new G4UIcmdWithAnInteger(" << 
108         , fpSkipReactionsFromChemList(new G4UI << 
109         , fpScaleForNewTemperature(new G4UIcmd << 
110         , fpInitChem(new G4UIcmdWithoutParamet << 
111         ,                                      << 
112          fpExcitationLevel(nullptr)            << 
113         , fpIonisationLevel(nullptr)           << 
114         , fpUserChemistryList(nullptr)         << 
115 {                                                  55 {
116     fpRunChem->SetParameterName("Number of run <<  56     fExcitationLevel = 0;
117                                 "(this works w <<  57     fIonisationLevel = 0;
118     fpRunChem->SetDefaultValue(1);             <<  58     fWriteFile       = false;
119     fpScaleForNewTemperature->SetUnitCategory( << 
120 }                                                  59 }
121                                                    60 
122 //-------------------------------------------- << 
123                                                << 
124 G4DNAChemistryManager* G4DNAChemistryManager::     61 G4DNAChemistryManager* G4DNAChemistryManager::Instance()
125 {                                                  62 {
126     if (fgInstance == nullptr)                 <<  63     if(!fInstance.get()) fInstance = auto_ptr<G4DNAChemistryManager>(new G4DNAChemistryManager());
127     {                                          <<  64     return fInstance.get();
128         G4AutoLock lock(&chemManExistence);    << 
129         if (fgInstance == nullptr) // MT : dou << 
130         {                                      << 
131             fgInstance = new G4DNAChemistryMan << 
132         }                                      << 
133         lock.unlock();                         << 
134     }                                          << 
135                                                << 
136     // make sure thread local data is initiali << 
137     if (fpThreadData == nullptr)               << 
138     {                                          << 
139         fpThreadData = new ThreadLocalData();  << 
140     }                                          << 
141                                                << 
142     assert(fpThreadData != nullptr);           << 
143                                                << 
144     return fgInstance;                         << 
145 }                                              << 
146                                                << 
147 //-------------------------------------------- << 
148                                                << 
149 G4DNAChemistryManager* G4DNAChemistryManager:: << 
150 {                                              << 
151     return fgInstance;                         << 
152 }                                                  65 }
153                                                    66 
154 //-------------------------------------------- << 
155                                                << 
156 G4DNAChemistryManager::~G4DNAChemistryManager(     67 G4DNAChemistryManager::~G4DNAChemistryManager()
157 {                                                  68 {
158     Clear();                                   <<  69     if (fOutput.is_open())
159     fgInstance = nullptr;                      << 
160 }                                              << 
161                                                << 
162 //-------------------------------------------- << 
163                                                << 
164 void G4DNAChemistryManager::Clear()            << 
165 {                                              << 
166     fpIonisationLevel.reset();                 << 
167     fpExcitationLevel.reset();                 << 
168                                                << 
169     if (fpUserChemistryList)                   << 
170     {                                              70     {
171         Deregister(*fpUserChemistryList);      <<  71         fOutput.close();
172     }                                              72     }
173                                                <<  73     if(fIonisationLevel) delete fIonisationLevel;
174     fpChemDNADirectory.reset();                <<  74     if(fExcitationLevel) delete fExcitationLevel;
175     fpActivateChem.reset();                    << 
176     fpRunChem.reset();                         << 
177                                                << 
178     fpSkipReactionsFromChemList.reset();       << 
179     fpInitChem.reset();                        << 
180                                                << 
181     if (fpThreadData != nullptr)               << 
182     {                                          << 
183         delete fpThreadData;                   << 
184         fpThreadData = nullptr;                << 
185     }                                          << 
186                                                << 
187     G4DNAMolecularReactionTable::DeleteInstanc     75     G4DNAMolecularReactionTable::DeleteInstance();
                                                   >>  76     G4MoleculeHandleManager::DeleteInstance();
188     G4MolecularConfiguration::DeleteManager();     77     G4MolecularConfiguration::DeleteManager();
189     G4VMoleculeCounter::DeleteInstance();      <<  78     fInstance.release();
190 }                                                  79 }
191                                                    80 
192 //-------------------------------------------- << 
193                                                << 
194 void G4DNAChemistryManager::DeleteInstance()       81 void G4DNAChemistryManager::DeleteInstance()
195 {                                                  82 {
196     G4AutoLock lock(&chemManExistence);        <<  83     if(fInstance.get())
197                                                <<  84         fInstance.reset();
198     if (fgInstance != nullptr)                 << 
199     {                                          << 
200         G4DNAChemistryManager* pDeleteMe = fgI << 
201         fgInstance = nullptr;                  << 
202         lock.unlock();                         << 
203         delete pDeleteMe;                      << 
204     }                                          << 
205     else                                       << 
206     {                                          << 
207         G4cerr << "G4DNAChemistryManager alrea << 
208     }                                          << 
209     lock.unlock();                             << 
210 }                                              << 
211                                                << 
212 //-------------------------------------------- << 
213                                                << 
214 G4bool G4DNAChemistryManager::Notify(G4Applica << 
215 {                                              << 
216     if (requestedState == G4State_Quit)        << 
217     {                                          << 
218         if (fVerbose != 0)                     << 
219         {                                      << 
220             G4cout << "G4DNAChemistryManager:: << 
221                    << G4endl;                  << 
222         }                                      << 
223         Clear();                               << 
224     }                                          << 
225     else if (requestedState == G4State_GeomClo << 
226     {                                          << 
227         fGeometryClosed = true;                << 
228     }                                          << 
229     else if (requestedState == G4State_Idle)   << 
230     {                                          << 
231         InitializeThreadSharedData();          << 
232     }                                          << 
233                                                << 
234     return true;                               << 
235 }                                              << 
236                                                << 
237 //-------------------------------------------- << 
238                                                << 
239 void G4DNAChemistryManager::SetNewValue(G4UIco << 
240 {                                              << 
241     if (pCommand == fpActivateChem.get())      << 
242     {                                          << 
243         SetChemistryActivation(G4UIcmdWithABoo << 
244     }                                          << 
245     else if (pCommand == fpRunChem.get())      << 
246     {                                          << 
247         int nbExec = value.empty() ? 1 : G4UIc << 
248         for (int i = 0 ; i < nbExec ; ++i)     << 
249         {                                      << 
250             Run();                             << 
251         }                                      << 
252     }                                          << 
253     else if (pCommand == fpSkipReactionsFromCh << 
254     {                                          << 
255         fSkipReactions = true;                 << 
256     }                                          << 
257     else if (pCommand == fpScaleForNewTemperat << 
258     {                                          << 
259         SetGlobalTemperature(fpScaleForNewTemp << 
260     }                                          << 
261     else if (pCommand == fpInitChem.get())     << 
262     {                                          << 
263         Initialize();                          << 
264         InitializeThread();                    << 
265     }                                          << 
266 }                                              << 
267                                                << 
268 //-------------------------------------------- << 
269                                                << 
270 G4String G4DNAChemistryManager::GetCurrentValu << 
271 {                                              << 
272     if (pCommand == fpActivateChem.get())      << 
273     {                                          << 
274         return G4UIcmdWithABool::ConvertToStri << 
275     }                                          << 
276     if (pCommand == fpScaleForNewTemperature.g << 
277     {                                          << 
278         return fpScaleForNewTemperature->Conve << 
279     }                                          << 
280     if (pCommand == fpSkipReactionsFromChemLis << 
281     {                                          << 
282         return G4UIcmdWithABool::ConvertToStri << 
283     }                                          << 
284                                                << 
285     return "";                                 << 
286 }                                                  85 }
287                                                    86 
288 //-------------------------------------------- << 
289                                                << 
290 void G4DNAChemistryManager::InitializeThreadSh << 
291 {                                              << 
292     if (!G4Threading::IsMasterThread())        << 
293     {                                          << 
294         return;                                << 
295     }                                          << 
296                                                << 
297     G4MoleculeTable::Instance()->PrepareMolecu << 
298     G4MoleculeTable::Instance()->Finalize();   << 
299 }                                              << 
300                                                << 
301 //-------------------------------------------- << 
302 void G4DNAChemistryManager::Run()              << 
303 {                                              << 
304     if (!fActiveChemistry)                     << 
305     {                                          << 
306         return;                                << 
307     }                                          << 
308                                                << 
309     InitializeThread();                        << 
310                                                << 
311     if (!fMasterInitialized)                   << 
312     {                                          << 
313         G4ExceptionDescription description;    << 
314         description << "Global components were << 
315         G4Exception("G4DNAChemistryManager::Ru << 
316                     description);              << 
317     }                                          << 
318                                                << 
319     if (!fpThreadData->fThreadInitialized)     << 
320     {                                          << 
321         G4ExceptionDescription description;    << 
322         description << "Thread local component << 
323         G4Exception("G4DNAChemistryManager::Ru << 
324                     description);              << 
325     }                                          << 
326                                                << 
327     G4MoleculeTable::Instance()->Finalize();   << 
328     G4Scheduler::Instance()->Process();        << 
329     if (fResetCounterWhenRunEnds)              << 
330     {                                          << 
331         G4VMoleculeCounter::Instance()->ResetC << 
332     }                                          << 
333     CloseFile();                               << 
334 }                                              << 
335                                                << 
336 //-------------------------------------------- << 
337                                                << 
338 void G4DNAChemistryManager::UseAsStandalone(G4 << 
339 {                                              << 
340     fUseInStandalone = flag;                   << 
341 }                                              << 
342                                                << 
343 //-------------------------------------------- << 
344                                                << 
345 void G4DNAChemistryManager::SetGun(G4ITGun* pC << 
346 {                                              << 
347     G4Scheduler::Instance()->SetGun(pChemGun); << 
348 }                                              << 
349                                                << 
350 //-------------------------------------------- << 
351                                                << 
352 void G4DNAChemistryManager::Initialize()       << 
353 {                                              << 
354     //======================================== << 
355     // MT MODE                                 << 
356     //======================================== << 
357     if (G4Threading::IsMultithreadedApplicatio << 
358     {                                          << 
359         //==================================== << 
360         // ON WORKER THREAD                    << 
361         //==================================== << 
362         if (G4Threading::IsWorkerThread())     << 
363         {                                      << 
364             InitializeThread(); // Will create << 
365             return;                            << 
366         }                                      << 
367         //==================================== << 
368         // ON MASTER THREAD                    << 
369         //==================================== << 
370                                                << 
371         InitializeMaster();                    << 
372         InitializeThreadSharedData();          << 
373         return;                                << 
374     }                                          << 
375     //======================================== << 
376     // IS NOT IN MT MODE                       << 
377     //======================================== << 
378                                                << 
379     InitializeMaster();                        << 
380     InitializeThreadSharedData();              << 
381     // In this case: InitializeThread is calle << 
382     return;                                    << 
383 }                                              << 
384                                                << 
385 //-------------------------------------------- << 
386                                                << 
387 void G4DNAChemistryManager::InitializeMaster() << 
388 {                                              << 
389     if (fMasterInitialized)                    << 
390     {                                          << 
391         return;                                << 
392     }                                          << 
393                                                << 
394     if (fVerbose != 0)                         << 
395     {                                          << 
396         G4cout << "G4DNAChemistryManager::Init << 
397     }                                          << 
398                                                << 
399                                                << 
400     if (fpUserChemistryList == nullptr)        << 
401     {                                          << 
402         G4ExceptionDescription description;    << 
403         description << "No user chemistry list << 
404         G4Exception("G4DNAChemistryManager::In << 
405                     FatalException, descriptio << 
406     }else                                      << 
407     {                                          << 
408       fpUserChemistryList->ConstructDissociati << 
409       if (!fSkipReactions)                     << 
410       {                                        << 
411           fpUserChemistryList->ConstructReacti << 
412       }                                        << 
413       else                                     << 
414       {                                        << 
415           G4DNAMolecularReactionTable::GetReac << 
416       }                                        << 
417     }                                          << 
418                                                << 
419     G4Scheduler::Instance();                   << 
420     // creates a concrete object of the schedu << 
421     fMasterInitialized = true;                 << 
422 }                                              << 
423                                                << 
424 //-------------------------------------------- << 
425                                                << 
426 void G4DNAChemistryManager::HandleStandaloneIn << 
427 {                                              << 
428     if (!fUseInStandalone || fPhysicsTableBuil << 
429     {                                          << 
430         return;                                << 
431     }                                          << 
432                                                << 
433     if (fVerbose != 0)                         << 
434     {                                          << 
435         G4cout << "G4DNAChemistryManager: Buil << 
436                   "molecule definition only."  << 
437                << G4endl;                      << 
438     }                                          << 
439                                                << 
440     fpUserChemistryList->BuildPhysicsTable();  << 
441                                                << 
442     if (!fGeometryClosed)                      << 
443     {                                          << 
444         if (fVerbose != 0)                     << 
445         {                                      << 
446             G4cout << "G4DNAChemistryManager:  << 
447         }                                      << 
448                                                << 
449         G4GeometryManager* pGeomManager = G4Ge << 
450         pGeomManager->OpenGeometry();          << 
451         pGeomManager->CloseGeometry(true, true << 
452         fGeometryClosed = true;                << 
453     }                                          << 
454                                                << 
455     fPhysicsTableBuilt = true;                 << 
456 }                                              << 
457                                                << 
458 //-------------------------------------------- << 
459                                                << 
460 void G4DNAChemistryManager::InitializeThread() << 
461 {                                              << 
462     if (fpThreadData->fThreadInitialized && !f << 
463     {                                          << 
464         return;                                << 
465     }                                          << 
466                                                << 
467     if (fpUserChemistryList == nullptr)        << 
468     {                                          << 
469         G4ExceptionDescription description;    << 
470         description << "No user chemistry list << 
471         G4Exception("G4DNAChemistryManager::In << 
472                     FatalException, descriptio << 
473     }else                                      << 
474     {                                          << 
475         HandleStandaloneInitialization();// To << 
476         fpUserChemistryList->ConstructTimeStep << 
477     }                                          << 
478                                                << 
479     if (fVerbose != 0)                         << 
480     {                                          << 
481         G4cout << "G4DNAChemistryManager::Init << 
482                << G4endl;                      << 
483     }                                          << 
484                                                << 
485     G4Scheduler::Instance()->Initialize();     << 
486                                                << 
487     fpThreadData->fThreadInitialized = true;   << 
488                                                << 
489     G4VMoleculeCounter::InitializeInstance();  << 
490                                                << 
491     InitializeFile();                          << 
492 }                                              << 
493                                                << 
494 //-------------------------------------------- << 
495                                                << 
496 void G4DNAChemistryManager::InitializeFile()   << 
497 {                                              << 
498     if (fVerbose != 0)                         << 
499     {                                          << 
500         G4cout << "G4DNAChemistryManager::Init << 
501                << G4endl;                      << 
502     }                                          << 
503                                                << 
504     if (fpThreadData->fpPhysChemIO)            << 
505     {                                          << 
506         fpThreadData->fpPhysChemIO->Initialize << 
507     }                                          << 
508 }                                              << 
509                                                << 
510 //-------------------------------------------- << 
511                                                << 
512 G4bool G4DNAChemistryManager::IsActivated()    << 
513 {                                              << 
514     return fgInstance != nullptr ? fgInstance- << 
515 }                                              << 
516                                                << 
517 //-------------------------------------------- << 
518                                                << 
519 G4bool G4DNAChemistryManager::IsChemistryActiv << 
520 {                                              << 
521     return fActiveChemistry;                   << 
522 }                                              << 
523                                                << 
524 //-------------------------------------------- << 
525                                                << 
526 void G4DNAChemistryManager::SetChemistryActiva << 
527 {                                              << 
528     fActiveChemistry = flag;                   << 
529 }                                              << 
530                                                << 
531 //-------------------------------------------- << 
532                                                << 
533 void G4DNAChemistryManager::WriteInto(const G4     87 void G4DNAChemistryManager::WriteInto(const G4String& output,
534                                       std::ios <<  88                                       ios_base::openmode mode)
535 {                                                  89 {
536     if (fVerbose != 0)                         <<  90     fOutput.open(output.data(), mode);
537     {                                          <<  91     fOutput << std::setprecision(6) << std::scientific;
538         G4cout << "G4DNAChemistryManager: Writ << 
539                << output.data() << G4endl;     << 
540     }                                          << 
541                                                << 
542     if (!fpThreadData->fpPhysChemIO)           << 
543     {                                          << 
544         fpThreadData->fpPhysChemIO = std::make << 
545     }                                          << 
546                                                << 
547     fpThreadData->fpPhysChemIO->WriteInto(outp << 
548                                                    92 
                                                   >>  93     fOutput << setw(11) << left << "#Parent ID"
                                                   >>  94             << setw(10) << "Molecule"
                                                   >>  95             << setw(14) << "Elec Modif"
                                                   >>  96             << setw(13) << "Energy (eV)"
                                                   >>  97             << setw(22) << "X pos of parent [nm]"
                                                   >>  98             << setw(22) << "Y pos of parent [nm]"
                                                   >>  99             << setw(22) << "Z pos of parent [nm]"
                                                   >> 100             << setw(14) << "X pos [nm]"
                                                   >> 101             << setw(14) << "Y pos [nm]"
                                                   >> 102             << setw(14) << "Z pos [nm]"
                                                   >> 103             << G4endl
                                                   >> 104             << setw(21) << "#"
                                                   >> 105             << setw(13) << "1)io/ex=0/1"
                                                   >> 106             << G4endl
                                                   >> 107             << setw(21) << "#"
                                                   >> 108             << setw(13) << "2)level=0...5"
                                                   >> 109             << G4endl;
                                                   >> 110     fWriteFile = true;
549 }                                                 111 }
550                                                   112 
551 //-------------------------------------------- << 
552                                                << 
553 void G4DNAChemistryManager::AddEmptyLineInOutp << 
554 {                                              << 
555     if (fpThreadData->fpPhysChemIO)            << 
556     {                                          << 
557         fpThreadData->fpPhysChemIO->AddEmptyLi << 
558     }                                          << 
559 }                                              << 
560                                                << 
561 //-------------------------------------------- << 
562                                                << 
563 void G4DNAChemistryManager::CloseFile()           113 void G4DNAChemistryManager::CloseFile()
564 {                                                 114 {
565     if (fpThreadData->fpPhysChemIO)            << 115     if (fOutput.is_open())
566     {                                             116     {
567         fpThreadData->fpPhysChemIO->CloseFile( << 117         fOutput.close();
568     }                                             118     }
                                                   >> 119     fWriteFile = false;
569 }                                                 120 }
570                                                   121 
571 //-------------------------------------------- << 122 G4WaterExcitationStructure* G4DNAChemistryManager::GetExcitationLevel()
572                                                << 
573 G4DNAWaterExcitationStructure* G4DNAChemistryM << 
574 {                                                 123 {
575     if (!fpExcitationLevel)                    << 124     if(!fExcitationLevel)
576     {                                             125     {
577         fpExcitationLevel = std::make_unique<G << 126         fExcitationLevel = new G4WaterExcitationStructure;
578     }                                             127     }
579     return fpExcitationLevel.get();            << 128     return fExcitationLevel;
580 }                                                 129 }
581                                                   130 
582 //-------------------------------------------- << 131 G4WaterIonisationStructure* G4DNAChemistryManager::GetIonisationLevel()
583                                                << 
584 G4DNAWaterIonisationStructure* G4DNAChemistryM << 
585 {                                                 132 {
586     if (!fpIonisationLevel)                    << 133     if(!fIonisationLevel)
587     {                                             134     {
588         fpIonisationLevel = std::make_unique<G << 135         fIonisationLevel = new G4WaterIonisationStructure;
589     }                                             136     }
590     return fpIonisationLevel.get();            << 137     return fIonisationLevel;
591 }                                                 138 }
592                                                   139 
593 //-------------------------------------------- << 
594                                                << 
595 void G4DNAChemistryManager::CreateWaterMolecul    140 void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modification,
596                                                   141                                                 G4int electronicLevel,
597                                                << 142                                                 const G4Track* theIncomingTrack)
598 {                                                 143 {
599     if (fpThreadData->fpPhysChemIO)            << 144     if(fWriteFile)
600     {                                             145     {
601         G4double energy = -1.;                    146         G4double energy = -1.;
602                                                   147 
603         switch (modification)                     148         switch (modification)
604         {                                         149         {
605         case eDissociativeAttachment:          << 150         case fExcitedMolecule :
606             energy = 0.;                       << 
607             break;                             << 
608         case eExcitedMolecule:                 << 
609             energy = GetExcitationLevel()->Exc    151             energy = GetExcitationLevel()->ExcitationEnergy(electronicLevel);
610             break;                                152             break;
611         case eIonizedMolecule:                 << 153         case fIonizedMolecule :
612             energy = GetIonisationLevel()->Ion    154             energy = GetIonisationLevel()->IonisationEnergy(electronicLevel);
613             break;                                155             break;
614         }                                         156         }
615                                                   157 
616         fpThreadData->fpPhysChemIO->CreateWate << 158         fOutput << setw(11) << left << theIncomingTrack->GetTrackID()
617                                                << 159                 << setw(10) << "H2O"
618                                                << 160                 << left << modification
619                                                << 161                 << internal <<":"
                                                   >> 162                 << right <<electronicLevel
                                                   >> 163                 << left
                                                   >> 164                 << setw(11) << ""
                                                   >> 165                 << std::setprecision(2) << std::fixed
                                                   >> 166                 << setw(13) << energy/eV
                                                   >> 167                 << std::setprecision(6) << std::scientific
                                                   >> 168                 << setw(22) << (theIncomingTrack->GetPosition().x())/nanometer
                                                   >> 169                 << setw(22) << (theIncomingTrack->GetPosition().y())/nanometer
                                                   >> 170                 << setw(22) << (theIncomingTrack->GetPosition().z())/nanometer
                                                   >> 171                 << G4endl;
620     }                                             172     }
621                                                   173 
622     if (fActiveChemistry)                      << 174     if(fActiveChemistry)
623     {                                             175     {
624         auto  pH2OMolecule = new G4Molecule(G4 << 176         G4Molecule * H2O = new G4Molecule (G4H2O::Definition());
625                                                   177 
626         switch (modification)                     178         switch (modification)
627         {                                         179         {
628         case eDissociativeAttachment:          << 180         case fExcitedMolecule :
629             pH2OMolecule->AddElectron(5, 1);   << 181             H2O -> ExciteMolecule(electronicLevel);
630             break;                             << 
631         case eExcitedMolecule:                 << 
632             pH2OMolecule->ExciteMolecule(4 - e << 
633             break;                                182             break;
634         case eIonizedMolecule:                 << 183         case fIonizedMolecule :
635             pH2OMolecule->IonizeMolecule(4 - e << 184             H2O -> IonizeMolecule(electronicLevel);
636             break;                                185             break;
637         }                                         186         }
638                                                   187 
639         G4double delayedTime = 0.;             << 188         G4Track * H2OTrack = H2O->BuildTrack(1*picosecond,
640         if(pIncomingTrack->GetUserInformation( << 189                                              theIncomingTrack->GetPosition());
641         {                                      << 
642             auto pPulseInfo = dynamic_cast<G4V << 
643               (pIncomingTrack->GetUserInformat << 
644             if(pPulseInfo != nullptr)          << 
645             {                                  << 
646                 delayedTime = pPulseInfo->GetD << 
647             }                                  << 
648         }                                      << 
649                                                   190 
650         G4Track* pH2OTrack = pH2OMolecule->Bui << 191         H2OTrack -> SetParentID(theIncomingTrack->GetTrackID());
651                                                << 192         H2OTrack -> SetTrackStatus(fStopButAlive);
                                                   >> 193         H2OTrack -> SetKineticEnergy(0.);
652                                                   194 
653         pH2OTrack->SetParentID(pIncomingTrack- << 195         G4ITStepManager::Instance()->PushTrack(H2OTrack);
654         pH2OTrack->SetTrackStatus(fStopButAliv << 
655         pH2OTrack->SetKineticEnergy(0.);       << 
656         PushTrack(pH2OTrack);                  << 
657     }                                             196     }
658 }                                                 197 }
659                                                   198 
660 //-------------------------------------------- << 199 void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* theIncomingTrack,
661 // pFinalPosition is optional                  << 200                                                    G4ThreeVector* finalPosition)
662 void G4DNAChemistryManager::CreateSolvatedElec << 
663                                                << 
664 {                                                 201 {
665     if (fpThreadData->fpPhysChemIO)            << 202     if(fWriteFile)
666     {                                             203     {
667         fpThreadData->fpPhysChemIO->CreateSolv << 204         fOutput << setw(11)<< theIncomingTrack->GetTrackID()
668                                                << 205                 << setw(10)<< "e_aq"
669     }                                          << 206                 << setw(14)<< -1
                                                   >> 207                 << std::setprecision(2) << std::fixed
                                                   >> 208                 << setw(13)<< theIncomingTrack->GetKineticEnergy()/eV
                                                   >> 209                 << std::setprecision(6) << std::scientific
                                                   >> 210                 << setw(22)<< (theIncomingTrack->GetPosition().x())/nanometer
                                                   >> 211                 << setw(22)<< (theIncomingTrack->GetPosition().y())/nanometer
                                                   >> 212                 << setw(22)<< (theIncomingTrack->GetPosition().z())/nanometer  ;
670                                                   213 
671     if (fActiveChemistry)                      << 214         if(finalPosition != 0)
672     {                                          << 
673         G4double delayedTime = 0.;             << 
674         if(pIncomingTrack->GetUserInformation( << 
675         {                                         215         {
676             auto pPulseInfo = dynamic_cast<G4V << 216             fOutput<< setw(14)<< (finalPosition->x())/nanometer
677               (pIncomingTrack->GetUserInformat << 217                    << setw(14)<< (finalPosition->y())/nanometer
678             if(pPulseInfo != nullptr)          << 218                    << setw(14)<< (finalPosition->z())/nanometer ;
679             {                                  << 
680                 delayedTime = pPulseInfo->GetD << 
681             }                                  << 
682         }                                         219         }
683                                                   220 
684         PushMolecule(std::make_unique<G4Molecu << 221         fOutput << G4endl;
685                      picosecond + delayedTime, << 
686                      pFinalPosition != nullptr << 
687                      pIncomingTrack->GetTrackI << 
688     }                                             222     }
689 }                                              << 
690                                                << 
691 //-------------------------------------------- << 
692                                                << 
693 void G4DNAChemistryManager::PushMolecule(std:: << 
694                                          doubl << 
695                                          const << 
696                                          int p << 
697 {                                              << 
698     assert(fActiveChemistry                    << 
699            && "To inject chemical species, the << 
700               "Check chemistry activation befo << 
701     G4Track* pTrack = pMolecule->BuildTrack(ti << 
702     pTrack->SetTrackStatus(fAlive);            << 
703     pTrack->SetParentID(parentID);             << 
704     pMolecule.release();                       << 
705     PushTrack(pTrack);                         << 
706 }                                              << 
707                                                << 
708 //-------------------------------------------- << 
709                                                << 
710 void G4DNAChemistryManager::SetGlobalTemperatu << 
711 {                                              << 
712     G4MolecularConfiguration::SetGlobalTempera << 
713     G4DNAMolecularReactionTable::Instance()->S << 
714 }                                              << 
715                                                   223 
716 //-------------------------------------------- << 224     if(fActiveChemistry)
717 // [[deprecated]] : chemistry list should neve << 
718 void G4DNAChemistryManager::SetChemistryList(G << 
719 {                                              << 
720     fpUserChemistryList.reset(pChemistryList); << 
721     fOwnChemistryList = false;                 << 
722     SetChemistryActivation(true);              << 
723 }                                              << 
724                                                << 
725 void G4DNAChemistryManager::SetChemistryList(G << 
726 {                                              << 
727     fpUserChemistryList.reset(&chemistryList); << 
728     fOwnChemistryList = false;                 << 
729     SetChemistryActivation(true);              << 
730 }                                              << 
731                                                << 
732 void G4DNAChemistryManager::SetChemistryList(s << 
733 {                                              << 
734     fpUserChemistryList = std::move(pChemistry << 
735     fOwnChemistryList = true;                  << 
736     SetChemistryActivation(true);              << 
737 }                                              << 
738                                                << 
739 //-------------------------------------------- << 
740                                                << 
741 void G4DNAChemistryManager::Deregister(G4VUser << 
742 {                                              << 
743     if (fpUserChemistryList.get() == &chemistr << 
744     {                                             225     {
745         if (!fpUserChemistryList->IsPhysicsCon << 226         G4Molecule* e_aq = new G4Molecule(G4Electron_aq::Definition());
746         {                                      << 227         G4Track * e_aqTrack = e_aq->BuildTrack(picosecond,theIncomingTrack->GetPosition());
747             fpUserChemistryList.reset();       << 228         e_aqTrack -> SetTrackStatus(fAlive);
748         }                                      << 229         e_aqTrack -> SetParentID(theIncomingTrack->GetTrackID());
749                                                << 230         G4ITStepManager::Instance()->PushTrack(e_aqTrack);
750         fpUserChemistryList.release();         << 231         G4ITManager<G4Molecule>::Instance()->Push(e_aqTrack);
751     }                                             232     }
752 }                                              << 
753                                                << 
754 //-------------------------------------------- << 
755                                                << 
756 void G4DNAChemistryManager::PushTrack(G4Track* << 
757 {                                              << 
758     G4ITTrackHolder::Instance()->Push(pTrack); << 
759 }                                              << 
760                                                << 
761 //-------------------------------------------- << 
762                                                << 
763 void G4DNAChemistryManager::SetVerbose(G4int v << 
764 {                                              << 
765     fVerbose = verbose;                        << 
766 }                                              << 
767                                                << 
768 //-------------------------------------------- << 
769                                                << 
770 G4bool G4DNAChemistryManager::IsCounterResetWh << 
771 {                                              << 
772     return fResetCounterWhenRunEnds;           << 
773 }                                              << 
774                                                << 
775 //-------------------------------------------- << 
776                                                << 
777 void G4DNAChemistryManager::ResetCounterWhenRu << 
778 {                                              << 
779     fResetCounterWhenRunEnds = resetCounterWhe << 
780 }                                              << 
781                                                << 
782 //-------------------------------------------- << 
783                                                << 
784 void G4DNAChemistryManager::ForceRebuildingPhy << 
785 {                                              << 
786     fPhysicsTableBuilt = false;                << 
787 }                                              << 
788                                                << 
789 //-------------------------------------------- << 
790                                                << 
791 void G4DNAChemistryManager::ForceMasterReiniti << 
792 {                                              << 
793     fMasterInitialized = false;                << 
794     InitializeMaster();                        << 
795 }                                              << 
796                                                << 
797 //-------------------------------------------- << 
798                                                << 
799 void G4DNAChemistryManager::ForceThreadReiniti << 
800 {                                              << 
801     fForceThreadReinitialization = true;       << 
802 }                                              << 
803                                                << 
804 //-------------------------------------------- << 
805                                                << 
806 void G4DNAChemistryManager::TagThreadForReinit << 
807 {                                              << 
808     fpThreadData->fThreadInitialized = false;  << 
809 }                                                 233 }
810                                                   234