Geant4-11
Functions
G4Accumulables Namespace Reference

Functions

template<typename T >
G4MergeFunction< T > GetMergeFunction (G4MergeMode mergeMode)
 
template<G4bool >
G4MergeFunction< G4boolGetMergeFunction (G4MergeMode mergeMode)
 
G4MergeMode GetMergeMode (const G4String &mergeModeName)
 

Function Documentation

◆ GetMergeFunction() [1/2]

template<typename T >
G4MergeFunction< T > G4Accumulables::GetMergeFunction ( G4MergeMode  mergeMode)

Definition at line 57 of file G4MergeMode.hh.

58{
59 switch ( mergeMode ) {
61 // return std::bind([](const T& x, const T& y) { return x + y; });
62 return [](const T& x, const T& y) { return x + y; };
63
65 return [](const T& x, const T& y) { return x * y; };
66
68 // return std::bind([](const T& x, const T& y) { return std::max(x,y);});
69 return [](const T& x, const T& y) { return std::max(x,y); };
70
72 // return std::bind([](const T& x, const T& y) { return std::min(x,y);});
73 return [](const T& x, const T& y) { return std::min(x,y); };
74 }
75
76 // Must never get here, but we need a return to satisfy MSVC
77 G4Exception("G4Accumulables::GetMergeFunction<T>",
78 "Analysis_F001", FatalException,
79 "Undefined merge mode");
80 return [](const T&, const T&) { return T(); };
81}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

References FatalException, G4Exception(), kAddition, kMaximum, kMinimum, kMultiplication, G4INCL::Math::max(), and G4INCL::Math::min().

◆ GetMergeFunction() [2/2]

template<G4bool >
G4MergeFunction< G4bool > G4Accumulables::GetMergeFunction ( G4MergeMode  mergeMode)

Definition at line 84 of file G4MergeMode.hh.

85{
86 switch ( mergeMode ) {
89 // return std::bind([](const T& x, const T& y) { return x + y; });
90 return [](const G4bool& x, const G4bool& y) { return x || y; };
91
94 return [](const G4bool& x, const G4bool& y) { return x && y; };
95 }
96}
bool G4bool
Definition: G4Types.hh:86

References kAddition, kMaximum, kMinimum, and kMultiplication.

◆ GetMergeMode()

G4MergeMode G4Accumulables::GetMergeMode ( const G4String mergeModeName)

Definition at line 35 of file G4MergeMode.cc.

35 {
36 if ( mergeModeName == "+" ) { return G4MergeMode::kAddition; }
37 else if ( mergeModeName == "*" ) { return G4MergeMode::kMultiplication; }
38 else {
39 G4ExceptionDescription description;
40 description
41 << "\"" << mergeModeName << "\" merge mode is not supported." << G4endl
42 << "Addition will be applied.";
43 G4Exception("G4Analysis::GetMergeMode",
44 "Analysis_W001", JustWarning, description);
46 }
47}
@ JustWarning
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57

References G4endl, G4Exception(), JustWarning, kAddition, and kMultiplication.