Skip to content

Commit e45fe05

Browse files
njacazioktf
authored andcommitted
Using real logaritmic axis in axis spec
1 parent eb4e205 commit e45fe05

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Framework/Core/include/Framework/HistogramSpec.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ struct AxisSpec {
124124
}
125125

126126
const double min = binEdges[0];
127-
const double width = (binEdges[1] - binEdges[0]) / nBins.value();
128-
binEdges.clear();
129-
binEdges.resize(0);
130-
for (int i = 0; i < nBins.value() + 1; i++) {
131-
binEdges.push_back(std::pow(10., min + i * width));
127+
const double max = binEdges[1];
128+
const double logmin = std::log10(min);
129+
const double logmax = std::log10(max);
130+
const int nbins = nBins.value();
131+
const double logdelta = (logmax - logmin) / (static_cast<double>(nbins));
132+
const double log10 = std::log10(10.);
133+
for (int i = 0; i < nbins + 1; i++) {
134+
binEdges.push_back(std::exp(log10 * (logmin + i * logdelta)));
132135
}
133136
nBins = std::nullopt;
134137
}

0 commit comments

Comments
 (0)