43 description <<
"Invalid range " << message;
44 G4String method(
"G4AccumulableManager::");
58G4AccumulableManager::G4AccumulableManager()
61 fgMasterInstance =
this;
69 for (
auto it : fAccumulablesToDelete ) {
79G4String G4AccumulableManager::GenerateName()
const
82 std::ostringstream os;
85 name.append(os.str());
90G4bool G4AccumulableManager::CheckName(
93 if (fMap.find(name) == fMap.end()) {
98 description <<
"Name " <<
name <<
" is already used." <<
G4endl;
99 description <<
"Parameter will be not created/registered.";
100 G4String method(
"G4AccumulableManager::");
101 method.append(where);
107G4bool G4AccumulableManager::CheckType(
110 if (accumulable->
GetType() != type) {
113 description <<
" " << accumulable->
GetName() <<
": Incompatible type.";
129 auto name = accumulable->
GetName();
131 if (G4Accumulables::VerboseLevel > 1 ) {
132 G4cout <<
"Going to register accumulable \"" << name <<
"\"" <<
G4endl;
136 if (!CheckName(name,
"RegisterAccumulable")) {
141 if (name.length() == 0u) {
142 name = GenerateName();
149 fMap[name] = accumulable;
150 fVector.push_back(accumulable);
152 if (G4Accumulables::VerboseLevel > 0 ) {
171 auto it = fMap.find(name);
172 if ( it == fMap.end() ) {
175 description <<
"Accumulable " << name <<
" does not exist.";
176 G4Exception(
"G4AccumulableManager::GetAccumulable",
190 if ( id < 0 || id >=
G4int(fVector.size()) ) {
193 description <<
"Accumulable " <<
id <<
" does not exist.";
194 G4Exception(
"G4AccumulableManager::GetAccumulable",
213 if (fgMasterInstance ==
nullptr) {
216 <<
"No master G4AccumulableManager instance exists." <<
G4endl
217 <<
"Accumulables will not be merged.";
229 auto it = fVector.begin();
230 for (
auto itMaster : fgMasterInstance->fVector ) {
234 itMaster->Merge(*(*(it++)));
244 for (
auto it : fVector ) {
252 for (
auto it : fVector ) {
262 if ( startId < 0 || startId >=
G4int(fVector.size()) ||
263 count <= 0 || startId + count >
G4int(fVector.size()) ) {
264 RangeException(
"Print",
265 std::to_string(startId) +
", " + std::to_string(count));
269 for (
auto id = startId;
id < startId + count; ++id ) {
270 fVector[id]->Print(options);
276 std::vector<G4VAccumulable*>::iterator startIt,
277 std::vector<G4VAccumulable*>::iterator endIt,
281 if ( startIt == fVector.end() || endIt == fVector.end() ) {
282 RangeException(
"Print",
"[startIt, endIt]");
286 for (
auto it = startIt; it != endIt; ++it ) {
287 (*it)->Print(options);
293 std::vector<G4VAccumulable*>::iterator startIt, std::size_t count,
296 Print(startIt, startIt+count, options);
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4TemplateRNGHelper< G4long > * G4TemplateRNGHelper< G4long >::instance
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4bool Register(G4AccValue< T > &accumulable)
G4bool RegisterAccumulable(G4AccValue< T > &accumulable)
virtual ~G4AccumulableManager()
static G4AccumulableManager * Instance()
G4VAccumulable * GetAccumulable(const G4String &name, G4bool warn=true) const
void Print(G4PrintOptions options=G4PrintOptions()) const
void SetName(const G4String &name)
virtual G4AccType GetType() const
const char * name(G4int ptype)