Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -26,22 +26,30 @@
// The common implementation of analysis manager classes.
// Author: Ivana Hrivnacova, 07/09/2015 (ivana@ipno.in2p3.fr)
// Author: Ivana Hrivnacova, IJCLab IN2P3/CNRS, 07/09/2015
#ifndef G4AccumulableManager_h
#define G4AccumulableManager_h 1
#include "G4Accumulable.hh"
#include "G4AccValue.hh"
#include "G4AccType.hh"
#include "globals.hh"
#include <map>
#include <vector>
class G4AccumulableManager;
class G4AnalysisManagerState;
class G4VAccumulable;
template <class T>
class G4ThreadLocalSingleton;
template <class T, std::size_t N>
class G4AccArray;
template <class Key, class T, class Compare, class Allocator>
class G4AccMap;
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
class G4AccUnorderedMap;
template <class T, class Allocator>
class G4AccVector;
class G4AccumulableManager
{
@@ -58,38 +66,124 @@ class G4AccumulableManager
// Create accumulables
//
template <typename T>
G4Accumulable<T>*
G4AccValue<T>*
CreateAccValue(const G4String& name, T value,
G4MergeMode mergeMode = G4MergeMode::kAddition);
template <typename T>
G4AccValue<T>*
CreateAccValue(T value,
G4MergeMode mergeMode = G4MergeMode::kAddition);
// Deprecated function using the old accumulable value name
//
template <typename T>
[[deprecated("Use `G4AccumulableManager::CreateAccValue<T>` instead")]]
G4AccValue<T>*
CreateAccumulable(const G4String& name, T value,
G4MergeMode mergeMode = G4MergeMode::kAddition);
template <typename T>
G4Accumulable<T>*
[[deprecated("Use `G4AccumulableManager::CreateAccValue<T>` instead")]]
G4AccValue<T>*
CreateAccumulable(T value,
G4MergeMode mergeMode = G4MergeMode::kAddition);
// Register existing accumulables
//
// templated accumulable
template <typename T>
G4bool RegisterAccumulable(G4Accumulable<T>& accumulable);
G4bool Register(G4AccValue<T>& accumulable);
template <class T, std::size_t N>
G4bool Register(G4AccArray<T, N>& accumulableArray);
template <class Key, class T, class Compare, class Allocator>
G4bool Register(G4AccMap<Key, T, Compare, Allocator>& accumulableMap);
template <class Key, class T, class Hash, class KeyEqual, class Allocator>
G4bool Register(G4AccUnorderedMap<Key, T, Hash, KeyEqual, Allocator>& accumulableUnorderedMap);
template <class T, class Allocator>
G4bool Register(G4AccVector<T, Allocator>& accumulableVector);
// user defined accumulable
G4bool Register(G4VAccumulable* accumulable);
// Deprecated functions with long name
//
template <typename T>
[[deprecated("Use `G4AccumulableManager::Register` instead")]]
G4bool RegisterAccumulable(G4AccValue<T>& accumulable);
// user defined accumulable
[[deprecated("Use `G4AccumulableManager::Register` instead")]]
G4bool RegisterAccumulable(G4VAccumulable* accumulable);
// Access registered accumulables
//
// Via name
// templated accumulable
//
template <typename T>
G4Accumulable<T>* GetAccumulable(const G4String& name, G4bool warn = true) const;
G4AccValue<T>* GetAccValue(const G4String& name, G4bool warn = true) const;
template <class T, std::size_t N>
G4AccArray<T, N>*
GetAccArray(const G4String& name, G4bool warn = true) const;
template <class Key, class T, class Compare = std::less<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
G4AccMap<Key, T, Compare, Allocator>*
GetAccMap(const G4String& name, G4bool warn = true) const;
template <class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
G4AccUnorderedMap<Key, T, Hash, KeyEqual, Allocator>*
GetAccUnorderedMap(const G4String& name, G4bool warn = true) const;
template <class T, class Allocator = std::allocator<T>>
G4AccVector<T, Allocator>*
GetAccVector(const G4String& name, G4bool warn = true) const;
// user defined accumulable
G4VAccumulable* GetAccumulable(const G4String& name, G4bool warn = true) const;
// Via id (in the order of registering)
// templated accumulable
// Deprecated function using the old accumulable value name
template <typename T>
G4Accumulable<T>* GetAccumulable(G4int id, G4bool warn = true) const;
[[deprecated("Use `G4AccumulableManager::GetAccValue<T>` instead")]]
G4AccValue<T>* GetAccumulable(const G4String& name, G4bool warn = true) const;
// Via id (in the order of registering)
// templated accumulable
//
template <typename T>
G4AccValue<T>* GetAccValue(G4int id, G4bool warn = true) const;
template <class T, std::size_t N>
G4AccArray<T, N>* GetAccArray(G4int id, G4bool warn = true) const;
template <class Key, class T, class Compare = std::less<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
G4AccMap<Key, T, Compare, Allocator>*
GetAccMap(G4int id, G4bool warn = true) const;
template <class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>,
class Allocator = std::allocator<std::pair<const Key, T>>>
G4AccUnorderedMap<Key, T, Hash, KeyEqual, Allocator>*
GetAccUnorderedMap(G4int id, G4bool warn = true) const;
template <class T, class Allocator = std::allocator<T>>
G4AccVector<T, Allocator>*
GetAccVector(G4int id, G4bool warn = true) const;
// user defined accumulable
G4VAccumulable* GetAccumulable(G4int id, G4bool warn = true) const;
// Deprecated function using the old accumulable value name
template <typename T>
[[deprecated("Use `G4AccumulableManager::GetAccValue<T>` instead")]]
G4AccValue<T>* GetAccumulable(G4int id, G4bool warn = true) const;
G4int GetNofAccumulables() const;
// Via vector iterators
@@ -101,6 +195,20 @@ class G4AccumulableManager
// Methods applied to all accumulables
void Merge();
void Reset();
void Print(G4PrintOptions options = G4PrintOptions()) const;
// Print a selected range
void Print(G4int startId, G4int count,
G4PrintOptions options = G4PrintOptions()) const;
void Print(std::vector<G4VAccumulable*>::iterator startIt, std::size_t count,
G4PrintOptions options = G4PrintOptions()) const;
void Print(std::vector<G4VAccumulable*>::iterator startIt,
std::vector<G4VAccumulable*>::iterator endIt,
G4PrintOptions options = G4PrintOptions()) const;
// Verbose level
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
private:
// Hide singleton ctor
@@ -111,9 +219,27 @@ class G4AccumulableManager
G4String GenerateName() const;
// Check if a name is already used in a map and print a warning
G4bool CheckName(const G4String& name, const G4String& where) const;
G4bool CheckType(G4VAccumulable* accumulable, G4AccType type, G4bool warn) const;
template <typename T>
G4Accumulable<T>* GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const;
G4AccValue<T>* GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const;
template <typename T, std::size_t N>
G4AccArray<T, N>* GetAccArray(G4VAccumulable* accumulable, G4bool warn) const;
template <typename Key, typename T, typename Compare = std::less<Key>,
typename Allocator = std::allocator<std::pair<const Key, T>>>
G4AccMap<Key, T, Compare, Allocator>*
GetAccMap(G4VAccumulable* accumulable, G4bool warn = true) const;
template <typename Key, typename T, typename Hash = std::hash<Key>, typename KeyEqual = std::equal_to<Key>,
typename Allocator = std::allocator<std::pair<const Key, T>>>
G4AccUnorderedMap<Key, T, Hash, KeyEqual, Allocator>*
GetAccUnorderedMap(G4VAccumulable* accumulable, G4bool warn = true) const;
template <typename T, typename Allocator = std::allocator<T>>
G4AccVector<T, Allocator>*
GetAccVector(G4VAccumulable* accumulable, G4bool warn) const;
// Constants
const G4String kBaseName = "accumulable";