38 if (binSchemeName ==
"linear")
return G4BinScheme::kLinear;
39 if (binSchemeName ==
"log")
return G4BinScheme::kLog;
40 if (binSchemeName ==
"user")
return G4BinScheme::kUser;
43 Warn(
"\"" + binSchemeName +
"\" binning scheme is not supported.\n"
44 "Linear binning will be applied.",
kNamespaceName,
"GetBinScheme");
46 return G4BinScheme::kLinear;
52 std::vector<G4double>& edges)
56 if ( binScheme == G4BinScheme::kUser ) {
58 Warn(
"There is no need to compute edges for G4BinScheme::kUser\n"
65 Warn(
"Illegal unit value (0), 1. will be used instead",
72 Warn(
"Illegal number of nbins value (0), call will be ignored",
78 auto xumin = xmin/unit;
79 auto xumax = xmax/unit;
81 if ( binScheme == G4BinScheme::kLinear ) {
82 auto dx = (fcn(xumax) - fcn(xumin) ) / nbins;
83 auto binValue = fcn(xumin);
84 while (
G4int(edges.size()) <= nbins ) {
85 edges.push_back(binValue);
91 if ( binScheme == G4BinScheme::kLog ) {
93 auto dlog = (std::log10(xumax) - std::log10(xumin))/ nbins;
94 auto dx = std::pow(10, dlog);
95 auto binValue = xumin;
96 while (
G4int(edges.size()) <= nbins ) {
97 edges.push_back(binValue);
107 std::vector<G4double>& newBins)
113 Warn(
"Illegal unit value (0), 1. will be used instead",
118 for (
auto element : edges) {
119 newBins.push_back(fcn(element/unit));
G4double(*)(G4double) G4Fcn
G4BinScheme GetBinScheme(const G4String &binSchemeName)
constexpr std::string_view kNamespaceName
void ComputeEdges(G4int nbins, G4double xmin, G4double xmax, G4double unit, G4Fcn fcn, G4BinScheme, std::vector< G4double > &edges)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)