File indexing completed on 2026-04-05 07:50:37
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
0029 #include "Manager.hh"
0030
0031 #include "G4AccumulableManager.hh"
0032
0033 #include <map>
0034 #include <mutex>
0035
0036 std::mutex init_mutex;
0037
0038 namespace RadioBio
0039 {
0040
0041
0042
0043 #define width 15L
0044
0045
0046
0047 Manager* Manager::CreateInstance()
0048 {
0049 if (fInstance) {
0050 G4Exception("RadioBioManager::createInstance", "RecreatingRadioBioManager", FatalException,
0051 "Creating another, new, instance of RadioBioManager");
0052 delete fInstance;
0053 }
0054
0055 fInstance = new Manager();
0056 return fInstance;
0057 }
0058
0059
0060
0061 Manager* Manager::GetInstance()
0062 {
0063 return fInstance;
0064 }
0065
0066
0067
0068
0069 Manager::~Manager()
0070 {
0071 for (auto q : fQuantities)
0072 delete q.second;
0073 }
0074
0075
0076
0077 void Manager::InitializeAll()
0078 {
0079 std::lock_guard<std::mutex> lock(init_mutex);
0080 for (auto const& q : fQuantities)
0081 (q.second)->Initialize();
0082 }
0083
0084
0085
0086 void Manager::ComputeAll()
0087 {
0088 for (auto const& q : fQuantities)
0089 (q.second)->Compute();
0090 }
0091
0092
0093
0094 void Manager::ResetAll()
0095 {
0096 for (auto const& q : fQuantities)
0097 (q.second)->Reset();
0098 }
0099
0100
0101
0102 void Manager::StoreAll()
0103 {
0104 for (auto const& q : fQuantities)
0105 (q.second)->Store();
0106 }
0107
0108
0109
0110 VRadiobiologicalQuantity* Manager::GetQuantity(G4String str)
0111 {
0112 return fQuantities.find(str)->second;
0113 }
0114
0115
0116
0117 void Manager::PrintParameters()
0118 {
0119 G4cout << "*******************************************" << G4endl
0120 << "*** right now registered quantities are ***" << G4endl;
0121 for (auto const& q : fQuantities)
0122 G4cout << "*** " << q.first;
0123 G4cout << "*** but their calculation might be not ****" << G4endl
0124 << "*** active. Ask for parameters of each ****" << G4endl
0125 << "*******************************************" << G4endl;
0126 }
0127
0128
0129
0130 void Manager::DigestAccumulables()
0131 {
0132 for (auto q : fQuantities) {
0133
0134 G4VAccumulable* GenAcc = G4AccumulableManager::Instance()->GetAccumulable(q.first);
0135
0136 if (!GenAcc) {
0137 G4Exception("RadioBioManager::AddFromAccumulable", "NoAccumulable", FatalException, q.first);
0138 }
0139
0140
0141 if (!q.second->IsCalculationEnabled()) continue;
0142
0143
0144 q.second->AddFromAccumulable(GenAcc);
0145 }
0146 }
0147
0148
0149
0150 bool Manager::Register(VRadiobiologicalQuantity* q, G4String name)
0151 {
0152 if (q == nullptr) {
0153 G4Exception("RadioBioManager::Register", "RegisteringNullptr", JustWarning,
0154 "Asking to register a quantity with null pointer!");
0155 return false;
0156 }
0157
0158 if (fQuantities.find(name) != fQuantities.end()) {
0159 G4Exception("RadioBioManager::Register", "RegisteringSameQuantity", FatalException,
0160 "Registering two radiobiological quantities with the same name!");
0161 return false;
0162 }
0163 fQuantities[name] = q;
0164 return true;
0165 }
0166
0167
0168
0169 }