File indexing completed on 2026-08-27 08:33:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsPlugins/Root/RootHistogramFit.hpp"
0010
0011 #include "ActsPlugins/Root/HistogramConverter.hpp"
0012
0013 #include <memory>
0014
0015 #include <TFitResult.h>
0016 #include <TH1.h>
0017
0018 namespace ActsPlugins {
0019
0020 std::optional<RootHistogramFit::Result> RootHistogramFit::operator()(
0021 const Acts::Experimental::Histogram1& hist,
0022 std::optional<Range> range) const {
0023 const std::unique_ptr<TH1F> rootHist = toRoot(hist);
0024
0025 const TFitResultPtr result =
0026 range.has_value()
0027 ? rootHist->Fit("gaus", (m_config.fitOptions + "R").c_str(), nullptr,
0028 range->first, range->second)
0029 : rootHist->Fit("gaus", m_config.fitOptions.c_str(), nullptr);
0030
0031 if (result.Get() == nullptr || result->Status() % 1000 != 0) {
0032 return std::nullopt;
0033 }
0034
0035 return Result{result->Parameter(1), result->Parameter(2), result->ParError(1),
0036 result->ParError(2)};
0037 }
0038
0039 }