File indexing completed on 2025-01-18 09:57:51
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 template <typename T>
0029 G4Accumulable<T>*
0030 G4AccumulableManager::GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const
0031 {
0032
0033 if ( ! accumulable ) return nullptr;
0034
0035
0036 auto taccumulable = dynamic_cast<G4Accumulable<T>*>(accumulable);
0037 if ( ! taccumulable && warn ) {
0038 G4ExceptionDescription description;
0039 description << " " << "Accumulable " << accumulable->GetName()
0040 << " has different type";
0041 G4Exception("G4AccumulableManager::GetAccumulable<T>",
0042 "Analysis_W001", JustWarning, description);
0043 return nullptr;
0044 }
0045
0046 return taccumulable;
0047 }
0048
0049
0050 template <typename T>
0051 G4Accumulable<T>*
0052 G4AccumulableManager::CreateAccumulable(
0053 const G4String& name, T value, G4MergeMode mergeMode)
0054 {
0055
0056 if ( ! CheckName(name, "CreateAccumulable") ) return 0;
0057
0058
0059 auto accumulable = new G4Accumulable<T>(name, value, mergeMode);
0060
0061
0062 RegisterAccumulable(accumulable);
0063 fAccumulablesToDelete.push_back(accumulable);
0064
0065 return accumulable;
0066 }
0067
0068
0069 template <typename T>
0070 G4Accumulable<T>*
0071 G4AccumulableManager::CreateAccumulable(
0072 T value, G4MergeMode mergeMode)
0073 {
0074 return CreateAccumulable(G4String(), value, mergeMode);
0075 }
0076
0077
0078 template <typename T>
0079 G4bool G4AccumulableManager::RegisterAccumulable(G4Accumulable<T>& accumulable)
0080 {
0081 return RegisterAccumulable(&accumulable);
0082 }
0083
0084
0085 template <typename T>
0086 G4Accumulable<T>*
0087 G4AccumulableManager::GetAccumulable(const G4String& name, G4bool warn) const
0088 {
0089
0090 auto accumulable = GetAccumulable(name, warn);
0091 return GetAccumulable<T>(accumulable, warn);
0092 }
0093
0094
0095 template <typename T>
0096 G4Accumulable<T>*
0097 G4AccumulableManager::GetAccumulable(G4int id, G4bool warn) const
0098 {
0099
0100 auto accumulable = GetAccumulable(id, warn);
0101 return GetAccumulable<T>(accumulable, warn);
0102 }
0103
0104
0105 inline G4int G4AccumulableManager::GetNofAccumulables() const
0106 {
0107 return G4int(fVector.size());
0108 }
0109
0110
0111 inline std::vector<G4VAccumulable*>::iterator G4AccumulableManager::Begin()
0112 {
0113 return fVector.begin();
0114 }
0115
0116
0117 inline std::vector<G4VAccumulable*>::iterator G4AccumulableManager::End()
0118 {
0119 return fVector.end();
0120 }
0121
0122
0123 inline std::vector<G4VAccumulable*>::const_iterator
0124 G4AccumulableManager::BeginConst() const
0125 {
0126 return fVector.begin();
0127 }
0128
0129
0130 inline std::vector<G4VAccumulable*>::const_iterator
0131 G4AccumulableManager::EndConst() const
0132 {
0133 return fVector.end();
0134 }