Loading...
Searching...
No Matches
Manager.cc
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//
27/// \file radiobiology/src/Manager.cc
28/// \brief Implementation of the RadioBio::Manager class
29
30#include "Manager.hh"
31
32#include "G4AccumulableManager.hh"
33
34#include <map>
35
36#include <mutex>
37
38std::mutex init_mutex;
39
40namespace RadioBio
41{
42
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45#define width 15L
46
47// To create the instance the DetectorConstruction must
48// be passed (to account for correct voxelization)
50{
51 if (fInstance) {
52 G4Exception("RadioBioManager::createInstance", "RecreatingRadioBioManager", FatalException,
53 "Creating another, new, instance of RadioBioManager");
54 delete fInstance;
55 }
56
57 fInstance = new Manager();
58 return fInstance;
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
70// Destructor deletes all the quantities
72{
73 for (auto q : fQuantities)
74 delete q.second;
75}
76
77//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78
80{
81
82 std::lock_guard<std::mutex> lock(init_mutex);
83 for (auto const& q : fQuantities)
84 (q.second)->Initialize();
85}
86
87//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88
90{
91 for (auto const& q : fQuantities)
92 (q.second)->Compute();
93}
94
95//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96
98{
99 for (auto const& q : fQuantities)
100 (q.second)->Reset();
101}
102
103//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104
106{
107 for (auto const& q : fQuantities)
108 (q.second)->Store();
109}
110
111//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112
114{
115 return fQuantities.find(str)->second;
116}
117
118//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119
121{
122 G4cout << "*******************************************" << G4endl
123 << "*** right now registered quantities are ***" << G4endl;
124 for (auto const& q : fQuantities)
125 G4cout << "*** " << q.first;
126 G4cout << "*** but their calculation might be not ****" << G4endl
127 << "*** active. Ask for parameters of each ****" << G4endl
128 << "*******************************************" << G4endl;
129}
130
131//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132
134{
135 for (auto q : fQuantities) {
136 // Hook in the accumulable manager the one named as the quantity (eg "Dose")
137 G4VAccumulable* GenAcc = G4AccumulableManager::Instance()->GetAccumulable(q.first);
138
139 if (!GenAcc) {
140 G4Exception("RadioBioManager::AddFromAccumulable", "NoAccumulable", FatalException, q.first);
141 }
142
143 // If calculation is not set enabled, exit
144 if (!q.second->IsCalculationEnabled()) continue;
145
146 // Add from the accumulable.
147 q.second->AddFromAccumulable(GenAcc);
148 }
149}
150
151//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152
154{
155 if (q == nullptr) {
156 G4Exception("RadioBioManager::Register", "RegisteringNullptr", JustWarning,
157 "Asking to register a quantity with null pointer!");
158 return false;
159 }
160
161 if (fQuantities.find(name) != fQuantities.end()) {
162 G4Exception("RadioBioManager::Register", "RegisteringSameQuantity", FatalException,
163 "Registering two radiobiological quantities with the same name!");
164 return false;
165 }
166 fQuantities[name] = q;
167 return true;
168}
169
170//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
171
172} // namespace RadioBio
std::mutex init_mutex
Definition Manager.cc:38
Definition of the RadioBio::Manager class.
void PrintParameters()
Definition Manager.cc:120
std::map< G4String, VRadiobiologicalQuantity * > fQuantities
Definition Manager.hh:78
void ComputeAll()
Definition Manager.cc:89
bool Register(VRadiobiologicalQuantity *, G4String)
Definition Manager.cc:153
VRadiobiologicalQuantity * GetQuantity(G4String)
Definition Manager.cc:113
void DigestAccumulables()
Definition Manager.cc:133
static Manager * CreateInstance()
Definition Manager.cc:49
static Manager * GetInstance()
Definition Manager.cc:63
void InitializeAll()
Definition Manager.cc:79
static Manager * fInstance
Definition Manager.hh:80

Applications | User Support | Publications | Collaboration