Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4::MoleculeCounter Namespace Reference

Classes

struct  FixedTimeComparer

Functions

template<typename T>
G4String GetTemplateTypeName ()
template<typename T>
G4bool Contains (const std::set< T > &_set, const T &_value)
template<typename T>
G4bool Contains (const std::vector< T > &_vector, const T &_value)
template<typename T, typename U>
G4bool ContainsKey (const std::map< T, U > &_map, const T &_key)
template<typename T, typename U>
const std::vector< T > GetMapIndices (const std::map< T, U > &_map)
template<typename T>
void DumpCounterMapIndices (const std::map< T, InnerCounterMapType > &map, G4bool includeEmpty=false)
template<typename T>
void DumpCounterMapContents (const std::map< T, InnerCounterMapType > &map, G4bool includeEmpty=false)
template<typename T>
std::set< G4doubleGetRecordedTimes (const std::map< T, InnerCounterMapType > &map)
template<typename TKey, typename TValue, typename TComp>
std::map< TKey, TValue, TComp >::iterator FindClosestEntryForKey (std::map< TKey, TValue, TComp > &map, TKey key)

Function Documentation

◆ Contains() [1/2]

template<typename T>
G4bool G4::MoleculeCounter::Contains ( const std::set< T > & _set,
const T & _value )

◆ Contains() [2/2]

template<typename T>
G4bool G4::MoleculeCounter::Contains ( const std::vector< T > & _vector,
const T & _value )

Definition at line 60 of file G4MoleculeCounterTemplates.hh.

61{
62 auto p = std::find(_vector.cbegin(), _vector.cend(), _value);
63 return p != _vector.cend();
64}

◆ ContainsKey()

template<typename T, typename U>
G4bool G4::MoleculeCounter::ContainsKey ( const std::map< T, U > & _map,
const T & _key )

Definition at line 67 of file G4MoleculeCounterTemplates.hh.

68{
69 auto keys = GetMapIndices(_map);
70 return Contains(keys, _key);
71}
const std::vector< T > GetMapIndices(const std::map< T, U > &_map)
G4bool Contains(const std::set< T > &_set, const T &_value)

◆ DumpCounterMapContents()

template<typename T>
void G4::MoleculeCounter::DumpCounterMapContents ( const std::map< T, InnerCounterMapType > & map,
G4bool includeEmpty = false )

Definition at line 101 of file G4MoleculeCounterTemplates.hh.

103{
104 G4cout << "--- BEGIN COUNTER MAP DUMP ---" << G4endl;
105 for (auto const& it : map) {
106 if (!includeEmpty && it.second.size() == 0) continue;
107 G4cout << " :: " << it.first.GetInfo() << G4endl;
108 for (auto const& it2 : it.second) {
109 G4cout << std::setw(3) << std::setprecision(3) << " " << G4BestUnit(it2.first, "Time")
110 << " " << std::setw(5) << it2.second << G4endl;
111 }
112 }
113 G4cout << "--- END COUNTER MAP DUMP ---" << G4endl;
114}
#define G4BestUnit(a, b)
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Referenced by G4VUserMoleculeCounter< TIndex >::Dump(), and G4VUserMoleculeReactionCounter< TIndex >::Dump().

◆ DumpCounterMapIndices()

template<typename T>
void G4::MoleculeCounter::DumpCounterMapIndices ( const std::map< T, InnerCounterMapType > & map,
G4bool includeEmpty = false )

Definition at line 87 of file G4MoleculeCounterTemplates.hh.

88{
89 G4cout << "--- BEGIN COUNTER MAP INDEX DUMP ---" << G4endl;
90 auto i = 0;
91 for (auto const& it : map) {
92 if (!includeEmpty && it.second.size() == 0) continue;
93 G4cout << i++ << ": " << it.first.GetInfo() << G4endl;
94 }
95 G4cout << "--- END COUNTER MAP INDEX DUMP ---" << G4endl;
96}

Referenced by G4VUserMoleculeCounter< TIndex >::DumpCounterMapIndices(), and G4VUserMoleculeReactionCounter< TIndex >::DumpCounterMapIndices().

◆ FindClosestEntryForKey()

template<typename TKey, typename TValue, typename TComp>
std::map< TKey, TValue, TComp >::iterator G4::MoleculeCounter::FindClosestEntryForKey ( std::map< TKey, TValue, TComp > & map,
TKey key )

Definition at line 135 of file G4MoleculeCounterTemplates.hh.

136{
137 if (map.empty()) return map.end();
138
139 auto it_lb = map.lower_bound(key);
140
141 if (it_lb == map.begin()) return it_lb;
142 if (it_lb == map.end()) return --it_lb;
143
144 auto prev_it = std::prev(it_lb);
145
146 if (std::abs(it_lb->first - key) < std::abs(prev_it->first - key))
147 return it_lb;
148 else
149 return prev_it;
150}

Referenced by G4VUserMoleculeCounter< TIndex >::AbsorbCounter(), G4VUserMoleculeReactionCounter< TIndex >::AbsorbCounter(), G4VUserMoleculeCounter< TIndex >::AddMolecule(), G4VUserMoleculeReactionCounter< TIndex >::RecordReaction(), and G4VUserMoleculeCounter< TIndex >::RemoveMolecule().

◆ GetMapIndices()

template<typename T, typename U>
const std::vector< T > G4::MoleculeCounter::GetMapIndices ( const std::map< T, U > & _map)

Definition at line 76 of file G4MoleculeCounterTemplates.hh.

77{
78 std::vector<T> output;
79 for (auto const& it : _map)
80 output.push_back(it.first);
81 return output;
82}

Referenced by ContainsKey(), G4VUserMoleculeCounter< TIndex >::GetMapIndices(), G4VUserMoleculeReactionCounter< TIndex >::GetMapIndices(), G4MoleculeCounterManager::RegisterCounter(), and G4MoleculeCounterManager::RegisterCounter().

◆ GetRecordedTimes()

template<typename T>
std::set< G4double > G4::MoleculeCounter::GetRecordedTimes ( const std::map< T, InnerCounterMapType > & map)

Definition at line 119 of file G4MoleculeCounterTemplates.hh.

120{
121 std::set<G4double> output{};
122 for (const auto& it : map) {
123 G4cerr << it.second.size() << G4endl;
124 for (const auto& it2 : it.second) {
125 output.insert(it2.first);
126 }
127 }
128 return output;
129}
G4GLOB_DLL std::ostream G4cerr

Referenced by G4VUserMoleculeCounter< TIndex >::GetRecordedTimes(), and G4VUserMoleculeReactionCounter< TIndex >::GetRecordedTimes().

◆ GetTemplateTypeName()