Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VMoleculeCounterInternalBase.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// Author: Christian Velten (2025)
27
28#ifndef G4VMoleculeCounterInternalBaseBASE_HH
29#define G4VMoleculeCounterInternalBaseBASE_HH 1
30
31#include "G4Exception.hh"
33#include "G4String.hh"
34#include "G4Types.hh"
35#include "G4UnitsTable.hh"
36#include "G4ios.hh"
37
38#include <iomanip>
39#include <map>
40#include <memory>
41#include <set>
42
43//------------------------------------------------------------------------------
44namespace G4
45{
46namespace MoleculeCounter
47{
49{
50 G4bool operator()(const G4double& a, const G4double& b) const;
52};
53} // namespace MoleculeCounter
54} // namespace G4
55
56//------------------------------------------------------------------------------
57
58using InnerCounterMapType = std::map<G4double, G4int, G4MoleculeCounterTimeComparer>;
59
60//------------------------------------------------------------------------------
61
62class G4VMoleculeCounterInternalBase
63{
64 friend class G4VMoleculeCounter;
66 // only allow these classes to derive
67
68 public:
70 {
72 virtual G4String GetInfo() const = 0;
73 };
74
75 private:
76 G4VMoleculeCounterInternalBase();
77 G4VMoleculeCounterInternalBase(const G4String&);
78 G4VMoleculeCounterInternalBase(G4VMoleculeCounterInternalBase const&) = delete;
79 void operator=(G4VMoleculeCounterInternalBase const& x) = delete;
80
81 public:
83
84 public:
85 virtual void Initialize() = 0;
86 virtual void InitializeUser() = 0;
87 virtual void ResetCounter() = 0;
88 virtual void Dump() const = 0;
89 virtual void DumpCounterMapIndices() const = 0;
90
91 virtual std::set<G4double> GetRecordedTimes() const = 0;
92
93 virtual void AbsorbCounter(const G4VMoleculeCounterInternalBase*) = 0;
94
95 private:
96 static G4ThreadLocal G4int _createdCounters;
97
98 protected:
100
104
106
107 G4double fActiveLowerBound{0}, fActiveUpperBound{std::numeric_limits<G4double>::max()};
109
112
114
115 public:
116 G4int GetId() const;
117 void SetManagedId(G4int);
118 G4int GetManagedId() const;
119 const G4String& GetName() const;
120
121 G4int GetVerbose() const;
122 void SetVerbose(G4int);
123
124 // Set counter active w.r.t. time
126 void SetActiveLowerBound(G4double, G4bool = true);
128 void SetActiveUpperBound(G4double, G4bool = true);
134
135 G4bool GetCheckTimeConsistencyWithScheduler() const; // w.r.t. scheduler time
137 G4bool GetCheckRecordedTimeConsistency() const; // w.r.t last recorded time
139
142
143 public:
144 static void SetFixedTimePrecision(G4double);
145};
146
147//------------------------------------------------------------------------------
148
150{
151 return fId;
152}
153
155{
156 if (fManagedId > -1) {
157 G4ExceptionDescription description;
158 description << "Someone is trying to change the managed id of this counter but it was already "
159 "changed from -1!\n";
160 description << " Id: " << fManagedId << "\n";
161 description << "Name: " << fName << "\n";
162 G4Exception("G4VMoleculeCounterInternalBase::SetManagedId", "MOLCTR000", FatalException, description);
163 }
164 fManagedId = id;
165}
170
172{
173 return fName;
174}
175
177{
178 return fVerbose;
179}
181{
182 fVerbose = verbose;
183}
184
194
204
213
228
237
246
251
253{
254 if (fIsInitialized) {
255 G4Exception("G4VMoleculeCounterInternalBase::SetTimeComparer()", "AlreadyInitialized", JustWarning,
256 "Molecule counter was already initialized, assigning the time comparer now may "
257 "have no effect!");
258 }
259 fTimeComparer = comparer;
260}
261
262//------------------------------------------------------------------------------
263
264#endif
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
std::map< G4double, G4int, G4MoleculeCounterTimeComparer > InnerCounterMapType
virtual std::set< G4double > GetRecordedTimes() const =0
const G4MoleculeCounterTimeComparer & GetTimeComparer() const
virtual void AbsorbCounter(const G4VMoleculeCounterInternalBase *)=0
void SetTimeComparer(const G4MoleculeCounterTimeComparer &)
virtual void Dump() const =0
virtual void InitializeUser()=0
virtual ~G4VMoleculeCounterInternalBase()=default
virtual void DumpCounterMapIndices() const =0
G4bool operator()(const G4double &a, const G4double &b) const
#define G4ThreadLocal
Definition tls.hh:77