Geant4 Cross Reference |
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 // $Id: G4DNAChemistryManager.cc 75583 2013-11-04 12:16:46Z gcosmo $ 26 // 27 // 27 // Author: Mathieu Karamitros (kara@cenbg.in2p 28 // Author: Mathieu Karamitros (kara@cenbg.in2p3.fr) 28 // 29 // 29 // WARNING : This class is released as a proto 30 // WARNING : This class is released as a prototype. 30 // It might strongly evolve or even disappear << 31 // It might strongly evolve or even disapear in the next releases. 31 // 32 // 32 // History: 33 // History: 33 // ----------- 34 // ----------- 34 // 10 Oct 2011 M.Karamitros created 35 // 10 Oct 2011 M.Karamitros created 35 // 36 // 36 // ------------------------------------------- 37 // ------------------------------------------------------------------- 37 38 38 #include "G4DNAChemistryManager.hh" 39 #include "G4DNAChemistryManager.hh" 39 << 40 #include "G4SystemOfUnits.hh" 40 #include "G4AutoLock.hh" << 41 #include "G4Molecule.hh" >> 42 #include "G4ITTrackHolder.hh" >> 43 #include "G4H2O.hh" 41 #include "G4DNAMolecularReactionTable.hh" 44 #include "G4DNAMolecularReactionTable.hh" 42 #include "G4DNAWaterExcitationStructure.hh" 45 #include "G4DNAWaterExcitationStructure.hh" 43 #include "G4DNAWaterIonisationStructure.hh" 46 #include "G4DNAWaterIonisationStructure.hh" 44 #include "G4Electron_aq.hh" 47 #include "G4Electron_aq.hh" 45 #include "G4GeometryManager.hh" << 48 #include "G4ITManager.hh" 46 #include "G4H2O.hh" << 47 #include "G4MolecularConfiguration.hh" 49 #include "G4MolecularConfiguration.hh" 48 #include "G4Molecule.hh" << 50 #include "G4MoleculeCounter.hh" 49 #include "G4MoleculeFinder.hh" << 51 #include "G4Tokenizer.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" << 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 53 68 G4ThreadLocal G4DNAChemistryManager::ThreadLoc << 54 using namespace std; 69 G4DNAChemistryManager::fpThreadData = null << 70 55 >> 56 auto_ptr<G4DNAChemistryManager> G4DNAChemistryManager::fInstance ; >> 57 G4ThreadLocal std::ofstream* G4DNAChemistryManager::fOutput = 0; 71 G4Mutex chemManExistence; 58 G4Mutex chemManExistence; 72 59 73 //-------------------------------------------- << 60 G4DNAChemistryManager::G4DNAChemistryManager() : 74 << 61 fActiveChemistry(false) 75 G4DNAChemistryManager::ThreadLocalData::Thread << 76 { 62 { 77 fpPhysChemIO = nullptr; << 63 fExcitationLevel = 0; 78 fThreadInitialized = false; << 64 fIonisationLevel = 0; >> 65 fWriteFile = false; 79 } 66 } 80 67 81 //-------------------------------------------- << 82 << 83 G4DNAChemistryManager::ThreadLocalData::~Threa << 84 { << 85 fpThreadData = nullptr; << 86 } << 87 << 88 //-------------------------------------------- << 89 << 90 void G4DNAChemistryManager::SetPhysChemIO(std: << 91 { << 92 fpThreadData->fpPhysChemIO = std::move(pPh << 93 } << 94 << 95 //-------------------------------------------- << 96 << 97 //-------------------------------------------- << 98 /* << 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 { << 116 fpRunChem->SetParameterName("Number of run << 117 "(this works w << 118 fpRunChem->SetDefaultValue(1); << 119 fpScaleForNewTemperature->SetUnitCategory( << 120 } << 121 << 122 //-------------------------------------------- << 123 << 124 G4DNAChemistryManager* G4DNAChemistryManager:: 68 G4DNAChemistryManager* G4DNAChemistryManager::Instance() 125 { 69 { 126 if (fgInstance == nullptr) << 70 if (fInstance.get() == 0) 127 { << 71 { 128 G4AutoLock lock(&chemManExistence); << 72 G4AutoLock lock(&chemManExistence); 129 if (fgInstance == nullptr) // MT : dou << 73 if(fInstance.get() == 0) // MT : double check at initialisation 130 { << 74 { 131 fgInstance = new G4DNAChemistryMan << 75 fInstance = auto_ptr<G4DNAChemistryManager> (new G4DNAChemistryManager()) ; 132 } << 76 } 133 lock.unlock(); << 77 lock.unlock(); 134 } << 78 } 135 << 79 return fInstance.get(); 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 } 80 } 153 81 154 //-------------------------------------------- << 155 << 156 G4DNAChemistryManager::~G4DNAChemistryManager( 82 G4DNAChemistryManager::~G4DNAChemistryManager() 157 { 83 { 158 Clear(); << 84 if(fIonisationLevel) delete fIonisationLevel; 159 fgInstance = nullptr; << 85 if(fExcitationLevel) delete fExcitationLevel; 160 } << 86 G4DNAMolecularReactionTable::DeleteInstance(); 161 << 87 G4MoleculeHandleManager::DeleteInstance(); 162 //-------------------------------------------- << 88 G4MolecularConfiguration::DeleteManager(); 163 << 89 fInstance.release(); 164 void G4DNAChemistryManager::Clear() << 90 G4MoleculeCounter::DeleteInstance(); 165 { << 166 fpIonisationLevel.reset(); << 167 fpExcitationLevel.reset(); << 168 << 169 if (fpUserChemistryList) << 170 { << 171 Deregister(*fpUserChemistryList); << 172 } << 173 << 174 fpChemDNADirectory.reset(); << 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 << 188 G4MolecularConfiguration::DeleteManager(); << 189 G4VMoleculeCounter::DeleteInstance(); << 190 } 91 } 191 92 192 //-------------------------------------------- << 193 << 194 void G4DNAChemistryManager::DeleteInstance() 93 void G4DNAChemistryManager::DeleteInstance() 195 { 94 { 196 G4AutoLock lock(&chemManExistence); << 95 G4AutoLock lock(&chemManExistence); 197 << 96 if(fInstance.get()) 198 if (fgInstance != nullptr) << 97 { 199 { << 98 fInstance.reset(); 200 G4DNAChemistryManager* pDeleteMe = fgI << 99 } 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 } << 287 << 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 } 100 } 493 101 494 //-------------------------------------------- << 495 << 496 void G4DNAChemistryManager::InitializeFile() 102 void G4DNAChemistryManager::InitializeFile() 497 { 103 { 498 if (fVerbose != 0) << 104 *fOutput << std::setprecision(6) << std::scientific; 499 { << 105 *fOutput << setw(11) << left << "#Parent ID" 500 G4cout << "G4DNAChemistryManager::Init << 106 << setw(10) << "Molecule" 501 << G4endl; << 107 << setw(14) << "Elec Modif" 502 } << 108 << setw(13) << "Energy (eV)" 503 << 109 << setw(22) << "X pos of parent [nm]" 504 if (fpThreadData->fpPhysChemIO) << 110 << setw(22) << "Y pos of parent [nm]" 505 { << 111 << setw(22) << "Z pos of parent [nm]" 506 fpThreadData->fpPhysChemIO->Initialize << 112 << setw(14) << "X pos [nm]" 507 } << 113 << setw(14) << "Y pos [nm]" 508 } << 114 << setw(14) << "Z pos [nm]" 509 << 115 << G4endl 510 //-------------------------------------------- << 116 << setw(21) << "#" 511 << 117 << setw(13) << "1)io/ex=0/1" 512 G4bool G4DNAChemistryManager::IsActivated() << 118 << G4endl 513 { << 119 << setw(21) << "#" 514 return fgInstance != nullptr ? fgInstance- << 120 << setw(13) << "2)level=0...5" >> 121 << G4endl; 515 } 122 } 516 123 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 124 void G4DNAChemistryManager::WriteInto(const G4String& output, 534 std::ios << 125 ios_base::openmode mode) 535 { 126 { 536 if (fVerbose != 0) << 127 fOutput = new std::ofstream(); 537 { << 128 fOutput->open(output.data(), mode); 538 G4cout << "G4DNAChemistryManager: Writ << 129 fWriteFile = true; 539 << output.data() << G4endl; << 540 } << 541 << 542 if (!fpThreadData->fpPhysChemIO) << 543 { << 544 fpThreadData->fpPhysChemIO = std::make << 545 } << 546 << 547 fpThreadData->fpPhysChemIO->WriteInto(outp << 548 << 549 } << 550 << 551 //-------------------------------------------- << 552 << 553 void G4DNAChemistryManager::AddEmptyLineInOutp << 554 { << 555 if (fpThreadData->fpPhysChemIO) << 556 { << 557 fpThreadData->fpPhysChemIO->AddEmptyLi << 558 } << 559 } 130 } 560 131 561 //-------------------------------------------- << 562 << 563 void G4DNAChemistryManager::CloseFile() 132 void G4DNAChemistryManager::CloseFile() 564 { 133 { 565 if (fpThreadData->fpPhysChemIO) << 134 if (fOutput->is_open()) 566 { << 135 { 567 fpThreadData->fpPhysChemIO->CloseFile( << 136 fOutput->close(); 568 } << 137 } 569 } << 570 138 571 //-------------------------------------------- << 139 fWriteFile = false; >> 140 } 572 141 573 G4DNAWaterExcitationStructure* G4DNAChemistryM 142 G4DNAWaterExcitationStructure* G4DNAChemistryManager::GetExcitationLevel() 574 { 143 { 575 if (!fpExcitationLevel) << 144 if(!fExcitationLevel) 576 { << 145 { 577 fpExcitationLevel = std::make_unique<G << 146 fExcitationLevel = new G4DNAWaterExcitationStructure; 578 } << 147 } 579 return fpExcitationLevel.get(); << 148 return fExcitationLevel; 580 } 149 } 581 150 582 //-------------------------------------------- << 583 << 584 G4DNAWaterIonisationStructure* G4DNAChemistryM 151 G4DNAWaterIonisationStructure* G4DNAChemistryManager::GetIonisationLevel() 585 { 152 { 586 if (!fpIonisationLevel) << 153 if(!fIonisationLevel) 587 { << 154 { 588 fpIonisationLevel = std::make_unique<G << 155 fIonisationLevel = new G4DNAWaterIonisationStructure; 589 } << 156 } 590 return fpIonisationLevel.get(); << 157 return fIonisationLevel; 591 } 158 } 592 159 593 //-------------------------------------------- << 594 << 595 void G4DNAChemistryManager::CreateWaterMolecul 160 void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modification, 596 << 161 G4int electronicLevel, 597 << 162 const G4Track* theIncomingTrack) 598 { << 599 if (fpThreadData->fpPhysChemIO) << 600 { << 601 G4double energy = -1.; << 602 << 603 switch (modification) << 604 { << 605 case eDissociativeAttachment: << 606 energy = 0.; << 607 break; << 608 case eExcitedMolecule: << 609 energy = GetExcitationLevel()->Exc << 610 break; << 611 case eIonizedMolecule: << 612 energy = GetIonisationLevel()->Ion << 613 break; << 614 } << 615 << 616 fpThreadData->fpPhysChemIO->CreateWate << 617 << 618 << 619 << 620 } << 621 << 622 if (fActiveChemistry) << 623 { << 624 auto pH2OMolecule = new G4Molecule(G4 << 625 << 626 switch (modification) << 627 { << 628 case eDissociativeAttachment: << 629 pH2OMolecule->AddElectron(5, 1); << 630 break; << 631 case eExcitedMolecule: << 632 pH2OMolecule->ExciteMolecule(4 - e << 633 break; << 634 case eIonizedMolecule: << 635 pH2OMolecule->IonizeMolecule(4 - e << 636 break; << 637 } << 638 << 639 G4double delayedTime = 0.; << 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 << 652 << 653 pH2OTrack->SetParentID(pIncomingTrack- << 654 pH2OTrack->SetTrackStatus(fStopButAliv << 655 pH2OTrack->SetKineticEnergy(0.); << 656 PushTrack(pH2OTrack); << 657 } << 658 } << 659 << 660 //-------------------------------------------- << 661 // pFinalPosition is optional << 662 void G4DNAChemistryManager::CreateSolvatedElec << 663 << 664 { << 665 if (fpThreadData->fpPhysChemIO) << 666 { << 667 fpThreadData->fpPhysChemIO->CreateSolv << 668 << 669 } << 670 << 671 if (fActiveChemistry) << 672 { << 673 G4double delayedTime = 0.; << 674 if(pIncomingTrack->GetUserInformation( << 675 { << 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 << 688 } << 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 << 716 //-------------------------------------------- << 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 { << 745 if (!fpUserChemistryList->IsPhysicsCon << 746 { << 747 fpUserChemistryList.reset(); << 748 } << 749 << 750 fpUserChemistryList.release(); << 751 } << 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 { 163 { 808 fpThreadData->fThreadInitialized = false; << 164 if(fWriteFile) >> 165 { >> 166 G4double energy = -1.; >> 167 >> 168 switch (modification) >> 169 { >> 170 case eDissociativeAttachment: >> 171 energy = -1; >> 172 break; >> 173 case eExcitedMolecule : >> 174 energy = GetExcitationLevel()->ExcitationEnergy(electronicLevel); >> 175 break; >> 176 case eIonizedMolecule : >> 177 energy = GetIonisationLevel()->IonisationEnergy(electronicLevel); >> 178 break; >> 179 } >> 180 >> 181 *fOutput << setw(11) << left << theIncomingTrack->GetTrackID() >> 182 << setw(10) << "H2O" >> 183 << left << modification >> 184 << internal <<":" >> 185 << right <<electronicLevel >> 186 << left >> 187 << setw(11) << "" >> 188 << std::setprecision(2) << std::fixed >> 189 << setw(13) << energy/eV >> 190 << std::setprecision(6) << std::scientific >> 191 << setw(22) << (theIncomingTrack->GetPosition().x())/nanometer >> 192 << setw(22) << (theIncomingTrack->GetPosition().y())/nanometer >> 193 << setw(22) << (theIncomingTrack->GetPosition().z())/nanometer >> 194 << G4endl; >> 195 } >> 196 >> 197 if(fActiveChemistry) >> 198 { >> 199 G4Molecule * H2O = new G4Molecule (G4H2O::Definition()); >> 200 >> 201 switch (modification) >> 202 { >> 203 case eDissociativeAttachment: >> 204 H2O -> AddElectron(5,1); >> 205 break; >> 206 case eExcitedMolecule : >> 207 H2O -> ExciteMolecule(electronicLevel); >> 208 break; >> 209 case eIonizedMolecule : >> 210 H2O -> IonizeMolecule(electronicLevel); >> 211 break; >> 212 } >> 213 >> 214 G4Track * H2OTrack = H2O->BuildTrack(1*picosecond, >> 215 theIncomingTrack->GetPosition()); >> 216 >> 217 H2OTrack -> SetParentID(theIncomingTrack->GetTrackID()); >> 218 H2OTrack -> SetTrackStatus(fStopButAlive); >> 219 H2OTrack -> SetKineticEnergy(0.); >> 220 >> 221 G4ITTrackHolder::Instance()->PushTrack(H2OTrack); >> 222 } >> 223 } >> 224 >> 225 void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* theIncomingTrack, >> 226 G4ThreeVector* finalPosition) >> 227 // finalPosition is a pointer because this argument is optional >> 228 { >> 229 if(fWriteFile) >> 230 { >> 231 *fOutput << setw(11)<< theIncomingTrack->GetTrackID() >> 232 << setw(10)<< "e_aq" >> 233 << setw(14)<< -1 >> 234 << std::setprecision(2) << std::fixed >> 235 << setw(13)<< theIncomingTrack->GetKineticEnergy()/eV >> 236 << std::setprecision(6) << std::scientific >> 237 << setw(22)<< (theIncomingTrack->GetPosition().x())/nanometer >> 238 << setw(22)<< (theIncomingTrack->GetPosition().y())/nanometer >> 239 << setw(22)<< (theIncomingTrack->GetPosition().z())/nanometer ; >> 240 >> 241 if(finalPosition != 0) >> 242 { >> 243 *fOutput<< setw(14)<< (finalPosition->x())/nanometer >> 244 << setw(14)<< (finalPosition->y())/nanometer >> 245 << setw(14)<< (finalPosition->z())/nanometer ; >> 246 } >> 247 >> 248 *fOutput << G4endl; >> 249 } >> 250 >> 251 if(fActiveChemistry) >> 252 { >> 253 G4Molecule* e_aq = new G4Molecule(G4Electron_aq::Definition()); >> 254 G4Track * e_aqTrack(0); >> 255 if(finalPosition) >> 256 { >> 257 e_aqTrack = e_aq->BuildTrack(picosecond,*finalPosition); >> 258 } >> 259 else >> 260 { >> 261 e_aqTrack = e_aq->BuildTrack(picosecond,theIncomingTrack->GetPosition()); >> 262 } >> 263 e_aqTrack -> SetTrackStatus(fAlive); >> 264 e_aqTrack -> SetParentID(theIncomingTrack->GetTrackID()); >> 265 G4ITTrackHolder::Instance()->PushTrack(e_aqTrack); >> 266 G4ITManager<G4Molecule>::Instance()->Push(e_aqTrack); >> 267 } >> 268 } >> 269 >> 270 >> 271 void G4DNAChemistryManager::PushMolecule(G4Molecule*& molecule, double time, >> 272 const G4ThreeVector& position, int parentID) >> 273 { >> 274 if(fWriteFile) >> 275 { >> 276 *fOutput << setw(11)<< parentID >> 277 << setw(10)<< molecule->GetName() >> 278 << setw(14)<< -1 >> 279 << std::setprecision(2) << std::fixed >> 280 << setw(13)<< -1 >> 281 << std::setprecision(6) << std::scientific >> 282 << setw(22)<< (position.x())/nanometer >> 283 << setw(22)<< (position.y())/nanometer >> 284 << setw(22)<< (position.z())/nanometer; >> 285 *fOutput << G4endl; >> 286 } >> 287 >> 288 if(fActiveChemistry) >> 289 { >> 290 G4Track* track = molecule->BuildTrack(time,position); >> 291 track -> SetTrackStatus(fAlive); >> 292 track -> SetParentID(parentID); >> 293 G4ITTrackHolder::Instance()->PushTrack(track); >> 294 G4ITManager<G4Molecule>::Instance()->Push(track); >> 295 } >> 296 else >> 297 { >> 298 delete molecule; >> 299 molecule = 0; >> 300 } >> 301 } >> 302 >> 303 void G4DNAChemistryManager::PushMoleculeAtParentTimeAndPlace(G4Molecule*& molecule, >> 304 const G4Track* theIncomingTrack) >> 305 { >> 306 if(fWriteFile) >> 307 { >> 308 *fOutput << setw(11)<< theIncomingTrack->GetTrackID() >> 309 << setw(10)<< molecule->GetName() >> 310 << setw(14)<< -1 >> 311 << std::setprecision(2) << std::fixed >> 312 << setw(13)<< theIncomingTrack->GetKineticEnergy()/eV >> 313 << std::setprecision(6) << std::scientific >> 314 << setw(22)<< (theIncomingTrack->GetPosition().x())/nanometer >> 315 << setw(22)<< (theIncomingTrack->GetPosition().y())/nanometer >> 316 << setw(22)<< (theIncomingTrack->GetPosition().z())/nanometer ; >> 317 *fOutput << G4endl; >> 318 } >> 319 >> 320 if(fActiveChemistry) >> 321 { >> 322 G4Track* track = molecule->BuildTrack(theIncomingTrack->GetGlobalTime(),theIncomingTrack->GetPosition()); >> 323 track -> SetTrackStatus(fAlive); >> 324 track -> SetParentID(theIncomingTrack->GetTrackID()); >> 325 G4ITTrackHolder::Instance()->PushTrack(track); >> 326 G4ITManager<G4Molecule>::Instance()->Push(track); >> 327 } >> 328 else >> 329 { >> 330 delete molecule; >> 331 molecule = 0; >> 332 } >> 333 } >> 334 >> 335 void G4DNAChemistryManager::AddEmptyLineInOuputFile() >> 336 { >> 337 if(fWriteFile) >> 338 { >> 339 *fOutput << G4endl; >> 340 } 809 } 341 } 810 342