Warning, file /include/Geant4/G4VMoleculeCounterInternalBase.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef G4VMoleculeCounterInternalBaseBASE_HH
0029 #define G4VMoleculeCounterInternalBaseBASE_HH 1
0030
0031 #include "G4Exception.hh"
0032 #include "G4MoleculeCounterTimeComparer.hh"
0033 #include "G4String.hh"
0034 #include "G4Types.hh"
0035 #include "G4UnitsTable.hh"
0036 #include "G4ios.hh"
0037
0038 #include <iomanip>
0039 #include <map>
0040 #include <memory>
0041 #include <set>
0042
0043
0044 namespace G4
0045 {
0046 namespace MoleculeCounter
0047 {
0048 struct FixedTimeComparer
0049 {
0050 G4bool operator()(const G4double& a, const G4double& b) const;
0051 static G4ThreadLocal G4double fPrecision;
0052 };
0053 }
0054 }
0055
0056
0057
0058 using InnerCounterMapType = std::map<G4double, G4int, G4MoleculeCounterTimeComparer>;
0059
0060
0061
0062 class G4VMoleculeCounterInternalBase
0063 {
0064 friend class G4VMoleculeCounter;
0065 friend class G4VMoleculeReactionCounter;
0066
0067
0068 public:
0069 struct G4VMoleculeCounterIndexInterface
0070 {
0071 virtual ~G4VMoleculeCounterIndexInterface() = default;
0072 virtual G4String GetInfo() const = 0;
0073 };
0074
0075 private:
0076 G4VMoleculeCounterInternalBase();
0077 G4VMoleculeCounterInternalBase(const G4String&);
0078 G4VMoleculeCounterInternalBase(G4VMoleculeCounterInternalBase const&) = delete;
0079 void operator=(G4VMoleculeCounterInternalBase const& x) = delete;
0080
0081 public:
0082 virtual ~G4VMoleculeCounterInternalBase() = default;
0083
0084 public:
0085 virtual void Initialize() = 0;
0086 virtual void InitializeUser() = 0;
0087 virtual void ResetCounter() = 0;
0088 virtual void Dump() const = 0;
0089 virtual void DumpCounterMapIndices() const = 0;
0090
0091 virtual std::set<G4double> GetRecordedTimes() const = 0;
0092
0093 virtual void AbsorbCounter(const G4VMoleculeCounterInternalBase*) = 0;
0094
0095 private:
0096 static G4ThreadLocal G4int _createdCounters;
0097
0098 protected:
0099 G4bool fIsInitialized{false};
0100
0101 G4int fId;
0102 G4int fManagedId{-1};
0103 G4String fName{};
0104
0105 G4int fVerbose{0};
0106
0107 G4double fActiveLowerBound{0}, fActiveUpperBound{std::numeric_limits<G4double>::max()};
0108 G4bool fActiveLowerBoundInclusive{true}, fActiveUpperBoundInclusive{true};
0109
0110 G4bool fCheckTimeIsConsistentWithScheduler{true};
0111 G4bool fCheckRecordedTimesAreConsistent{true};
0112
0113 G4MoleculeCounterTimeComparer fTimeComparer{};
0114
0115 public:
0116 G4int GetId() const;
0117 void SetManagedId(G4int);
0118 G4int GetManagedId() const;
0119 const G4String& GetName() const;
0120
0121 G4int GetVerbose() const;
0122 void SetVerbose(G4int);
0123
0124
0125 G4double GetActiveLowerBound() const;
0126 void SetActiveLowerBound(G4double, G4bool = true);
0127 G4double GetActiveUpperBound() const;
0128 void SetActiveUpperBound(G4double, G4bool = true);
0129 G4bool GetActiveLowerBoundInclusive() const;
0130 G4bool GetActiveUpperBoundInclusive() const;
0131 G4bool IsTimeBelowLowerBound(G4double) const;
0132 G4bool IsTimeAboveUpperBound(G4double) const;
0133 G4bool IsActiveAtGlobalTime(G4double) const;
0134
0135 G4bool GetCheckTimeConsistencyWithScheduler() const;
0136 void SetCheckTimeConsistencyWithScheduler(G4bool = true);
0137 G4bool GetCheckRecordedTimeConsistency() const;
0138 void SetCheckRecordedTimeConsistency(G4bool = true);
0139
0140 const G4MoleculeCounterTimeComparer& GetTimeComparer() const;
0141 void SetTimeComparer(const G4MoleculeCounterTimeComparer&);
0142
0143 public:
0144 static void SetFixedTimePrecision(G4double);
0145 };
0146
0147
0148
0149 inline G4int G4VMoleculeCounterInternalBase::GetId() const
0150 {
0151 return fId;
0152 }
0153
0154 inline void G4VMoleculeCounterInternalBase::SetManagedId(G4int id)
0155 {
0156 if (fManagedId > -1) {
0157 G4ExceptionDescription description;
0158 description << "Someone is trying to change the managed id of this counter but it was already "
0159 "changed from -1!\n";
0160 description << " Id: " << fManagedId << "\n";
0161 description << "Name: " << fName << "\n";
0162 G4Exception("G4VMoleculeCounterInternalBase::SetManagedId", "MOLCTR000", FatalException, description);
0163 }
0164 fManagedId = id;
0165 }
0166 inline G4int G4VMoleculeCounterInternalBase::GetManagedId() const
0167 {
0168 return fManagedId;
0169 }
0170
0171 inline const G4String& G4VMoleculeCounterInternalBase::GetName() const
0172 {
0173 return fName;
0174 }
0175
0176 inline G4int G4VMoleculeCounterInternalBase::GetVerbose() const
0177 {
0178 return fVerbose;
0179 }
0180 inline void G4VMoleculeCounterInternalBase::SetVerbose(G4int verbose)
0181 {
0182 fVerbose = verbose;
0183 }
0184
0185 inline G4double G4VMoleculeCounterInternalBase::GetActiveLowerBound() const
0186 {
0187 return fActiveLowerBound;
0188 }
0189 inline void G4VMoleculeCounterInternalBase::SetActiveLowerBound(G4double time, G4bool inclusive)
0190 {
0191 fActiveLowerBound = time;
0192 fActiveLowerBoundInclusive = inclusive;
0193 }
0194
0195 inline G4double G4VMoleculeCounterInternalBase::GetActiveUpperBound() const
0196 {
0197 return fActiveUpperBound;
0198 }
0199 inline void G4VMoleculeCounterInternalBase::SetActiveUpperBound(G4double time, G4bool inclusive)
0200 {
0201 fActiveUpperBound = time;
0202 fActiveUpperBoundInclusive = inclusive;
0203 }
0204
0205 inline G4bool G4VMoleculeCounterInternalBase::GetActiveLowerBoundInclusive() const
0206 {
0207 return fActiveLowerBoundInclusive;
0208 }
0209 inline G4bool G4VMoleculeCounterInternalBase::GetActiveUpperBoundInclusive() const
0210 {
0211 return fActiveUpperBoundInclusive;
0212 }
0213
0214 inline G4bool G4VMoleculeCounterInternalBase::IsTimeBelowLowerBound(G4double time) const
0215 {
0216 return (fActiveLowerBoundInclusive && time < fActiveLowerBound)
0217 || (!fActiveLowerBoundInclusive && time <= fActiveLowerBound);
0218 }
0219 inline G4bool G4VMoleculeCounterInternalBase::IsTimeAboveUpperBound(G4double time) const
0220 {
0221 return (fActiveUpperBoundInclusive && time > fActiveUpperBound)
0222 || (!fActiveUpperBoundInclusive && time >= fActiveUpperBound);
0223 }
0224 inline G4bool G4VMoleculeCounterInternalBase::IsActiveAtGlobalTime(G4double time) const
0225 {
0226 return !(IsTimeBelowLowerBound(time) || IsTimeAboveUpperBound(time));
0227 }
0228
0229 inline G4bool G4VMoleculeCounterInternalBase::GetCheckTimeConsistencyWithScheduler() const
0230 {
0231 return fCheckTimeIsConsistentWithScheduler;
0232 }
0233 inline void G4VMoleculeCounterInternalBase::SetCheckTimeConsistencyWithScheduler(G4bool flag)
0234 {
0235 fCheckTimeIsConsistentWithScheduler = flag;
0236 }
0237
0238 inline G4bool G4VMoleculeCounterInternalBase::GetCheckRecordedTimeConsistency() const
0239 {
0240 return fCheckRecordedTimesAreConsistent;
0241 }
0242 inline void G4VMoleculeCounterInternalBase::SetCheckRecordedTimeConsistency(G4bool flag)
0243 {
0244 fCheckRecordedTimesAreConsistent = flag;
0245 }
0246
0247 inline const G4MoleculeCounterTimeComparer& G4VMoleculeCounterInternalBase::GetTimeComparer() const
0248 {
0249 return fTimeComparer;
0250 }
0251
0252 inline void G4VMoleculeCounterInternalBase::SetTimeComparer(const G4MoleculeCounterTimeComparer& comparer)
0253 {
0254 if (fIsInitialized) {
0255 G4Exception("G4VMoleculeCounterInternalBase::SetTimeComparer()", "AlreadyInitialized", JustWarning,
0256 "Molecule counter was already initialized, assigning the time comparer now may "
0257 "have no effect!");
0258 }
0259 fTimeComparer = comparer;
0260 }
0261
0262
0263
0264 #endif