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 11.0.p4)


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