Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MoleculeCounterManager Class Referencefinal

#include <G4MoleculeCounterManager.hh>

Public Member Functions

 G4MoleculeCounterManager (Private)
 ~G4MoleculeCounterManager ()
void Initialize ()
G4int RegisterCounter (std::unique_ptr< G4VMoleculeCounter >)
G4int RegisterCounter (std::unique_ptr< G4VMoleculeReactionCounter >)
void DeregisterAllCounters ()
void BeginOfEventAction (const G4Event *)
void BeginOfRunAction (const G4Run *)
void EndOfEventAction (const G4Event *)
void EndOfRunAction (const G4Run *)
void DumpMasterCounters () const
void DumpWorkerCounters () const
void AbsorbWorkerManagerCounters (const G4MoleculeCounterManager *=nullptr)
void AddMoleculeWithoutTrack (const G4MolecularConfiguration *, G4double, G4int=1)
void RemoveMoleculeWithoutTrack (const G4MolecularConfiguration *, G4double, G4int=1)
void AddMolecule (const G4Track *, G4double, G4int=1)
void RemoveMolecule (const G4Track *, G4double, G4int=1)
void AddMolecule (const G4Track *, const G4StepPoint *, G4double, G4int=1)
void RemoveMolecule (const G4Track *, const G4StepPoint *, G4double, G4int=1)
void ActivateCounterAtTimes (G4int, G4double, G4double, G4bool=true, G4bool=true)
void RecordReaction (const G4DNAMolecularReactionData *, G4double, G4int=1)
void ActivateReactionCounterAtTimes (G4int, G4double, G4double, G4bool=true, G4bool=true)
void ResetCounters ()
void NotifyOfStep (const G4Step *)
void NotifyOfFinalize ()
void BroadcastIgnoreMolecule (const G4MoleculeDefinition *)
void BroadcastIgnoreReactant (const G4MolecularConfiguration *)
void BroadcastRegisterAllMoleculesAndReactants ()
G4bool GetIsActive () const
void SetIsActive (G4bool flag)
G4int GetVerbosity () const
void SetVerbosity (G4int v)
G4bool GetResetCountersBeforeEvent () const
void SetResetCountersBeforeEvent (G4bool=true)
G4bool GetResetCountersBeforeRun () const
void SetResetCountersBeforeRun (G4bool=true)
G4bool GetResetMasterCounterWithWorkers () const
void SetResetMasterCounterWithWorkers (G4bool=true)
G4bool GetAccumulateCounterIntoMaster () const
void SetAccumulateCounterIntoMaster (G4bool=true)
std::vector< const G4VMoleculeCounter * > GetMoleculeCounters () const
std::vector< const G4VMoleculeCounter * > GetMoleculeCounters (G4String) const
template<typename T = G4VMoleculeCounter>
const T * GetMoleculeCounter (G4int) const
G4VMoleculeCounterGetEditableMoleculeCounter (G4int) const
std::vector< const G4VMoleculeReactionCounter * > GetMoleculeReactionCounters () const
std::vector< const G4VMoleculeReactionCounter * > GetMoleculeReactionCounters (G4String) const
G4VMoleculeReactionCounterGetEditableMoleculeReactionCounter (G4int) const
template<typename T = G4VMoleculeReactionCounter>
const T * GetMoleculeReactionCounter (G4int) const

Static Public Member Functions

static G4MoleculeCounterManagerInstance ()
static G4MoleculeCounterManagerGetInstanceIfExists ()
static void DeleteInstance ()

Detailed Description

Definition at line 50 of file G4MoleculeCounterManager.hh.

Constructor & Destructor Documentation

◆ G4MoleculeCounterManager()

G4MoleculeCounterManager::G4MoleculeCounterManager ( G4MoleculeCounterManager::Private )

Definition at line 58 of file G4MoleculeCounterManager.cc.

59 : fVerbosity(0), fIsInitialized(false), fIsActive(true)
60{
61 fpMessenger = std::make_unique<G4MoleculeCounterManagerMessenger>(this);
62}

Referenced by AbsorbWorkerManagerCounters(), GetInstanceIfExists(), and Instance().

◆ ~G4MoleculeCounterManager()

G4MoleculeCounterManager::~G4MoleculeCounterManager ( )

Definition at line 64 of file G4MoleculeCounterManager.cc.

65{
66 // The manager owns all the counters as raw pointers, clean up:
68
69 if (fVerbosity > 0) {
70 if (GetResetCountersBeforeRun() && !fBeginOfRunTriggered.load()) {
71 G4Exception("G4MoleculeCounterManager::~G4MoleculeCounterManager", "MOLMAN000", JustWarning,
72 "The molecule counter manager was configured to reset counters before each run"
73 " but the BeginOfRunAction was never triggered!\n"
74 "Ensure that the user code calls either the G4DNAChemistryManager's or "
75 "G4MoleculeCounterManager's Run methods!");
76 }
77 if (GetResetCountersBeforeEvent() && !fBeginOfEventTriggered.load()
79 {
80 // ignore, if this is the master of a MT application
81 G4Exception("G4MoleculeCounterManager::~G4MoleculeCounterManager", "MOLMAN000", JustWarning,
82 "The molecule counter manager was configured to reset counters before each event"
83 " but the BeginOfEventAction was never triggered!\n"
84 "This can occurr if this thread is never processing an event but:\n"
85 "Ensure that the user code calls either the G4DNAChemistryManager's or "
86 "G4MoleculeCounterManager's Event methods!");
87 }
88 }
89
90 // Handle the recorded master and worker instances
92 // This is the master's dtor: set the master const* to nullptr (as it will point to nothing of use)
93 G4AutoLock lockMaster(&masterInstanceMutex);
94 fpMasterInstance = nullptr;
95 }
96 else {
97 // This is a worker's dtor: make sure that this worker is still in the list of instances.
98 // If not, throw a warning (something fishy going on?)
99 // Either way, set this worker's const* to nullptr in the list of instances.
100 G4AutoLock lock(&workerInstancesMutex);
101 auto it = std::find(fWorkerInstances.begin(), fWorkerInstances.end(), this);
102 if (it == fWorkerInstances.end()) {
104 "G4MoleculeCounterManager::~G4MoleculeCounterManager", "MOLMAN_DTOR", JustWarning,
105 "The destroyed instance of G4MoleculeCounterManager has not been registered as a worker!");
106 }
107 else {
108 (*it) = nullptr;
109 }
110 }
111}
G4TemplateAutoLock< G4Mutex > G4AutoLock
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4bool IsWorkerThread()
G4bool IsMultithreadedApplication()
G4bool IsMasterThread()

Member Function Documentation

◆ AbsorbWorkerManagerCounters()

void G4MoleculeCounterManager::AbsorbWorkerManagerCounters ( const G4MoleculeCounterManager * selectedWorker = nullptr)

Definition at line 565 of file G4MoleculeCounterManager.cc.

567{
568 if (selectedWorker == nullptr && !G4Threading::IsMasterThread()) {
569 // Can only call without worker from master thread!
570 G4ExceptionDescription description;
571 description << "This method may only be called from the master thread!";
572 G4Exception("G4MoleculeCounterManager::AbsorbWorkerManagerCounters", "MOLMAN999",
573 FatalException, description);
574 }
575
576 // prevent changes to any of the instances
577 G4AutoLock lockMaster(&masterInstanceMutex);
578 G4AutoLock lockWorker(&workerInstancesMutex);
579
580 for (auto const& worker : fWorkerInstances) {
581 if (selectedWorker == nullptr || worker != selectedWorker) continue;
582
583 for (auto& [id, masterCounter] : fpMasterInstance->fCounters) {
584 // acquire worker counter
585 auto workerCounter = worker->GetMoleculeCounter(id);
586 masterCounter->AbsorbCounter(workerCounter);
587 }
588
589 for (auto& [id, masterCounter] : fpMasterInstance->fReactionCounters) {
590 // acquire worker counter
591 auto workerCounter = worker->GetMoleculeReactionCounter(id);
592 masterCounter->AbsorbCounter(workerCounter);
593 }
594 }
595}
@ FatalException
std::ostringstream G4ExceptionDescription

Referenced by EndOfEventAction(), and EndOfRunAction().

◆ ActivateCounterAtTimes()

void G4MoleculeCounterManager::ActivateCounterAtTimes ( G4int id,
G4double aboveTime,
G4double belowTime,
G4bool aboveTimeInclusive = true,
G4bool belowTimeInclusive = true )

Definition at line 401 of file G4MoleculeCounterManager.cc.

404{
405 if (fVerbosity > 0) {
406 G4cout << "G4MoleculeCounterManager::ActivateCounterAtTimes ("
407 << (G4Threading::IsMasterThread() ? "master" : "worker") << ")" << G4endl;
408 }
409
410 auto counter = GetEditableMoleculeCounter(id);
411 counter->SetActiveLowerBound(aboveTime, aboveTimeInclusive);
412 counter->SetActiveUpperBound(belowTime, belowTimeInclusive);
413}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4VMoleculeCounter * GetEditableMoleculeCounter(G4int) const

◆ ActivateReactionCounterAtTimes()

void G4MoleculeCounterManager::ActivateReactionCounterAtTimes ( G4int id,
G4double aboveTime,
G4double belowTime,
G4bool aboveTimeInclusive = true,
G4bool belowTimeInclusive = true )

Definition at line 415 of file G4MoleculeCounterManager.cc.

419{
420 if (fVerbosity > 0) {
421 G4cout << "G4MoleculeCounterManager::ActivateReactionCounterAtTimes ("
422 << (G4Threading::IsMasterThread() ? "master" : "worker") << ")" << G4endl;
423 }
424
425 auto counter = GetEditableMoleculeReactionCounter(id);
426 counter->SetActiveLowerBound(aboveTime, aboveTimeInclusive);
427 counter->SetActiveUpperBound(belowTime, belowTimeInclusive);
428}
G4VMoleculeReactionCounter * GetEditableMoleculeReactionCounter(G4int) const

◆ AddMolecule() [1/2]

void G4MoleculeCounterManager::AddMolecule ( const G4Track * aTrack,
const G4StepPoint * aStepPoint,
G4double time,
G4int n = 1 )

Definition at line 235 of file G4MoleculeCounterManager.cc.

237{
238 for (auto& [id, counter] : fCounters) {
239 if (counter->GetSensitiveToStepping()) {
240 counter->AddMolecule(counter->BuildIndex(aTrack, aStepPoint), time, n);
241 }
242 }
243}

◆ AddMolecule() [2/2]

void G4MoleculeCounterManager::AddMolecule ( const G4Track * aTrack,
G4double time,
G4int n = 1 )

Definition at line 221 of file G4MoleculeCounterManager.cc.

222{
223 for (auto& [id, counter] : fCounters) {
224 counter->AddMolecule(counter->BuildIndex(aTrack), time, n);
225 }
226}

Referenced by G4Molecule::BuildTrack().

◆ AddMoleculeWithoutTrack()

void G4MoleculeCounterManager::AddMoleculeWithoutTrack ( const G4MolecularConfiguration * molecule,
G4double time,
G4int n = 1 )

Definition at line 205 of file G4MoleculeCounterManager.cc.

207{
208 for (auto& [id, counter] : fCounters) {
209 counter->AddMolecule(counter->BuildSimpleIndex(molecule), time, n);
210 }
211}

◆ BeginOfEventAction()

void G4MoleculeCounterManager::BeginOfEventAction ( const G4Event * )

Definition at line 504 of file G4MoleculeCounterManager.cc.

505{
506 fBeginOfEventTriggered = true;
507
509 // trigger reset if:
510 // * is not an MT app (master = worker)
511 // * is an MT app, master, and we want to reset the master
512 // * is an MT app and worker
518 }
519}

Referenced by G4DNAChemistryManager::BeginOfEventAction().

◆ BeginOfRunAction()

void G4MoleculeCounterManager::BeginOfRunAction ( const G4Run * )

Definition at line 523 of file G4MoleculeCounterManager.cc.

524{
525 fBeginOfRunTriggered = true;
526
528 // trigger reset if:
529 // * is not an MT app (master = worker)
530 // * is an MT app, master, and we want to reset the master
531 // * is an MT app and worker
537 }
538}

Referenced by G4DNAChemistryManager::BeginOfRunAction().

◆ BroadcastIgnoreMolecule()

void G4MoleculeCounterManager::BroadcastIgnoreMolecule ( const G4MoleculeDefinition * molecule)

Definition at line 312 of file G4MoleculeCounterManager.cc.

313{
314 for (auto& [id, counter] : fCounters) {
315 counter->IgnoreMolecule(molecule);
316 }
317}

◆ BroadcastIgnoreReactant()

void G4MoleculeCounterManager::BroadcastIgnoreReactant ( const G4MolecularConfiguration * molecule)

Definition at line 319 of file G4MoleculeCounterManager.cc.

320{
321 for (auto& [id, counter] : fCounters) {
322 counter->IgnoreReactant(molecule);
323 }
324}

◆ BroadcastRegisterAllMoleculesAndReactants()

void G4MoleculeCounterManager::BroadcastRegisterAllMoleculesAndReactants ( )

Definition at line 326 of file G4MoleculeCounterManager.cc.

327{
328 for (auto& [id, counter] : fCounters) {
329 counter->RegisterAll();
330 }
331}

◆ DeleteInstance()

void G4MoleculeCounterManager::DeleteInstance ( )
static

Definition at line 151 of file G4MoleculeCounterManager.cc.

152{
153 G4AutoLock lock(&managerInstance);
154
155 if (fpInstance != nullptr) {
156 fpInstance.reset();
157 // this should (test!) trigger the dtor, which will delete/deregister the counters
158 }
159}

Referenced by G4DNAChemistryManager::Clear().

◆ DeregisterAllCounters()

void G4MoleculeCounterManager::DeregisterAllCounters ( )

Definition at line 367 of file G4MoleculeCounterManager.cc.

368{
369 for (auto& [id, ctr] : fCounters) {
370 delete ctr;
371 }
372 fCounters.clear();
373
374 for (auto& [id, ctr] : fReactionCounters) {
375 delete ctr;
376 }
377 fReactionCounters.clear();
378}

Referenced by ~G4MoleculeCounterManager().

◆ DumpMasterCounters()

void G4MoleculeCounterManager::DumpMasterCounters ( ) const

Definition at line 599 of file G4MoleculeCounterManager.cc.

600{
601 G4AutoLock lock(&masterInstanceMutex);
602
603 for (auto const& pCounter : fpMasterInstance->GetMoleculeCounters()) {
604 G4cout << "=========================================================================== \n"
605 << " >> [MASTER] Dumping Molecule Counter `" << pCounter->GetName() << "`\n"
606 << G4endl;
607 pCounter->Dump();
608 G4cout << "\n=========================================================================== "
609 << G4endl;
610 }
611
612 for (auto const& pCounter : fpMasterInstance->GetMoleculeReactionCounters()) {
613 G4cout << "=========================================================================== \n"
614 << " >> [MASTER] Dumping Molecule Reaction Counter `" << pCounter->GetName() << "`\n"
615 << G4endl;
616 pCounter->Dump();
617 G4cout << "\n=========================================================================== "
618 << G4endl;
619 }
620}

◆ DumpWorkerCounters()

void G4MoleculeCounterManager::DumpWorkerCounters ( ) const

Definition at line 624 of file G4MoleculeCounterManager.cc.

625{
626 G4AutoLock lock(&workerInstancesMutex);
627
628 for (auto const& worker : G4MoleculeCounterManager::fWorkerInstances) {
629 for (auto const& pCounter : worker->GetMoleculeCounters()) {
630 G4cout << "=========================================================================== \n"
631 << " >> [WORKER<" << worker << ">] Dumping Molecule Counter `" << pCounter->GetName()
632 << "`\n"
633 << G4endl;
634 pCounter->Dump();
635 G4cout << "\n=========================================================================== "
636 << G4endl;
637 }
638
639 for (auto const& pCounter : worker->GetMoleculeReactionCounters()) {
640 G4cout << "=========================================================================== \n"
641 << " >> [WORKER<" << worker << ">] Dumping Molecule Reaction Counter `"
642 << pCounter->GetName() << "`\n"
643 << G4endl;
644 pCounter->Dump();
645 G4cout << "\n=========================================================================== "
646 << G4endl;
647 }
648 }
649}

◆ EndOfEventAction()

void G4MoleculeCounterManager::EndOfEventAction ( const G4Event * )

Definition at line 542 of file G4MoleculeCounterManager.cc.

543{
544 // EndOfEvent is never triggered on the master of a G4MT
547 {
549 }
550}
void AbsorbWorkerManagerCounters(const G4MoleculeCounterManager *=nullptr)

Referenced by G4DNAChemistryManager::EndOfEventAction().

◆ EndOfRunAction()

void G4MoleculeCounterManager::EndOfRunAction ( const G4Run * )

Definition at line 554 of file G4MoleculeCounterManager.cc.

555{
558 // if ResetBeforeEvent, AbsorbWorkerManagerCounters will have been triggered already
561}

Referenced by G4DNAChemistryManager::EndOfRunAction().

◆ GetAccumulateCounterIntoMaster()

G4bool G4MoleculeCounterManager::GetAccumulateCounterIntoMaster ( ) const

Definition at line 685 of file G4MoleculeCounterManager.cc.

686{
687 return fAccumulateCounterIntoMaster.load();
688}

Referenced by EndOfEventAction(), and EndOfRunAction().

◆ GetEditableMoleculeCounter()

G4VMoleculeCounter * G4MoleculeCounterManager::GetEditableMoleculeCounter ( G4int id) const

Definition at line 432 of file G4MoleculeCounterManager.cc.

433{
434 auto it = fCounters.find(id);
435 if (it == fCounters.end()) {
436 G4ExceptionDescription description;
437 description << "No molecule counter with Id = " << id << " was found!\n";
438 G4Exception("G4MoleculeCounterManager::GetMoleculeCounter", "MOLMAN001", FatalErrorInArgument,
439 description);
440 return nullptr;
441 }else{
442 return it->second;
443 }
444}
@ FatalErrorInArgument

Referenced by ActivateCounterAtTimes(), and GetMoleculeCounter().

◆ GetEditableMoleculeReactionCounter()

G4VMoleculeReactionCounter * G4MoleculeCounterManager::GetEditableMoleculeReactionCounter ( G4int id) const

Definition at line 467 of file G4MoleculeCounterManager.cc.

468{
469 auto it = fReactionCounters.find(id);
470 if (it == fReactionCounters.end()) {
471 G4ExceptionDescription description;
472 description << "No molecule reaction counter with Id = " << id << " was found!\n";
473 G4Exception("G4MoleculeCounterManager::GetMoleculeReactionCounter", "MOLMAN001",
474 FatalErrorInArgument, description);
475 return nullptr;
476 }else
477 {
478 return it->second;
479 }
480}

Referenced by ActivateReactionCounterAtTimes(), and GetMoleculeReactionCounter().

◆ GetInstanceIfExists()

G4MoleculeCounterManager * G4MoleculeCounterManager::GetInstanceIfExists ( )
static

◆ GetIsActive()

G4bool G4MoleculeCounterManager::GetIsActive ( ) const
inline

Definition at line 156 of file G4MoleculeCounterManager.hh.

156{ return fIsActive; }

◆ GetMoleculeCounter()

template<typename T>
const T * G4MoleculeCounterManager::GetMoleculeCounter ( G4int id) const

Definition at line 227 of file G4MoleculeCounterManager.hh.

228{
229 static_assert(std::is_base_of<G4VMoleculeCounter, T>::value,
230 "T must be derived from G4VMoleculeCounter!");
231 auto base_ptr = GetEditableMoleculeCounter(id);
232 if (base_ptr == nullptr) return nullptr;
233 const T* ptr = dynamic_cast<const T*>(base_ptr);
234 return ptr;
235}

◆ GetMoleculeCounters() [1/2]

std::vector< const G4VMoleculeCounter * > G4MoleculeCounterManager::GetMoleculeCounters ( ) const

Definition at line 446 of file G4MoleculeCounterManager.cc.

447{
448 std::vector<const G4VMoleculeCounter*> output;
449 output.reserve(fCounters.size());
450 for (auto& [id, counter] : fCounters)
451 output.push_back(counter);
452 return output;
453}

◆ GetMoleculeCounters() [2/2]

std::vector< const G4VMoleculeCounter * > G4MoleculeCounterManager::GetMoleculeCounters ( G4String name) const

Definition at line 455 of file G4MoleculeCounterManager.cc.

456{
457 std::vector<const G4VMoleculeCounter*> output;
458 for (auto& [id, counter] : fCounters) {
459 if (name == counter->GetName()) output.push_back(counter);
460 }
461 return output;
462}

◆ GetMoleculeReactionCounter()

template<typename T>
const T * G4MoleculeCounterManager::GetMoleculeReactionCounter ( G4int id) const

Definition at line 238 of file G4MoleculeCounterManager.hh.

239{
240 static_assert(std::is_base_of<G4VMoleculeReactionCounter, T>::value,
241 "T must be derived from G4VMoleculeReactionCounter!");
242 auto base_ptr = GetEditableMoleculeReactionCounter(id);
243 if (base_ptr == nullptr) return nullptr;
244 const T* ptr = dynamic_cast<const T*>(base_ptr);
245 return ptr;
246}

◆ GetMoleculeReactionCounters() [1/2]

std::vector< const G4VMoleculeReactionCounter * > G4MoleculeCounterManager::GetMoleculeReactionCounters ( ) const

Definition at line 483 of file G4MoleculeCounterManager.cc.

484{
485 std::vector<const G4VMoleculeReactionCounter*> output;
486 output.reserve(fReactionCounters.size());
487 for (auto& [id, counter] : fReactionCounters)
488 output.push_back(counter);
489 return output;
490}

◆ GetMoleculeReactionCounters() [2/2]

std::vector< const G4VMoleculeReactionCounter * > G4MoleculeCounterManager::GetMoleculeReactionCounters ( G4String name) const

Definition at line 493 of file G4MoleculeCounterManager.cc.

494{
495 std::vector<const G4VMoleculeReactionCounter*> output;
496 for (auto& [id, counter] : fReactionCounters) {
497 if (name == counter->GetName()) output.push_back(counter);
498 }
499 return output;
500}

◆ GetResetCountersBeforeEvent()

G4bool G4MoleculeCounterManager::GetResetCountersBeforeEvent ( ) const

Definition at line 658 of file G4MoleculeCounterManager.cc.

659{
660 return fResetCountersBeforeEvent.load();
661}

Referenced by BeginOfEventAction(), EndOfEventAction(), EndOfRunAction(), and ~G4MoleculeCounterManager().

◆ GetResetCountersBeforeRun()

G4bool G4MoleculeCounterManager::GetResetCountersBeforeRun ( ) const

Definition at line 672 of file G4MoleculeCounterManager.cc.

673{
674 return fResetCountersBeforeRun.load();
675}

Referenced by BeginOfRunAction(), EndOfRunAction(), and ~G4MoleculeCounterManager().

◆ GetResetMasterCounterWithWorkers()

G4bool G4MoleculeCounterManager::GetResetMasterCounterWithWorkers ( ) const

Definition at line 698 of file G4MoleculeCounterManager.cc.

699{
700 return fResetMasterCounterWithWorkers.load();
701}

Referenced by BeginOfEventAction(), and BeginOfRunAction().

◆ GetVerbosity()

G4int G4MoleculeCounterManager::GetVerbosity ( ) const
inline

Definition at line 159 of file G4MoleculeCounterManager.hh.

159{ return fVerbosity; }

Referenced by NotifyOfStep().

◆ Initialize()

void G4MoleculeCounterManager::Initialize ( )

Definition at line 167 of file G4MoleculeCounterManager.cc.

168{
169 if (fVerbosity > 0) {
170 G4cout << "G4MoleculeCounterManager::Initialize ("
171 << (G4Threading::IsMasterThread() ? "master" : "worker") << ")" << G4endl;
172 }
173
176 InitializeWorker();
177 else
178 InitializeMaster();
179 }
180 else {
181 InitializeMaster();
182 }
183}

Referenced by G4DNAChemistryManager::InitializeMaster(), and G4DNAChemistryManager::InitializeThread().

◆ Instance()

◆ NotifyOfFinalize()

void G4MoleculeCounterManager::NotifyOfFinalize ( )

Definition at line 301 of file G4MoleculeCounterManager.cc.

302{
303 for (auto& [id, counter] : fCounters) {
304 counter->SchedulerFinalizedTracking();
305 }
306}

◆ NotifyOfStep()

void G4MoleculeCounterManager::NotifyOfStep ( const G4Step * aStep)

Definition at line 279 of file G4MoleculeCounterManager.cc.

280{
281 const G4Track* aTrack = aStep->GetTrack();
282
283 for (auto& [id, counter] : fCounters) {
284 auto preStepIndex = counter->BuildIndex(aTrack, aStep->GetPreStepPoint());
285 auto postStepIndex = counter->BuildIndex(aTrack, aStep->GetPostStepPoint());
286
287 if (!(*preStepIndex == *postStepIndex)) {
288#ifdef G4VERBOSE
289 if (GetVerbosity() > 1) {
290 G4cout << "G4MoleculeCounterManager::NotifyOfStep for counter " << counter->GetName()
291 << ":\n-- Pre = " << preStepIndex->GetInfo() << "\n"
292 << "-- Post = " << postStepIndex->GetInfo() << G4endl;
293 }
294#endif
295 counter->RemoveMolecule(std::move(preStepIndex), aTrack->GetGlobalTime(), 1);
296 counter->AddMolecule(std::move(postStepIndex), aTrack->GetGlobalTime(), 1);
297 }
298 }
299}
G4Track * GetTrack() const
G4StepPoint * GetPreStepPoint() const
G4StepPoint * GetPostStepPoint() const
G4double GetGlobalTime() const

◆ RecordReaction()

void G4MoleculeCounterManager::RecordReaction ( const G4DNAMolecularReactionData * reactionData,
G4double time,
G4int n = 1 )

Definition at line 257 of file G4MoleculeCounterManager.cc.

259{
260 for (auto& [id, counter] : fReactionCounters) {
261 counter->RecordReaction(counter->BuildSimpleIndex(reactionData), time, n);
262 }
263}

Referenced by G4DNAIRT::MakeReaction(), G4DNAMakeReaction::MakeReaction(), and G4DNAMolecularReaction::MakeReaction().

◆ RegisterCounter() [1/2]

G4int G4MoleculeCounterManager::RegisterCounter ( std::unique_ptr< G4VMoleculeCounter > counter)

Definition at line 339 of file G4MoleculeCounterManager.cc.

340{
341 auto idProvider = [&]() {
342 if (fCounters.size() == 0) return 0;
343 auto indices = G4::MoleculeCounter::GetMapIndices(fCounters);
344 auto lastIndex = *indices.rbegin();
345 return ++lastIndex;
346 };
347
348 return RegisterCounter(fCounters, std::move(counter), idProvider);
349}
G4int RegisterCounter(std::unique_ptr< G4VMoleculeCounter >)
const std::vector< T > GetMapIndices(const std::map< T, U > &_map)

Referenced by RegisterCounter(), and RegisterCounter().

◆ RegisterCounter() [2/2]

G4int G4MoleculeCounterManager::RegisterCounter ( std::unique_ptr< G4VMoleculeReactionCounter > counter)

Definition at line 353 of file G4MoleculeCounterManager.cc.

354{
355 auto idProvider = [&] {
356 if (fReactionCounters.size() == 0) return 0;
357 auto indices = G4::MoleculeCounter::GetMapIndices(fReactionCounters);
358 auto lastIndex = *indices.rbegin();
359 return ++lastIndex;
360 };
361
362 return RegisterCounter(fReactionCounters, std::move(counter), idProvider);
363}

◆ RemoveMolecule() [1/2]

void G4MoleculeCounterManager::RemoveMolecule ( const G4Track * aTrack,
const G4StepPoint * aStepPoint,
G4double time,
G4int n = 1 )

Definition at line 245 of file G4MoleculeCounterManager.cc.

247{
248 for (auto& [id, counter] : fCounters) {
249 if (counter->GetSensitiveToStepping()) {
250 counter->RemoveMolecule(counter->BuildIndex(aTrack, aStepPoint), time, n);
251 }
252 }
253}

◆ RemoveMolecule() [2/2]

void G4MoleculeCounterManager::RemoveMolecule ( const G4Track * aTrack,
G4double time,
G4int n = 1 )

Definition at line 228 of file G4MoleculeCounterManager.cc.

229{
230 for (auto& [id, counter] : fCounters) {
231 counter->RemoveMolecule(counter->BuildIndex(aTrack), time, n);
232 }
233}

Referenced by G4Molecule::~G4Molecule().

◆ RemoveMoleculeWithoutTrack()

void G4MoleculeCounterManager::RemoveMoleculeWithoutTrack ( const G4MolecularConfiguration * molecule,
G4double time,
G4int n = 1 )

Definition at line 213 of file G4MoleculeCounterManager.cc.

215{
216 for (auto& [id, counter] : fCounters) {
217 counter->RemoveMolecule(counter->BuildSimpleIndex(molecule), time, n);
218 }
219}

◆ ResetCounters()

void G4MoleculeCounterManager::ResetCounters ( )

Definition at line 386 of file G4MoleculeCounterManager.cc.

387{
388 if (fVerbosity > 0) {
389 G4cout << "G4MoleculeCounterManager::ResetCounters ("
390 << (G4Threading::IsMasterThread() ? "master" : "worker") << ")" << G4endl;
391 }
392
393 for (auto& [id, counter] : fCounters)
394 counter->ResetCounter();
395 for (auto& [id, counter] : fReactionCounters)
396 counter->ResetCounter();
397}

Referenced by BeginOfEventAction(), and BeginOfRunAction().

◆ SetAccumulateCounterIntoMaster()

void G4MoleculeCounterManager::SetAccumulateCounterIntoMaster ( G4bool flag = true)

Definition at line 689 of file G4MoleculeCounterManager.cc.

690{
691 if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit)
692 fAccumulateCounterIntoMaster = flag;
693 else
694 G4Exception("G4DNAChemistryManager::SetAccumulateCounterIntoMaster", "WRONG_STATE",
695 FatalException, "This flag may only be set during the PreInit state!");
696}
@ G4State_PreInit
static G4StateManager * GetStateManager()

◆ SetIsActive()

void G4MoleculeCounterManager::SetIsActive ( G4bool flag)
inline

Definition at line 157 of file G4MoleculeCounterManager.hh.

157{ fIsActive = flag; }

◆ SetResetCountersBeforeEvent()

void G4MoleculeCounterManager::SetResetCountersBeforeEvent ( G4bool flag = true)

Definition at line 662 of file G4MoleculeCounterManager.cc.

663{
664 if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit) {
665 fResetCountersBeforeEvent = flag;
666 }
667 else
668 G4Exception("G4DNAChemistryManager::SetResetCountersBeforeEvent", "WRONG_STATE", FatalException,
669 "This flag may only be set during the PreInit state!");
670}

◆ SetResetCountersBeforeRun()

void G4MoleculeCounterManager::SetResetCountersBeforeRun ( G4bool flag = true)

Definition at line 676 of file G4MoleculeCounterManager.cc.

677{
678 if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit)
679 fResetCountersBeforeRun = flag;
680 else
681 G4Exception("G4DNAChemistryManager::SetResetCountersBeforeRun", "WRONG_STATE", FatalException,
682 "This flag may only be set during the PreInit state!");
683}

◆ SetResetMasterCounterWithWorkers()

void G4MoleculeCounterManager::SetResetMasterCounterWithWorkers ( G4bool flag = true)

Definition at line 702 of file G4MoleculeCounterManager.cc.

703{
704 if (G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit)
705 fResetMasterCounterWithWorkers = flag;
706 else
707 G4Exception("G4DNAChemistryManager::SetResetMasterCounterWithWorkers", "WRONG_STATE",
708 FatalException, "This flag may only be set during the PreInit state!");
709}

◆ SetVerbosity()

void G4MoleculeCounterManager::SetVerbosity ( G4int v)
inline

Definition at line 160 of file G4MoleculeCounterManager.hh.

160{ fVerbosity = v; }

The documentation for this class was generated from the following files: